您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ strtoll函数代码示例

51自学网 2021-06-03 08:32:35
  C++
这篇教程C++ strtoll函数代码示例写得很实用,希望能帮到您。

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

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

示例1: process_config_line

//.........这里部分代码省略.........			value = 2;		else			fatal("%.200s line %d: Bad yes/no/ask argument.", filename, linenum);		if (*activep && *intptr == -1)			*intptr = value;		break;	case oCompression:		intptr = &options->compression;		goto parse_flag;	case oTCPKeepAlive:		intptr = &options->tcp_keep_alive;		goto parse_flag;	case oNoHostAuthenticationForLocalhost:		intptr = &options->no_host_authentication_for_localhost;		goto parse_flag;	case oNumberOfPasswordPrompts:		intptr = &options->number_of_password_prompts;		goto parse_int;	case oCompressionLevel:		intptr = &options->compression_level;		goto parse_int;	case oRekeyLimit:		arg = strdelim(&s);		if (!arg || *arg == '/0')			fatal("%.200s line %d: Missing argument.", filename, linenum);		if (arg[0] < '0' || arg[0] > '9')			fatal("%.200s line %d: Bad number.", filename, linenum);		orig = val64 = strtoll(arg, &endofnumber, 10);		if (arg == endofnumber)			fatal("%.200s line %d: Bad number.", filename, linenum);		switch (toupper((unsigned char)*endofnumber)) {		case '/0':			scale = 1;			break;		case 'K':			scale = 1<<10;			break;		case 'M':			scale = 1<<20;			break;		case 'G':			scale = 1<<30;			break;		default:			scale = 0;			fatal("%.200s line %d: Invalid RekeyLimit suffix",			    filename, linenum);		}		val64 *= scale;		/* detect integer wrap and too-large limits */		if ((val64 / scale) != orig || val64 > UINT_MAX)			fatal("%.200s line %d: RekeyLimit too large",			    filename, linenum);		if (val64 < 16)			fatal("%.200s line %d: RekeyLimit too small",			    filename, linenum);		if (*activep && options->rekey_limit == -1)			options->rekey_limit = (u_int32_t)val64;		break;
开发者ID:VargMon,项目名称:netbsd-cvs-mirror,代码行数:66,


示例2: main

intmain(int argc, char *argv[]){	char *buf;	size_t bufsiz;	const char *format;	int ch;	setprogname(argv[0]);	(void)setlocale(LC_ALL, "");	while ((ch = getopt(argc, argv, "ad:jnr:u")) != -1) {		switch (ch) {		case 'a':		/* adjust time slowly */			aflag = 1;			nflag = 1;			break;		case 'd':			rflag = 1;			tval = parsedate(optarg, NULL, NULL);			if (tval == -1)				errx(1, "Cannot parse `%s'", optarg);			break;		case 'j':		/* don't set time */			jflag = 1;			break;		case 'n':		/* don't set network */			nflag = 1;			break;		case 'r':		/* user specified seconds */			rflag = 1;			tval = strtoll(optarg, NULL, 0);			break;		case 'u':		/* do everything in UTC */			(void)putenv("TZ=UTC0");			break;		default:			usage();		}	}	argc -= optind;	argv += optind;	if (!rflag && time(&tval) == -1)		err(EXIT_FAILURE, "time");	format = "%a %b %e %H:%M:%S %Z %Y";	/* allow the operands in any order */	if (*argv && **argv == '+') {		format = *argv + 1;		++argv;	}	if (*argv) {		setthetime(*argv);		++argv;	}	if (*argv && **argv == '+')		format = *argv + 1;	if ((buf = malloc(bufsiz = 1024)) == NULL)		goto bad;	while (strftime(buf, bufsiz, format, localtime(&tval)) == 0)		if ((buf = realloc(buf, bufsiz <<= 1)) == NULL)			goto bad;	(void)printf("%s/n", buf);	free(buf);	return 0;bad:	err(1, "Cannot allocate format buffer");}
开发者ID:lacombar,项目名称:netbsd-alc,代码行数:73,


示例3: main

//.........这里部分代码省略.........			usage();	}	if (version != 1) {		fprintf(stderr, _("%s: does not support swapspace version %d./n"),			program_name, version);		exit(EXIT_FAILURE);	}#ifdef HAVE_LIBUUID	if(opt_uuid) {		if (uuid_parse(opt_uuid, uuid_dat) != 0)			die(_("error: UUID parsing failed"));	} else		uuid_generate(uuid_dat);	uuid = uuid_dat;#endif	init_signature_page();	/* get pagesize */	atexit(deinit_signature_page);	if (!device_name) {		fprintf(stderr,			_("%s: error: Nowhere to set up swap on?/n"),			program_name);		usage();	}	if (block_count) {		/* this silly user specified the number of blocks explicitly */		char *tmp = NULL;		long long blks;		errno = 0;		blks = strtoll(block_count, &tmp, 0);		if ((tmp == block_count) ||		    (tmp && *tmp) ||		    (errno != 0 && (blks == LLONG_MAX || blks == LLONG_MIN)) ||		    blks < 0)			usage();		PAGES = blks / (pagesize / 1024);	}	sz = get_size(device_name);	if (!PAGES) {		PAGES = sz;	} else if (PAGES > sz && !force) {		fprintf(stderr,			_("%s: error: "			  "size %llu KiB is larger than device size %llu KiB/n"),			program_name,			PAGES*(pagesize/1024), sz*(pagesize/1024));		exit(1);	}	if (PAGES < MIN_GOODPAGES) {		fprintf(stderr,			_("%s: error: swap area needs to be at least %ld KiB/n"),			program_name, (long)(MIN_GOODPAGES * pagesize/1024));		usage();	}#ifdef __linux__	if (get_linux_version() >= KERNEL_VERSION(2,3,4))		maxpages = UINT_MAX + 1ULL;	else if (get_linux_version() >= KERNEL_VERSION(2,2,1))		maxpages = V1_MAX_PAGES;
开发者ID:tcdog001,项目名称:autelan,代码行数:67,


示例4: main

int main(int argc, char *argv[]){	int r;	int fd;	struct stat sb;	char *addr;	u64 gcov_list_addr;	printf("sizes: %zu %zu %zu %zu/n",	       sizeof(gcov_unsigned_int),	       sizeof(struct gcov_ctr_info),	       sizeof(struct gcov_fn_info),	       sizeof(struct gcov_info));	if (argc < 3) {		fprintf(stderr, "Usage:/n"			"/t%s skiboot.dump gcov_offset/n/n",			argv[0]);		return -1;	}	/* argv[1] = skiboot.dump */	fd = open(argv[1], O_RDONLY);	if (fd < 0) {		fprintf(stderr, "Cannot open dump: %s (error %d %s)/n",			argv[1], errno, strerror(errno));		exit(-1);	}	r = fstat(fd, &sb);	if (r < 0) {		fprintf(stderr, "Cannot stat dump, %d %s/n",			errno, strerror(errno));		exit(-1);	}	addr = mmap(NULL, sb.st_size, PROT_READ, MAP_PRIVATE, fd, 0);	assert(addr != NULL);	skiboot_dump_size = sb.st_size;	printf("Skiboot memory dump %p - %p/n",	       (void*)SKIBOOT_OFFSET, (void*)SKIBOOT_OFFSET+sb.st_size);	gcov_list_addr = strtoll(argv[2], NULL, 0);	gcov_list_addr = (u64)(addr + (gcov_list_addr - SKIBOOT_OFFSET));	gcov_list_addr = be64toh(*(u64*)gcov_list_addr);	printf("Skiboot gcov_info_list at %p/n", (void*)gcov_list_addr);	do {		gcov_info_list = (struct gcov_info *)(addr + (gcov_list_addr - SKIBOOT_OFFSET));		write_gcda(addr, gcov_info_list);		gcov_list_addr = be64toh((u64)gcov_info_list->next);	} while(gcov_list_addr);	munmap(addr, sb.st_size);	close(fd);	return 0;}
开发者ID:ddstreet,项目名称:skiboot,代码行数:61,


示例5: main

////=========================================================================//int main(int argc, char **argv) {    int j;    // Set sane defaults    modesInitConfig();    signal(SIGINT, sigintHandler); // Define Ctrl/C handler (exit program)    // Parse the command line options    for (j = 1; j < argc; j++) {        int more = j+1 < argc; // There are more arguments        if (!strcmp(argv[j],"--device-index") && more) {            Modes.dev_index = verbose_device_search(argv[++j]);        } else if (!strcmp(argv[j],"--gain") && more) {            Modes.gain = (int) atof(argv[++j])*10; // Gain is in tens of DBs        } else if (!strcmp(argv[j],"--enable-agc")) {            Modes.enable_agc++;        } else if (!strcmp(argv[j],"--freq") && more) {            Modes.freq = (int) strtoll(argv[++j],NULL,10);        } else if (!strcmp(argv[j],"--ifile") && more) {            Modes.filename = strdup(argv[++j]);        } else if (!strcmp(argv[j],"--fix")) {            Modes.nfix_crc = 1;        } else if (!strcmp(argv[j],"--no-fix")) {            Modes.nfix_crc = 0;        } else if (!strcmp(argv[j],"--no-crc-check")) {            Modes.check_crc = 0;        } else if (!strcmp(argv[j],"--phase-enhance")) {            Modes.phase_enhance = 1;        } else if (!strcmp(argv[j],"--raw")) {            Modes.raw = 1;        } else if (!strcmp(argv[j],"--net")) {            Modes.net = 1;        } else if (!strcmp(argv[j],"--modeac")) {            Modes.mode_ac = 1;        } else if (!strcmp(argv[j],"--net-beast")) {            Modes.beast = 1;        } else if (!strcmp(argv[j],"--net-only")) {            Modes.net = 1;            Modes.net_only = 1;       } else if (!strcmp(argv[j],"--net-heartbeat") && more) {            Modes.net_heartbeat_rate = atoi(argv[++j]) * 15;       } else if (!strcmp(argv[j],"--net-ro-size") && more) {            Modes.net_output_raw_size = atoi(argv[++j]);        } else if (!strcmp(argv[j],"--net-ro-rate") && more) {            Modes.net_output_raw_rate = atoi(argv[++j]);        } else if (!strcmp(argv[j],"--net-ro-port") && more) {            if (Modes.beast) // Required for legacy backward compatibility                {Modes.net_output_beast_port = atoi(argv[++j]);;}            else                {Modes.net_output_raw_port = atoi(argv[++j]);}        } else if (!strcmp(argv[j],"--net-ri-port") && more) {            Modes.net_input_raw_port = atoi(argv[++j]);        } else if (!strcmp(argv[j],"--net-bo-port") && more) {            Modes.net_output_beast_port = atoi(argv[++j]);        } else if (!strcmp(argv[j],"--net-bi-port") && more) {            Modes.net_input_beast_port = atoi(argv[++j]);        } else if (!strcmp(argv[j],"--net-http-port") && more) {            Modes.net_http_port = atoi(argv[++j]);        } else if (!strcmp(argv[j],"--net-sbs-port") && more) {            Modes.net_output_sbs_port = atoi(argv[++j]);        } else if (!strcmp(argv[j],"--net-buffer") && more) {            Modes.net_sndbuf_size = atoi(argv[++j]);        } else if (!strcmp(argv[j],"--onlyaddr")) {            Modes.onlyaddr = 1;        } else if (!strcmp(argv[j],"--metric")) {            Modes.metric = 1;        } else if (!strcmp(argv[j],"--aggressive")) {            Modes.nfix_crc = MODES_MAX_BITERRORS;        } else if (!strcmp(argv[j],"--interactive")) {            Modes.interactive = 1;        } else if (!strcmp(argv[j],"--interactive-rows") && more) {            Modes.interactive_rows = atoi(argv[++j]);        } else if (!strcmp(argv[j],"--interactive-ttl") && more) {            Modes.interactive_display_ttl = atoi(argv[++j]);        } else if (!strcmp(argv[j],"--lat") && more) {            Modes.fUserLat = atof(argv[++j]);        } else if (!strcmp(argv[j],"--lon") && more) {            Modes.fUserLon = atof(argv[++j]);        } else if (!strcmp(argv[j],"--debug") && more) {            char *f = argv[++j];            while(*f) {                switch(*f) {                case 'D': Modes.debug |= MODES_DEBUG_DEMOD; break;                case 'd': Modes.debug |= MODES_DEBUG_DEMODERR; break;                case 'C': Modes.debug |= MODES_DEBUG_GOODCRC; break;                case 'c': Modes.debug |= MODES_DEBUG_BADCRC; break;                case 'p': Modes.debug |= MODES_DEBUG_NOPREAMBLE; break;                case 'n': Modes.debug |= MODES_DEBUG_NET; break;                case 'j': Modes.debug |= MODES_DEBUG_JS; break;                default:                    fprintf(stderr, "Unknown debugging flag: %c/n", *f);                    exit(1);                    break;                }                f++;            }//.........这里部分代码省略.........
开发者ID:Pokey1,项目名称:dump1090,代码行数:101,


示例6: parse_default

// Converts the default value in string "str" into "d".  Passes a ref on str.// Returns true on success.static bool parse_default(char *str, upb_fielddef *f) {  bool success = true;  char *end;  switch (upb_fielddef_type(f)) {    case UPB_TYPE_INT32: {      long val = strtol(str, &end, 0);      if (val > INT32_MAX || val < INT32_MIN || errno == ERANGE || *end)        success = false;      else        upb_fielddef_setdefaultint32(f, val);      break;    }    case UPB_TYPE_INT64: {      long long val = strtoll(str, &end, 0);      if (val > INT64_MAX || val < INT64_MIN || errno == ERANGE || *end)        success = false;      else        upb_fielddef_setdefaultint64(f, val);      break;    }    case UPB_TYPE_UINT32: {      long val = strtoul(str, &end, 0);      if (val > UINT32_MAX || errno == ERANGE || *end)        success = false;      else        upb_fielddef_setdefaultuint32(f, val);      break;    }    case UPB_TYPE_UINT64: {      unsigned long long val = strtoull(str, &end, 0);      if (val > UINT64_MAX || errno == ERANGE || *end)        success = false;      else        upb_fielddef_setdefaultuint64(f, val);      break;    }    case UPB_TYPE_DOUBLE: {      double val = strtod(str, &end);      if (errno == ERANGE || *end)        success = false;      else        upb_fielddef_setdefaultdouble(f, val);      break;    }    case UPB_TYPE_FLOAT: {      float val = strtof(str, &end);      if (errno == ERANGE || *end)        success = false;      else        upb_fielddef_setdefaultfloat(f, val);      break;    }    case UPB_TYPE_BOOL: {      if (strcmp(str, "false") == 0)        upb_fielddef_setdefaultbool(f, false);      else if (strcmp(str, "true") == 0)        upb_fielddef_setdefaultbool(f, true);      else        success = false;      break;    }    default: abort();  }  return success;}
开发者ID:YauzZ,项目名称:upb,代码行数:67,


示例7: atoll

/* Convert a string to a long long int.  */long long intatoll (const char *nptr){  return strtoll (nptr, (char **) NULL, 10);}
开发者ID:Dinesh-Ramakrishnan,项目名称:glibc,代码行数:6,


示例8: main

//.........这里部分代码省略.........        case 'b':            i_bandwidth = strtol( optarg, NULL, 0 );            break;        case 'I':            i_inversion = strtol( optarg, NULL, 0 );            break;        case 'm':            psz_modulation = optarg;            break;        case 'P':            i_pilot = strtol( optarg, NULL, 0 );            break;        case '1':            i_mis = strtol( optarg, NULL, 0 );            break;        case 'K':            i_fec_lp = strtol( optarg, NULL, 0 );            break;        case 'G':            i_guard = strtol( optarg, NULL, 0 );            break;        case 'X':            i_transmission = strtol( optarg, NULL, 0 );            break;        case 'O':            i_frontend_timeout_duration = strtoll( optarg, NULL, 0 ) * 1000;            break;        case 'H':            i_hierarchy = strtol( optarg, NULL, 0 );            break;        case 'u':            b_budget_mode = 1;            break;        case 'w':            b_select_pmts = 1; //!b_select_pmts;            break;        case 'U':            b_udp_global = true;            break;        case 'L':            i_latency_global = strtoll( optarg, NULL, 0 ) * 1000;            break;        case 'E':            i_retention_global = strtoll( optarg, NULL, 0 ) * 1000;            break;        case 'd':            psz_dup_config = optarg;            break;        case 'D':            psz_udp_src = optarg;
开发者ID:BATYD-Turksat,项目名称:dvblast,代码行数:67,


示例9: postgres_ingest_stats

static void postgres_ingest_stats(postgres_check_info_t *ci) {  if(ci->rv == PGRES_TUPLES_OK) {    /* metrics */    int nrows, ncols, i, j;    nrows = PQntuples(ci->result);    ncols = PQnfields(ci->result);    noit_stats_set_metric(&ci->current, "row_count", METRIC_INT32, &nrows);    for (i=0; i<nrows; i++) {      noitL(nldeb, "postgres: row %d [%d cols]:/n", i, ncols);      if(ncols<2) continue;      if(PQgetisnull(ci->result, i, 0)) continue;      for (j=1; j<ncols; j++) {        Oid coltype;        int iv, *piv;        int64_t lv, *plv;        double dv, *pdv;        char *sv;        char mname[128];          snprintf(mname, sizeof(mname), "%s`%s",                 PQgetvalue(ci->result, i, 0), PQfname(ci->result, j));        coltype = PQftype(ci->result, j);        noitL(nldeb, "postgres:   col %d (%s) type %d: %s/n", j, mname, coltype,              PQgetisnull(ci->result, i, j) ? "[[null]]" : PQgetvalue(ci->result, i, j));        switch(coltype) {          case BOOLOID:            if(PQgetisnull(ci->result, i, j)) piv = NULL;            else {              iv = strcmp(PQgetvalue(ci->result, i, j), "f") ? 1 : 0;              piv = &iv;            }            noit_stats_set_metric(&ci->current, mname, METRIC_INT32, piv);            break;          case INT2OID:          case INT4OID:          case INT8OID:            if(PQgetisnull(ci->result, i, j)) plv = NULL;            else {              lv = strtoll(PQgetvalue(ci->result, i, j), NULL, 10);              plv = &lv;            }            noit_stats_set_metric(&ci->current, mname, METRIC_INT64, plv);            break;          case FLOAT4OID:          case FLOAT8OID:          case NUMERICOID:            if(PQgetisnull(ci->result, i, j)) pdv = NULL;            else {              dv = atof(PQgetvalue(ci->result, i, j));              pdv = &dv;            }            noit_stats_set_metric(&ci->current, mname, METRIC_DOUBLE, pdv);            break;          default:            if(PQgetisnull(ci->result, i, j)) sv = NULL;            else sv = PQgetvalue(ci->result, i, j);            noit_stats_set_metric(&ci->current, mname, METRIC_GUESS, sv);            break;        }      }    }  }}
开发者ID:Icarus-xx,项目名称:reconnoiter,代码行数:63,


示例10: config_ParseHost

bool config_ParseHost( output_config_t *p_config, char *psz_string ){    struct addrinfo *p_ai;    int i_mtu;    p_config->psz_displayname = strdup( psz_string );    p_ai = ParseNodeService( psz_string, &psz_string, DEFAULT_PORT );    if ( p_ai == NULL ) return false;    memcpy( &p_config->connect_addr, p_ai->ai_addr, p_ai->ai_addrlen );    freeaddrinfo( p_ai );    p_config->i_family = p_config->connect_addr.ss_family;    if ( p_config->i_family == AF_UNSPEC ) return false;    if ( psz_string == NULL || !*psz_string ) goto end;    if ( *psz_string == '@' )    {        psz_string++;        p_ai = ParseNodeService( psz_string, &psz_string, 0 );        if ( p_ai == NULL || p_ai->ai_family != p_config->i_family )            msg_Warn( NULL, "invalid bind address" );        else            memcpy( &p_config->bind_addr, p_ai->ai_addr, p_ai->ai_addrlen );        freeaddrinfo( p_ai );    }    while ( (psz_string = strchr( psz_string, '/' )) != NULL )    {        *psz_string++ = '/0';#define IS_OPTION( option ) (!strncasecmp( psz_string, option, strlen(option) ))#define ARG_OPTION( option ) (psz_string + strlen(option))        if ( IS_OPTION("udp") )            p_config->i_config |= OUTPUT_UDP;        else if ( IS_OPTION("dvb") )            p_config->i_config |= OUTPUT_DVB;        else if ( IS_OPTION("epg") )            p_config->i_config |= OUTPUT_EPG;        else if ( IS_OPTION("tsid=") )            p_config->i_tsid = strtol( ARG_OPTION("tsid="), NULL, 0 );        else if ( IS_OPTION("retention=") )            p_config->i_max_retention = strtoll( ARG_OPTION("retention="),                                                 NULL, 0 ) * 1000;        else if ( IS_OPTION("latency=") )            p_config->i_output_latency = strtoll( ARG_OPTION("latency="),                                                  NULL, 0 ) * 1000;        else if ( IS_OPTION("ttl=") )            p_config->i_ttl = strtol( ARG_OPTION("ttl="), NULL, 0 );        else if ( IS_OPTION("tos=") )            p_config->i_tos = strtol( ARG_OPTION("tos="), NULL, 0 );        else if ( IS_OPTION("mtu=") )            p_config->i_mtu = strtol( ARG_OPTION("mtu="), NULL, 0 );        else if ( IS_OPTION("ifindex=") )            p_config->i_if_index_v6 = strtol( ARG_OPTION("ifindex="), NULL, 0 );        else if ( IS_OPTION("srvname=")  )        {            if ( p_config->psz_service_name )                free( p_config->psz_service_name );            p_config->psz_service_name = config_stropt( ARG_OPTION("srvname=") );        }        else if ( IS_OPTION("srvprovider=") )        {            if ( !p_config->psz_service_provider )                free( p_config->psz_service_provider );            p_config->psz_service_provider = config_stropt( ARG_OPTION("srvprovider=") );        }        else if ( IS_OPTION("srcaddr=") )        {            if ( p_config->i_family != AF_INET ) {                msg_Err( NULL, "RAW sockets currently implemented for ipv4 only");                return false;            }            if ( !p_config->psz_srcaddr )                free( p_config->psz_srcaddr );            p_config->psz_srcaddr = config_stropt( ARG_OPTION("srcaddr=") );            p_config->i_config |= OUTPUT_RAW;        }        else if ( IS_OPTION("srcport=") )            p_config->i_srcport = strtol( ARG_OPTION("srcport="), NULL, 0 );        else if ( IS_OPTION("ssrc=") )        {            in_addr_t i_addr = inet_addr( ARG_OPTION("ssrc=") );            memcpy( p_config->pi_ssrc, &i_addr, 4 * sizeof(uint8_t) );        }        else if ( IS_OPTION("pidmap=") )        {            char *str1;            char *saveptr = NULL;            char *tok = NULL;            int i, i_newpid;            for (i = 0, str1 = config_stropt( (ARG_OPTION("pidmap="))); i < N_MAP_PIDS; i++, str1 = NULL)            {                tok = strtok_r(str1, ",", &saveptr);                if ( !tok )                    break;                i_newpid = strtoul(tok, NULL, 0);                if ( !i_newpid ) {//.........这里部分代码省略.........
开发者ID:BATYD-Turksat,项目名称:dvblast,代码行数:101,


示例11: sparc_cpu_parse_features

static void sparc_cpu_parse_features(CPUState *cs, char *features,                                     Error **errp){    SPARCCPU *cpu = SPARC_CPU(cs);    sparc_def_t *cpu_def = cpu->env.def;    char *featurestr;    uint32_t plus_features = 0;    uint32_t minus_features = 0;    uint64_t iu_version;    uint32_t fpu_version, mmu_version, nwindows;    featurestr = features ? strtok(features, ",") : NULL;    while (featurestr) {        char *val;        if (featurestr[0] == '+') {            add_flagname_to_bitmaps(featurestr + 1, &plus_features);        } else if (featurestr[0] == '-') {            add_flagname_to_bitmaps(featurestr + 1, &minus_features);        } else if ((val = strchr(featurestr, '='))) {            *val = 0; val++;            if (!strcmp(featurestr, "iu_version")) {                char *err;                iu_version = strtoll(val, &err, 0);                if (!*val || *err) {                    error_setg(errp, "bad numerical value %s", val);                    return;                }                cpu_def->iu_version = iu_version;#ifdef DEBUG_FEATURES                fprintf(stderr, "iu_version %" PRIx64 "/n", iu_version);#endif            } else if (!strcmp(featurestr, "fpu_version")) {                char *err;                fpu_version = strtol(val, &err, 0);                if (!*val || *err) {                    error_setg(errp, "bad numerical value %s", val);                    return;                }                cpu_def->fpu_version = fpu_version;#ifdef DEBUG_FEATURES                fprintf(stderr, "fpu_version %x/n", fpu_version);#endif            } else if (!strcmp(featurestr, "mmu_version")) {                char *err;                mmu_version = strtol(val, &err, 0);                if (!*val || *err) {                    error_setg(errp, "bad numerical value %s", val);                    return;                }                cpu_def->mmu_version = mmu_version;#ifdef DEBUG_FEATURES                fprintf(stderr, "mmu_version %x/n", mmu_version);#endif            } else if (!strcmp(featurestr, "nwindows")) {                char *err;                nwindows = strtol(val, &err, 0);                if (!*val || *err || nwindows > MAX_NWINDOWS ||                    nwindows < MIN_NWINDOWS) {                    error_setg(errp, "bad numerical value %s", val);                    return;                }                cpu_def->nwindows = nwindows;#ifdef DEBUG_FEATURES                fprintf(stderr, "nwindows %d/n", nwindows);#endif            } else {                error_setg(errp, "unrecognized feature %s", featurestr);                return;            }        } else {            error_setg(errp, "feature string `%s' not in format "                             "(+feature|-feature|feature=xyz)", featurestr);            return;        }        featurestr = strtok(NULL, ",");    }    cpu_def->features |= plus_features;    cpu_def->features &= ~minus_features;#ifdef DEBUG_FEATURES    print_features(stderr, fprintf, cpu_def->features, NULL);#endif}
开发者ID:AdrianHuang,项目名称:qemu,代码行数:87,


示例12: parseIntLiteral

ValueHolderPtr parseIntLiteral(ModulePtr module, IntLiteral *x){    CompilerState* cst = module->cst;    TypePtr defaultType = module->attrDefaultIntegerType.ptr();    if (defaultType == NULL)        defaultType = cst->int32Type;    char *ptr = const_cast<char *>(x->value.c_str());    char *end = ptr;    int base = ishex(ptr) ? 16 : 10;    ValueHolderPtr vh;    if (typeSuffix(x->suffix, defaultType, "ss", cst->int8Type)) {        long y = strtol(ptr, &end, base);        if (*end != 0)            error("invalid int8 literal");        if ((errno == ERANGE) || (y < SCHAR_MIN) || (y > SCHAR_MAX))            error("int8 literal out of range");        vh = new ValueHolder(cst->int8Type);        *((char *)vh->buf) = (char)y;    }    else if (typeSuffix(x->suffix, defaultType, "s", cst->int16Type)) {        long y = strtol(ptr, &end, base);        if (*end != 0)            error("invalid int16 literal");        if ((errno == ERANGE) || (y < SHRT_MIN) || (y > SHRT_MAX))            error("int16 literal out of range");        vh = new ValueHolder(cst->int16Type);        *((short *)vh->buf) = (short)y;    }    else if (typeSuffix(x->suffix, defaultType, "i", cst->int32Type)) {        long y = strtol(ptr, &end, base);        if (*end != 0)            error("invalid int32 literal");        if (errno == ERANGE || (y < INT_MIN) || (y > INT_MAX))            error("int32 literal out of range");        vh = new ValueHolder(cst->int32Type);        *((int *)vh->buf) = (int)y;    }    else if (typeSuffix(x->suffix, defaultType, "l", cst->int64Type)) {        long long y = strtoll(ptr, &end, base);        if (*end != 0)            error("invalid int64 literal");        if (errno == ERANGE)            error("int64 literal out of range");        vh = new ValueHolder(cst->int64Type);        *((long long *)vh->buf) = y;    }    else if (typeSuffix(x->suffix, defaultType, "ll", cst->int128Type)) {        long long y = strtoll(ptr, &end, base);        if (*end != 0)            error("invalid int128 literal");        if (errno == ERANGE)            error("int128 literal out of range");        vh = new ValueHolder(cst->int128Type);        *((clay_int128 *)vh->buf) = y;    }    else if (typeSuffix(x->suffix, defaultType, "uss", cst->uint8Type)) {        unsigned long y = strtoul(ptr, &end, base);        if (*end != 0)            error("invalid uint8 literal");        if ((errno == ERANGE) || (y > UCHAR_MAX))            error("uint8 literal out of range");        vh = new ValueHolder(cst->uint8Type);        *((unsigned char *)vh->buf) = (unsigned char)y;    }    else if (typeSuffix(x->suffix, defaultType, "us", cst->uint16Type)) {        unsigned long y = strtoul(ptr, &end, base);        if (*end != 0)            error("invalid uint16 literal");        if ((errno == ERANGE) || (y > USHRT_MAX))            error("uint16 literal out of range");        vh = new ValueHolder(cst->uint16Type);        *((unsigned short *)vh->buf) = (unsigned short)y;    }    else if (typeSuffix(x->suffix, defaultType, "u", cst->uint32Type)) {        unsigned long y = strtoul(ptr, &end, base);        if (*end != 0)            error("invalid uint32 literal");        if (errno == ERANGE)            error("uint32 literal out of range");        vh = new ValueHolder(cst->uint32Type);        *((unsigned int *)vh->buf) = (unsigned int)y;    }    else if (typeSuffix(x->suffix, defaultType, "ul", cst->uint64Type)) {        unsigned long long y = strtoull(ptr, &end, base);        if (*end != 0)            error("invalid uint64 literal");        if (errno == ERANGE)            error("uint64 literal out of range");        vh = new ValueHolder(cst->uint64Type);        *((unsigned long long *)vh->buf) = y;    }    else if (typeSuffix(x->suffix, defaultType, "ull", cst->uint128Type)) {        unsigned long long y = strtoull(ptr, &end, base);        if (*end != 0)            error("invalid uint128 literal");        if (errno == ERANGE)            error("uint128 literal out of range");        vh = new ValueHolder(cst->uint128Type);        *((clay_uint128 *)vh->buf) = y;//.........这里部分代码省略.........
开发者ID:galchinsky,项目名称:clay,代码行数:101,


示例13: HandleClient

void HandleClient(int sock) {  char buffer[BUFFSIZE];  char *tailptr;  int received = -1;  long long int respsize,sendsize;  char* blockptr = malloc(BLOCKSIZE);  memset(blockptr,0xaa,BLOCKSIZE);  /* Receive message */  if ((received = recv(sock, buffer, BUFFSIZE-1, 0)) < 0) {    Die("Failed to receive initial bytes from client");  }  /* get the client request - for now, just expect a number which is the size of the     expected response message */  buffer[received] = 0; /* parsing needs to know where the input string ends.... */  respsize = strtoll(buffer, &tailptr,10);  fprintf(stderr, "client request (/"%s/")",buffer);  if (errno) {      Die("/nFailed to parse client request");    } else {      switch ( *tailptr ) {        case 'k' :        case 'K' :          respsize <<= 10;          break;        case 'm' :        case 'M' :          respsize <<= 20;          break;        case 'g' :        case 'G' :          respsize <<= 30;          break;      };      fprintf(stderr, ", parsed request as %lld bytes/n",respsize);    }  /* Send bytes and check for more incoming data in loop */#ifdef ZEROCOPY  char tmpn[] = "/tmp/XXXXXX" ;   int   tmpfd = mkstemp(tmpn);  ftruncate(tmpfd,respsize);  while (respsize > 0) {    sendsize = respsize > MAX_RW_COUNT ? MAX_RW_COUNT : respsize;    respsize -= sendsize;    /* Send the next block */    if (sendfile(sock, tmpfd, 0, sendsize) != sendsize) {      Die("Failed to send bytes to client");    }  }  close(tmpfd);  unlink(tmpn);  #else  while (respsize > 0) {    sendsize = respsize > BLOCKSIZE ? BLOCKSIZE : respsize;    respsize -= sendsize;    /* Send the next block */    if (send(sock, blockptr, sendsize, 0) != sendsize) {      Die("Failed to send bytes to client");    }  }#endif  close(sock);}
开发者ID:hdb3,项目名称:tinytcp,代码行数:67,


示例14: strchr

// parse a @SQ line from the SAM file// start points at the first tag of the linebool ReadDataFile_SAM::parseReferenceSequenceLine(char *start){    char *seq_name = NULL;    char *seq_len = NULL;    char *delim;    for(;;)    {        // look for the next delimiter        delim = strchr(start, '/t');        // zero out the next delimiter if found        if (delim)        {            *delim = 0;        }        if (strncmp(start, "SN:", strlen("SN:")) == 0)        {            if (seq_name != NULL)            {                log_warning(stderr, "SAM file warning (line %d): multiple SN tags in @SQ record/n", numLines);            } else {                seq_name = &start[3];            }        } else if (strncmp(start, "LN:", strlen("LN:")) == 0) {            if (seq_len != NULL)            {                log_warning(stderr, "SAM file warning (line %d): multiple LN tags in @SQ record/n", numLines);            } else {                seq_len = &start[3];            }        }        if (!delim)        {            // this was the last token            break;        }        // advance to next token        start = delim + 1;    }    if (seq_name == NULL || seq_len == NULL)    {        log_warning(stderr, "SAM file warning (line %d): missing required tags in @SQ record/n", numLines);        return true;    }    char *endptr = NULL;#if WIN32    uint64 len = strtol(seq_len, &endptr, 10);#else    uint64 len = strtoll(seq_len, &endptr, 10);#endif    if (!endptr || endptr == seq_len || *endptr != '/0')    {        log_warning(stderr, "SAM file warning (line %d): invalid sequence length in @SQ record/n", numLines);    }    sq_names.push_back(std::string(seq_name));    sq_lengths.push_back(len);    return true;}
开发者ID:NVlabs,项目名称:nvbio-gpl,代码行数:68,


示例15: primary_parser_package_start

static voidprimary_parser_package_start (PrimarySAXContext *ctx,                              const char *name,                              const char **attrs){    SAXContext *sctx = &ctx->sctx;    Package *p = sctx->current_package;    int i;    const char *attr;    const char *value;    g_assert (p != NULL);    sctx->want_text = TRUE;    if (!strcmp (name, "format")) {        ctx->state = PRIMARY_PARSER_FORMAT;    }    else if (!strcmp (name, "version")) {        parse_version_info(attrs, p);    }    else if (!strcmp (name, "checksum")) {        for (i = 0; attrs && attrs[i]; i++) {            attr = attrs[i];            value = attrs[++i];            if (!strcmp (attr, "type"))                p->checksum_type = g_string_chunk_insert (p->chunk, value);        }    }    else if (!strcmp (name, "time")) {        for (i = 0; attrs && attrs[i]; i++) {            attr = attrs[i];            value = attrs[++i];            if (!strcmp (attr, "file"))                p->time_file = strtol(value, NULL, 10);            else if (!strcmp (attr, "build"))                p->time_build = strtol(value, NULL, 10);        }    }    else if (!strcmp (name, "size")) {        for (i = 0; attrs && attrs[i]; i++) {            attr = attrs[i];            value = attrs[++i];            if (!strcmp (attr, "package"))                p->size_package = strtoll(value, NULL, 10);            else if (!strcmp (attr, "installed"))                p->size_installed = strtoll(value, NULL, 10);            else if (!strcmp (attr, "archive"))                p->size_archive = strtoll(value, NULL, 10);        }    }    else if (!strcmp (name, "location")) {        for (i = 0; attrs && attrs[i]; i++) {            attr = attrs[i];            value = attrs[++i];            if (!strcmp (attr, "href"))                p->location_href = g_string_chunk_insert (p->chunk, value);            else if (!strcmp (attr, "xml:base"))                p->location_base = g_string_chunk_insert (p->chunk, value);        }    }}
开发者ID:rpm-software-management,项目名称:yum-metadata-parser,代码行数:72,


示例16: readLog

static int64 readLog(FILE *input,                     sqlite3 *db){  int64 eventCount = 0;  /* declare statements for every event type */  EVENT_LIST(EVENT_TYPE_DECLARE_STATEMENT, X);  /* prepare statements for every event type */  EVENT_LIST(EVENT_TYPE_PREPARE_STATEMENT, X);  runStatement(db, "BEGIN", "Transaction start");  while (TRUE) { /* loop for each event */    char line[MAX_LOG_LINE_LENGTH];    char *p;    char *q;    int last_index=0;    sqlite3_stmt *statement = NULL;    int res;    int64 clock_field;    long code;    p = fgets(line, MAX_LOG_LINE_LENGTH, input);    if (!p) {      if (feof(input))        break;      else        error("Couldn't read line after event %llu", eventCount);    }    eventCount++;    clock_field = strtoll(p, &q, 16);    if (q == p)      error("event %llu clock field not a hex integer: %s",            eventCount, p);    if (*q != ' ')      error("event %llu code field not preceded by ' ': %s",            eventCount, q);    while(*q == ' ')      ++q;    p = q;    code = strtol(p, &q, 16);    if (q == p)      error("event %llu code field not an integer: %s",            eventCount, p);    p = q;    /* Write event to SQLite. */    switch (code) {      /* this macro sets statement and last_index */      EVENT_LIST(EVENT_TYPE_WRITE_SQL, X);    default:      error("Event %llu has Unknown event code %d", eventCount, code);    }    /* bind the fields we store for every event */ /    res = sqlite3_bind_int64(statement, last_index+1, logSerial);    if (res != SQLITE_OK)      sqlite_error(res, db, "Event %llu bind of log_serial failed.", eventCount);    res = sqlite3_bind_int64(statement, last_index+2, clock_field);    if (res != SQLITE_OK)      sqlite_error(res, db, "Event %llu bind of clock failed.", eventCount);    res = sqlite3_step(statement);    if (res != SQLITE_DONE)      sqlite_error(res, db, "insert of event %llu failed.", eventCount);    res = sqlite3_reset(statement);    if (res != SQLITE_OK)      sqlite_error(res, db, "Couldn't reset insert statement of event %llu", eventCount);    if (progress) {      if ((eventCount % SMALL_TICK) == 0) {        printf(".");        fflush(stdout);        if (((eventCount / SMALL_TICK) % BIG_TICK) == 0) {          printf("/n");          fflush(stdout);          evlog(LOG_SOMETIMES, "%lu events.", (unsigned long)eventCount);        }      }    }  }  if (progress) {    printf("/n");    fflush(stdout);  }  runStatement(db, "COMMIT", "Transaction finish");  logFileCompleted(db, eventCount);  /* finalize all the statements */  EVENT_LIST(EVENT_TYPE_FINALIZE_STATEMENT, X);  return eventCount;}
开发者ID:alisheikh,项目名称:hornet,代码行数:97,


示例17: dehumanize_number

/* * Converts the number given in 'str', which may be given in a humanized * form (as described in humanize_number(3), but with some limitations), * to an int64_t without units. * In case of success, 0 is returned and *size holds the value. * Otherwise, -1 is returned and *size is untouched. * * TODO: Internationalization, SI units. */intdehumanize_number(const char *str, int64_t *size){	char *ep, unit;	const char *delimit;	long multiplier;	long long tmp, tmp2;	size_t len;	len = strlen(str);	if (len == 0) {		errno = EINVAL;		return -1;	}	multiplier = 1;	unit = str[len - 1];	if (isalpha((unsigned char)unit)) {		switch (tolower((unsigned char)unit)) {		case 'b':			multiplier = 1;			break;		case 'k':			multiplier = 1024;			break;		case 'm':			multiplier = 1024 * 1024;			break;		case 'g':			multiplier = 1024 * 1024 * 1024;			break;		default:			errno = EINVAL;			return -1; /* Invalid suffix. */		}		delimit = &str[len - 1];	} else		delimit = NULL;	errno = 0;	tmp = strtoll(str, &ep, 10);	if (str[0] == '/0' || (ep != delimit && *ep != '/0'))		return -1; /* Not a number. */	else if (errno == ERANGE && (tmp == LLONG_MAX || tmp == LLONG_MIN))		return -1; /* Out of range. */	tmp2 = tmp * multiplier;	tmp2 = tmp2 / multiplier;	if (tmp != tmp2) {		errno = ERANGE;		return -1; /* Out of range. */	}	tmp *= multiplier;#ifdef _DIAGASSERT	_DIAGASSERT(__type_fit(int64_t, tmp));#endif	*size = (int64_t)tmp;	return 0;}
开发者ID:Stichting-MINIX-Research-Foundation,项目名称:minix,代码行数:75,


示例18: put_str_one

int put_str_one(void *buf,char *cp,T_PkgType *typ,char CURDLM){	int ret;	register char *cp1;	cp1=typ->offset+(char *)buf;	ret=0;	switch(typ->type) {		case CH_CLOB:			*(char **)cp1=cp;			if(CURDLM) strcpy_esc(cp,cp,-1,CURDLM); //有问题			typ->len=strlen(cp);			ret=1;			break;		case CH_BYTE:			byte_cpy(cp1,cp,typ->len);			ret=1;			break;		case CH_DATE:		case CH_CNUM:		case CH_CHAR:			*cp1=0;			strcpy_esc(cp1,cp,typ->len,CURDLM);			ret=1;			break;		case CH_FLOAT:			*(float *)cp1=strtof(cp,&cp);;			ret=1;			break;		case CH_DOUBLE:			*(double *)cp1=strtod(cp,&cp);;			ret=1;			break;		case CH_LDOUBLE:			*(long double *)cp1=strtold(cp,&cp);			break;		case CH_JUL:		case CH_CJUL:			if(!*cp) *(INT4 *)cp1=TIMENULL;			else if(typ->format){				*(int *)cp1=rstrfmttojul(cp,										 typ->format);			} else {				*(int *)cp1= rstrjul(cp);			}			ret=1;			break;		case CH_MINUTS:		case CH_CMINUTS:			if(!*cp) *(INT4 *)cp1=TIMENULL;			else if(typ->format){				*(INT4 *)cp1=rstrminfmt(cp,typ->format);			} else *(INT4 *)cp1=rstrmin(cp);			ret=1;			break;		case CH_TIME:		case CH_CTIME:			if(!*cp) *(INT64 *)cp1=INT64NULL;			else if(typ->format){				*(INT64 *)cp1=rstrsecfmt(cp,typ->format);			} else *(INT64 *)cp1=rstrsecfmt(cp,"YYYYMMDDHH24MISS");			ret=1;			break;		case CH_USEC:			if(!*cp) *(INT64 *)cp1=INT64NULL;			else if(typ->format){				*(INT64 *)cp1=rstrusecfmt(cp,typ->format);			} else *(INT64 *)cp1=rstrusecfmt(cp,"YYYYMMDDHH24MISS.FF6");			ret=1;			break;		case CH_TINY:		{			int tmp;			if(!*cp) {				*cp1=TINYNULL;				break;			}			tmp=atoi(cp);			*cp1=(char)tmp;			break;		}		case CH_SHORT:			*(short *)cp1=SHORTNULL;			ret=sscanf(cp,"%hd",(short *)cp1);			ret=1;			break;		case CH_INT:			if(!*cp) {				*(int *)cp1=INTNULL;				break;			}			*(int *)cp1=atoi(cp);			break;		case CH_LONG:			if(!*cp) {				*(long *)cp1=LONGNULL;				break;			}			*(long *)cp1=strtol(cp,&cp,10);//.........这里部分代码省略.........
开发者ID:weihualiu,项目名称:sdbc,代码行数:101,


示例19: main

int main (int argc, char **argv) {	rd_kafka_topic_t *rkt;	char *brokers = "localhost:9092";	char mode = 'C';	char *topic = NULL;	int partition = RD_KAFKA_PARTITION_UA;	int opt;	rd_kafka_conf_t *conf;	rd_kafka_topic_conf_t *topic_conf;	char errstr[512];	int64_t start_offset = 0;        int report_offsets = 0;	int do_conf_dump = 0;	char tmp[16];        int64_t seek_offset = 0;        int64_t tmp_offset = 0;	int get_wmarks = 0;	quiet = !isatty(STDIN_FILENO);	/* Kafka configuration */	conf = rd_kafka_conf_new();        /* Set logger */        rd_kafka_conf_set_log_cb(conf, logger);	/* Quick termination */	snprintf(tmp, sizeof(tmp), "%i", SIGIO);	rd_kafka_conf_set(conf, "internal.termination.signal", tmp, NULL, 0);	/* Topic configuration */	topic_conf = rd_kafka_topic_conf_new();	while ((opt = getopt(argc, argv, "PCLt:p:b:z:qd:o:eX:As:")) != -1) {		switch (opt) {		case 'P':		case 'C':                case 'L':			mode = opt;			break;		case 't':			topic = optarg;			break;		case 'p':			partition = atoi(optarg);			break;		case 'b':			brokers = optarg;			break;		case 'z':			if (rd_kafka_conf_set(conf, "compression.codec",					      optarg,					      errstr, sizeof(errstr)) !=			    RD_KAFKA_CONF_OK) {				fprintf(stderr, "%% %s/n", errstr);				exit(1);			}			break;		case 'o':                case 's':			if (!strcmp(optarg, "end"))				tmp_offset = RD_KAFKA_OFFSET_END;			else if (!strcmp(optarg, "beginning"))				tmp_offset = RD_KAFKA_OFFSET_BEGINNING;			else if (!strcmp(optarg, "stored"))				tmp_offset = RD_KAFKA_OFFSET_STORED;                        else if (!strcmp(optarg, "report"))                                report_offsets = 1;			else if (!strcmp(optarg, "wmark"))				get_wmarks = 1;			else {				tmp_offset = strtoll(optarg, NULL, 10);				if (tmp_offset < 0)					tmp_offset = RD_KAFKA_OFFSET_TAIL(-tmp_offset);			}                        if (opt == 'o')                                start_offset = tmp_offset;                        else if (opt == 's')                                seek_offset = tmp_offset;			break;		case 'e':			exit_eof = 1;			break;		case 'd':			if (rd_kafka_conf_set(conf, "debug", optarg,					      errstr, sizeof(errstr)) !=			    RD_KAFKA_CONF_OK) {				fprintf(stderr,					"%% Debug configuration failed: "					"%s: %s/n",					errstr, optarg);				exit(1);			}			break;		case 'q':			quiet = 1;			break;		case 'A'://.........这里部分代码省略.........
开发者ID:2510109890,项目名称:librdkafka,代码行数:101,


示例20: main

//.........这里部分代码省略.........  pch = pchSampleData;  while (pch = strchr(pch, '/n'))  {    proflistlength++;    pch++;  }  printf("%i lines in sample data file./n", proflistlength);    /* extract text data into binary table */  pProfTable = (profilehit *) malloc(proflistlength * sizeof(profilehit));  if (pProfTable == NULL)  {    printf("Failed to allocate %i bytes for pProfTable!/n", proflistlength * sizeof(profilehit));    free(pOpAddrTable);    free(pchSampleData);    return 6;  }  pch = pchSampleData;  j = 0;  long long llOffset = 0;  while (j < proflistlength)  {    long lAddress;    int iSamples;    float fPercentage;    char *pchNext = strchr(pch, '/n');    if (pchNext != NULL) *pchNext++ = 0; // null-terminate this line    if (strstr(pch, "range:0x") != NULL) // search for offset change    {      pch = strstr(pch, "range:0x") + 8; // extract hex value and update our offset      char *pch2 = pch;      while (isHex(*pch2)) pch2++;      *pch2 = 0;      llOffset = strtoll(pch, NULL, 16);    }    else // parse line for sample point    {      int rval = ParseProfLine(pch, &lAddress, &iSamples, &fPercentage);      if (rval != 0)      {        pProfTable[j].x86addr = (unsigned long) (lAddress + llOffset);        pProfTable[j].samples = iSamples;        j++;      }    }    pch = pchNext;    if (pch == NULL) break;  }  free(pchSampleData);  proflistlength = j;  printf("Found %i profile hits./n", proflistlength);  /* clear r4300 instruction sample data table */  for (i = 0; i < 132; i++)    instr_samples[i] = 0;      /* calculate r4300 instruction profiling data by merging the tables */  samp_unknown  = 0;  samp_blockend = 0;  samp_notcompiled = 0;  samp_wrappers = 0;  samp_flush = 0;  i = 0; // i == OpAddrTable index  lOpStart = pOpAddrTable[0].x86addr;  lOpEnd   = pOpAddrTable[1].x86addr;  for (j = 0; j < proflistlength; j++) // j == pProfTable index
开发者ID:Gillou68310,项目名称:mupen64plus-core,代码行数:67,


示例21: recv_print_job

//.........这里部分代码省略.........	    syslog(LOG_ERR, "Too many data files (%d)", num_data);	    putchar(1);	    status = 1;	    break;	  }	  strlcpy(data[num_data], name, sizeof(data[0]));          if ((fd = cupsTempFd(temp[num_data], sizeof(temp[0]))) < 0)	  {	    syslog(LOG_ERR, "Unable to open temporary data file /"%s/" - %s",        	   temp[num_data], strerror(errno));	    putchar(1);	    status = 1;	    break;	  }	  strlcpy(filename, temp[num_data], sizeof(filename));          num_data ++;	  break;    }    putchar(status);    if (status)      break;   /*    * Copy the data or control file from the client...    */    for (total = (size_t)strtoll(count, NULL, 10); total > 0; total -= (size_t)bytes)    {      if (total > sizeof(line))        bytes = (ssize_t)sizeof(line);      else        bytes = (ssize_t)total;      if ((bytes = (ssize_t)fread(line, 1, (size_t)bytes, stdin)) > 0)        bytes = write(fd, line, (size_t)bytes);      if (bytes < 1)      {	syslog(LOG_ERR, "Error while reading file - %s",               strerror(errno));        status = 1;	break;      }    }   /*    * Read trailing nul...    */    if (!status)    {      if (fread(line, 1, 1, stdin) < 1)      {        status = 1;	syslog(LOG_ERR, "Error while reading trailing nul - %s",               strerror(errno));      }      else if (line[0])      {
开发者ID:aosm,项目名称:cups,代码行数:67,


示例22: parse_options

/** * parse_options */static void parse_options(int argc, char *argv[]){	long long ll;	char *s, *s2;	int c;	if (argc && *argv)		EXEC_NAME = *argv;	fprintf(stderr, "%s v%s (libntfs-3g)/n", EXEC_NAME, VERSION);	while ((c = getopt(argc, argv, "fh?nqvVl")) != EOF)		switch (c) {		case 'f':			opts.force = 1;			break;		case 'n':			opts.no_action = 1;			break;		case 'q':			opts.quiet = 1;			ntfs_log_clear_levels(NTFS_LOG_LEVEL_QUIET);			break;		case 'v':			opts.verbose++;			ntfs_log_set_levels(NTFS_LOG_LEVEL_VERBOSE);			break;		case 'V':			/* Version number already printed, so just exit. */			exit(0);		case 'l':			copyright();			license();			exit(0);		case 'h':		case '?':		default:			usage();		}	if (optind == argc)		usage();	if (opts.verbose > 1)		ntfs_log_set_levels(NTFS_LOG_LEVEL_DEBUG | NTFS_LOG_LEVEL_TRACE |			NTFS_LOG_LEVEL_VERBOSE | NTFS_LOG_LEVEL_QUIET);	/* Get the device. */	dev_name = argv[optind++];	ntfs_log_verbose("device name = %s/n", dev_name);	if (optind == argc)		usage();	/* Get the inode. */	ll = strtoll(argv[optind++], &s, 0);	if (*s || !ll || (ll >= LLONG_MAX && errno == ERANGE))		err_exit("Invalid inode number: %s/n", argv[optind - 1]);	inode = ll;	ntfs_log_verbose("inode = %lli/n", (long long)inode);	if (optind == argc)		usage();	/* Get the attribute type, if specified. */	s = argv[optind++];	if (optind == argc) {		attr_type = AT_DATA;		attr_name = AT_UNNAMED;		attr_name_len = 0;	} else {		unsigned long ul;		ul = strtoul(s, &s2, 0);		if (*s2 || !ul || (ul >= ULONG_MAX && errno == ERANGE))			err_exit("Invalid attribute type %s: %s/n", s,					strerror(errno));		attr_type = ul;		/* Get the attribute name, if specified. */		s = argv[optind++];		if (optind != argc) {			/* Convert the string to little endian Unicode. */			attr_name_len = ntfs_mbstoucs(s, &attr_name);			if ((int)attr_name_len < 0)				err_exit("Invalid attribute name /"%s/": %s/n",						s, strerror(errno));			/* Keep hold of the original string. */			s2 = s;			s = argv[optind++];			if (optind != argc)				usage();		} else {			attr_name = AT_UNNAMED;			attr_name_len = 0;		}	}	ntfs_log_verbose("attribute type = 0x%x/n", (unsigned int)attr_type);//.........这里部分代码省略.........
开发者ID:Einheri,项目名称:wl500g,代码行数:101,


示例23: simple_hash

void *pluginsd_worker_thread(void *arg){    struct plugind *cd = (struct plugind *)arg;    char line[PLUGINSD_LINE_MAX + 1];#ifdef DETACH_PLUGINS_FROM_NETDATA    unsigned long long usec = 0, susec = 0;    struct timeval last = {0, 0} , now = {0, 0};#endif    char *words[MAX_WORDS] = { NULL };    uint32_t SET_HASH = simple_hash("SET");    uint32_t BEGIN_HASH = simple_hash("BEGIN");    uint32_t END_HASH = simple_hash("END");    uint32_t FLUSH_HASH = simple_hash("FLUSH");    uint32_t CHART_HASH = simple_hash("CHART");    uint32_t DIMENSION_HASH = simple_hash("DIMENSION");    uint32_t DISABLE_HASH = simple_hash("DISABLE");#ifdef DETACH_PLUGINS_FROM_NETDATA    uint32_t MYPID_HASH = simple_hash("MYPID");    uint32_t STOPPING_WAKE_ME_UP_PLEASE_HASH = simple_hash("STOPPING_WAKE_ME_UP_PLEASE");#endif    size_t count = 0;    for(;;) {        if(unlikely(netdata_exit)) break;        FILE *fp = mypopen(cd->cmd, &cd->pid);        if(unlikely(!fp)) {            error("Cannot popen(/"%s/", /"r/").", cd->cmd);            break;        }        info("PLUGINSD: '%s' running on pid %d", cd->fullfilename, cd->pid);        RRDSET *st = NULL;        char *s;        uint32_t hash;        while(likely(fgets(line, PLUGINSD_LINE_MAX, fp) != NULL)) {            if(unlikely(netdata_exit)) break;            line[PLUGINSD_LINE_MAX] = '/0';            // debug(D_PLUGINSD, "PLUGINSD: %s: %s", cd->filename, line);            int w = pluginsd_split_words(line, words, MAX_WORDS);            s = words[0];            if(unlikely(!s || !*s || !w)) {                // debug(D_PLUGINSD, "PLUGINSD: empty line");                continue;            }            // debug(D_PLUGINSD, "PLUGINSD: words 0='%s' 1='%s' 2='%s' 3='%s' 4='%s' 5='%s' 6='%s' 7='%s' 8='%s' 9='%s'", words[0], words[1], words[2], words[3], words[4], words[5], words[6], words[7], words[8], words[9]);            hash = simple_hash(s);            if(likely(hash == SET_HASH && !strcmp(s, "SET"))) {                char *dimension = words[1];                char *value = words[2];                if(unlikely(!dimension || !*dimension)) {                    error("PLUGINSD: '%s' is requesting a SET on chart '%s', without a dimension. Disabling it.", cd->fullfilename, st->id);                    cd->enabled = 0;                    killpid(cd->pid, SIGTERM);                    break;                }                if(unlikely(!value || !*value)) value = NULL;                if(unlikely(!st)) {                    error("PLUGINSD: '%s' is requesting a SET on dimension %s with value %s, without a BEGIN. Disabling it.", cd->fullfilename, dimension, value?value:"<nothing>");                    cd->enabled = 0;                    killpid(cd->pid, SIGTERM);                    break;                }                if(unlikely(st->debug)) debug(D_PLUGINSD, "PLUGINSD: '%s' is setting dimension %s/%s to %s", cd->fullfilename, st->id, dimension, value?value:"<nothing>");                if(value) rrddim_set(st, dimension, strtoll(value, NULL, 0));            }            else if(likely(hash == BEGIN_HASH && !strcmp(s, "BEGIN"))) {                char *id = words[1];                char *microseconds_txt = words[2];                if(unlikely(!id)) {                    error("PLUGINSD: '%s' is requesting a BEGIN without a chart id. Disabling it.", cd->fullfilename);                    cd->enabled = 0;                    killpid(cd->pid, SIGTERM);                    break;                }                st = rrdset_find(id);                if(unlikely(!st)) {                    error("PLUGINSD: '%s' is requesting a BEGIN on chart '%s', which does not exist. Disabling it.", cd->fullfilename, id);                    cd->enabled = 0;                    killpid(cd->pid, SIGTERM);                    break;                }//.........这里部分代码省略.........
开发者ID:NAStools,项目名称:netdata,代码行数:101,


示例24: atoll

/* LONGLONG */long long intatoll(const char *str){	return (strtoll(str, (char **)NULL, 10));}
开发者ID:AgamAgarwal,项目名称:minix,代码行数:6,


示例25: var_OptionParse

/** Parse a stringified option * This function parse a string option and create the associated object * variable * The option must be of the form "[no[-]]foo[=bar]" where foo is the * option name and bar is the value of the option. * /param p_obj the object in which the variable must be created * /param psz_option the option to parse * /param trusted whether the option is set by a trusted input or not * /return nothing */void var_OptionParse( vlc_object_t *p_obj, const char *psz_option,                      bool trusted ){    char *psz_name, *psz_value;    int  i_type;    bool b_isno = false;    vlc_value_t val;    val.psz_string = NULL;    /* It's too much of a hassle to remove the ':' when we parse     * the cmd line :) */    if( psz_option[0] == ':' )        psz_option++;    if( !psz_option[0] )        return;    psz_name = strdup( psz_option );    if( psz_name == NULL )        return;    psz_value = strchr( psz_name, '=' );    if( psz_value != NULL )        *psz_value++ = '/0';    i_type = config_GetType( p_obj, psz_name );    if( !i_type && !psz_value )    {        /* check for "no-foo" or "nofoo" */        if( !strncmp( psz_name, "no-", 3 ) )        {            memmove( psz_name, psz_name + 3, strlen(psz_name) + 1 - 3 );        }        else if( !strncmp( psz_name, "no", 2 ) )        {            memmove( psz_name, psz_name + 2, strlen(psz_name) + 1 - 2 );        }        else goto cleanup;           /* Option doesn't exist */        b_isno = true;        i_type = config_GetType( p_obj, psz_name );    }    if( !i_type ) goto cleanup; /* Option doesn't exist */    if( ( i_type != VLC_VAR_BOOL ) &&        ( !psz_value || !*psz_value ) ) goto cleanup; /* Invalid value */    /* check if option is unsafe */    if( !trusted && !config_IsSafe( psz_name ) )    {        msg_Err( p_obj, "unsafe option /"%s/" has been ignored for "                        "security reasons", psz_name );        free( psz_name );        return;    }    /* Create the variable in the input object.     * Children of the input object will be able to retreive this value     * thanks to the inheritance property of the object variables. */    var_Create( p_obj, psz_name, i_type );    switch( i_type )    {    case VLC_VAR_BOOL:        val.b_bool = !b_isno;        break;    case VLC_VAR_INTEGER:        val.i_int = strtoll( psz_value, NULL, 0 );        break;    case VLC_VAR_FLOAT:        val.f_float = us_atof( psz_value );        break;    case VLC_VAR_STRING:        val.psz_string = psz_value;        break;    default:        goto cleanup;    }    var_Set( p_obj, psz_name, val );cleanup:    free( psz_name );}
开发者ID:RodrigoNieves,项目名称:vlc,代码行数:99,


示例26: __config_process_value

/* * __config_process_value -- *	Deal with special config values like true / false. */static int__config_process_value(WT_CONFIG *conf, WT_CONFIG_ITEM *value){	char *endptr;	/* Empty values are okay: we can't do anything interesting with them. */	if (value->len == 0)		return (0);	if (value->type == WT_CONFIG_ITEM_ID) {		if (strncasecmp(value->str, "true", value->len) == 0) {			value->type = WT_CONFIG_ITEM_BOOL;			value->val = 1;		} else if (strncasecmp(value->str, "false", value->len) == 0) {			value->type = WT_CONFIG_ITEM_BOOL;			value->val = 0;		}	} else if (value->type == WT_CONFIG_ITEM_NUM) {		errno = 0;		value->val = strtoll(value->str, &endptr, 10);		/* Check any leftover characters. */		while (endptr < value->str + value->len)			switch (*endptr++) {			case 'b':			case 'B':				/* Byte: no change. */				break;			case 'k':			case 'K':				WT_SHIFT_INT64(value->val, 10);				break;			case 'm':			case 'M':				WT_SHIFT_INT64(value->val, 20);				break;			case 'g':			case 'G':				WT_SHIFT_INT64(value->val, 30);				break;			case 't':			case 'T':				WT_SHIFT_INT64(value->val, 40);				break;			case 'p':			case 'P':				WT_SHIFT_INT64(value->val, 50);				break;			default:				/*				 * We didn't get a well-formed number.  That				 * might be okay, the required type will be				 * checked by __wt_config_check.				 */				value->type = WT_CONFIG_ITEM_ID;				break;			}		/*		 * If we parsed the whole string but the number is out of range,		 * report an error.  Don't report an error for strings that		 * aren't well-formed integers: if an integer is expected, that		 * will be caught by __wt_config_check.		 */		if (value->type == WT_CONFIG_ITEM_NUM && errno == ERANGE)			goto range;	}	return (0);range:	return (__config_err(conf, "Number out of range", ERANGE));}
开发者ID:EaseTech,项目名称:wiredtiger,代码行数:77,


示例27: storage_trunk_load

static int storage_trunk_load(){#define TRUNK_DATA_FIELD_COUNT  6#define TRUNK_LINE_MAX_LENGHT  64	int64_t restore_offset;	char trunk_data_filename[MAX_PATH_SIZE];	char buff[4 * 1024 + 1];	int line_count;	char *pLineStart;	char *pLineEnd;	char *cols[TRUNK_DATA_FIELD_COUNT];	FDFSTrunkFullInfo trunkInfo;	int result;	int fd;	int bytes;	int len;	snprintf(trunk_data_filename, sizeof(trunk_data_filename), /		"%s/data/%s", g_fdfs_base_path, STORAGE_TRUNK_DATA_FILENAME);	if (g_trunk_init_reload_from_binlog)	{		if (unlink(trunk_data_filename) != 0)		{			result = errno != 0 ? errno : ENOENT;			if (result != ENOENT)			{				logError("file: "__FILE__", line: %d, " /					"unlink file %s fail, " /					"errno: %d, error info: %s", __LINE__, /					trunk_data_filename, result, /					STRERROR(result));				return result;			}		}		restore_offset = 0;		return storage_trunk_restore(restore_offset);	}	fd = open(trunk_data_filename, O_RDONLY);	if (fd < 0)	{		result = errno != 0 ? errno : EIO;		if (result == ENOENT)		{			restore_offset = 0;			return storage_trunk_restore(restore_offset);		}		logError("file: "__FILE__", line: %d, " /			"open file %s fail, " /			"errno: %d, error info: %s", /			__LINE__, trunk_data_filename, /			result, STRERROR(result));		return result;	}	if ((bytes=read(fd, buff, sizeof(buff) - 1)) < 0)	{		result = errno != 0 ? errno : EIO;		logError("file: "__FILE__", line: %d, " /			"read from file %s fail, " /			"errno: %d, error info: %s", /			__LINE__, trunk_data_filename, /			result, STRERROR(result));		close(fd);		return result;	}	*(buff + bytes) = '/0';	pLineEnd = strchr(buff, '/n');	if (pLineEnd == NULL)	{		logError("file: "__FILE__", line: %d, " /			"read offset from file %s fail", /			__LINE__, trunk_data_filename);		close(fd);		return EINVAL;	}	*pLineEnd = '/0';	restore_offset = strtoll(buff, NULL, 10);	pLineStart = pLineEnd + 1;  //skip /n	line_count = 0;	while (1)	{		pLineEnd = strchr(pLineStart, '/n');		if (pLineEnd == NULL)		{			if (bytes < sizeof(buff) - 1) //EOF			{				break;			}			len = strlen(pLineStart);			if (len > TRUNK_LINE_MAX_LENGHT)			{				logError("file: "__FILE__", line: %d, " /					"file %s, line length: %d too long", ///.........这里部分代码省略.........
开发者ID:CCoder123,项目名称:pproj,代码行数:101,



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


C++ strtolower函数代码示例
C++ strtol函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。