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

C++ sl_init函数代码示例

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

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



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

示例1: help

/*
 * Help command.
 * Call each command handler with argc == 0 and argv[0] == name.
 */
void
help(int argc, char *argv[])
{
	struct cmd *c;

	if (argc == 1) {
		StringList *buf;

		buf = sl_init();
		fprintf(ttyout, "%sommands may be abbreviated.  Commands are:\n\n",
		    proxy ? "Proxy c" : "C");
		for (c = cmdtab; c < &cmdtab[NCMDS]; c++)
			if (c->c_name && (!proxy || c->c_proxy))
				sl_add(buf, c->c_name);
		list_vertical(buf);
		sl_free(buf, 0);
		return;
	}

#define HELPINDENT ((int) sizeof("disconnect"))

	while (--argc > 0) {
		char *arg;

		arg = *++argv;
		c = getcmd(arg);
		if (c == (struct cmd *)-1)
			fprintf(ttyout, "?Ambiguous help command %s\n", arg);
		else if (c == (struct cmd *)0)
			fprintf(ttyout, "?Invalid help command %s\n", arg);
		else
			fprintf(ttyout, "%-*s\t%s\n", HELPINDENT,
				c->c_name, c->c_help);
	}
}
开发者ID:appleorange1,项目名称:bitrig,代码行数:39,代码来源:main.c


示例2: run_slash_script

static int
run_slash_script(request_rec* r, void* stack_top)
{
    sl_vm_t* vm;
    slash_context_t ctx;
    sl_vm_frame_t exit_frame, exception_frame;
    char* last_slash;
    SLVAL error;
    sl_static_init();
    vm = sl_init("apache2");
    sl_gc_set_stack_top(vm->arena, stack_top);
    vm->cwd = sl_alloc_buffer(vm->arena, strlen(r->canonical_filename) + 10);
    strcpy(vm->cwd, r->canonical_filename);
    last_slash = strrchr(vm->cwd, '/');
    if(last_slash) {
        *last_slash = 0;
    }
    SL_TRY(exit_frame, SL_UNWIND_ALL, {
        SL_TRY(exception_frame, SL_UNWIND_EXCEPTION, {
            ctx.headers_sent = 0;
            ctx.vm = vm;
            ctx.r = r;
            vm->data = &ctx;
            setup_request_object(vm, r);
            setup_response_object(vm);
            ap_set_content_type(r, "text/html; charset=utf-8");
            sl_do_file(vm, r->canonical_filename);
        }, error, {
            sl_response_clear(vm);
            sl_render_error_page(vm, error);
        });
开发者ID:Hmaal,项目名称:slash,代码行数:31,代码来源:mod_slash.c


示例3: complete_ifname

unsigned char
complete_ifname(char *word, int list, EditLine *el)
{
	StringList *words;
	size_t wordlen;
	unsigned char rv;   

	words = sl_init();
	wordlen = strlen(word);

	struct if_nameindex *ifn_list, *ifnp;

	if ((ifn_list = if_nameindex()) == NULL)
		return 0;

	for (ifnp = ifn_list; ifnp->if_name != NULL; ifnp++) {
                if (wordlen > strlen(ifnp->if_name))
                        continue;
                if (strncmp(word, ifnp->if_name, wordlen) == 0)
                        sl_add(words, ifnp->if_name);
        }

        rv = complete_ambiguous(word, list, words, el);
	if_freenameindex(ifn_list);
        sl_free(words, 0);
        return (rv);
}
开发者ID:danrl,项目名称:nsh,代码行数:27,代码来源:complete.c


示例4: _local_initshells

/*ARGSUSED*/
static int
_local_initshells(void *rv, void *cb_data, va_list ap)
{
	char	*sp, *cp;
	FILE	*fp;
	char	 line[MAXPATHLEN + 2];

	if (sl)
		sl_free(sl, 1);
	sl = sl_init();

	if ((fp = fopen(_PATH_SHELLS, "r")) == NULL)
		return NS_UNAVAIL;

	sp = cp = line;
	while (fgets(cp, MAXPATHLEN + 1, fp) != NULL) {
		while (*cp != '#' && *cp != '/' && *cp != '\0')
			cp++;
		if (*cp == '#' || *cp == '\0')
			continue;
		sp = cp;
		while (!isspace(*cp) && *cp != '#' && *cp != '\0')
			cp++;
		*cp++ = '\0';
		sl_add(sl, strdup(sp));
	}
	fclose(fp);
	return NS_SUCCESS;
}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:30,代码来源:getusershell.c


示例5: complete_command

/*
 * Complete a command
 */
static unsigned char
complete_command(char *word, int list, EditLine *el, char **table, int stlen)
{
	char **c;
	struct ghs *ghs;
	StringList *words;
	size_t wordlen;
	unsigned char rv;

	if (table == NULL)
		return(CC_ERROR);

	words = sl_init();
	wordlen = strlen(word);

	for (c = table; *c != NULL; c = (char **)((char *)c + stlen)) {
		ghs = (struct ghs *)c;
		if (wordlen > strlen(ghs->name))
			continue;
		if (strncmp(word, ghs->name, wordlen) == 0)
			sl_add(words, ghs->name);
	}

	rv = complete_ambiguous(word, list, words, el);
	sl_free(words, 0);
	return (rv);
}
开发者ID:danrl,项目名称:nsh,代码行数:30,代码来源:complete.c


示例6: _dns_initshells

/*ARGSUSED*/
static int
_dns_initshells(void *rv, void *cb_data, va_list ap)
{
	char	  shellname[] = "shells-XXXXX";
	int	  hsindex, hpi, r;
	char	**hp;
	void	 *context;

	if (sl)
		sl_free(sl, 1);
	sl = sl_init();
	r = NS_UNAVAIL;
	if (hesiod_init(&context) == -1)
		return (r);

	for (hsindex = 0; ; hsindex++) {
		snprintf(shellname, sizeof(shellname)-1, "shells-%d", hsindex);
		hp = hesiod_resolve(context, shellname, "shells");
		if (hp == NULL) {
			if (errno == ENOENT) {
				if (hsindex == 0)
					r = NS_NOTFOUND;
				else
					r = NS_SUCCESS;
			}
			break;
		} else {
			for (hpi = 0; hp[hpi]; hpi++)
				sl_add(sl, hp[hpi]);
			free(hp);
		}
	}
	hesiod_end(context);
	return (r);
}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:36,代码来源:getusershell.c


示例7: conf_rtables

void conf_rtables(FILE *output)
{
	int i, rtableid;
	StringList *rtables;

	rtables = sl_init();
	if (db_select_rtable_rtables(rtables) < 0) {
		printf("%% database failure select rtables rtable\n");
		sl_free(rtables, 1);
		return;
	}
	for (i = 0; i < rtables->sl_cur; i++) {
		const char *errmsg = NULL;

		rtableid = strtonum(rtables->sl_str[i], 0, RT_TABLEID_MAX, &errmsg);
		if (rtableid == 0)
			continue;
		if (errmsg) {
			printf("%% Invalid route table (%d) %s: %s\n",  i,
			    rtables->sl_str[i], errmsg);
			continue;
		}
		conf_rtables_rtable(output, rtableid);
	}

	sl_free(rtables, 1);
}
开发者ID:sthen,项目名称:nsh,代码行数:27,代码来源:conf.c


示例8: conf_sppp_mh

void
conf_sppp_mh(FILE *output, struct sauthreq *spa, char *ifname, char *pfx)
{
	int i;
	char type[TYPESZ];
	StringList *req;

	if (!(spa->proto | spa->name[0] | spa->secret[0] | (spa->flags &
	    AUTHFLAG_NOCALLOUT) | (spa->flags & AUTHFLAG_NORECHALLENGE)))
		return;
	fprintf(output, " %s", pfx);
	if (spa->proto)
		for (i = 0; i < nitems(spppproto); i++)
			if (spa->proto == spppproto[i].type)
				fprintf(output, " proto %s", spppproto[i].name);
	if (spa->name[0])
		fprintf(output, " name %s", spa->name);

	snprintf(type, TYPESZ, "%skey", pfx);
	req = sl_init();
	if (db_select_flag_x_ctl(req, type, ifname) >= 0) {
		if (req->sl_cur > 0)
			fprintf(output, " key %s", req->sl_str[0]);
	}
	sl_free(req, 1);

	if (spa->flags & AUTHFLAG_NOCALLOUT)
		fprintf(output, " flag callin");
	if (spa->flags & AUTHFLAG_NORECHALLENGE)
		fprintf(output, " flag norechallenge");
	fprintf(output, "\n");
}
开发者ID:sthen,项目名称:nsh,代码行数:32,代码来源:ppp.c


示例9: main

int
main(int argc, char *argv[])
{
        printf("Welcome to Shoestrap\n");

        struct sl_interpreter_state *state = sl_init();
        char *input_string = malloc(MAX_INPUT_SIZE * sizeof(char));
        sl_value in, out;

        while (1) {
                printf(">> ");
                fflush(stdin);
                input_string = fgets(input_string, MAX_INPUT_SIZE, stdin);

                if (input_string == NULL) {
                        break;
                }

                struct sl_keep_list *old = state->keep_list;

                in = sl_read(state, input_string);
                out = sl_eval(state, in, state->global_env);

                sl_free_keep_list(state->keep_list, old);
                state->keep_list = old;

                sl_p(state, out);
        }

        free(input_string);
        sl_destroy(state);
        return 0;
}
开发者ID:davidbalbert,项目名称:shoelaces,代码行数:33,代码来源:shoestrap.c


示例10: vio_partition_val

vio_err_t vio_partition_val(vio_ctx *ctx, vio_val *v, vio_val *q, vio_val **out_rets, vio_val **out_parts) {
    vio_err_t err = 0;
    struct partition *p = NULL;
    struct partition_item *it = NULL;
    vio_val *ret;
    sl_skiplist parts;

    sl_init(&parts, cmp_vals, ctx, NULL, NULL);

    for (uint32_t i = 0; i < v->vlen; ++i) {
        VIO__ERRIF(ctx->sp >= VIO_STACK_SIZE, VE_STACK_OVERFLOW);
        ctx->stack[ctx->sp++] = v->vv[i];
        vio_exec(ctx, q->bc);
        ret = ctx->stack[--ctx->sp];
        if (!sl_find(&parts, ret, &p)) {
            VIO__ERRIF((p = (struct partition *)malloc(sizeof(struct partition))) == NULL, VE_ALLOC_FAIL);
            p->last = NULL;
            p->size = 0;
            sl_insert(&parts, ret, p, NULL);
        }
        VIO__ERRIF((it = (struct partition_item *)malloc(sizeof(struct partition_item))) == NULL, VE_ALLOC_FAIL);
        it->next = p->last;
        it->v = v->vv[i];
        p->last = it;
        ++p->size;
    }

    VIO__CHECK(vio_vec(ctx, out_rets, sl_size(&parts), NULL));
    VIO__CHECK(vio_vec(ctx, out_parts, sl_size(&parts), NULL));
    struct part_data pd = { .i = 0, .rets = *out_rets, .parts = *out_parts, .ctx = ctx };
    sl_iter(&parts, fill_partitions_and_free, &pd);
    sl_free(&parts);
    return 0;

    error:
    sl_iter(&parts, gotta_free_em_all, NULL);
    sl_free(&parts);
    return err;
}

vio_err_t vio_partition(vio_ctx *ctx) {
    vio_err_t err = 0;
    vio_val *q, *vec, *rets, *parts;
    VIO__RAISEIF(ctx->sp < 2, VE_STACK_EMPTY,
                 "Partition context requires a quotation and vector, but the "
                 "stack doesnt't have enough values.");

    VIO__CHECK(vio_coerce(ctx, ctx->stack[--ctx->sp], &q, vv_quot));
    VIO__CHECK(vio_coerce(ctx, ctx->stack[--ctx->sp], &vec, vv_vec));
    VIO__CHECK(vio_partition_val(ctx, vec, q, &rets, &parts));
    ctx->stack[ctx->sp++] = rets;
    ctx->stack[ctx->sp++] = parts;
    return 0;

    error:
    return err;
}
开发者ID:alpha123,项目名称:vio,代码行数:57,代码来源:vecapply.c


示例11: setup_vm

static sl_vm_t*
setup_vm(void* stack_top)
{
    sl_static_init();
    sl_vm_t* vm = sl_init("cli");
    sl_gc_set_stack_top(vm->arena, stack_top);
    setup_vm_request(vm);
    setup_vm_response(vm);
    return vm;
}
开发者ID:Hmaal,项目名称:slash,代码行数:10,代码来源:cli.c


示例12: rs_init

static void rs_init(void){
    int fd;
    sl_init(0x3f8);
    hook(IF_WRITE,rs_write);
    hook(IF_INTR,_io);
    hook(IF_OPEN,rs_open);
    regirq(4);
    fd = open("/dev/ttyS0",O_RDONLY);
    run(fd,FIF_MOUNT,getpid(),0,0);
}
开发者ID:LuoZhongYao,项目名称:none,代码行数:10,代码来源:serial.c


示例13: conf_rtables_rtable

void conf_rtables_rtable(FILE *output, int rtableid)
{
	int i;
	StringList *rtable_name, *rtable_daemons;

	rtable_name = sl_init();

	if (db_select_name_rtable(rtable_name, rtableid) < 0) {
		printf("%% database failure select rtables name\n");
		sl_free(rtable_name, 1);
		return;
	} else {
		fprintf(output, "rtable %d %s\n", rtableid,
		    rtable_name->sl_str[0]);
	}

	sl_free(rtable_name, 1);

	/*
	 * Routes must be printed before we attempt to start daemons,
	 * else rtables will not be created in the kernel (Unless an
	 * rdomain is created by specifing one on an interface prior
	 * to this point. An rdomain creates a new corresponding rtable)
	 */
	conf_arp(output, " arp ");
	conf_routes(output, " route ", AF_INET, RTF_STATIC, rtableid);
	conf_routes(output, " route ", AF_INET6, RTF_STATIC, rtableid);

	rtable_daemons = sl_init();

	if (db_select_flag_x_ctl_rtable(rtable_daemons, "ctl", rtableid) < 0) {
		printf("%% database failure select ctl rtable\n");
		sl_free(rtable_daemons, 1);
		return;
	} else {
		for (i = 0; i < rtable_daemons->sl_cur; i++)
			conf_ctl(output, " ", rtable_daemons->sl_str[i], rtableid);
	}

	sl_free(rtable_daemons, 1);

	fprintf(output, "!\n");
}
开发者ID:sthen,项目名称:nsh,代码行数:43,代码来源:conf.c


示例14: mail_sl_init

/*
 * sl_init() with inbuilt error checking
 */
static StringList *
mail_sl_init(void)
{
	StringList *p;

	p = sl_init();
	if (p == NULL)
		err(EXIT_FAILURE, "Unable to allocate memory for stringlist");
	return p;
}
开发者ID:ryo,项目名称:netbsd-src,代码行数:13,代码来源:complete.c


示例15: sl_init_data

struct sl* sl_init_data(struct generic_data data) {
	struct sl *l = sl_init();
	struct sl_node *n = malloc(sizeof(*n));
	n->data = data;
	n->above = n->below = NULL;
	n->prev = l->lists[0].head;
	n->next = l->lists[0].tail;
	l->lists[0].head->next = n;
	l->lists[0].tail->prev = n;
	return l;
}
开发者ID:BWV1055,项目名称:Data-Structures,代码行数:11,代码来源:skip_list.c


示例16: init_locales_list

/*
 * Retrieve sorted list of system locales (or user locales, if PATH_LOCALE
 * environment variable is set)
 */
void
init_locales_list(void)
{
	DIR *dirp;
	struct dirent *dp;
	size_t i;
	int bogus;

	/* why call this function twice ? */
	if (locales != NULL)
		return;

	/* initialize StringList */
	locales = sl_init();
	if (locales == NULL)
		err(1, "could not allocate memory");

	/* get actual locales directory name */
	if (__detect_path_locale() != 0)
		err(1, "unable to find locales storage");

	/* open locales directory */
	dirp = opendir(_PathLocale);
	if (dirp == NULL)
		err(1, "could not open directory '%s'", _PathLocale);

	/* scan directory and store its contents except "." and ".." */
	while ((dp = readdir(dirp)) != NULL) {
		if (*(dp->d_name) == '.')
			continue;		/* exclude "." and ".." */
		for (bogus = i = 0; i < NBOGUS; i++)
			if (strncmp(dp->d_name, boguslocales[i],
			    strlen(boguslocales[i])) == 0)
				bogus = 1;
		if (!bogus)
			sl_add(locales, strdup(dp->d_name));
	}
	closedir(dirp);

	/* make sure that 'POSIX' and 'C' locales are present in the list.
	 * POSIX 1003.1-2001 requires presence of 'POSIX' name only here, but
	 * we also list 'C' for constistency
	 */
	if (sl_find(locales, "POSIX") == NULL)
		sl_add(locales, "POSIX");

	if (sl_find(locales, "C") == NULL)
		sl_add(locales, "C");

	/* make output nicer, sort the list */
	qsort(locales->sl_str, locales->sl_cur, sizeof(char *), scmp);
}
开发者ID:Hooman3,项目名称:freebsd,代码行数:56,代码来源:locale.c


示例17: _nis_initshells

/*ARGSUSED*/
static int
_nis_initshells(void *rv, void *cb_data, va_list ap)
{
	static char *ypdomain;
	char	*key, *data;
	char	*lastkey;
	int	 keylen, datalen;
	int	 r;

	if (sl)
		sl_free(sl, 1);
	sl = sl_init();

	if (ypdomain == NULL) {
		switch (yp_get_default_domain(&ypdomain)) {
		case 0:
			break;
		case YPERR_RESRC:
			return NS_TRYAGAIN;
		default:
			return NS_UNAVAIL;
		}
	}

	/*
	 * `key' and `data' point to strings dynamically allocated by
	 * the yp_... functions.
	 * `data' is directly put into the stringlist of shells.
	 */
	key = data = NULL;
	if (yp_first(ypdomain, "shells", &key, &keylen, &data, &datalen))
		return NS_UNAVAIL;
	do {
		data[datalen] = '\0';		/* clear trailing \n */
		sl_add(sl, data);

		lastkey = key;
		r = yp_next(ypdomain, "shells", lastkey, keylen,
		    &key, &keylen, &data, &datalen);
		free(lastkey);
	} while (r == 0);

	if (r == YPERR_NOMORE) {
		/*
		 * `data' and `key' ought to be NULL - do not try to free them.
		 */
		return NS_SUCCESS;
	}

	return NS_UNAVAIL;
}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:52,代码来源:getusershell.c


示例18: complete_executable

/*
 * Complete a local executable
 */
static unsigned char
complete_executable(EditLine *el, char *word, int dolist)
{
	StringList *words;
	char dir[ MAXPATHLEN ];
	char *fname;
	unsigned char rv;
	size_t len;
	int error;

	if ((fname = strrchr(word, '/')) == NULL) {
		dir[0] = '\0';		/* walk the path */
		fname = word;
	} else {
		if (fname == word) {
			dir[0] = '/';
			dir[1] = '\0';
		} else {
			len = fname - word;
			(void)strncpy(dir, word, len);
			dir[fname - word] = '\0';
		}
		fname++;
	}

	words = sl_init();

	if (*dir == '\0') {		/* walk path */
		char *env;
		char *path;
		env = getenv("PATH");
		len = strlen(env);
		path = salloc(len + 1);
		(void)strcpy(path, env);
		error = find_execs(word, path, words);
	}
	else {		/* check specified dir only */
		error = find_execs(word, dir, words);
	}
	if (error != 0)
		return CC_ERROR;

	rv = complete_ambiguous(el, fname, dolist, words);
	if (rv == CC_REFRESH) {
		if (el_insertstr(el, " ") == -1)
			rv = CC_ERROR;
	}
	sl_free(words, 1);

	return rv;
}
开发者ID:ryo,项目名称:netbsd-src,代码行数:54,代码来源:complete.c


示例19: sl_dialog

int sl_dialog(OBJECT *tree, int start, SLIDER *slider)
{
	XDINFO info;
	int button;

	sl_init(tree, slider);

	xd_open(tree, &info);
	button = sl_form_do(tree, start, slider, &info) & 0x7FFF;
	xd_change(&info, button, NORMAL, 0);
	xd_close(&info);

	return button;
}
开发者ID:daemqn,项目名称:Atari_ST_Sources,代码行数:14,代码来源:SLIDER.C


示例20: run_slash_script

static void
run_slash_script(slash_api_base_t* api, cgi_options* options, void* stack_top)
{
    sl_vm_t* vm;
    slash_context_t ctx;
    sl_vm_frame_t exit_frame, exception_frame;
    char* canonical_filename;
    SLVAL error;

    sl_static_init();
    vm = sl_init("cgi-fcgi");

    bzero(&ctx, sizeof(ctx));
    ctx.api = api;
    ctx.headers_sent = 0;
    ctx.vm = vm;
    vm->data = &ctx;

    sl_gc_set_stack_top(vm->arena, stack_top);

    load_cgi_options(vm, options);
    load_request_info(vm, options, api, &ctx.info);

#ifdef SL_TEST
    register_cgi_test_utils(vm);
#endif

    canonical_filename = ctx.info.real_canonical_filename;
#ifndef SL_TEST
    vm->cwd = ctx.info.real_canonical_dir;
#endif

    if(canonical_filename) {
        SL_TRY(exit_frame, SL_UNWIND_ALL, {
            SL_TRY(exception_frame, SL_UNWIND_EXCEPTION, {
                bool request_valid = setup_request_object(vm, &ctx.info);

                setup_response_object(vm);

                if(!request_valid) {
                    sl_error(vm, vm->lib.Error, "Invalid Request");
                }

                sl_do_file_hashbang(vm, canonical_filename,
                    api->type == SLASH_REQUEST_CGI);
            }, error, {
                sl_response_clear(vm);
                sl_render_error_page(vm, error);
            });
        }, error, {});
开发者ID:PatrickFang,项目名称:slash,代码行数:50,代码来源:cgi.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ slab_is_available函数代码示例发布时间:2022-05-30
下一篇:
C++ sl_WlanSetMode函数代码示例发布时间: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