本文整理汇总了C++中rstr_get函数的典型用法代码示例。如果您正苦于以下问题:C++ rstr_get函数的具体用法?C++ rstr_get怎么用?C++ rstr_get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rstr_get函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: set_source
static void
set_source(glw_t *w, rstr_t *filename)
{
glw_image_t *gi = (glw_image_t *)w;
const rstr_t *curname;
if(gi->gi_pending_url != NULL)
curname = gi->gi_pending_url;
else if(gi->gi_pending != NULL)
curname = gi->gi_pending->glt_url;
else if(gi->gi_current != NULL)
curname = gi->gi_current->glt_url;
else
curname = NULL;
if(curname != NULL && filename != NULL && !strcmp(rstr_get(filename),
rstr_get(curname)))
return;
if(gi->gi_pending_url != NULL)
rstr_release(gi->gi_pending_url);
gi->gi_pending_url = filename ? rstr_dup(filename) : rstr_alloc("");
}
示例2: hc_prop
static int
hc_prop(http_connection_t *hc, const char *remain, void *opaque,
http_cmd_t method)
{
htsbuf_queue_t out;
rstr_t *r;
int rval, i;
prop_t *p;
const char *action = http_arg_get_req(hc, "action");
if(remain == NULL)
return 404;
p = prop_from_path(remain);
if(p == NULL)
return 404;
htsbuf_queue_init(&out, 0);
switch(method) {
case HTTP_CMD_GET:
if(action != NULL) {
event_t *e = event_create_action_str(action);
prop_send_ext_event(p, e);
event_release(e);
rval = HTTP_STATUS_OK;
break;
}
r = prop_get_string(p, NULL);
if(r == NULL) {
char **childs = prop_get_name_of_childs(p);
if(childs == NULL) {
rval = HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE;
break;
}
for(i = 0; childs[i] != NULL; i++) {
htsbuf_qprintf(&out, "\t%s\n", childs[i]);
}
} else {
htsbuf_append(&out, rstr_get(r), strlen(rstr_get(r)));
htsbuf_append(&out, "\n", 1);
rstr_release(r);
}
rval = http_send_reply(hc, 0, "text/ascii", NULL, NULL, 0, &out);
break;
default:
rval = HTTP_STATUS_METHOD_NOT_ALLOWED;
break;
}
prop_ref_dec(p);
return rval;
}
示例3: callback_opt
static void
callback_opt(void *opaque, prop_event_t event, ...)
{
setting_t *s = opaque;
prop_callback_string_t *cb;
prop_t *c;
rstr_t *name;
va_list ap;
va_start(ap, event);
cb = s->s_callback;
if(event != PROP_SELECT_CHILD)
return;
c = va_arg(ap, prop_t *);
name = c ? prop_get_name(c) : NULL;
va_end(ap);
if(cb != NULL)
cb(s->s_opaque, rstr_get(name));
if(s->s_store != NULL && s->s_saver != NULL) {
htsmsg_delete_field(s->s_store, s->s_id);
if(name != NULL)
htsmsg_add_str(s->s_store, s->s_id, rstr_get(name));
s->s_saver(s->s_saver_opaque, s->s_store);
}
rstr_release(name);
}
示例4: glw_view_load1
/**
* Load a view file and do lexographical parsing
*
* Returns pointer to last token, or NULL if an error occured.
* If an error occured 'ei' will be filled with data
*/
token_t *
glw_view_load1(glw_root_t *gr, rstr_t *url, errorinfo_t *ei, token_t *prev,
int may_unlock)
{
token_t *last;
char errbuf[256];
rstr_t *p = fa_absolute_path(url, prev->file);
if(may_unlock)
glw_unlock(gr);
buf_t *b = fa_load(rstr_get(p),
FA_LOAD_VPATHS(gr->gr_vpaths),
FA_LOAD_ERRBUF(errbuf, sizeof(errbuf)),
NULL);
if(may_unlock)
glw_lock(gr);
if(b == NULL) {
snprintf(ei->error, sizeof(ei->error), "Unable to open \"%s\" -- %s",
rstr_get(p), errbuf);
snprintf(ei->file, sizeof(ei->file), "%s", rstr_get(prev->file));
ei->line = prev->line;
rstr_release(p);
return NULL;
}
last = glw_view_lexer(gr, buf_cstr(b), ei, p, prev);
buf_release(b);
rstr_release(p);
return last;
}
示例5: glw_view_seterr
int
glw_view_seterr(errorinfo_t *ei, token_t *b, const char *fmt, ...)
{
char buf[PATH_MAX];
va_list ap;
va_start(ap, fmt);
assert(b != NULL);
if(ei == NULL) {
#ifdef GLW_VIEW_ERRORINFO
snprintf(buf, sizeof(buf), "GLW: %s:%d", rstr_get(b->file), b->line);
#else
snprintf(buf, sizeof(buf), "GLW: file?:##");
#endif
tracev(TRACE_NO_PROP, TRACE_ERROR, buf, fmt, ap);
return -1;
}
vsnprintf(ei->error, sizeof(ei->error), fmt, ap);
va_end(ap);
#ifdef GLW_VIEW_ERRORINFO
snprintf(ei->file, sizeof(ei->file), "%s", rstr_get(b->file));
ei->line = b->line;
#else
snprintf(ei->file, sizeof(ei->file), "file?");
#endif
return -1;
}
示例6: rstr_spn
rstr_t *
rstr_spn(rstr_t *s, const char *set, int offset)
{
size_t len = strlen(rstr_get(s));
if(offset >= len)
return rstr_dup(s);
size_t l = strcspn(rstr_get(s) + offset, set) + offset;
if(l == len)
return rstr_dup(s);
return rstr_allocl(rstr_get(s), l);
}
示例7: notify_add
void *
notify_add(prop_t *root, notify_type_t type, const char *icon, int delay,
rstr_t *fmt, ...)
{
char msg[256];
prop_t *p;
const char *typestr;
int tl;
va_list ap, apx;
switch(type) {
case NOTIFY_INFO: typestr = "info"; tl = TRACE_INFO; break;
case NOTIFY_WARNING: typestr = "warning"; tl = TRACE_INFO; break;
case NOTIFY_ERROR: typestr = "error"; tl = TRACE_ERROR; break;
default: return NULL;
}
va_start(ap, fmt);
va_copy(apx, ap);
tracev(0, tl, "notify", rstr_get(fmt), ap);
vsnprintf(msg, sizeof(msg), rstr_get(fmt), apx);
va_end(ap);
va_end(apx);
rstr_release(fmt);
p = prop_create_root(NULL);
prop_set_string(prop_create(p, "text"), msg);
prop_set_string(prop_create(p, "type"), typestr);
if(icon != NULL)
prop_set_string(prop_create(p, "icon"), icon);
p = prop_ref_inc(p);
if(prop_set_parent(p, root ?: notify_prop_entries))
prop_destroy(p);
if(delay != 0) {
prop_t *r = NULL;
if(delay < 0) {
r = prop_ref_inc(p);
delay = -delay;
}
callout_arm(NULL, notify_timeout, p, delay);
return r;
}
return p;
}
示例8: nls_string_find
static nls_string_t *
nls_string_find(const char *key)
{
nls_string_t *ns;
unsigned int hash = mystrhash(key) % NLS_STRING_HASH_WIDTH;
hts_mutex_lock(&nls_mutex);
LIST_FOREACH(ns, &nls_strings[hash], ns_link)
if(!strcmp(rstr_get(ns->ns_key), key))
break;
if(ns == NULL) {
ns = calloc(1, sizeof(nls_string_t));
ns->ns_key = rstr_alloc(key);
ns->ns_prop = prop_create_root(NULL);
prop_set_rstring(ns->ns_prop, ns->ns_key);
} else {
LIST_REMOVE(ns, ns_link);
}
LIST_INSERT_HEAD(&nls_strings[hash], ns, ns_link);
hts_mutex_unlock(&nls_mutex);
return ns;
}
示例9: glw_quad_render
static void
glw_quad_render(glw_t *w, const glw_rctx_t *rc)
{
glw_quad_t *q = (glw_quad_t *)w;
if(q->recompile) {
glw_destroy_program(w->glw_root, q->prog);
q->prog = glw_make_program(w->glw_root, NULL, rstr_get(q->fs));
q->recompile = 0;
}
if(!glw_renderer_initialized(&q->r)) {
glw_renderer_init_quad(&q->r);
glw_renderer_vtx_pos(&q->r, 0, -1, -1, 0);
glw_renderer_vtx_pos(&q->r, 1, 1, -1, 0);
glw_renderer_vtx_pos(&q->r, 2, 1, 1, 0);
glw_renderer_vtx_pos(&q->r, 3, -1, 1, 0);
}
glw_renderer_draw(&q->r, w->glw_root, rc,
NULL,
&q->color, NULL, rc->rc_alpha * w->glw_alpha, 0,
q->prog);
}
示例10: is_plugin_blacklisted
static int
is_plugin_blacklisted(const char *id, const char *version, rstr_t **reason)
{
char tmp[512];
int verint = parse_version_int(version);
if(!strcmp(id, "custombg")) {
if(reason != NULL) {
*reason =
_("Custom backgrounds can now be set in Settings -> Look and Feel");
}
return 1;
}
for(int i = 0; i < ARRAYSIZE(blacklist); i++) {
if(strcmp(id, blacklist[i].id))
continue;
if(verint >= blacklist[i].version)
continue;
if(reason != NULL) {
rstr_t *f = _("Version %s is no longer compatible with Movian");
snprintf(tmp, sizeof(tmp), rstr_get(f), version);
rstr_release(f);
*reason = rstr_alloc(tmp);
}
return 1;
}
return 0;
}
示例11: be_prop_open
static int
be_prop_open(prop_t *page, const char *url)
{
proppage_t *pp;
openpage_t *op;
hts_mutex_lock(&pp_mutex);
LIST_FOREACH(pp, &proppages, pp_link)
if(!strcmp(rstr_get(pp->pp_url), url))
break;
if(pp == NULL) {
hts_mutex_unlock(&pp_mutex);
return 1;
}
op = calloc(1, sizeof(openpage_t));
LIST_INSERT_HEAD(&pp->pp_pages, op, op_link);
op->op_pp = pp;
op->op_root = prop_ref_inc(page);
op->op_page_sub =
prop_subscribe(PROP_SUB_TRACK_DESTROY,
PROP_TAG_CALLBACK, op_cb, op,
PROP_TAG_MUTEX, &pp_mutex,
PROP_TAG_ROOT, page,
NULL);
prop_link(pp->pp_model, prop_create(page, "model"));
hts_mutex_unlock(&pp_mutex);
return 0;
}
示例12: get_identity
static const char *
get_identity(glw_t *w)
{
glw_image_t *gi = (glw_image_t *)w;
glw_loadable_texture_t *glt = gi->gi_current;
return glt ? rstr_get(glt->glt_url) : "unloaded";
}
示例13: news_sink
static void
news_sink(void *opaque, prop_event_t event, ...)
{
prop_t *p = opaque;
event_t *e;
va_list ap;
va_start(ap, event);
switch(event) {
case PROP_DESTROYED:
prop_unsubscribe(va_arg(ap, prop_sub_t *));
prop_ref_dec(p);
break;
case PROP_EXT_EVENT:
e = va_arg(ap, event_t *);
if(event_is_type(e, EVENT_DYNAMIC_ACTION)) {
const event_payload_t *ep = (const event_payload_t *)e;
if(!strcmp(ep->payload, "dismiss")) {
rstr_t *id = prop_get_string(p, "id", NULL);
dismis_news(rstr_get(id));
rstr_release(id);
prop_destroy(opaque);
}
}
break;
default:
break;
}
va_end(ap);
}
示例14: notifications_update
static void
notifications_update(void *opaque, prop_event_t event, ...)
{
statusbar_t *sb = opaque;
prop_t *p, *txt;
statusbar_entry_t *sbe;
char *buf;
rstr_t *msg;
int i, l;
va_list ap;
va_start(ap, event);
switch(event) {
case PROP_ADD_CHILD:
p = va_arg(ap, prop_t *);
txt = prop_get_by_name(PNVEC("self", "text"), 1,
PROP_TAG_NAMED_ROOT, p, "self",
NULL);
if(txt != NULL) {
msg = prop_get_string(txt);
if(msg != NULL) {
buf = mystrdupa(rstr_get(msg));
l = strlen(buf);
for(i = 0; i < l; i++)
if(buf[i] < ' ')
buf[i] = ' ';
sbe = calloc(1, sizeof(statusbar_entry_t));
sbe->p = prop_ref_inc(p);
sbe->id = gtk_statusbar_push(GTK_STATUSBAR(sb->bar), sb->ctxid, buf);
LIST_INSERT_HEAD(&sb->entries, sbe, link);
rstr_release(msg);
}
prop_ref_dec(txt);
}
break;
case PROP_DEL_CHILD:
p = va_arg(ap, prop_t *);
LIST_FOREACH(sbe, &sb->entries, link)
if(sbe->p == p)
break;
if(sbe == NULL)
break;
prop_ref_dec(sbe->p);
gtk_statusbar_remove(GTK_STATUSBAR(sb->bar), sb->ctxid, sbe->id);
LIST_REMOVE(sbe, link);
free(sbe);
break;
default:
break;
}
}
示例15: set_float3
static int
set_float3(glw_view_eval_context_t *ec, const token_attrib_t *a,
struct token *t)
{
const float *vec3;
float v[3];
switch(t->type) {
case TOKEN_VECTOR_FLOAT:
switch(t->t_elements) {
case 3:
vec3 = t->t_float_vector_int;
break;
default:
return glw_view_seterr(ec->ei, t,
"Attribute '%s': invalid vector size %d",
a->name, t->t_elements);
}
break;
case TOKEN_FLOAT:
v[0] = v[1] = v[2] = t->t_float;
vec3 = v;
break;
case TOKEN_INT:
v[0] = v[1] = v[2] = t->t_int;
vec3 = v;
break;
case TOKEN_VOID:
v[0] = v[1] = v[2] = 0;
vec3 = v;
break;
default:
return glw_view_seterr(ec->ei, t, "Attribute '%s' expects a vec3, got %s",
a->name, token2name(t));
}
glw_t *w = ec->w;
const glw_class_t *gc = w->glw_class;
int r = gc->gc_set_float3 ? gc->gc_set_float3(w, a->attrib, vec3) : -1;
if(r == -1) {
TRACE(TRACE_DEBUG, "GLW",
"Widget %s at %s:%d does not respond to attribute %s",
gc->gc_name, rstr_get(t->file), t->line, a->name);
return 0;
}
if(r)
attr_need_refresh(w->glw_root, t, a, r);
return 0;
}