• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ dstr_init函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中dstr_init函数的典型用法代码示例。如果您正苦于以下问题:C++ dstr_init函数的具体用法?C++ dstr_init怎么用?C++ dstr_init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了dstr_init函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: dstr_init

char *xcap_uri_for_rls_resource(const str_t *xcap_root, const str_t *uri)
{
	dstring_t s;
	int l;
	str_t c_uri;
	char *dst = NULL;

	if (!xcap_root) return NULL;
	dstr_init(&s, 2 * xcap_root->len + 32);
	dstr_append_str(&s, xcap_root);
	if (xcap_root->s[xcap_root->len - 1] != '/') dstr_append(&s, "/", 1);
	dstr_append_zt(&s, "rls-services/global/index/~~/rls-services/service[@uri=%22");
	canonicalize_uri(uri, &c_uri);
	dstr_append_str(&s, &c_uri);
	if (c_uri.s) cds_free(c_uri.s);
	
	dstr_append_zt(&s, "%22]");
	l = dstr_get_data_length(&s);
	if (l > 0) {
		dst = (char *)cds_malloc(l + 1);
		if (dst) {
			dstr_get_data(&s, dst);
			dst[l] = 0;
		}
	}
	dstr_destroy(&s);
	return dst;
}
开发者ID:2pac,项目名称:kamailio,代码行数:28,代码来源:resource_list.c


示例2: xshm_server_changed

/**
 * The x server was changed
 */
static bool xshm_server_changed(obs_properties_t *props,
		obs_property_t *p, obs_data_t *settings)
{
	UNUSED_PARAMETER(p);

	bool advanced           = obs_data_get_bool(settings, "advanced");
	int_fast32_t old_screen = obs_data_get_int(settings, "screen");
	const char *server      = obs_data_get_string(settings, "server");
	obs_property_t *screens = obs_properties_get(props, "screen");

	/* we want a real NULL here in case there is no string here */
	server = (advanced && *server) ? server : NULL;

	obs_property_list_clear(screens);

	Display *dpy = XOpenDisplay(server);
	if (!dpy) {
		obs_property_set_enabled(screens, false);
		return true;
	}

	struct dstr screen_info;
	dstr_init(&screen_info);
	bool xinerama = xinerama_is_active(dpy);
	int_fast32_t count = (xinerama) ?
			xinerama_screen_count(dpy) : XScreenCount(dpy);

	for (int_fast32_t i = 0; i < count; ++i) {
		int_fast32_t x, y, w, h;
		x = y = w = h = 0;

		if (xinerama)
			xinerama_screen_geo(dpy, i, &x, &y, &w, &h);
		else
			x11_screen_geo(dpy, i, &w, &h);

		dstr_printf(&screen_info, "Screen %"PRIuFAST32" (%"PRIuFAST32
				"x%"PRIuFAST32" @ %"PRIuFAST32
				",%"PRIuFAST32")", i, w, h, x, y);

		obs_property_list_add_int(screens, screen_info.array, i);
	}

	/* handle missing screen */
	if (old_screen + 1 > count) {
		dstr_printf(&screen_info, "Screen %"PRIuFAST32" (not found)",
				old_screen);
		size_t index = obs_property_list_add_int(screens,
				screen_info.array, old_screen);
		obs_property_list_item_disable(screens, index, true);

	}

	dstr_free(&screen_info);

	XCloseDisplay(dpy);
	obs_property_set_enabled(screens, true);

	return true;
}
开发者ID:ScottMichaud,项目名称:obs-studio,代码行数:63,代码来源:xshm-input.c


示例3: create_lpidf_document

int create_lpidf_document(presentity_info_t *p, str_t *dst, str_t *dst_content_type)
{
	dstring_t buf;
	int err;
	
	if (!dst) return -1;
	
	str_clear(dst);
	if (dst_content_type) str_clear(dst_content_type);

	if (!p) return -1;
	
	if (dst_content_type) {
		if (str_dup_zt(dst_content_type, "text/lpidf") < 0) {
			return -1;
		}
	}

/*	if (!p->first_tuple) return 0;*/	/* no tuples => nothing to say */ 
	
	dstr_init(&buf, 2048);
	
	doc_add_presentity(&buf, p);
	
	err = dstr_get_str(&buf, dst);
	dstr_destroy(&buf);
	
	if (err != 0) {
		str_free_content(dst);
		if (dst_content_type) str_free_content(dst_content_type);
	}
	
	return err;
}
开发者ID:BackupTheBerlios,项目名称:ser,代码行数:34,代码来源:lpidf.c


示例4: ep_write_main

static void ep_write_main(struct effect_parser *ep, struct dstr *shader,
		struct ep_func *func, struct dstr *call_str)
{
	struct dstr param_str;
	struct dstr adjusted_call;

	dstr_init(&param_str);
	dstr_init_copy_dstr(&adjusted_call, call_str);

	dstr_cat(shader, "\n");
	dstr_cat(shader, func->ret_type);
	dstr_cat(shader, " main(");

	ep_write_main_params(ep, shader, &param_str, func);

	dstr_cat(shader, ")");
	if (func->mapping) {
		dstr_cat(shader, " : ");
		dstr_cat(shader, func->mapping);
	}

	dstr_cat(shader, "\n{\n\treturn ");
	dstr_cat_dstr(shader, &adjusted_call);
	dstr_cat(shader, "\n}\n");

	dstr_free(&adjusted_call);
	dstr_free(&param_str);
}
开发者ID:ArnoldSchiller,项目名称:obs-studio,代码行数:28,代码来源:effect-parser.c


示例5: v4l2_format_list

/*
 * List formats for device
 */
static void v4l2_format_list(int dev, obs_property_t *prop)
{
	struct v4l2_fmtdesc fmt;
	fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
	fmt.index = 0;
	struct dstr buffer;
	dstr_init(&buffer);

	obs_property_list_clear(prop);

	while (v4l2_ioctl(dev, VIDIOC_ENUM_FMT, &fmt) == 0) {
		dstr_copy(&buffer, (char *) fmt.description);
		if (fmt.flags & V4L2_FMT_FLAG_EMULATED)
			dstr_cat(&buffer, " (Emulated)");

		if (v4l2_to_obs_video_format(fmt.pixelformat)
				!= VIDEO_FORMAT_NONE) {
			obs_property_list_add_int(prop, buffer.array,
					fmt.pixelformat);
			blog(LOG_INFO, "Pixelformat: %s (available)",
			     buffer.array);
		} else {
			blog(LOG_INFO, "Pixelformat: %s (unavailable)",
			     buffer.array);
		}
		fmt.index++;
	}

	dstr_free(&buffer);
}
开发者ID:Socapex,项目名称:obs-studio,代码行数:33,代码来源:v4l2-input.c


示例6: v4l2_dv_timing_list

/*
 * List dv timings for the device
 */
static void v4l2_dv_timing_list(int dev, obs_property_t *prop)
{
	struct v4l2_dv_timings dvt;
	struct dstr buf;
	int index = 0;
	dstr_init(&buf);

	obs_property_list_clear(prop);

	obs_property_list_add_int(prop, obs_module_text("LeaveUnchanged"), -1);

	while (v4l2_enum_dv_timing(dev, &dvt, index) == 0) {
		/* i do not pretend to understand, this is from qv4l2 ... */
		double h    = (double) dvt.bt.height + dvt.bt.vfrontporch +
				dvt.bt.vsync + dvt.bt.vbackporch +
				dvt.bt.il_vfrontporch + dvt.bt.il_vsync +
				dvt.bt.il_vbackporch;
		double w    = (double) dvt.bt.width + dvt.bt.hfrontporch +
				dvt.bt.hsync + dvt.bt.hbackporch;
		double i    = (dvt.bt.interlaced) ? 2.0f : 1.0f;
		double rate = (double) dvt.bt.pixelclock / (w * (h / i));

		dstr_printf(&buf, "%ux%u%c %.2f",
				dvt.bt.width, dvt.bt.height,
				(dvt.bt.interlaced) ? 'i' : 'p', rate);

		obs_property_list_add_int(prop, buf.array, index);

		index++;
	}

	dstr_free(&buf);
}
开发者ID:Socapex,项目名称:obs-studio,代码行数:36,代码来源:v4l2-input.c


示例7: config_set_default_double

void config_set_default_double(config_t config, const char *section,
		const char *name, double value)
{
	struct dstr str;
	dstr_init(&str);
	dstr_printf(&str, "%g", value);
	config_set_item(&config->defaults, section, name, str.array);
}
开发者ID:Alucard014,项目名称:obs-studio,代码行数:8,代码来源:config-file.c


示例8: dstr_right

void dstr_right(struct dstr *dst, const struct dstr *str, const size_t pos)
{
	struct dstr temp;
	dstr_init(&temp);
	dstr_ncopy(&temp, str->array+pos, str->len-pos);
	dstr_copy_dstr(dst, &temp);
	dstr_free(&temp);
}
开发者ID:ootz90,项目名称:obs-studio,代码行数:8,代码来源:dstr.c


示例9: config_set_int

void config_set_int(config_t *config, const char *section,
		const char *name, int64_t value)
{
	struct dstr str;
	dstr_init(&str);
	dstr_printf(&str, "%lld", value);
	config_set_item(&config->sections, section, name, str.array);
}
开发者ID:Antidote,项目名称:obs-studio,代码行数:8,代码来源:config-file.c


示例10: dstr_vcatf

void dstr_vcatf(struct dstr *dst, const char *format, va_list args)
{
	struct dstr temp;
	dstr_init(&temp);
	dstr_vprintf(&temp, format, args);
	dstr_cat_dstr(dst, &temp);
	dstr_free(&temp);
}
开发者ID:ootz90,项目名称:obs-studio,代码行数:8,代码来源:dstr.c


示例11: config_set_default_uint

void config_set_default_uint(config_t config, const char *section,
		const char *name, uint64_t value)
{
	struct dstr str;
	dstr_init(&str);
	dstr_printf(&str, "%llu", value);
	config_set_item(&config->defaults, section, name, str.array);
}
开发者ID:Alucard014,项目名称:obs-studio,代码行数:8,代码来源:config-file.c


示例12: dstr_mid

void dstr_mid(struct dstr *dst, const struct dstr *str, const size_t start,
		const size_t count)
{
	struct dstr temp;
	dstr_init(&temp);
	dstr_copy_dstr(&temp, str);
	dstr_ncopy(dst, temp.array+start, count);
	dstr_free(&temp);
}
开发者ID:ootz90,项目名称:obs-studio,代码行数:9,代码来源:dstr.c


示例13: create_headers

static inline int create_headers(struct watcher* _w, str *dst, str *content_type)
{
    dstring_t buf;
    time_t t;
    int err = 0;

    dstr_init(&buf, 256);
    str_clear(dst);

    /* required by RFC 3261 */
    dstr_append_zt(&buf, "Max-Forwards: 70\r\n");

    /* Event header */

    dstr_append_zt(&buf, "Event: ");
    dstr_append_zt(&buf, event_package2str(_w->event_package));
    dstr_append_zt(&buf, "\r\n");

    /* Content-Type header */

    /* content types can have dynamical parameters (multipart/related)
     * => don't generate them "staticaly"; use values created in the
     * time of document creation */
    if (!is_str_empty(content_type)) { /* documents without body doesn't need it */
        dstr_append_zt(&buf, "Content-Type: ");
        dstr_append_str(&buf, content_type);
        dstr_append_zt(&buf, "\r\n");
    }

    /* Contact header */

    if (is_str_empty(&_w->server_contact)) {
        LOG(L_WARN, "add_contact_hf(): Can't add empty contact to NOTIFY.\n");
    }
    else {
        dstr_append_zt(&buf, "Contact: ");
        dstr_append_str(&buf, &_w->server_contact);
        dstr_append_zt(&buf, "\r\n");
    }

    /* Subscription-State header */

    if (_w->expires) t = _w->expires - time(0);
    else t = 0;

    if (add_subs_state_hf(&buf, _w->status, t) < 0) {
        LOG(L_ERR, "create_headers(): Error while adding Subscription-State\n");
        dstr_destroy(&buf);
        return -3;
    }

    err = dstr_get_str(&buf, dst);
    dstr_destroy(&buf);

    return err;
}
开发者ID:kiryu,项目名称:kamailio,代码行数:56,代码来源:notify.c


示例14: init_output_sstream

int init_output_sstream(sstream_t *ss, int out_buff_resize)
{
	if (!ss) return -1;
	
	ss->type = sstream_out;
	str_clear(&ss->in);
	ss->in_pos = 0;
	dstr_init(&ss->out, out_buff_resize);
	return 0;
}
开发者ID:2pac,项目名称:kamailio,代码行数:10,代码来源:serialize.c


示例15: dstr_init

/* on windows, data files should always be in [base directory]/data */
char *obs_find_plugin_file(const char *file)
{
	struct dstr path;
	dstr_init(&path);

	if (check_path(file, "data/obs-plugins/", &path))
		return path.array;

	if (check_path(file, "../../data/obs-plugins/", &path))
		return path.array;

	dstr_free(&path);
	return NULL;
}
开发者ID:Arkkis,项目名称:obs-studio,代码行数:15,代码来源:obs-windows.c


示例16: config_save

int config_save(config_t config)
{
	FILE *f;
	struct dstr str;
	size_t i, j;

	if (!config)
		return CONFIG_ERROR;

	dstr_init(&str);

	f = os_fopen(config->file, "wb");
	if (!f)
		return CONFIG_FILENOTFOUND;

	for (i = 0; i < config->sections.num; i++) {
		struct config_section *section = darray_item(
				sizeof(struct config_section),
				&config->sections, i);

		if (i) dstr_cat(&str, "\n");

		dstr_cat(&str, "{");
		dstr_cat(&str, section->name);
		dstr_cat(&str, "]\n");

		for (j = 0; j < section->items.num; j++) {
			struct config_item *item = darray_item(
					sizeof(struct config_item),
					&section->items, i);

			dstr_cat(&str, item->name);
			dstr_cat(&str, "=");
			dstr_cat(&str, item->value);
			dstr_cat(&str, "\n");
		}
	}

#ifdef _WIN32
	fwrite("\xEF\xBB\xBF", 1, 3, f);
#endif
	fwrite(str.array, 1, str.len, f);
	fclose(f);

	dstr_free(&str);

	return CONFIG_SUCCESS;
}
开发者ID:Alucard014,项目名称:obs-studio,代码行数:48,代码来源:config-file.c


示例17: v4l2_framerate_list

/*
 * List framerates for device and resolution
 */
static void v4l2_framerate_list(int dev, uint_fast32_t pixelformat,
		uint_fast32_t width, uint_fast32_t height, obs_property_t *prop)
{
	struct v4l2_frmivalenum frmival;
	frmival.pixel_format = pixelformat;
	frmival.width = width;
	frmival.height = height;
	frmival.index = 0;
	struct dstr buffer;
	dstr_init(&buffer);

	obs_property_list_clear(prop);

	obs_property_list_add_int(prop, obs_module_text("LeaveUnchanged"), -1);

	v4l2_ioctl(dev, VIDIOC_ENUM_FRAMEINTERVALS, &frmival);

	switch(frmival.type) {
	case V4L2_FRMIVAL_TYPE_DISCRETE:
		while (v4l2_ioctl(dev, VIDIOC_ENUM_FRAMEINTERVALS,
				&frmival) == 0) {
			float fps = (float) frmival.discrete.denominator /
				frmival.discrete.numerator;
			int pack = v4l2_pack_tuple(frmival.discrete.numerator,
					frmival.discrete.denominator);
			dstr_printf(&buffer, "%.2f", fps);
			obs_property_list_add_int(prop, buffer.array, pack);
			frmival.index++;
		}
		break;
	default:
		blog(LOG_INFO, "Stepwise and Continuous framerates "
			"are currently hardcoded");

		for (const int *packed = v4l2_framerates; *packed; ++packed) {
			int num;
			int denom;
			v4l2_unpack_tuple(&num, &denom, *packed);
			float fps = (float) denom / num;
			dstr_printf(&buffer, "%.2f", fps);
			obs_property_list_add_int(prop, buffer.array, *packed);
		}
		break;
	}

	dstr_free(&buffer);
}
开发者ID:Bl00drav3n,项目名称:obs-studio,代码行数:50,代码来源:v4l2-input.c


示例18: cf_include_file

static void cf_include_file(struct cf_preprocessor *pp,
		const struct cf_token *file_token)
{
	struct cf_lexer new_lex;
	struct dstr str_file;
	FILE *file;
	char *file_data;
	struct cf_token *tokens;
	size_t i;

	dstr_init(&str_file);
	dstr_copy_strref(&str_file, &file_token->str);
	dstr_mid(&str_file, &str_file, 1, str_file.len-2);

	/* if dependency already exists, run preprocessor on it */
	for (i = 0; i < pp->dependencies.num; i++) {
		struct cf_lexer *dep = pp->dependencies.array+i;

		if (strcmp(dep->file, str_file.array) == 0) {
			tokens = cf_lexer_gettokens(dep);
			cf_preprocess_tokens(pp, false, &tokens);
			goto exit;
		}
	}

	file = os_fopen(str_file.array, "rb");
	if (!file) {
		cf_adderror(pp, file_token, "Could not open file '$1'",
				file_token->str.array, NULL, NULL);
		goto exit;
	}

	os_fread_utf8(file, &file_data);
	fclose(file);

	cf_lexer_init(&new_lex);
	cf_lexer_lex(&new_lex, file_data, str_file.array);
	tokens = cf_lexer_gettokens(&new_lex);
	cf_preprocess_tokens(pp, false, &tokens);
	bfree(file_data);

	da_push_back(pp->dependencies, &new_lex);

exit:
	dstr_free(&str_file);
}
开发者ID:Alucard014,项目名称:obs-studio,代码行数:46,代码来源:cf-lexer.c


示例19: ep_makeshaderstring

static void ep_makeshaderstring(struct effect_parser *ep,
		struct dstr *shader, struct darray *shader_call,
		struct darray *used_params)
{
	struct cf_token *token = shader_call->array;
	struct cf_token *func_name;
	struct ep_func *func;
	struct dstr call_str;

	dstr_init(&call_str);

	if (!token)
		return;

	while (token->type != CFTOKEN_NONE && is_whitespace(*token->str.array))
		token++;

	if (token->type == CFTOKEN_NONE ||
	    strref_cmp(&token->str, "NULL") == 0)
		return;

	func_name = token;

	while (token->type != CFTOKEN_NONE) {
		struct ep_param *param = ep_getparam_strref(ep, &token->str);
		if (param)
			ep_write_param(shader, param, used_params);

		dstr_cat_strref(&call_str, &token->str);
		token++;
	}

	func = ep_getfunc_strref(ep, &func_name->str);
	if (!func)
		return;

	ep_write_func(ep, shader, func, used_params);
	ep_write_main(ep, shader, func, &call_str);

	dstr_free(&call_str);

	ep_reset_written(ep);
}
开发者ID:Dead133,项目名称:obs-studio,代码行数:43,代码来源:effect-parser.c


示例20: v4l2_resolution_list

/*
 * List resolutions for device and format
 */
static void v4l2_resolution_list(int dev, uint_fast32_t pixelformat,
		obs_property_t *prop)
{
	struct v4l2_frmsizeenum frmsize;
	frmsize.pixel_format = pixelformat;
	frmsize.index = 0;
	struct dstr buffer;
	dstr_init(&buffer);

	obs_property_list_clear(prop);

	obs_property_list_add_int(prop, obs_module_text("LeaveUnchanged"), -1);

	v4l2_ioctl(dev, VIDIOC_ENUM_FRAMESIZES, &frmsize);

	switch(frmsize.type) {
	case V4L2_FRMSIZE_TYPE_DISCRETE:
		while (v4l2_ioctl(dev, VIDIOC_ENUM_FRAMESIZES, &frmsize) == 0) {
			dstr_printf(&buffer, "%dx%d", frmsize.discrete.width,
					frmsize.discrete.height);
			obs_property_list_add_int(prop, buffer.array,
					v4l2_pack_tuple(frmsize.discrete.width,
					frmsize.discrete.height));
			frmsize.index++;
		}
		break;
	default:
		blog(LOG_INFO, "Stepwise and Continuous framesizes "
			"are currently hardcoded");

		for (const int *packed = v4l2_framesizes; *packed; ++packed) {
			int width;
			int height;
			v4l2_unpack_tuple(&width, &height, *packed);
			dstr_printf(&buffer, "%dx%d", width, height);
			obs_property_list_add_int(prop, buffer.array, *packed);
		}
		break;
	}

	dstr_free(&buffer);
}
开发者ID:Bl00drav3n,项目名称:obs-studio,代码行数:45,代码来源:v4l2-input.c



注:本文中的dstr_init函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ dsyslog函数代码示例发布时间:2022-05-30
下一篇:
C++ dstr_copy函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap