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

C++ LEN函数代码示例

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

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



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

示例1: body_out

static void body_out(void *context, int rec_type, const char *buf,
		             ssize_t len, off_t offset)
{
    HBC_TEST_CONTEXT *dp = (HBC_TEST_CONTEXT *) context;
    char   *out;

    if (dp->body_checks == 0
	|| (out = hbc_body_checks(context, dp->body_checks,
				  buf, len, offset)) == buf) {
	vstring_sprintf(dp->buf, "%d BODY %c %ld\t|%s",
			dp->recno, rec_type, (long) offset, buf);
	out_cb(dp, rec_type, STR(dp->buf), LEN(dp->buf), offset);
    } else if (out != 0) {
	vstring_sprintf(dp->buf, "%d BODY %c %ld\t|%s",
			dp->recno, rec_type, (long) offset, out);
	out_cb(dp, rec_type, STR(dp->buf), LEN(dp->buf), offset);
	myfree(out);
    }
    dp->recno += 1;
}
开发者ID:ajinkya93,项目名称:netbsd-src,代码行数:20,代码来源:header_body_checks.c


示例2: combobox_panel

static void
combobox_panel(struct gui_panel_layout *panel, struct show_window *demo)
{
    gui_int i = 0;
    static const char *options[] = {"easy", "normal", "hard", "hell", "doom", "godlike"};
    gui_panel_row(panel, 30, 3);
    for (i = 0; i < (gui_int)LEN(options); i++) {
        if (gui_panel_option(panel, options[i], demo->combo_selection == i))
            demo->combo_selection = i;
    }
}
开发者ID:island-org,项目名称:gui,代码行数:11,代码来源:demo.c


示例3: SKIP_SPACE

static const char *xml_parse_meta_text(ACL_XML *xml, const char *data)
{
	int   ch;

	if (LEN(xml->curr_node->text) == 0) {
		SKIP_SPACE(data);
	}

	while ((ch = *data) != 0) {
		if (xml->curr_node->quote) {
			if (ch == xml->curr_node->quote) {
				xml->curr_node->quote = 0;
			}
			ADDCH(xml->curr_node->text, ch);
		} else if (IS_QUOTE(ch)) {
			if (xml->curr_node->quote == 0) {
				xml->curr_node->quote = ch;
			}
			ADDCH(xml->curr_node->text, ch);
		} else if (ch == '<') {
			xml->curr_node->nlt++;
			ADDCH(xml->curr_node->text, ch);
		} else if (ch == '>') {
			if (xml->curr_node->nlt == 0) {
				char *last;
				size_t off;

				data++;
				xml->curr_node->status = ACL_XML_S_MEND;
				if ((xml->curr_node->flag & ACL_XML_F_META_QM) == 0)
					break;

				last = acl_vstring_end(xml->curr_node->text) - 1;
				if (last < STR(xml->curr_node->text) || *last != '?')
					break;
				off = ACL_VSTRING_LEN(xml->curr_node->text) - 1;
				if (off == 0)
					break;
				ACL_VSTRING_AT_OFFSET(xml->curr_node->text, off);
				ACL_VSTRING_TERMINATE(xml->curr_node->text);
				xml_meta_attr(xml->curr_node);
				break;
			}
			xml->curr_node->nlt--;
			ADDCH(xml->curr_node->text, ch);
		} else {
			ADDCH(xml->curr_node->text, ch);
		}
		data++;
	}

	ACL_VSTRING_TERMINATE(xml->curr_node->text);
	return (data);
}
开发者ID:10jschen,项目名称:acl,代码行数:54,代码来源:acl_xml_parse.c


示例4: gf3m_sub

/* $e <- x-y$ */
static void gf3m_sub(element_t e, element_t a, element_t b) {
    unsigned long *e1 = DATA1(e), *e2 = DATA2(e), *a1 = DATA1(a),
            *a2 = DATA2(a), *b1 = DATA2(b), *b2 = DATA1(b);
    unsigned i;
    for (i = 0; i < LEN(e); i++, e1++, e2++, a1++, a2++, b1++, b2++) {
        unsigned long t = (*a1 | *a2) & (*b1 | *b2), c1 = t ^ (*a1 | *b1), c2 =
                t ^ (*a2 | *b2);
        *e1 = c1;
        *e2 = c2;
    }
}
开发者ID:mahdiz,项目名称:mpclib,代码行数:12,代码来源:ternary_extension_field.cpp


示例5: postmap_header

static void postmap_header(void *ptr, int unused_header_class,
			           const HEADER_OPTS *unused_header_info,
			           VSTRING *header_buf,
			           off_t offset)
{

    /*
     * Don't re-invent an already working wheel.
     */
    postmap_body(ptr, 0, STR(header_buf), LEN(header_buf), offset);
}
开发者ID:Gelma,项目名称:Postfix,代码行数:11,代码来源:postmap.c


示例6: main

main(int unused_argc, char **unused_argv)
{
    VSTRING *raw = vstring_alloc(BUFLEN);
    VSTRING *hex = vstring_alloc(100);
    int     len;

    while ((len = read_buf(VSTREAM_IN, raw)) > 0) {
	hex_quote(hex, STR(raw));
	if (hex_unquote(raw, STR(hex)) == 0)
	    msg_fatal("bad input: %.100s", STR(hex));
	if (LEN(raw) != len)
	    msg_fatal("len %d != raw len %d", len, LEN(raw));
	if (vstream_fwrite(VSTREAM_OUT, STR(raw), LEN(raw)) != LEN(raw))
	    msg_fatal("write error: %m");
    }
    vstream_fflush(VSTREAM_OUT);
    vstring_free(raw);
    vstring_free(hex);
    return (0);
}
开发者ID:TonyChengTW,项目名称:Rmail,代码行数:20,代码来源:hex_quote.c


示例7: gf3m_to_bytes

int gf3m_to_bytes(unsigned char *d, element_ptr e) {
    unsigned long *a = DATA1(e), *b = DATA2(e);
    unsigned long i, j;
    for (i = 0; i < LEN(e); i++, a++, b++) {
        for (j = 0; j < sizeof(unsigned long) * 8; j += 8) {
            *(d++) = (unsigned char) ((*a) >> j);
            *(d++) = (unsigned char) ((*b) >> j);
        }
    }
    return SIZE(e);
}
开发者ID:mahdiz,项目名称:mpclib,代码行数:11,代码来源:ternary_extension_field.cpp


示例8: rbug_send_texture_read_reply

int rbug_send_texture_read_reply(struct rbug_connection *__con,
                                 uint32_t serial,
                                 uint32_t format,
                                 uint32_t blockw,
                                 uint32_t blockh,
                                 uint32_t blocksize,
                                 uint8_t *data,
                                 uint32_t data_len,
                                 uint32_t stride,
                                 uint32_t *__serial)
{
	uint32_t __len = 0;
	uint32_t __pos = 0;
	uint8_t *__data = NULL;
	int __ret = 0;

	LEN(8); /* header */
	LEN(4); /* serial */
	LEN(4); /* format */
	LEN(4); /* blockw */
	LEN(4); /* blockh */
	LEN(4); /* blocksize */
	LEN_ARRAY(1, data); /* data */
	LEN(4); /* stride */

	/* align */
	PAD(__len, 8);

	__data = (uint8_t*)MALLOC(__len);
	if (!__data)
		return -ENOMEM;

	WRITE(4, int32_t, ((int32_t)RBUG_OP_TEXTURE_READ_REPLY));
	WRITE(4, uint32_t, ((uint32_t)(__len / 4)));
	WRITE(4, uint32_t, serial); /* serial */
	WRITE(4, uint32_t, format); /* format */
	WRITE(4, uint32_t, blockw); /* blockw */
	WRITE(4, uint32_t, blockh); /* blockh */
	WRITE(4, uint32_t, blocksize); /* blocksize */
	WRITE_ARRAY(1, uint8_t, data); /* data */
	WRITE(4, uint32_t, stride); /* stride */

	/* final pad */
	PAD(__pos, 8);

	if (__pos != __len) {
		__ret = -EINVAL;
	} else {
		rbug_connection_send_start(__con, RBUG_OP_TEXTURE_READ_REPLY, __len);
		rbug_connection_write(__con, __data, __len);
		__ret = rbug_connection_send_finish(__con, __serial);
	}

	FREE(__data);
	return __ret;
}
开发者ID:1065672644894730302,项目名称:Chromium,代码行数:56,代码来源:rbug_texture.c


示例9: rotate_block

/* rotate pieces in blocks by either 90^ or -90^ around (0, 0) pivot */
static int rotate_block(struct blocks *block, enum blocks_input_cmd cmd)
{
	int new_x, new_y;
	int bounds_x, bounds_y;
	int dir = 1;
	size_t i;

	if (!block)
		return -1;

	/* Don't rotate O block */
	if (block->type == O_BLOCK)
		return 1;

	if (cmd == ROT_LEFT)
		dir = -1;

	/* Check each piece for a collision before we write any changes */
	for (i = 0; i < LEN(block->p); i++) {
		bounds_x = block->p[i].y * (-dir) + block->col_off;
		bounds_y = block->p[i].x * (dir) + block->row_off;

		/* Check for out of bounds on each piece */
		if (bounds_x < 0 || bounds_x >= BLOCKS_MAX_COLUMNS ||
		    bounds_y < 0 || bounds_y >= BLOCKS_MAX_ROWS ||
		    /* Also check if a piece already exists here */
		    blocks_at_yx(bounds_y, bounds_x))
			return 0;
	}

	/* No collisions, so update the block position. */
	for (i = 0; i < LEN(block->p); i++) {
		new_x = block->p[i].y * (-dir);
		new_y = block->p[i].x * (dir);

		block->p[i].x = new_x;
		block->p[i].y = new_y;
	}

	return 1;
}
开发者ID:theta43,项目名称:tetris,代码行数:42,代码来源:blocks.c


示例10: rbug_send_shader_list_reply

int rbug_send_shader_list_reply(struct rbug_connection *__con,
                                uint32_t serial,
                                rbug_shader_t *shaders,
                                uint32_t shaders_len,
                                uint32_t *__serial)
{
	uint32_t __len = 0;
	uint32_t __pos = 0;
	uint8_t *__data = NULL;
	int __ret = 0;

	LEN(8); /* header */
	LEN(4); /* serial */
	LEN_ARRAY(8, shaders); /* shaders */

	/* align */
	PAD(__len, 8);

	__data = (uint8_t*)MALLOC(__len);
	if (!__data)
		return -ENOMEM;

	WRITE(4, int32_t, ((int32_t)RBUG_OP_SHADER_LIST_REPLY));
	WRITE(4, uint32_t, ((uint32_t)(__len / 4)));
	WRITE(4, uint32_t, serial); /* serial */
	WRITE_ARRAY(8, rbug_shader_t, shaders); /* shaders */

	/* final pad */
	PAD(__pos, 8);

	if (__pos != __len) {
		__ret = -EINVAL;
	} else {
		rbug_connection_send_start(__con, RBUG_OP_SHADER_LIST_REPLY, __len);
		rbug_connection_write(__con, __data, __len);
		__ret = rbug_connection_send_finish(__con, __serial);
	}

	FREE(__data);
	return __ret;
}
开发者ID:Bluerise,项目名称:bitrig-xenocara,代码行数:41,代码来源:rbug_shader.c


示例11: name2sig

int
name2sig(const char *name)
{
	size_t i;

	for (i = 0; i < LEN(sigs); i++)
		if (!strcasecmp(sigs[i].name, name))
			return sigs[i].sig;
	eprintf("%s: bad signal name\n", name);

	return -1; /* not reached */
}
开发者ID:michaelforney,项目名称:sbase,代码行数:12,代码来源:kill.c


示例12: gf3m_neg

/* $y <- (-x)$ */
static void gf3m_neg(element_t y, element_t x) {
    unsigned long *a1 = DATA1(x), *a2 = DATA2(x), *c1 = DATA1(y),
            *c2 = DATA2(y);
    if (a1 == c1) {
        unsigned i;
        for (i = 0; i < LEN(y); i++, a1++, a2++)
            swap(a1, a2);
    } else {
        memcpy(c1, a2, SIZE(y) / 2);
        memcpy(c2, a1, SIZE(y) / 2);
    }
}
开发者ID:mahdiz,项目名称:mpclib,代码行数:13,代码来源:ternary_extension_field.cpp


示例13: test_get_flow_info_one_flow

void test_get_flow_info_one_flow( void** state )
{
	char* links[] = { "alink", "onemore", NULL };
	datalink_id_t link_ids[ LEN( links ) - 1 ] = { 13, 15 };
	char* ips[] = { "1.2.3.4", "4.3.2.1" };
	dladm_flow_attr_t attrs[] = { { .fa_linkid = link_ids[ 0 ],
	                                .fa_flowname = "aflow",
	                                .fa_flow_desc = { .fd_mask = FLOW_IP_LOCAL | FLOW_IP_PROTOCOL | FLOW_ULP_PORT_LOCAL,
	                                                  .fd_protocol = IPPROTO_TCP,
	                                                  .fd_local_port = 12 } },

	                              { .fa_linkid = link_ids[ 1 ],
开发者ID:robertboczek,项目名称:solaris-crossbow,代码行数:12,代码来源:flowadm_wrapper.c


示例14: midi_pop

MidiEvent midi_pop()
{
	if (!midi_count()) err(1, "midi queue underflow");

	locker(1);
	MidiEvent me = *head++;
	if (head == &events[LEN(events)]) head = events;
	nevent--;
	locker(0);

	return me;
}
开发者ID:cjxgm,项目名称:learning,代码行数:12,代码来源:midi.c


示例15: attr_print64_long_num

static void attr_print64_long_num(ACL_VSTREAM *fp, unsigned long long_num)
{
    static __thread ACL_VSTRING *plain;

    if (plain == 0) {
	plain = acl_vstring_alloc(10);
	acl_pthread_atexit_add(plain, free_vstring);
    }

    acl_vstring_sprintf(plain, "%lu", long_num);
    attr_print64_str(fp, STR(plain), (int) LEN(plain));
}
开发者ID:1514louluo,项目名称:acl,代码行数:12,代码来源:attr_print64.c


示例16: deinitialization

/*!
	\brief frees the sem[] array
	\param owner
		if owner is nonzero, further deinitialization (sem_unlink)
		is performed
	\details
		Every element of sem[] will be SEM_FAILED after this function
		is called. If owner is nonzero, the semaphores will be unlinked
*/
static void free_semaphores(int owner)
{
    int i;
    for(i = 0; i < LEN(sem); i++) {
        if(sem[i] != SEM_FAILED) {
            (void)sem_close(sem[i]);
            sem[i] = SEM_FAILED;
        }
        if(owner != 0)
            (void)sem_unlink(SEM_NAME[i]);
    }
}
开发者ID:chtisgit,项目名称:osue,代码行数:21,代码来源:common.c


示例17: print_resolved_types

static void print_resolved_types(TYPERUN *pp)
{
    fprintf(stderr, "   Types: ");
    while(pp)
    {
        BidiStrIndex i;
        for(i = 0; i < LEN (pp); i++)
            fprintf(stderr, "%c", bidi_type_name(pp->type));
        pp = pp->next;
    }
    fprintf(stderr, "\n");
}
开发者ID:hyller,项目名称:GladiatorLibrary,代码行数:12,代码来源:charset-bidi.c


示例18: reset

const std::list<rfc822_addr*>& rfc822::parse_addrs(const char* in)
{
	reset();

	if (in == NULL || *in == 0)
	{
		logger_error("input invalid");
		return (addrs_);
	}
	TOK822 *tree = tok822_parse(in);
	if (tree == NULL)
	{
		logger_error("tok822_parse(%s) error", in);
		return (addrs_);
	}

	const ACL_VSTRING* comment_prev = NULL;
	string buf;

	for (TOK822 *tp = tree; tp; tp = tp->next)
	{
		if (tp->type == TOK822_ATOM
			|| tp->type == TOK822_COMMENT
			|| tp->type == TOK822_QSTRING
			|| tp->vstr != NULL)
		{
			comment_prev = tp->vstr;
		}

		if (tp->type != TOK822_ADDR || tp->head == NULL)
			continue;

		ACL_VSTRING* addrp = acl_vstring_alloc(32);
		(void) tok822_internalize(addrp, tp->head, TOK822_STR_DEFL);
		rfc822_addr* addr = (rfc822_addr*)
			acl_mymalloc(sizeof(rfc822_addr));
		addr->addr = acl_vstring_export(addrp);
		if (comment_prev)
		{
			buf.clear();
			rfc2047::decode(STR(comment_prev), LEN(comment_prev),
				&buf, "gb18030");
			addr->comment = acl_mystrdup(buf.c_str());
			comment_prev = NULL;
		}
		else
			addr->comment = NULL;
		addrs_.push_back(addr);
	}

	tok822_free_tree(tree);
	return (addrs_);
}
开发者ID:10jschen,项目名称:acl,代码行数:53,代码来源:rfc822.cpp


示例19: main

int     main(int unused_argc, char **unused_argv)
{
    VSTRING *unquoted = vstring_alloc(BUFLEN);
    VSTRING *quoted = vstring_alloc(100);
    ssize_t len;

    while ((len = read_buf(VSTREAM_IN, unquoted)) > 0) {
	xtext_quote(quoted, STR(unquoted), "+=");
	if (xtext_unquote(unquoted, STR(quoted)) == 0)
	    msg_fatal("bad input: %.100s", STR(quoted));
	if (LEN(unquoted) != len)
	    msg_fatal("len %ld != unquoted len %ld",
		      (long) len, (long) LEN(unquoted));
	if (vstream_fwrite(VSTREAM_OUT, STR(unquoted), LEN(unquoted)) != LEN(unquoted))
	    msg_fatal("write error: %m");
    }
    vstream_fflush(VSTREAM_OUT);
    vstring_free(unquoted);
    vstring_free(quoted);
    return (0);
}
开发者ID:aosm,项目名称:postfix,代码行数:21,代码来源:xtext.c


示例20: parse_json

static void parse_json(const char *data)
{
	ACL_JSON *json = acl_json_alloc();
	ACL_VSTRING *buf1 = acl_vstring_alloc(128);
	ACL_VSTRING *buf2 = acl_vstring_alloc(128);
	ACL_ARRAY *nodes;
	const char *tag = "header";

	printf("buf    src: %s\r\n", data);

	printf("------------------------------------------------\r\n");

	acl_json_update(json, data);
	acl_json_build(json, buf1);
	printf("result src: %s\r\n", STR(buf1));

	printf("------------------------------------------------\r\n");

	nodes = acl_json_getElementsByTagName(json, tag);
	if (nodes == NULL)
	{
		printf("not found tag: %s\r\n", tag);
		acl_vstring_free(buf1);
		acl_vstring_free(buf2);
		acl_json_free(json);
		return;
	}

	printf(">>>tag: %s, len: %d\r\n", tag, acl_array_size(nodes));

	ACL_ITER iter;

#define	STR	acl_vstring_str
#define	LEN	ACL_VSTRING_LEN

	acl_foreach(iter, nodes)
	{
		ACL_JSON_NODE *node = (ACL_JSON_NODE*) iter.data;
		ACL_JSON_NODE *tag_node = node->tag_node;
		if (tag_node == NULL)
			continue;

		printf(">>>tag: %s\r\n", STR(node->ltag));

		ACL_ITER iter2;
		acl_foreach(iter2, tag_node)
		{
			ACL_JSON_NODE *node1 = (ACL_JSON_NODE*) iter2.data;
			if (node1->ltag == NULL || LEN(node1->ltag) == 0)
				continue;
			printf(">>>child tag: %s, txt: %s\r\n", STR(node1->ltag),
				node1->text ? STR(node1->text) : "null");
		}
开发者ID:10jschen,项目名称:acl,代码行数:53,代码来源:main.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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