这篇教程C++ strtoull函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中strtoull函数的典型用法代码示例。如果您正苦于以下问题:C++ strtoull函数的具体用法?C++ strtoull怎么用?C++ strtoull使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了strtoull函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: vsscanf//.........这里部分代码省略......... base = 16; break; case 'i': base = 0; case 'd': is_sign = true; case 'u': break; case '%': /* looking for '%' in str */ if (*str++ != '%') return num; continue; default: /* invalid format; stop here */ return num; } /* have some sort of integer conversion. * first, skip white space in buffer. */ str = skip_spaces(str); digit = *str; if (is_sign && digit == '-') digit = *(str + 1); if (!digit || (base == 16 && !isxdigit(digit)) || (base == 10 && !isdigit(digit)) || (base == 8 && (!isdigit(digit) || digit > '7')) || (base == 0 && !isdigit(digit))) break; if (is_sign) val.s = qualifier != 'L' ? strtol(str, &next, base) : strtoll(str, &next, base); else val.u = qualifier != 'L' ? strtoul(str, &next, base) : strtoull(str, &next, base); if (field_width > 0 && next - str > field_width) { if (base == 0) _parse_integer_fixup_radix(str, &base); while (next - str > field_width) { if (is_sign) val.s = sdiv64(val.s, base); else val.u = udiv64(val.u, base); --next; } } switch (qualifier) { case 'H': /* that's 'hh' in format */ if (is_sign) *va_arg(args, signed char *) = val.s; else *va_arg(args, unsigned char *) = val.u; break; case 'h': if (is_sign) *va_arg(args, short *) = val.s; else *va_arg(args, unsigned short *) = val.u; break; case 'l': if (is_sign) *va_arg(args, long *) = val.s; else *va_arg(args, unsigned long *) = val.u; break; case 'L': if (is_sign) *va_arg(args, long long *) = val.s; else *va_arg(args, unsigned long long *) = val.u; break; case 'Z': case 'z': *va_arg(args, size_t *) = val.u; break; default: if (is_sign) *va_arg(args, int *) = val.s; else *va_arg(args, unsigned int *) = val.u; break; } num++; if (!next) break; str = next; } return num;}
开发者ID:32bitmicro,项目名称:xvisor,代码行数:101,
示例2: processline//.........这里部分代码省略......... members_size = ftell(fp); /* Get file length */ rewind(fp); /* Back to start of file */ members = calloc(members_size + 1, sizeof(char)); if(members == NULL ) { fprintf(stderr, "/nInsufficient memory to read file: %s/n", p); syntaxError = 1; fclose(fp); break; } /* Read the entire file into members * NOTE: -- fread returns number of items successfully read * not the number of bytes. We're requesting one item of * members_size bytes. So we expect the return value here * to be 1. */ if (fread(members, members_size, 1, fp) != 1){ fprintf(stderr, "Error reading file: %s/n", p); syntaxError = 1; fclose(fp); break; } fclose(fp); } else if (strcmp(p, "-version")==0){ p = strtok (NULL," "); if (version != -1 || p == NULL){ syntaxError = 1; break; }#ifdef WIN32 version = _strtoui64(p, NULL, 16);#else version = strtoull(p, NULL, 16);#endif if (version < 0) { syntaxError = 1; break; } } else { syntaxError = 1; break; } p = strtok (NULL," "); } if (syntaxError) return; rc = zoo_areconfig(zh, joining, leaving, members, version, my_data_completion, strdup(line)); free(joining); free(leaving); free(members); if (rc) { fprintf(stderr, "Error %d for %s/n", rc, line); } } else if (startsWith(line, "set ")) { char *ptr; line += 4; if (line[0] != '/') { fprintf(stderr, "Path must start with /, found: %s/n", line); return; } ptr = strchr(line, ' '); if (!ptr) { fprintf(stderr, "No data found after path/n"); return;
开发者ID:FloodDragon,项目名称:zookeeper,代码行数:67,
示例3: xml_to_nodestatic void xml_to_node(xmlNodePtr xml_node, plist_t * plist_node){ xmlNodePtr node = NULL; plist_data_t data = NULL; plist_t subnode = NULL; //for string long len = 0; int type = 0; if (!xml_node) return; for (node = xml_node->children; node; node = node->next) { while (node && !xmlStrcmp(node->name, XPLIST_TEXT)) node = node->next; if (!node) break; if (!xmlStrcmp(node->name, BAD_CAST("comment"))) { continue; } data = plist_new_plist_data(); subnode = plist_new_node(data); if (*plist_node) node_attach(*plist_node, subnode); else *plist_node = subnode; if (!xmlStrcmp(node->name, XPLIST_TRUE)) { data->boolval = TRUE; data->type = PLIST_BOOLEAN; data->length = 1; continue; } if (!xmlStrcmp(node->name, XPLIST_FALSE)) { data->boolval = FALSE; data->type = PLIST_BOOLEAN; data->length = 1; continue; } if (!xmlStrcmp(node->name, XPLIST_INT)) { xmlChar *strval = xmlNodeGetContent(node); data->intval = strtoull((char*)strval, NULL, 0); data->type = PLIST_UINT; data->length = 8; xmlFree(strval); continue; } if (!xmlStrcmp(node->name, XPLIST_REAL)) { xmlChar *strval = xmlNodeGetContent(node); data->realval = atof((char *) strval); data->type = PLIST_REAL; data->length = 8; xmlFree(strval); continue; } if (!xmlStrcmp(node->name, XPLIST_DATE)) { xmlChar *strval = xmlNodeGetContent(node); time_t time = 0; if (strlen((const char*)strval) >= 11) { struct tm btime; struct tm* tm_utc; parse_date((const char*)strval, &btime); time = mktime(&btime); tm_utc = gmtime(&time); time -= (mktime(tm_utc) - time); } data->timeval.tv_sec = (long)time; data->timeval.tv_usec = 0; data->type = PLIST_DATE; data->length = sizeof(struct timeval); xmlFree(strval); continue; } if (!xmlStrcmp(node->name, XPLIST_STRING)) { xmlChar *strval = xmlNodeGetContent(node); len = strlen((char *) strval); type = xmlDetectCharEncoding(strval, len); if (XML_CHAR_ENCODING_UTF8 == type || XML_CHAR_ENCODING_ASCII == type || XML_CHAR_ENCODING_NONE == type) { data->strval = strdup((char *) strval); data->type = PLIST_STRING; data->length = strlen(data->strval); }//.........这里部分代码省略.........
开发者ID:bzm97,项目名称:libplist,代码行数:101,
示例4: diskarenapart//.........这里部分代码省略......... if(arenaname[0] == 0){ diskarenatable(c, disk, table); goto out; } if(xfindarena(table, arenaname, &start, &end) < 0){ hprint(&c->hout, "no such arena %s/n", arenaname); goto out; } hprint(&c->hout, "<h2>arena %s</h2>/n", arenaname); hprint(&c->hout, "<pre>start=%#llx end=%#llx<pre>/n", start, end); if(end < start || end - start < HeadSize){ hprint(&c->hout, "bad size %#llx/n", end - start); goto out; } // read arena header, tail blk = vtmalloc(HeadSize); if(readpart(p, start, blk, HeadSize) != HeadSize){ hprint(&c->hout, "reading header: %r/n"); vtfree(blk); goto out; } if(unpackarenahead(&head, blk) < 0){ hprint(&c->hout, "corrupt arena header: %r/n"); // hhex(blk, HeadSize); vtfree(blk); goto out; } vtfree(blk); hprint(&c->hout, "head:/n<pre>/n"); hprint(&c->hout, "version=%d name=%s blocksize=%d size=%#llx clumpmagic=%#ux/n", head.version, head.name, head.blocksize, head.size, head.clumpmagic); hprint(&c->hout, "</pre><br><br>/n"); if(head.blocksize > MaxIoSize || head.blocksize >= end - start){ hprint(&c->hout, "corrupt block size %d/n", head.blocksize); goto out; } blk = vtmalloc(head.blocksize); if(readpart(p, end - head.blocksize, blk, head.blocksize) < 0){ hprint(&c->hout, "reading tail: %r/n"); vtfree(blk); goto out; } memset(&arena, 0, sizeof arena); arena.part = p; arena.blocksize = head.blocksize; arena.clumpmax = head.blocksize / ClumpInfoSize; arena.base = start + head.blocksize; arena.size = end - start - 2 * head.blocksize; if(unpackarena(&arena, blk) < 0){ vtfree(blk); goto out; } scorecp(arena.score, blk+head.blocksize - VtScoreSize); vtfree(blk); hprint(&c->hout, "tail:/n<pre>/n"); hprint(&c->hout, "version=%d name=%s/n", arena.version, arena.name); hprint(&c->hout, "ctime=%d %s/n", arena.ctime, fmttime(tbuf, arena.ctime)); hprint(&c->hout, "wtime=%d %s/n", arena.wtime, fmttime(tbuf, arena.wtime)); hprint(&c->hout, "clumpmagic=%#ux/n", arena.clumpmagic); hprint(&c->hout, "score %V/n", arena.score); hprint(&c->hout, "diskstats:/n"); hprint(&c->hout, "/tclumps=%,d cclumps=%,d used=%,lld uncsize=%,lld sealed=%d/n", arena.diskstats.clumps, arena.diskstats.cclumps, arena.diskstats.used, arena.diskstats.uncsize, arena.diskstats.sealed); hprint(&c->hout, "memstats:/n"); hprint(&c->hout, "/tclumps=%,d cclumps=%,d used=%,lld uncsize=%,lld sealed=%d/n", arena.memstats.clumps, arena.memstats.cclumps, arena.memstats.used, arena.memstats.uncsize, arena.memstats.sealed); if(arena.clumpmax == 0){ hprint(&c->hout, "bad clumpmax/n"); goto out; } score = hargstr(c, "score", ""); clump = hargstr(c, "clump", ""); if(clump[0]){ off = strtoull(clump, 0, 0); diskarenaclump(c, &arena, off, score[0] ? score : nil); }else if(score[0]){ diskarenaclump(c, &arena, -1, score); }else{ diskarenatoc(c, &arena); }out: free(table); return 0;}
开发者ID:99years,项目名称:plan9,代码行数:101,
示例5: hammer_cmd_mirror_read//.........这里部分代码省略......... /* * Just stream the histogram, then stop */ if (streaming == 0) streaming = -1; } if (streaming && histogram) { ++histindex; mirror.tid_end = histogram_ary[histindex].tid; estbytes = histogram_ary[histindex-1].bytes; mrec_tmp.pfs.pfsd.sync_end_tid = mirror.tid_end; } else { estbytes = 0; } write_mrecord(1, HAMMER_MREC_TYPE_PFSD, &mrec_tmp, sizeof(mrec_tmp.pfs)); /* * A cycle file overrides the beginning TID only if we are * not operating in two-way or histogram mode. */ if (TwoWayPipeOpt == 0 && histogram == 0) { hammer_get_cycle(&mirror.key_beg, &mirror.tid_beg); } /* * An additional argument overrides the beginning TID regardless * of what mode we are in. This is not recommending if operating * in two-way mode. */ if (ac == 2) mirror.tid_beg = strtoull(av[1], NULL, 0); if (streaming == 0 || VerboseOpt >= 2) { fprintf(stderr, "Mirror-read: Mirror %016jx to %016jx", (uintmax_t)mirror.tid_beg, (uintmax_t)mirror.tid_end); if (histogram) fprintf(stderr, " (bulk= %ju)", (uintmax_t)estbytes); fprintf(stderr, "/n"); fflush(stderr); } if (mirror.key_beg.obj_id != (int64_t)HAMMER_MIN_OBJID) { fprintf(stderr, "Mirror-read: Resuming at object %016jx/n", (uintmax_t)mirror.key_beg.obj_id); } /* * Nothing to do if begin equals end. */ if (mirror.tid_beg >= mirror.tid_end) { if (streaming == 0 || VerboseOpt >= 2) fprintf(stderr, "Mirror-read: No work to do/n"); sleep(DelayOpt); didwork = 0; histogram = 0; goto done; } didwork = 1; /* * Write out bulk records */ mirror.ubuf = buf;
开发者ID:davshao,项目名称:dragonfly_drm4,代码行数:67,
示例6: mainint main (int argc, char **argv) { char *brokers = "localhost"; char mode = 'C'; char *topic = NULL; const char *key = NULL; int partition = RD_KAFKA_PARTITION_UA; /* random */ int opt; int msgcnt = -1; int sendflags = 0; char *msgpattern = "librdkafka_performance testing!"; int msgsize = strlen(msgpattern); const char *debug = NULL; rd_ts_t now; char errstr[512]; uint64_t seq = 0; int seed = time(NULL); rd_kafka_topic_t *rkt; rd_kafka_conf_t *conf; rd_kafka_topic_conf_t *topic_conf; const char *compression = "no"; int64_t start_offset = 0; int batch_size = 0; int idle = 0; /* Kafka configuration */ conf = rd_kafka_conf_new(); rd_kafka_conf_set_error_cb(conf, err_cb); rd_kafka_conf_set_dr_cb(conf, msg_delivered); /* Producer config */ rd_kafka_conf_set(conf, "queue.buffering.max.messages", "500000", NULL, 0); rd_kafka_conf_set(conf, "message.send.max.retries", "3", NULL, 0); rd_kafka_conf_set(conf, "retry.backoff.ms", "500", NULL, 0); /* Consumer config */ /* Tell rdkafka to (try to) maintain 1M messages * in its internal receive buffers. This is to avoid * application -> rdkafka -> broker per-message ping-pong * latency. * The larger the local queue, the higher the performance. * Try other values with: ... -X queued.min.messages=1000 */ rd_kafka_conf_set(conf, "queued.min.messages", "1000000", NULL, 0); /* Kafka topic configuration */ topic_conf = rd_kafka_topic_conf_new(); rd_kafka_topic_conf_set(topic_conf, "message.timeout.ms", "5000", NULL, 0); while ((opt = getopt(argc, argv, "PCt:p:b:s:k:c:fi:Dd:m:S:x:R:a:z:o:X:B:eT:qI")) != -1) { switch (opt) { case 'P': case 'C': mode = opt; break; case 't': topic = optarg; break; case 'p': partition = atoi(optarg); break; case 'b': brokers = optarg; break; case 's': msgsize = atoi(optarg); break; case 'k': key = optarg; break; case 'c': msgcnt = atoi(optarg); break; case 'D': sendflags |= RD_KAFKA_MSG_F_FREE; break; case 'i': dispintvl = atoi(optarg); break; case 'm': msgpattern = optarg; break; case 'S': seq = strtoull(optarg, NULL, 10); do_seq = 1; break; case 'x': exit_after = atoi(optarg); break; case 'R': seed = atoi(optarg); break; case 'a': if (rd_kafka_topic_conf_set(topic_conf, "request.required.acks",//.........这里部分代码省略.........
开发者ID:vadimg,项目名称:librdkafka,代码行数:101,
示例7: parseNetDevLine/* information are parsed but not all are used in our case, ie. for xenstat */int parseNetDevLine(char *line, char *iface, unsigned long long *rxBytes, unsigned long long *rxPackets, unsigned long long *rxErrs, unsigned long long *rxDrops, unsigned long long *rxFifo, unsigned long long *rxFrames, unsigned long long *rxComp, unsigned long long *rxMcast, unsigned long long *txBytes, unsigned long long *txPackets, unsigned long long *txErrs, unsigned long long *txDrops, unsigned long long *txFifo, unsigned long long *txColls, unsigned long long *txCarrier, unsigned long long *txComp){ /* Temporary/helper variables */ int ret; char *tmp; int i = 0, x = 0, col = 0; regex_t r; regmatch_t matches[19]; int num = 19; /* Regular exception to parse all the information from /proc/net/dev line */ char *regex = "([^:]*):([^ ]*)[ ]*([^ ]*)[ ]*([^ ]*)[ ]*([^ ]*)[ ]*([^ ]*)[ ]*([^ ]*)" "[ ]*([^ ]*)[ ]*([^ ]*)[ ]*([^ ]*)[ ]*([^ ]*)[ ]*([^ ]*)[ ]*([^ ]*)[ ]*" "([^ ]*)[ ]*([^ ]*)[ ]*([^ ]*)[ ]*([^ ]*)[ ]*([^ ]*)"; /* Initialize all variables called has passed as non-NULL to zeros */ if (iface != NULL) memset(iface, 0, sizeof(*iface)); if (rxBytes != NULL) *rxBytes = 0; if (rxPackets != NULL) *rxPackets = 0; if (rxErrs != NULL) *rxErrs = 0; if (rxDrops != NULL) *rxDrops = 0; if (rxFifo != NULL) *rxFifo = 0; if (rxFrames != NULL) *rxFrames = 0; if (rxPackets != NULL) *rxPackets = 0; if (rxComp != NULL) *rxComp = 0; if (txBytes != NULL) *txBytes = 0; if (txPackets != NULL) *txPackets = 0; if (txErrs != NULL) *txErrs = 0; if (txDrops != NULL) *txDrops = 0; if (txFifo != NULL) *txFifo = 0; if (txColls != NULL) *txColls = 0; if (txCarrier != NULL) *txCarrier = 0; if (txComp != NULL) *txComp = 0; if ((ret = regcomp(&r, regex, REG_EXTENDED))) { regfree(&r); return ret; } tmp = (char *)malloc( sizeof(char) ); if (regexec (&r, line, num, matches, REG_EXTENDED) == 0){ for (i = 1; i < num; i++) { /* The expression matches are empty sometimes so we need to check it first */ if (matches[i].rm_eo - matches[i].rm_so > 0) { /* Col variable contains current id of non-empty match */ col++; tmp = (char *)realloc(tmp, (matches[i].rm_eo - matches[i].rm_so + 1) * sizeof(char)); for (x = matches[i].rm_so; x < matches[i].rm_eo; x++) tmp[x - matches[i].rm_so] = line[x]; /* We populate all the fields from /proc/net/dev line */ if (i > 1) { unsigned long long ullTmp = strtoull(tmp, NULL, 10); switch (col) { case 2: if (rxBytes != NULL) *rxBytes = ullTmp; break; case 3: if (rxPackets != NULL) *rxPackets = ullTmp; break; case 4: if (rxErrs != NULL) *rxErrs = ullTmp; break; case 5: if (rxDrops != NULL) *rxDrops = ullTmp; break; case 6: if (rxFifo != NULL) *rxFifo = ullTmp; break; case 7: if (rxFrames != NULL) *rxFrames = ullTmp; break; case 8: if (rxComp != NULL) *rxComp = ullTmp; break;//.........这里部分代码省略.........
开发者ID:0day-ci,项目名称:xen,代码行数:101,
示例8: sprintfvoid cpu_linux::measurement_start(void){ ifstream file; DIR *dir; struct dirent *entry; char filename[256]; int len; unsigned int i; abstract_cpu::measurement_start(); len = sprintf(filename, "/sys/devices/system/cpu/cpu%i/cpuidle", number); dir = opendir(filename); if (!dir) return; /* For each C-state, there is a stateX directory which * contains a 'usage' and a 'time' (duration) file */ while ((entry = readdir(dir))) { char linux_name[64]; char human_name[64]; uint64_t usage = 0; uint64_t duration = 0; if (strlen(entry->d_name) < 3) continue; strcpy(linux_name, entry->d_name); strcpy(human_name, linux_name); sprintf(filename + len, "/%s/name", entry->d_name); file.open(filename, ios::in); if (file) { file.getline(human_name, 64); file.close(); } if (strcmp(human_name, "C0")==0) strcpy(human_name, _("C0 polling")); sprintf(filename + len, "/%s/usage", entry->d_name); file.open(filename, ios::in); if (file) { file >> usage; file.close(); } sprintf(filename + len, "/%s/time", entry->d_name); file.open(filename, ios::in); if (file) { file >> duration; file.close(); } update_cstate(linux_name, human_name, usage, duration, 1); } closedir(dir); last_stamp = 0; for (i = 0; i < children.size(); i++) if (children[i]) children[i]->wiggle(); sprintf(filename, "/sys/devices/system/cpu/cpu%i/cpufreq/stats/time_in_state", first_cpu); file.open(filename, ios::in); if (file) { char line[1024]; while (file) { uint64_t f; file.getline(line, 1024); f = strtoull(line, NULL, 10); account_freq(f, 0); } file.close(); } account_freq(0, 0);}
开发者ID:AllenDou,项目名称:powertop,代码行数:88,
示例9: ipsw_get_latest_fwint ipsw_get_latest_fw(plist_t version_data, const char* product, char** fwurl, unsigned char* sha1buf){ *fwurl = NULL; if (sha1buf != NULL) { memset(sha1buf, '/0', 20); } plist_t n1 = plist_dict_get_item(version_data, "MobileDeviceSoftwareVersionsByVersion"); if (!n1) { error("%s: ERROR: Can't find MobileDeviceSoftwareVersionsByVersion dict in version data/n", __func__); return -1; } plist_dict_iter iter = NULL; plist_dict_new_iter(n1, &iter); if (!iter) { error("%s: ERROR: Can't get dict iter/n", __func__); return -1; } char* key = NULL; long long unsigned int major = 0; plist_t val = NULL; do { plist_dict_next_item(n1, iter, &key, &val); if (key) { plist_t pr = plist_access_path(n1, 3, key, "MobileDeviceSoftwareVersions", product); if (pr) { long long unsigned int v = strtoull(key, NULL, 10); if (v > major) major = v; } free(key); } } while (val); free(iter); if (major == 0) { error("%s: ERROR: Can't find major version?!/n", __func__); return -1; } char majstr[32]; // should be enough for a uint64_t value sprintf(majstr, FMT_qu, (long long unsigned int)major); n1 = plist_access_path(version_data, 7, "MobileDeviceSoftwareVersionsByVersion", majstr, "MobileDeviceSoftwareVersions", product, "Unknown", "Universal", "Restore"); if (!n1) { error("%s: ERROR: Can't get Unknown/Universal/Restore node?!/n", __func__); return -1; } plist_t n2 = plist_dict_get_item(n1, "BuildVersion"); if (!n2 || (plist_get_node_type(n2) != PLIST_STRING)) { error("%s: ERROR: Can't get build version node?!/n", __func__); return -1; } char* strval = NULL; plist_get_string_val(n2, &strval); n1 = plist_access_path(version_data, 5, "MobileDeviceSoftwareVersionsByVersion", majstr, "MobileDeviceSoftwareVersions", product, strval); if (!n1) { error("%s: ERROR: Can't get MobileDeviceSoftwareVersions/%s node?!/n", __func__, strval); free(strval); return -1; } free(strval); strval = NULL; n2 = plist_dict_get_item(n1, "SameAs"); if (n2) { plist_get_string_val(n2, &strval); } if (strval) { n1 = plist_access_path(version_data, 5, "MobileDeviceSoftwareVersionsByVersion", majstr, "MobileDeviceSoftwareVersions", product, strval); free(strval); strval = NULL; if (!n1 || (plist_dict_get_size(n1) == 0)) { error("%s: ERROR: Can't get MobileDeviceSoftwareVersions/%s dict/n", __func__, product); return -1; } } n2 = plist_access_path(n1, 2, "Update", "BuildVersion"); if (n2) { strval = NULL; plist_get_string_val(n2, &strval); if (strval) { n1 = plist_access_path(version_data, 5, "MobileDeviceSoftwareVersionsByVersion", majstr, "MobileDeviceSoftwareVersions", product, strval); free(strval); strval = NULL; } } n2 = plist_access_path(n1, 2, "Restore", "FirmwareURL"); if (!n2 || (plist_get_node_type(n2) != PLIST_STRING)) { error("%s: ERROR: Can't get FirmwareURL node/n", __func__); return -1; } plist_get_string_val(n2, fwurl);//.........这里部分代码省略.........
开发者ID:Blackmamba0,项目名称:idevicerestore,代码行数:101,
示例10: http_header_receive |