本文整理汇总了C++中LEN函数的典型用法代码示例。如果您正苦于以下问题:C++ LEN函数的具体用法?C++ LEN怎么用?C++ LEN使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LEN函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
}
示例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);
}
示例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;
}
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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 */
}
示例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);
}
}
示例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 ],
示例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;
}
示例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));
}