当前位置: 首页>>代码示例>>C++>>正文


C++ SLEN函数代码示例

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


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

示例1: main

int main(int argc, char **argv)
{
	line_ctx ctx;
	
	if (argc != 2) {
		printf("Usage: %s <filename>\n", argv[0]);
		return 1;
	}

	memset(&ctx, 0, sizeof(ctx));


	lwc_intern_string("class", SLEN("class"), &ctx.attr_class);
	lwc_intern_string("id", SLEN("id"), &ctx.attr_id);
	
	assert(css__parse_testfile(argv[1], handle_line, &ctx) == true);
	
	/* and run final test */
	if (ctx.tree != NULL)
		run_test(&ctx, ctx.exp, ctx.expused);

	free(ctx.exp);
	
	lwc_string_unref(ctx.attr_class);
	lwc_string_unref(ctx.attr_id);
	
	lwc_iterate_strings(printing_lwc_iterator, NULL);
	
	assert(fail_because_lwc_leaked == false);
	
	printf("PASS\n");
	return 0;
}
开发者ID:LucidFusionLabs,项目名称:libcss,代码行数:33,代码来源:select-common.c

示例2: _dom_document_initialise

/* Initialise the document */
dom_exception _dom_document_initialise(dom_document *doc,
                                       dom_events_default_action_fetcher daf)
{
    dom_exception err;
    dom_string *name;

    err = dom_string_create((const uint8_t *) "#document",
                            SLEN("#document"), &name);
    if (err != DOM_NO_ERR)
        return err;

    doc->nodelists = NULL;

    err = _dom_node_initialise(&doc->base, doc, DOM_DOCUMENT_NODE,
                               name, NULL, NULL, NULL);
    dom_string_unref(name);
    if (err != DOM_NO_ERR)
        return err;

    list_init(&doc->pending_nodes);

    doc->id_name = NULL;
    doc->quirks = DOM_DOCUMENT_QUIRKS_MODE_NONE;

    err = dom_string_create_interned((const uint8_t *) "class",
                                     SLEN("class"), &doc->class_string);
    if (err != DOM_NO_ERR)
        return err;

    /* We should not pass a NULL when all things hook up */
    return _dom_document_event_internal_initialise(doc, &doc->dei, daf);
}
开发者ID:pcwalton,项目名称:NetSurf,代码行数:33,代码来源:document.c

示例3: mimesniff__compute_image

static nserror mimesniff__compute_image(lwc_string *official_type,
		const uint8_t *data, size_t len, lwc_string **effective_type)
{
#define SIG(t, s) { (const uint8_t *) s, SLEN(s), t }
	static const struct it_s {
		const uint8_t *sig;
		size_t len;
		lwc_string **type;
	} image_types[] = {
		SIG(&image_gif,                "GIF87a"),
		SIG(&image_gif,                "GIF89a"),
		SIG(&image_png,                "\x89PNG\r\n\x1a\n"),
		SIG(&image_jpeg,               "\xff\xd8\xff"),
		SIG(&image_bmp,                "BM"),
		SIG(&image_vnd_microsoft_icon, "\x00\x00\x01\x00"),
		{ NULL, 0, NULL }
	};
#undef SIG

	const struct it_s *it;

	if (data == NULL) {
		lwc_string_unref(official_type);
		return NSERROR_NEED_DATA;
	}

	for (it = image_types; it->sig != NULL; it++) {
		if (it->len <= len && memcmp(data, it->sig, it->len) == 0) {
			lwc_string_unref(official_type);
			*effective_type = lwc_string_ref(*it->type);
			return NSERROR_OK;
		}
	}

	/* WebP has a signature that doesn't fit into the above table */
	if (SLEN("RIFF????WEBPVP") <= len && 
			memcmp(data, "RIFF", SLEN("RIFF")) == 0 && 
			memcmp(data + SLEN("RIFF????"), 
					"WEBPVP", SLEN("WEBPVP")) == 0 ) {
		lwc_string_unref(official_type);
		*effective_type = lwc_string_ref(image_webp);
		return NSERROR_OK;
	}

	*effective_type = official_type;

	return NSERROR_OK;
}
开发者ID:EyMenZ,项目名称:NetSurf-OS3,代码行数:48,代码来源:mimesniff.c

示例4: nsgtk_theme_searchimage_default

static GtkImage *
nsgtk_theme_searchimage_default(nsgtk_search_buttons tbbutton,
		GtkIconSize iconsize)
{
	char *imagefile;
	GtkImage *image;
	switch(tbbutton) {

	case (SEARCH_BACK_BUTTON):
		return GTK_IMAGE(gtk_image_new_from_stock("gtk-go-back", iconsize));
	case (SEARCH_FORWARD_BUTTON):
		return GTK_IMAGE(gtk_image_new_from_stock("gtk-go-forward",
							  iconsize));
	case (SEARCH_CLOSE_BUTTON):
		return GTK_IMAGE(gtk_image_new_from_stock("gtk-close", iconsize));
	default: {
		size_t len = SLEN("themes/Alpha.png") +
			strlen(res_dir_location) + 1;
		imagefile = malloc(len);
		if (imagefile == NULL) {
			warn_user(messages_get("NoMemory"), 0);
			return NULL;
		}
		snprintf(imagefile, len, "%sthemes/Alpha.png",
			 res_dir_location);
		image = GTK_IMAGE(
			gtk_image_new_from_file(imagefile));
		free(imagefile);
		return image;
	}
	}
}
开发者ID:pcwalton,项目名称:NetSurf,代码行数:32,代码来源:theme.c

示例5: COMBO_CHANGED

END_HANDLER

COMBO_CHANGED(comboSearch, search_provider)	
{
	nsgtk_scaffolding *current = scaf_list;
	char *name;

	/* refresh web search prefs from file */
	search_web_provider_details(nsoption_charp(search_provider));

	/* retrieve ico */
	search_web_retrieve_ico(false);

	/* callback may handle changing gui */
	if (search_web_ico() != NULL)
		gui_window_set_search_ico(search_web_ico());

	/* set entry */
	name = search_web_provider_name();
	if (name == NULL) {
		warn_user(messages_get("NoMemory"), 0);
		continue;
	}
	char content[strlen(name) + SLEN("Search ") + 1];
	sprintf(content, "Search %s", name);
	free(name);
	while (current) {
		nsgtk_scaffolding_set_websearch(current, content);
		current = nsgtk_scaffolding_iterate(current);
	}
}
开发者ID:pcwalton,项目名称:NetSurf,代码行数:31,代码来源:options.c

示例6: theme_install_read

static bool theme_install_read(const char *data, unsigned long len)
{
	char *filename, *newfilename;
	size_t namelen;
	int handle = g_file_open_tmp("nsgtkthemeXXXXXX", &filename, NULL);
	if (handle == -1) {
		warn_user(messages_get("gtkFileError"),
			  "temporary theme file");
		return false;
	}
	ssize_t written = write(handle, data, len);
	close(handle);
	if ((unsigned)written != len)
		return false;

	/* get name of theme; set as dirname */
	namelen = SLEN("themes/") + strlen(res_dir_location) + 1;
	char dirname[namelen];
	snprintf(dirname, namelen, "%sthemes/", res_dir_location);

	/* save individual files in theme */
	newfilename = container_extract_theme(filename, dirname);
	g_free(filename);
	if (newfilename == NULL)
		return false;
	nsgtk_theme_add(newfilename);
	free(newfilename);

	return true;
}
开发者ID:pcwalton,项目名称:NetSurf,代码行数:30,代码来源:theme.c

示例7: amiga_path_to_nsurl

/**
 * Create a nsurl from a path using amiga file handling.
 *
 * Perform the necessary operations on a path to generate a nsurl.
 *
 * @param[in] path The path to convert.
 * @param[out] url_out pointer to recive the nsurl, The returned url
 *                     must be unreferenced by the caller.
 * @return NSERROR_OK and the url is placed in \a url or error code on
 *         faliure.
 */
static nserror amiga_path_to_nsurl(const char *path, struct nsurl **url_out)
{
	char *colon = NULL;
	char *r = NULL;
	char newpath[1024 + strlen(path)];
	BPTR lock = 0;
	nserror ret;

	if((lock = Lock(path, SHARED_LOCK))) {
		DevNameFromLock(lock, newpath, sizeof newpath, DN_FULLPATH);
		UnLock(lock);
	}
	else strlcpy(newpath, path, sizeof newpath);

	r = malloc(strlen(newpath) + SLEN("file:///") + 1);
	if (r == NULL) {
		return NSERROR_NOMEM;
	}

	if((colon = strchr(newpath, ':'))) *colon = '/';

	strcpy(r, "file:///");
	strcat(r, newpath);

	ret = nsurl_create(r, url_out);
	free(r);

	return ret;
}
开发者ID:EyMenZ,项目名称:NetSurf-OS3,代码行数:40,代码来源:misc.c

示例8: nsgtk_options_theme_combo

static void nsgtk_options_theme_combo(void) {
/* populate theme combo from themelist file */
	GtkBox *box = GTK_BOX(glade_xml_get_widget(gladeFile, "themehbox"));
	char buf[50];
	combotheme = gtk_combo_box_new_text();
	size_t len = SLEN("themelist") + strlen(res_dir_location) + 1;
	char themefile[len];
	if ((combotheme == NULL) || (box == NULL)) {
		warn_user(messages_get("NoMemory"), 0);
		return;
	}
	snprintf(themefile, len, "%sthemelist", res_dir_location);
	FILE *fp = fopen((const char *)themefile, "r");
	if (fp == NULL) {
		LOG(("Failed opening themes file"));
		warn_user("FileError", (const char *) themefile);
		return;
	}
	while (fgets(buf, sizeof(buf), fp) != NULL) {
		/* Ignore blank lines */
		if (buf[0] == '\0')
			continue;
		
		/* Remove trailing \n */
		buf[strlen(buf) - 1] = '\0';
		
		gtk_combo_box_append_text(GTK_COMBO_BOX(combotheme), buf);
	}
	fclose(fp);
	gtk_combo_box_set_active(GTK_COMBO_BOX(combotheme), 
			option_current_theme);
	gtk_box_pack_start(box, combotheme, FALSE, TRUE, 0);
	gtk_widget_show(combotheme);		
}
开发者ID:MarkieMark,项目名称:netsurf-git-svn,代码行数:34,代码来源:gtk_options.c

示例9: nsgtk_download_store_update_item

static void nsgtk_download_store_update_item (struct gui_download_window *dl)
{
	gchar *info = nsgtk_download_info_to_string(dl);
	char *human = human_friendly_bytesize(dl->speed);
	char speed[strlen(human) + SLEN("/s") + 1];
	sprintf(speed, "%s/s", human);
	gchar *time = nsgtk_download_time_to_string(dl->time_remaining);
	gboolean pulse = dl->status == NSGTK_DOWNLOAD_WORKING;

	/* Updates iter (which is needed to set and get data) with the dl row */
	gtk_tree_model_get_iter(GTK_TREE_MODEL(nsgtk_download_store),
				&nsgtk_download_iter,
				gtk_tree_row_reference_get_path(dl->row));

	gtk_list_store_set(nsgtk_download_store, &nsgtk_download_iter,
			   NSGTK_DOWNLOAD_PULSE, pulse ? dl->progress : -1,
			   NSGTK_DOWNLOAD_PROGRESS, pulse ? 0 : dl->progress,
			   NSGTK_DOWNLOAD_INFO, info,
			   NSGTK_DOWNLOAD_SPEED, dl->speed == 0 ? "-" : speed,
			   NSGTK_DOWNLOAD_REMAINING, time,
			   NSGTK_DOWNLOAD, dl,
			   -1);

	g_free(info);
	g_free(time);
}
开发者ID:arczi84,项目名称:NetSurf-68k,代码行数:26,代码来源:download.c

示例10: move_chars

static inline void move_chars(struct part *p, int x, int y, int nx, int ny)
{
	if (LEN(y) - x <= 0) return;
	copy_chars(p, nx, ny, LEN(y) - x, &POS(x, y));
	SLEN(y, x);
	move_links(p, x, y, nx, ny);
}
开发者ID:ebichu,项目名称:dd-wrt,代码行数:7,代码来源:html_r.c

示例11: fetch_rsrc_register

void fetch_rsrc_register(void)
{
	lwc_string *scheme;
	int err;

	err = find_app_resources();

	if (err < B_OK) {
		warn_user("Resources", strerror(err));
		return;
	}

	if (lwc_intern_string("rsrc", SLEN("rsrc"), &scheme) != lwc_error_ok) {
		die("Failed to initialise the fetch module "
				"(couldn't intern \"rsrc\").");
	}

	fetch_add_fetcher(scheme,
		fetch_rsrc_initialise,
		fetch_rsrc_can_fetch,
		fetch_rsrc_setup,
		fetch_rsrc_start,
		fetch_rsrc_abort,
		fetch_rsrc_free,
		fetch_rsrc_poll,
		fetch_rsrc_finalise);
}
开发者ID:Achal-Aggarwal,项目名称:netsurf,代码行数:27,代码来源:fetch_rsrc.cpp

示例12: typestr

const char *
typestr(unsigned t, size_t n)
{
  static char buf[SLEN(n) + 4];
  char *p = buf + sizeof buf - 1;

  *p = '\0';
  if (! (t & (T_GROUP | T_BITFIELD)) && 1 < n)
    *--p = t & T_LSBFIRST ? 'l' : 'm';

  do
    *--p = '0' + n % 10;
  while (n /= 10);

  if (t & T_GROUP)
    *--p = 's';
  else if (t & T_BITFIELD)
    *--p = 'b';
  else if (t & T_TWOSCOMP)
    *--p = 't', *--p = 's';
  else if (t & T_ONESCOMP)
    *--p = 'o', *--p = 's';
  else if (t & T_SIGNMAG)
    *--p = 'm', *--p = 's';
  else
    *--p = 'u';

  return p;
}
开发者ID:d5h,项目名称:gah,代码行数:29,代码来源:main.c

示例13: debug_un

static int
debug_un(char *str, size_t len, const struct sockaddr_un *sun)
{
	return snprintf(str, len, "sun_len=%u, sun_family=%u, sun_path=%*s",
	    SLEN(sun), sun->sun_family, (int)sizeof(sun->sun_path),
	    sun->sun_path);
}
开发者ID:0mp,项目名称:freebsd,代码行数:7,代码来源:sockaddr_snprintf.c

示例14: nsgtk_theme_add

void nsgtk_theme_add(const char *themename)
{
	size_t len;
	GtkWidget *notification, *label;
	len = SLEN("themelist") + strlen(res_dir_location) + 1;
	char themefile[len];
	snprintf(themefile, len, "%s%s", res_dir_location, "themelist");
	/* conduct verification here; no adding duplicates to list */
	if (nsgtk_theme_verify(themename) == false) {
		warn_user(messages_get("gtkThemeDup"), 0);
		return;
	}
	FILE *fp = fopen(themefile, "a");
	if (fp == NULL) {
		warn_user(messages_get("gtkFileError"), themefile);
		return;
	}
	fprintf(fp, "%s\n", themename);
	fclose(fp);

	/* notification that theme was added successfully */
	notification = gtk_dialog_new_with_buttons(messages_get("gtkThemeAdd"),
			NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_OK,
			GTK_RESPONSE_NONE, NULL);
	if (notification == NULL) {
		warn_user(messages_get("NoMemory"), 0);
		return;
	}
	len = SLEN("\t\t\t\t\t\t") + strlen(messages_get("gtkThemeAdd")) + 1;
	char labelcontent[len];
	snprintf(labelcontent, len, "\t\t\t%s\t\t\t",
		 messages_get("gtkThemeAdd"));
	label = gtk_label_new(labelcontent);
	if (label == NULL) {
		warn_user(messages_get("NoMemory"), 0);
		return;
	}
	g_signal_connect_swapped(notification, "response",
				 G_CALLBACK(gtk_widget_destroy), notification);
	gtk_container_add(GTK_CONTAINER(nsgtk_dialog_get_action_area(GTK_DIALOG(notification))), label);
	gtk_widget_show_all(notification);

	/* update combo */
	if (wndPreferences != NULL) {
		nsgtk_options_combo_theme_add(themename);
	}
}
开发者ID:pcwalton,项目名称:NetSurf,代码行数:47,代码来源:theme.c

示例15: debug_in

static int
debug_in(char *str, size_t len, const struct sockaddr_in *sin)
{
	return snprintf(str, len, "sin_len=%u, sin_family=%u, sin_port=%u, "
	    "sin_addr.s_addr=%08x",
	    SLEN(sin), sin->sin_family, sin->sin_port,
	    sin->sin_addr.s_addr);
}
开发者ID:0mp,项目名称:freebsd,代码行数:8,代码来源:sockaddr_snprintf.c


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