本文整理汇总了C++中print_value函数的典型用法代码示例。如果您正苦于以下问题:C++ print_value函数的具体用法?C++ print_value怎么用?C++ print_value使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了print_value函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv)
{
int rv;
int fd = open(argv[1], O_RDWR);
struct lead lead;
pread(fd, &lead, sizeof(lead), 0);
// First header
struct header hdr;
pread(fd, &hdr, sizeof(hdr), sizeof(lead));
hdr.nindex = be32toh(hdr.nindex);
hdr.len = be32toh(hdr.len);
long hdrofs = sizeof(struct lead);
long idxofs = hdrofs + sizeof(struct header);
long storeofs = idxofs + hdr.nindex * sizeof(struct idxentry);
printf("== Signatures ==\nHeader offset: 0x%lx\nIndex offset: 0x%lx\n"
"Store: 0x%lx - 0x%lx\nIndex entries (%u):\n",
hdrofs, idxofs, storeofs, storeofs + hdr.len, hdr.nindex);
int i;
int64_t remsize = -1;
for (i = 0; i < hdr.nindex; i++) {
struct idxentry ent;
pread(fd, &ent, sizeof(ent), idxofs + i * sizeof(struct idxentry));
ent.tag = be32toh(ent.tag);
ent.type = be32toh(ent.type);
ent.offset = storeofs + be32toh(ent.offset);
ent.count = be32toh(ent.count);
if (ent.tag == RPMSIGTAG_LONGSIZE) {
assert(ent.type == RPM_INT64_TYPE);
assert(ent.count == 1);
pread(fd, &remsize, sizeof(remsize), ent.offset);
remsize = be64toh(remsize);
} else if (ent.tag == RPMSIGTAG_SIZE) {
assert(ent.type == RPM_INT32_TYPE);
assert(ent.count == 1);
uint32_t remsize32 = 0;
pread(fd, &remsize32, sizeof(remsize32), ent.offset);
remsize = be32toh(remsize32);
}
const char *name = hdr_tag_name(ent.tag);
if (name)
printf(" %s: ", name);
else
printf(" %d: ", ent.tag);
print_value(fd, &ent);
printf("\n");
if (i == 0) {
// Is this what "sealed" means?
uint32_t tag = ent.tag;
assert(TAG_IS_REGION(tag));
assert(ent.type == RPM_BIN_TYPE);
assert(ent.count == 16);
pread(fd, &ent, sizeof(ent), ent.offset);
ent.tag = be32toh(ent.tag);
ent.type = be32toh(ent.type);
ent.offset = storeofs + be32toh(ent.offset);
ent.count = be32toh(ent.count);
assert(ent.tag == tag);
assert(ent.type == RPM_BIN_TYPE);
assert(ent.count == 16);
assert(ent.offset == idxofs);
}
}
printf("\n");
assert(remsize >= 0);
// Pad to 8-byte alignment and seek past pad
hdrofs = storeofs + hdr.len;
hdrofs = ((hdrofs + 7) / 8) * 8;
lseek(fd, hdrofs, SEEK_SET);
// Second header
pread(fd, &hdr, sizeof(hdr), hdrofs);
hdr.nindex = be32toh(hdr.nindex);
hdr.len = be32toh(hdr.len);
idxofs = hdrofs + sizeof(struct header);
storeofs = idxofs + hdr.nindex * sizeof(struct idxentry);
printf("== Header ==\nTotal filesize: 0x%lx\nHeader offset: 0x%lx\n"
"Index offset: 0x%lx\nStore: 0x%lx - 0x%lx\nIndex entries (%u):\n",
hdrofs + remsize, hdrofs, idxofs, storeofs, storeofs + hdr.len, hdr.nindex);
for (i = 0; i < hdr.nindex; i++) {
struct idxentry ent;
pread(fd, &ent, sizeof(ent), idxofs + i * sizeof(struct idxentry));
ent.tag = be32toh(ent.tag);
ent.type = be32toh(ent.type);
//.........这里部分代码省略.........
开发者ID:djpohly,项目名称:rpm-decap,代码行数:101,代码来源:info.c
示例2: while
/* Render an array to text */
static char *print_array(cJSON * item, int depth, int fmt, printbuffer * p)
{
char **entries;
char *out = 0, *ptr, *ret;
int len = 5;
cJSON *child = item->child;
int numentries = 0, i = 0, fail = 0;
size_t tmplen = 0;
/* How many entries in the array? */
while (child)
numentries++, child = child->next;
/* Explicitly handle numentries==0 */
if (!numentries) {
if (p)
out = ensure(p, 3);
else
out = (char *) cJSON_malloc(3);
if (out)
strcpy(out, "[]");
return out;
}
if (p) {
/* Compose the output array. */
i = p->offset;
ptr = ensure(p, 1);
if (!ptr)
return 0;
*ptr = '[';
p->offset++;
child = item->child;
while (child && !fail) {
print_value(child, depth + 1, fmt, p);
p->offset = update(p);
if (child->next) {
len = fmt ? 2 : 1;
ptr = ensure(p, len + 1);
if (!ptr)
return 0;
*ptr++ = ',';
if (fmt)
*ptr++ = ' ';
*ptr = 0;
p->offset += len;
}
child = child->next;
}
ptr = ensure(p, 2);
if (!ptr)
return 0;
*ptr++ = ']';
*ptr = 0;
out = (p->buffer) + i;
} else {
/* Allocate an array to hold the values for each */
entries = (char **) cJSON_malloc(numentries * sizeof(char *));
if (!entries)
return 0;
memset(entries, 0, numentries * sizeof(char *));
/* Retrieve all the results: */
child = item->child;
while (child && !fail) {
ret = print_value(child, depth + 1, fmt, 0);
entries[i++] = ret;
if (ret)
len += strlen(ret) + 2 + (fmt ? 1 : 0);
else
fail = 1;
child = child->next;
}
/* If we didn't fail, try to malloc the output string */
if (!fail)
out = (char *) cJSON_malloc(len);
/* If that fails, we fail. */
if (!out)
fail = 1;
/* Handle failure. */
if (fail) {
for (i = 0; i < numentries; i++)
if (entries[i])
cJSON_free(entries[i]);
cJSON_free(entries);
return 0;
}
/* Compose the output array. */
*out = '[';
ptr = out + 1;
*ptr = 0;
for (i = 0; i < numentries; i++) {
tmplen = strlen(entries[i]);
memcpy(ptr, entries[i], tmplen);
ptr += tmplen;
if (i != numentries - 1) {
*ptr++ = ',';
if (fmt)
//.........这里部分代码省略.........
开发者ID:hurley25,项目名称:ttms,代码行数:101,代码来源:cJSON.c
示例3: print_value
/* Render a cJSON item/entity/structure to text. */
char *cJSON_Print(cJSON *item) {return print_value(item,0,1);}
开发者ID:Velleman,项目名称:VM204-Firmware,代码行数:2,代码来源:cJSON.c
示例4: output
void InstructionPrinter::do_InstanceOf(InstanceOf* x) {
output()->print("instanceof(");
print_value(x->obj());
output()->print(") ");
print_klass(x->klass());
}
开发者ID:GregBowyer,项目名称:ManagedRuntimeInitiative,代码行数:6,代码来源:c1_InstructionPrinter.cpp
示例5: print_unsafe_raw_op
void InstructionPrinter::do_UnsafePutRaw(UnsafePutRaw* x) {
print_unsafe_raw_op(x, "UnsafePutRaw");
output()->print(", value ");
print_value(x->value());
output()->put(')');
}
开发者ID:GregBowyer,项目名称:ManagedRuntimeInitiative,代码行数:6,代码来源:c1_InstructionPrinter.cpp
示例6: PRINTF
GLOBAL Int UMF_report_vector
(
Int n,
const double Xx [ ],
const double Xz [ ],
Int prl,
Int user,
Int scalar
)
{
Int n2, i ;
if (user || prl >= 4)
{
PRINTF (("dense vector, n = "ID". ", n)) ;
}
if (user)
{
if (!Xx)
{
PRINTF (("ERROR: vector not present\n\n")) ;
return (UMFPACK_ERROR_argument_missing) ;
}
if (n < 0)
{
PRINTF (("ERROR: length of vector is < 0\n\n")) ;
return (UMFPACK_ERROR_n_nonpositive) ;
}
}
if (user || prl >= 4)
{
PRINTF4 (("\n")) ;
}
if (prl == 4)
{
/* print level of 4 */
n2 = MIN (10, n) ;
for (i = 0 ; i < n2 ; i++)
{
print_value (i, Xx, Xz, scalar) ;
}
if (n2 < n)
{
PRINTF ((" ...\n")) ;
print_value (n-1, Xx, Xz, scalar) ;
}
}
else if (prl > 4)
{
/* print level 4 or more */
for (i = 0 ; i < n ; i++)
{
print_value (i, Xx, Xz, scalar) ;
}
}
PRINTF4 ((" dense vector ")) ;
if (user || prl >= 4)
{
PRINTF (("OK\n\n")) ;
}
return (UMFPACK_OK) ;
}
开发者ID:GHilmarG,项目名称:Ua,代码行数:66,代码来源:umf_report_vector.c
示例7: print_value
void InstructionPrinter::print_field(AccessField* field) {
print_value(field->obj());
output()->print("._%d", field->offset());
}
开发者ID:GregBowyer,项目名称:ManagedRuntimeInitiative,代码行数:4,代码来源:c1_InstructionPrinter.cpp
示例8: while
/* Render an array to text */
static char *print_array(srjson_doc_t *doc, srjson_t *item, int depth, int fmt)
{
char **entries;
char *out = 0, *ptr, *ret;
int len = 5;
srjson_t *child = item->child;
int numentries = 0, i = 0, fail = 0;
/* How many entries in the array? */
while (child)
numentries++, child = child->next;
/* Allocate an array to hold the values for each */
entries = (char **) doc->malloc_fn(numentries * sizeof(char *));
if (!entries)
return 0;
memset(entries, 0, numentries * sizeof(char *));
/* Retrieve all the results: */
child = item->child;
while (child && !fail) {
ret = print_value(doc, child, depth + 1, fmt);
entries[i++] = ret;
if (ret)
len += strlen(ret) + 2 + (fmt ? 1 : 0);
else
fail = 1;
child = child->next;
}
/* If we didn't fail, try to malloc the output string */
if (!fail)
out = (char *) doc->malloc_fn(len);
/* If that fails, we fail. */
if (!out)
fail = 1;
/* Handle failure. */
if (fail) {
for (i = 0; i < numentries; i++)
if (entries[i])
doc->free_fn(entries[i]);
doc->free_fn(entries);
return 0;
}
/* Compose the output array. */
*out = '[';
ptr = out + 1;
*ptr = 0;
for (i = 0; i < numentries; i++) {
strcpy(ptr, entries[i]);
ptr += strlen(entries[i]);
if (i != numentries - 1) {
*ptr++ = ',';
if (fmt)
*ptr++ = ' ';
*ptr = 0;
}
doc->free_fn(entries[i]);
}
doc->free_fn(entries);
*ptr++ = ']';
*ptr++ = 0;
return out;
}
开发者ID:DileepNunna,项目名称:kamailio,代码行数:64,代码来源:srjson.c
示例9: print_value
char *srjson_PrintUnformatted(srjson_doc_t *doc, srjson_t *item) {
return print_value(doc, item, 0, 0);
}
开发者ID:DileepNunna,项目名称:kamailio,代码行数:3,代码来源:srjson.c
示例10: print_stats
static void
print_stats(const gchar *filename, capture_info *cf_info)
{
const gchar *file_type_string, *file_encap_string;
time_t start_time_t;
time_t stop_time_t;
/* Build printable strings for various stats */
file_type_string = wtap_file_type_string(cf_info->file_type);
file_encap_string = wtap_encap_string(cf_info->file_encap);
start_time_t = (time_t)cf_info->start_time;
stop_time_t = (time_t)cf_info->stop_time;
if (filename) printf ("File name: %s\n", filename);
if (cap_file_type) printf ("File type: %s%s\n",
file_type_string,
cf_info->iscompressed ? " (gzip compressed)" : "");
if (cap_file_encap) printf ("File encapsulation: %s\n", file_encap_string);
if (cap_file_encap && (cf_info->file_encap == WTAP_ENCAP_PER_PACKET)) {
int i;
for (i=0; i<WTAP_NUM_ENCAP_TYPES; i++) {
if (cf_info->encap_counts[i] > 0)
printf(" %s\n", wtap_encap_string(i));
}
}
if (cap_snaplen && cf_info->snap_set)
printf ("Packet size limit: file hdr: %u bytes\n", cf_info->snaplen);
else if(cap_snaplen && !cf_info->snap_set)
printf ("Packet size limit: file hdr: (not set)\n");
if (cf_info->snaplen_max_inferred > 0) {
if (cf_info->snaplen_min_inferred == cf_info->snaplen_max_inferred)
printf ("Packet size limit: inferred: %u bytes\n", cf_info->snaplen_min_inferred);
else
printf ("Packet size limit: inferred: %u bytes - %u bytes (range)\n",
cf_info->snaplen_min_inferred, cf_info->snaplen_max_inferred);
}
if (cap_packet_count) printf ("Number of packets: %u\n", cf_info->packet_count);
if (cap_file_size) printf ("File size: %" G_GINT64_MODIFIER "d bytes\n", cf_info->filesize);
if (cap_data_size) printf ("Data size: %" G_GINT64_MODIFIER "u bytes\n", cf_info->packet_bytes);
if (cf_info->times_known) {
if (cap_duration)
print_value("Capture duration: ", 0, " seconds", cf_info->duration);
if (cap_start_time)
printf ("Start time: %s", time_string(start_time_t, cf_info, TRUE));
if (cap_end_time)
printf ("End time: %s", time_string(stop_time_t, cf_info, TRUE));
if (cap_data_rate_byte)
print_value("Data byte rate: ", 2, " bytes/sec", cf_info->data_rate);
if (cap_data_rate_bit)
print_value("Data bit rate: ", 2, " bits/sec", cf_info->data_rate*8);
}
if (cap_packet_size) printf ("Average packet size: %.2f bytes\n", cf_info->packet_size);
if (cf_info->times_known) {
if (cap_packet_rate)
print_value("Average packet rate: ", 2, " packets/sec", cf_info->packet_rate);
}
#ifdef HAVE_LIBGCRYPT
if (cap_file_hashes) {
printf ("SHA1: %s\n", file_sha1);
printf ("RIPEMD160: %s\n", file_rmd160);
printf ("MD5: %s\n", file_md5);
}
#endif /* HAVE_LIBGCRYPT */
if (cap_order) printf ("Strict time order: %s\n", order_string(cf_info->order));
}
开发者ID:AnkitKejriwal,项目名称:wireshark,代码行数:65,代码来源:capinfos.c
示例11: print_indexed
void InstructionPrinter::do_StoreIndexed(StoreIndexed* x) {
print_indexed(x);
output()->print(" := ");
print_value(x->value());
output()->print(" (%c)", type2char(x->elt_type()));
}
开发者ID:GregBowyer,项目名称:ManagedRuntimeInitiative,代码行数:6,代码来源:c1_InstructionPrinter.cpp
示例12: print_unsafe_op
void InstructionPrinter::print_unsafe_object_op(UnsafeObjectOp* op, const char* name) {
print_unsafe_op(op, name);
print_value(op->object());
output()->print(", ");
print_value(op->offset());
}
开发者ID:GregBowyer,项目名称:ManagedRuntimeInitiative,代码行数:6,代码来源:c1_InstructionPrinter.cpp
示例13: print_unsafe_object_op
void InstructionPrinter::do_UnsafePutObject(UnsafePutObject* x) {
print_unsafe_object_op(x, "UnsafePutObject");
output()->print(", value ");
print_value(x->value());
output()->put(')');
}
开发者ID:GregBowyer,项目名称:ManagedRuntimeInitiative,代码行数:6,代码来源:c1_InstructionPrinter.cpp
示例14: print_field
void InstructionPrinter::do_StoreField(StoreField* x) {
print_field(x);
output()->print(" := ");
print_value(x->value());
output()->print(" (%c)", type2char(x->field()->type()->basic_type()));
}
开发者ID:GregBowyer,项目名称:ManagedRuntimeInitiative,代码行数:6,代码来源:c1_InstructionPrinter.cpp
示例15: lowprobe_device
static int lowprobe_device(blkid_probe pr, const char *devname,
int chain, char *show[], int output,
uint64_t offset, uint64_t size)
{
const char *data;
const char *name;
int nvals = 0, n, num = 1;
size_t len;
int fd;
int rc = 0;
static int first = 1;
fd = open(devname, O_RDONLY|O_CLOEXEC);
if (fd < 0) {
fprintf(stderr, "error: %s: %m\n", devname);
return BLKID_EXIT_NOTFOUND;
}
if (blkid_probe_set_device(pr, fd, offset, size))
goto done;
if (chain & LOWPROBE_TOPOLOGY)
rc = lowprobe_topology(pr);
if (rc >= 0 && (chain & LOWPROBE_SUPERBLOCKS))
rc = lowprobe_superblocks(pr);
if (rc < 0)
goto done;
if (!rc)
nvals = blkid_probe_numof_values(pr);
if (nvals && !first && output & (OUTPUT_UDEV_LIST | OUTPUT_EXPORT_LIST))
/* add extra line between output from devices */
fputc('\n', stdout);
if (nvals && (output & OUTPUT_DEVICE_ONLY)) {
printf("%s\n", devname);
goto done;
}
for (n = 0; n < nvals; n++) {
if (blkid_probe_get_value(pr, n, &name, &data, &len))
continue;
if (show[0] && !has_item(show, name))
continue;
len = strnlen((char *) data, len);
print_value(output, num++, devname, (char *) data, name, len);
}
if (first)
first = 0;
if (nvals >= 1 && !(output & (OUTPUT_VALUE_ONLY |
OUTPUT_UDEV_LIST | OUTPUT_EXPORT_LIST)))
printf("\n");
done:
if (rc == -2) {
if (output & OUTPUT_UDEV_LIST)
print_udev_ambivalent(pr);
else
fprintf(stderr,
"%s: ambivalent result (probably more "
"filesystems on the device, use wipefs(8) "
"to see more details)\n",
devname);
}
close(fd);
if (rc == -2)
return BLKID_EXIT_AMBIVAL; /* ambivalent probing result */
if (!nvals)
return BLKID_EXIT_NOTFOUND; /* nothing detected */
return 0; /* success */
}
开发者ID:HorvathAkosPeter,项目名称:util-linux,代码行数:73,代码来源:blkid.c
注:本文中的print_value函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论