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

C++ ERRCHK函数代码示例

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

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



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

示例1: mb_put_acl

static int
mb_put_acl(mbchain_t *mbp, i_ntacl_t *acl)
{
	i_ntace_t **acep;
	uint16_t acl_len, *acl_len_p;
	int i, cnt0, error;

	cnt0 = mbp->mb_count;

	ERRCHK(mb_put_uint8(mbp, acl->acl_revision));
	ERRCHK(mb_put_uint8(mbp, 0)); /* pad1 */
	acl_len_p = mb_reserve(mbp, sizeof (*acl_len_p));
	if (acl_len_p == NULL) {
		error = ENOMEM;
		goto errout;
	}
	ERRCHK(mb_put_uint16le(mbp, acl->acl_acecount));
	ERRCHK(mb_put_uint16le(mbp, 0)); /* pad2 */

	acep = &acl->acl_acevec[0];
	for (i = 0; i < acl->acl_acecount; i++) {
		ERRCHK(mb_put_ace(mbp, *acep));
		acep++;
	}

	/* Fill in acl_len_p */
	acl_len = mbp->mb_count - cnt0;
	*acl_len_p = htoles(acl_len);

	/* Success! */
	return (0);

errout:
	return (error);
}
开发者ID:NanXiao,项目名称:illumos-joyent,代码行数:35,代码来源:smbfs_ntacl.c


示例2: vcc_ParseVcl

static void
vcc_ParseVcl(struct vcc *tl)
{
	struct token *tok;

	assert(vcc_IdIs(tl->t, "vcl"));
	vcc_NextToken(tl);
	tok = tl->t;
	tok->src->syntax = vcc_DoubleVal(tl);
	ERRCHK(tl);
	if (tl->t->e - tok->b > 4) {
		VSB_printf(tl->sb,
		    "Don't play silly buggers with VCL version numbers\n");
		vcc_ErrWhere2(tl, tok, tl->t);
		ERRCHK(tl);
	}
	if (tl->syntax != 0.0 && tok->src->syntax > tl->syntax) {
		VSB_printf(tl->sb,
		    "VCL version %.1f higher than"
		    " the top level version %.1f\n",
		    tok->src->syntax, tl->syntax);
		vcc_ErrWhere2(tl, tok, tl->t);
		ERRCHK(tl);
	}
	ExpectErr(tl, ';');
	vcc_NextToken(tl);
}
开发者ID:varnishcache,项目名称:varnish-cache,代码行数:27,代码来源:vcc_parse.c


示例3: vcc_expr0

static void
vcc_expr0(struct vcc *tl, struct expr **e, enum var_type fmt)
{
	struct expr *e2;
	struct token *tk;

	*e = NULL;
	vcc_expr_cand(tl, e, fmt);
	ERRCHK(tl);
	if ((*e)->fmt != BOOL || tl->t->tok != T_COR)
		return;
	*e = vcc_expr_edit(BOOL, "(\v+\n\v1", *e, NULL);
	while (tl->t->tok == T_COR) {
		vcc_NextToken(tl);
		tk = tl->t;
		vcc_expr_cand(tl, &e2, fmt);
		ERRCHK(tl);
		if (e2->fmt != BOOL) {
			VSB_printf(tl->sb,
			    "'||' must be followed by BOOL, found ");
			VSB_printf(tl->sb, "%s.\n", vcc_Type(e2->fmt));
			vcc_ErrWhere2(tl, tk, tl->t);
			return;
		}
		*e = vcc_expr_edit(BOOL, "\v1\v-\n||\v+\n\v2", *e, e2);
	}
	*e = vcc_expr_edit(BOOL, "\v1\v-\n)", *e, NULL);
}
开发者ID:BabyOnlineSG,项目名称:pkg-varnish,代码行数:28,代码来源:vcc_expr.c


示例4: Bitio_New

/*===========================================================================*
 *
 * Bitio_New
 *
 *  Create a new bit bucket; filePtr is a pointer to the open file the
 *  bits should ultimately be written to.
 *
 * RETURNS: pointer to the resulting bit bucket
 *
 * SIDE EFFECTS:    none
 *
 *===========================================================================*/
BitBucket *
Bitio_New(FILE * const filePtr) {

    BitBucket *bbPtr;

    bbPtr = (BitBucket *) malloc(sizeof(BitBucket));
    ERRCHK(bbPtr, "malloc");

    bbPtr->firstPtr = bbPtr->lastPtr = malloc(sizeof(struct bitBucket));
    ERRCHK(bbPtr->firstPtr, "malloc");

    bbPtr->totalbits = 0;
    bbPtr->cumulativeBits = 0;
    bbPtr->bitsWritten = 0;
    bbPtr->filePtr = filePtr;

    bbPtr->firstPtr->nextPtr = NULL;
    bbPtr->firstPtr->bitsleft = MAXBITS_PER_BUCKET;
    bbPtr->firstPtr->bitsleftcur = 32;
    bbPtr->firstPtr->currword = 0;
    memset((char *)bbPtr->firstPtr->bits, 0, 
           sizeof(uint32) * WORDS_PER_BUCKET);

    return bbPtr;
}
开发者ID:Eleanor66613,项目名称:CS131,代码行数:37,代码来源:bitio.c


示例5: mb_put_sid

static int
mb_put_sid(mbchain_t *mbp, i_ntsid_t *sid)
{
	uint32_t *subauthp;
	int error, i;

	if (sid == NULL)
		return (EINVAL);

	ERRCHK(mb_put_uint8(mbp, sid->sid_revision));
	ERRCHK(mb_put_uint8(mbp, sid->sid_subauthcount));
	ERRCHK(mb_put_mem(mbp, sid->sid_authority, 6, MB_MSYSTEM));

	subauthp = &sid->sid_subauthvec[0];
	for (i = 0; i < sid->sid_subauthcount; i++) {
		ERRCHK(mb_put_uint32le(mbp, *subauthp));
		subauthp++;
	}

	/* Success! */
	return (0);

errout:
	return (error);
}
开发者ID:NanXiao,项目名称:illumos-joyent,代码行数:25,代码来源:smbfs_ntacl.c


示例6: vcc_Expr

void
vcc_Expr(struct vcc *tl, enum var_type fmt)
{
	struct expr *e;
	struct token *t1;

	assert(fmt != VOID);

	t1 = tl->t;
	vcc_expr0(tl, &e, fmt);
	ERRCHK(tl);
	e->t1 = t1;
	if (fmt == STRING || fmt == STRING_LIST) {
		vcc_expr_tostring(tl, &e, fmt);
		ERRCHK(tl);
	}
	if (!tl->err && fmt != e->fmt)  {
		VSB_printf(tl->sb, "Expression has type %s, expected %s\n",
		    vcc_Type(e->fmt), vcc_Type(fmt));
		tl->err = 1;
	}
	if (!tl->err) {
		if (e->fmt == STRING_LIST) {
			e = vcc_expr_edit(STRING_LIST,
			    "\v+\n\v1,\nvrt_magic_string_end\v-", e, NULL);
		}
		vcc_expr_fmt(tl->fb, tl->indent, e);
		VSB_putc(tl->fb, '\n');
	} else {
		if (t1 != tl->t)
			vcc_ErrWhere2(tl, t1, tl->t);
	}
	vcc_delete_expr(e);
}
开发者ID:drakeshs,项目名称:Varnish-Cache,代码行数:34,代码来源:vcc_expr.c


示例7: vcc_Compound

static void
vcc_Compound(struct vcc *tl)
{
	int i;

	SkipToken(tl, '{');
	Fb(tl, 1, "{\n");
	tl->indent += INDENT;
	C(tl, ";");
	while (1) {
		ERRCHK(tl);
		switch (tl->t->tok) {
		case '{':
			vcc_Compound(tl);
			break;
		case '}':
			vcc_NextToken(tl);
			tl->indent -= INDENT;
			Fb(tl, 1, "}\n");
			return;
		case CSRC:
			if (tl->allow_inline_c) {
				Fb(tl, 1, "%.*s\n",
				    (int) (tl->t->e - (tl->t->b + 2)),
				    tl->t->b + 1);
				vcc_NextToken(tl);
			} else {
				VSB_printf(tl->sb,
				    "Inline-C not allowed\n");
				vcc_ErrWhere(tl, tl->t);
			}
			break;
		case EOI:
			VSB_printf(tl->sb,
			    "End of input while in compound statement\n");
			tl->err = 1;
			return;
		case ID:
			if (vcc_IdIs(tl->t, "if")) {
				vcc_IfStmt(tl);
				break;
			} else {
				i = vcc_ParseAction(tl);
				ERRCHK(tl);
				if (i) {
					SkipToken(tl, ';');
					break;
				}
			}
			/* FALLTHROUGH */
		default:
			/* We deliberately do not mention inline C */
			VSB_printf(tl->sb,
			    "Expected an action, 'if', '{' or '}'\n");
			vcc_ErrWhere(tl, tl->t);
			return;
		}
	}
}
开发者ID:varnishcache,项目名称:varnish-cache,代码行数:59,代码来源:vcc_parse.c


示例8: vcc_ParseLeastBusyDirector

void
vcc_ParseLeastBusyDirector(struct tokenlist *tl, const struct token *t_policy,
    const struct token *t_dir)
{
	struct token *t_field, *t_be;
	int nbh, nelem;
	struct fld_spec *fs;
	const char *first;

	fs = vcc_FldSpec(tl, "!backend", NULL);

	Fc(tl, 0, "\nstatic const struct vrt_dir_least_busy_entry "
	    "vdrre_%.*s[] = {\n", PF(t_dir));

	for (nelem = 0; tl->t->tok != '}'; nelem++) {	/* List of members */
		first = "";
		t_be = tl->t;
		vcc_ResetFldSpec(fs);
		nbh = -1;

		ExpectErr(tl, '{');
		vcc_NextToken(tl);
		Fc(tl, 0, "\t{");

		while (tl->t->tok != '}') {	/* Member fields */
			vcc_IsField(tl, &t_field, fs);
			ERRCHK(tl);
			if (vcc_IdIs(t_field, "backend")) {
				vcc_ParseBackendHost(tl, &nbh,
				    t_dir, t_policy, nelem);
				Fc(tl, 0, "%s .host = &bh_%d", first, nbh);
				ERRCHK(tl);
			} else {
				ErrInternal(tl);
			}
			first = ", ";
		}
		vcc_FieldsOk(tl, fs);
		if (tl->err) {
			vsb_printf(tl->sb,
			    "\nIn member host specification starting at:\n");
			vcc_ErrWhere(tl, t_be);
			return;
		}
		Fc(tl, 0, " },\n");
		vcc_NextToken(tl);
	}
	Fc(tl, 0, "};\n");
	Fc(tl, 0,
	    "\nstatic const struct vrt_dir_least_busy vdrr_%.*s = {\n",
	    PF(t_dir));
	Fc(tl, 0, "\t.name = \"%.*s\",\n", PF(t_dir));
	Fc(tl, 0, "\t.nmember = %d,\n", nelem);
	Fc(tl, 0, "\t.members = vdrre_%.*s,\n", PF(t_dir));
	Fc(tl, 0, "};\n");
	Fi(tl, 0, "\tVRT_init_dir_least_busy("
	    "cli, &VGC_backend_%.*s , &vdrr_%.*s);\n", PF(t_dir), PF(t_dir));
	Ff(tl, 0, "\tVRT_fini_dir(cli, VGC_backend_%.*s);\n", PF(t_dir));
}
开发者ID:attisan,项目名称:Varnish-Least-Busy-Director,代码行数:59,代码来源:vcc_dir_least_busy.c


示例9: vcc_ParseRoundRobinDirector

void
vcc_ParseRoundRobinDirector(struct vcc *tl)
{
	struct token *t_field, *t_be;
	int nelem;
	struct fld_spec *fs;
	const char *first;
	char *p;

	fs = vcc_FldSpec(tl, "!backend", NULL);

	Fc(tl, 0, "\nstatic const struct vrt_dir_round_robin_entry "
	    "vdrre_%.*s[] = {\n", PF(tl->t_dir));

	for (nelem = 0; tl->t->tok != '}'; nelem++) {	/* List of members */
		first = "";
		t_be = tl->t;
		vcc_ResetFldSpec(fs);

		SkipToken(tl, '{');
		Fc(tl, 0, "\t{");

		while (tl->t->tok != '}') {	/* Member fields */
			vcc_IsField(tl, &t_field, fs);
			ERRCHK(tl);
			if (vcc_IdIs(t_field, "backend")) {
				vcc_ParseBackendHost(tl, nelem, &p);
				ERRCHK(tl);
				AN(p);
				Fc(tl, 0, "%s .host = VGC_backend_%s",
				    first, p);
			} else {
				ErrInternal(tl);
			}
			first = ", ";
		}
		vcc_FieldsOk(tl, fs);
		if (tl->err) {
			VSB_printf(tl->sb,
			    "\nIn member host specification starting at:\n");
			vcc_ErrWhere(tl, t_be);
			return;
		}
		Fc(tl, 0, " },\n");
		vcc_NextToken(tl);
	}
	Fc(tl, 0, "};\n");
	Fc(tl, 0,
	    "\nstatic const struct vrt_dir_round_robin vgc_dir_priv_%.*s = {\n",
	    PF(tl->t_dir));
	Fc(tl, 0, "\t.name = \"%.*s\",\n", PF(tl->t_dir));
	Fc(tl, 0, "\t.nmember = %d,\n", nelem);
	Fc(tl, 0, "\t.members = vdrre_%.*s,\n", PF(tl->t_dir));
	Fc(tl, 0, "};\n");
}
开发者ID:BabyOnlineSG,项目名称:pkg-varnish,代码行数:55,代码来源:vcc_dir_round_robin.c


示例10: parse_return

static void
parse_return(struct vcc *tl)
{
	unsigned hand;
	const char *h;

	vcc_NextToken(tl);
	ExpectErr(tl, '(');
	vcc_NextToken(tl);
	ExpectErr(tl, ID);

	hand = VCL_RET_MAX;
	h = NULL;
#define VCL_RET_MAC(l, U, B)				\
		if (vcc_IdIs(tl->t, #l)) {		\
			hand = VCL_RET_ ## U;		\
			h = #U;				\
		}
#include "tbl/vcl_returns.h"
#undef VCL_RET_MAC
	if (h == NULL) {
		VSB_printf(tl->sb, "Expected return action name.\n");
		vcc_ErrWhere(tl, tl->t);
		ERRCHK(tl);
	}
	assert(hand < VCL_RET_MAX);

	vcc_ProcAction(tl->curproc, hand, tl->t);
	vcc_NextToken(tl);
	if (tl->t->tok == '(') {
		if (hand == VCL_RET_SYNTH)
			parse_return_synth(tl);
		else if (hand == VCL_RET_VCL)
			parse_return_vcl(tl);
		else if (hand == VCL_RET_PASS)
			parse_return_pass(tl);
		else {
			VSB_printf(tl->sb, "Arguments not allowed.\n");
			vcc_ErrWhere(tl, tl->t);
		}
	} else {
		if (hand == VCL_RET_SYNTH || hand == VCL_RET_VCL) {
			VSB_printf(tl->sb, "Missing argument.\n");
			vcc_ErrWhere(tl, tl->t);
		}
	}
	ERRCHK(tl);
	Fb(tl, 1, "VRT_handling(ctx, VCL_RET_%s);\n", h);
	Fb(tl, 1, "return (1);\n");
	ExpectErr(tl, ')');
	vcc_NextToken(tl);
}
开发者ID:varnishcache,项目名称:varnish-cache,代码行数:52,代码来源:vcc_action.c


示例11: vcc_ParseBackend

void
vcc_ParseBackend(struct vcc *tl)
{
	struct token *t_first, *t_be;
	struct symbol *sym;
	const char *dn;

	tl->ndirector++;
	t_first = tl->t;
	SkipToken(tl, ID);		/* ID: backend */

	vcc_ExpectVid(tl, "backend");	/* ID: name */
	ERRCHK(tl);

	t_be = tl->t;
	if (vcc_IdIs(tl->t, "default")) {
		if (tl->first_director != NULL) {
			tl->first_director->noref = 0;
			tl->first_director = NULL;
			tl->default_director = NULL;
		}
		if (tl->default_director != NULL) {
			VSB_printf(tl->sb,
			    "Only one default director possible.\n");
			vcc_ErrWhere(tl, t_first);
			return;
		}
		vcc_NextToken(tl);
		dn = "vgc_backend_default";
		tl->default_director = dn;
	} else {
		sym = VCC_HandleSymbol(tl, BACKEND, "vgc_backend");
		ERRCHK(tl);
		dn = sym->rname;
		if (tl->default_director == NULL) {
			tl->first_director = sym;
			tl->default_director = dn;
			sym->noref = 1;
		}
	}
	Fh(tl, 0, "\nstatic VCL_BACKEND %s;\n", dn);
	vcc_ParseHostDef(tl, t_be, dn);
	if (tl->err) {
		VSB_printf(tl->sb,
		    "\nIn %.*s specification starting at:\n", PF(t_first));
		vcc_ErrWhere(tl, t_first);
		return;
	}
}
开发者ID:fgsch,项目名称:varnish-cache,代码行数:49,代码来源:vcc_backend.c


示例12: mb_put_ace

static int
mb_put_ace(mbchain_t *mbp, i_ntace_t *ace)
{
	int cnt0, error;
	uint16_t ace_len, *ace_len_p;

	if (ace == NULL)
		return (EINVAL);

	cnt0 = mbp->mb_count;

	/*
	 * Put the (fixed-size) ACE header
	 * Will fill in the length later.
	 */
	ERRCHK(mb_put_uint8(mbp, ace->ace_hdr.ace_type));
	ERRCHK(mb_put_uint8(mbp, ace->ace_hdr.ace_flags));
	ace_len_p = mb_reserve(mbp, sizeof (*ace_len_p));
	if (ace_len_p == NULL) {
		error = ENOMEM;
		goto errout;
	}

	switch (ace->ace_hdr.ace_type) {
	case ACCESS_ALLOWED_ACE_TYPE:
	case ACCESS_DENIED_ACE_TYPE:
	case SYSTEM_AUDIT_ACE_TYPE:
	case SYSTEM_ALARM_ACE_TYPE:
		/* Put type-specific data. */
		ERRCHK(mb_put_uint32le(mbp, ace->ace_v2.ace_rights));
		ERRCHK(mb_put_sid(mbp, ace->ace_v2.ace_sid));
		break;

	/* other types todo */
	default:
		error = EIO;
		goto errout;
	}

	/* Fill in the (OtW) ACE length. */
	ace_len = mbp->mb_count - cnt0;
	*ace_len_p = htoles(ace_len);

	/* Success! */
	return (0);

errout:
	return (error);
}
开发者ID:NanXiao,项目名称:illumos-joyent,代码行数:49,代码来源:smbfs_ntacl.c


示例13: parse_set

static void
parse_set(struct vcc *tl)
{
	const struct var *vp;
	const struct arith *ap;
	enum var_type fmt;

	vcc_NextToken(tl);
	ExpectErr(tl, ID);
	vp = vcc_FindVar(tl, tl->t, 1, "cannot be set");
	ERRCHK(tl);
	assert(vp != NULL);
	Fb(tl, 1, "%s", vp->lname);
	vcc_NextToken(tl);
	fmt = vp->fmt;
	for (ap = arith; ap->type != VOID; ap++) {
		if (ap->type != fmt)
			continue;
		if (ap->oper != tl->t->tok)
			continue;
		if (ap->oper != '=')
			Fb(tl, 0, "%s %c ", vp->rname, *tl->t->b);
		vcc_NextToken(tl);
		fmt = ap->want;
		break;
	}
	if (ap->type == VOID)
		SkipToken(tl, ap->oper);
	if (fmt == STRING) {
		vcc_Expr(tl, STRING_LIST);
	} else {
		vcc_Expr(tl, fmt);
	}
	Fb(tl, 1, ");\n");
}
开发者ID:tpn,项目名称:Varnish-Cache,代码行数:35,代码来源:vcc_action.c


示例14: vxp_expr

static void
vxp_expr(struct vxp *vxp, struct vex **pvex)
{
	vxp_expr_or(vxp, pvex);
	ERRCHK(vxp);
	ExpectErr(vxp, EOI);
}
开发者ID:Matt8109,项目名称:Varnish-Cache,代码行数:7,代码来源:vxp_parse.c


示例15: parse_return

static void
parse_return(struct tokenlist *tl)
{
	int retval = 0;

	vcc_NextToken(tl);
	ExpectErr(tl, '(');
	vcc_NextToken(tl);
	ExpectErr(tl, ID);

#define VCL_RET_MAC(l, U)						\
	do {								\
		if (vcc_IdIs(tl->t, #l)) {				\
			Fb(tl, 1, "VRT_done(sp, VCL_RET_" #U ");\n");	\
			vcc_ProcAction(tl->curproc, VCL_RET_##U, tl->t);\
			retval = 1;					\
		}							\
	} while (0);
#include "vcl_returns.h"
#undef VCL_RET_MAC
	if (!retval) {
		vsb_printf(tl->sb, "Expected return action name.\n");
		vcc_ErrWhere(tl, tl->t);
		ERRCHK(tl);
	}
	vcc_NextToken(tl);
	ExpectErr(tl, ')');
	vcc_NextToken(tl);
}
开发者ID:smallvil,项目名称:Cache-Terminator,代码行数:29,代码来源:vcc_action.c


示例16: vcc_ByteVal

static void
vcc_ByteVal(struct vcc *tl, double *d)
{
	double v, sc;

	v = vcc_DoubleVal(tl);
	ERRCHK(tl);
	if (tl->t->tok != ID) {
		VSB_printf(tl->sb, "Expected BYTES unit (B, KB, MB...) got ");
		vcc_ErrToken(tl, tl->t);
		VSB_printf(tl->sb, "\n");
		vcc_ErrWhere(tl, tl->t);
		return;
	}
	if (vcc_IdIs(tl->t, "B"))
		sc = 1.;
	else if (vcc_IdIs(tl->t, "KB"))
		sc = 1024.;
	else if (vcc_IdIs(tl->t, "MB"))
		sc = 1024. * 1024.;
	else if (vcc_IdIs(tl->t, "GB"))
		sc = 1024. * 1024. * 1024.;
	else if (vcc_IdIs(tl->t, "TB"))
		sc = 1024. * 1024. * 1024. * 1024.;
	else {
		VSB_printf(tl->sb, "Unknown BYTES unit ");
		vcc_ErrToken(tl, tl->t);
		VSB_printf(tl->sb,
		    ".  Legal are 'B', 'KB', 'MB', 'GB' and 'TB'\n");
		vcc_ErrWhere(tl, tl->t);
		return;
	}
	vcc_NextToken(tl);
	*d = v * sc;
}
开发者ID:BabyOnlineSG,项目名称:pkg-varnish,代码行数:35,代码来源:vcc_expr.c


示例17: Emit_Sockaddr

static void
Emit_Sockaddr(struct vcc *tl, const struct token *t_host,
    const struct token *t_port)
{
	const char *ipv4, *ipv4a, *ipv6, *ipv6a, *pa;
	char buf[256];

	AN(t_host->dec);

	if (t_port != NULL)
		bprintf(buf, "%s %s", t_host->dec, t_port->dec);
	else
		bprintf(buf, "%s", t_host->dec);
	Resolve_Sockaddr(tl, buf, "80",
	    &ipv4, &ipv4a, &ipv6, &ipv6a, &pa, 2, t_host, "Backend host");
	ERRCHK(tl);
	if (ipv4 != NULL) {
		Fb(tl, 0, "\t.ipv4_suckaddr = (const struct suckaddr *)%s,\n",
		    ipv4);
		Fb(tl, 0, "\t.ipv4_addr = \"%s\",\n", ipv4a);
	}
	if (ipv6 != NULL) {
		Fb(tl, 0, "\t.ipv6_suckaddr = (const struct suckaddr *)%s,\n",
		    ipv6);
		Fb(tl, 0, "\t.ipv6_addr = \"%s\",\n", ipv6a);
	}
	Fb(tl, 0, "\t.port = \"%s\",\n", pa);
	Fb(tl, 0, "\t.path = (void *) 0,\n");
}
开发者ID:fgsch,项目名称:varnish-cache,代码行数:29,代码来源:vcc_backend.c


示例18: vcc_ParseBackend

void
vcc_ParseBackend(struct vcc *tl)
{
	struct token *t_first, *t_be;
	struct symbol *sym;
	char vgcname[MAX_BACKEND_NAME + 20];

	t_first = tl->t;
	vcc_NextToken(tl);		/* ID: backend */

	vcc_ExpectCid(tl);		/* ID: name */
	ERRCHK(tl);

	if (tl->t->e - tl->t->b > MAX_BACKEND_NAME) {
		VSB_printf(tl->sb,
		    "Name of %.*s too long (max %d, is %zu):\n",
		    PF(t_first), MAX_BACKEND_NAME,
		    (size_t)(tl->t->e - tl->t->b));
		vcc_ErrWhere(tl, tl->t);
		return;
	}

	t_be = tl->t;
	vcc_NextToken(tl);

	sprintf(vgcname, "vgc_backend_%.*s", PF(t_be));
	Fh(tl, 0, "\nstatic struct director *%s;\n", vgcname);

	sym = VCC_HandleSymbol(tl, t_be, BACKEND, "%s", vgcname);
	ERRCHK(tl);

	vcc_ParseHostDef(tl, t_be, vgcname);
	ERRCHK(tl);

	if (tl->err) {
		VSB_printf(tl->sb,
		    "\nIn %.*s specification starting at:\n", PF(t_first));
		vcc_ErrWhere(tl, t_first);
		return;
	}

	if (tl->default_director == NULL || vcc_IdIs(t_be, "default")) {
		tl->default_director = sym->rname;
		tl->t_default_director = t_be;
	}
}
开发者ID:kivikakk,项目名称:varnish-cache,代码行数:46,代码来源:vcc_backend.c


示例19: get_bind

void get_bind (int server_type)
{
   uuid_t obj_uuid;
   unsigned32 status;
   rpc_ns_handle_t imp_ctxt;
   char *obj_uuid_string;
   char *entry_name;
   rpc_binding_handle_t *binding_handle;

   if (server_type == 1) {
      printf ( "Obtaining phone server's binding handle\n" );
      obj_uuid_string = PHON_OBJ_UUID;
      entry_name =      PHON_ENTRY_NAME;
      binding_handle =  &phon_bh;
   } else {
      printf ( "Obtaining address server's binding handle\n" );
      obj_uuid_string = ADDR_OBJ_UUID;
      entry_name =      ADDR_ENTRY_NAME;
      binding_handle =  &addr_bh;
   } /* endif */


   /* Create object UUID for phone directory from string.                     */
   uuid_from_string ( obj_uuid_string, &obj_uuid, &status );
   ERRCHK ( status );

   /* Set up context to import the bindings of the phone server.              */
   rpc_ns_binding_import_begin ( rpc_c_ns_syntax_dce, entry_name,
                                 look_v1_0_c_ifspec, &obj_uuid,
                                 &imp_ctxt, &status );
   ERRCHK ( status );

   /* Get the first binding handle of the phone server.                       */
   rpc_ns_binding_import_next ( imp_ctxt, binding_handle, &status );
   ERRCHK ( status );

   /* Release the context.                                                    */
   rpc_ns_binding_import_done ( &imp_ctxt, &status );
   ERRCHK ( status );

   if (server_type == 1) {
      printf ( "Phone server's binding done\n" );
   } else {
      printf ( "Address server's binding done\n" );
   } /* endif */
}
开发者ID:OS2World,项目名称:DEV-SAMPLES-The-IBM-Developer-Connection-Release-12,代码行数:46,代码来源:LOOKUP.C


示例20: Bitio_Write

/*===========================================================================*
 *
 * Bitio_Write
 *
 *  Writes 'nbits' bits from 'bits' into the given bit bucket
 *  'nbits' must be between 0 and 32
 *
 * RETURNS: nothing
 *
 * SIDE EFFECTS:    if the number of bits in the bit bucket surpasses
 *          MAX_BITS, then that many bits are flushed to the
 *          appropriate output file
 *
 *===========================================================================*/
void
Bitio_Write(BitBucket * const bbPtr, 
            uint32      const bits_arg, 
            int         const nbits) {

    register struct bitBucket *lastPtr, *newPtr;
    register int delta;
    uint32 bits;
    
    bits=bits_arg;
    assert(nbits <= 32 && nbits >= 0);

    /*
     * Clear top bits if not part of data, necessary due to down and
     * dirty calls of Bitio_Write with unecessary top bits set.
     */

    bits &= lower_mask[nbits];
    bits = bits & lower_mask[nbits];

    bbPtr->totalbits += nbits;
    bbPtr->cumulativeBits += nbits;
    lastPtr = bbPtr->lastPtr;

    delta = nbits - lastPtr->bitsleft;
    if (delta >= 0) {
        /*
         * there's not enough room in the current bucket, so we're
         * going to have to allocate another bucket
         */
        newPtr = lastPtr->nextPtr = (struct bitBucket *) 
            malloc(sizeof(struct bitBucket));
        ERRCHK(newPtr, "malloc");
        newPtr->nextPtr = NULL;
        newPtr->bitsleft = MAXBITS_PER_BUCKET;
        newPtr->bitsleftcur = 32;
        newPtr->currword = 0;
        memset((char *)newPtr->bits, 0, sizeof(uint32) * WORDS_PER_BUCKET);
        bbPtr->lastPtr = newPtr;

        assert(lastPtr->currword == WORDS_PER_BUCKET - 1);
        lastPtr->bits[WORDS_PER_BUCKET - 1] |= (bits >> delta);
        lastPtr->bitsleft = 0;
        lastPtr->bitsleftcur = 0;
        /* lastPtr->currword++; */

        if (!delta) {
            if ( bbPtr->totalbits > MAX_BITS ) {
                Dump(bbPtr);
            }
        }

        assert(delta <= 32);
        newPtr->bits[0] = (bits & lower_mask[delta]) << (32 - delta);
        newPtr->bitsleft -= delta;
        newPtr->bitsleftcur -= delta;
    } else {
开发者ID:Eleanor66613,项目名称:CS131,代码行数:71,代码来源:bitio.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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