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

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

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

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

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

示例1: memcpy

void CProjExt::DoDataExchange(CDataExchange* pDX){  proj_extension tmp;  CComboBox *cb2;  CButton *cb;  CWnd *cw;  CString tmpstr;  int i,j,k;  int flg;  memcpy(&tmp,&the_projectile.extension,sizeof(proj_extension));	CDialog::DoDataExchange(pDX);	//{{AFX_DATA_MAP(CProjExt)		// NOTE: the ClassWizard will add DDX and DDV calls here	//}}AFX_DATA_MAP  tmpstr.Format("0x%02x",the_projectile.extension.aoe);  DDX_Text(pDX, IDC_ATTR, tmpstr);  the_projectile.extension.aoe=(short) strtonum(tmpstr);  DDX_Text(pDX, IDC_UNKNOWN2, the_projectile.extension.flags);  tmpstr=convert_radius(the_projectile.extension.tradius);  DDX_Text(pDX, IDC_TRIGGER, tmpstr);  the_projectile.extension.tradius=(short) strtonum(tmpstr);  tmpstr=convert_radius(the_projectile.extension.radius);  DDX_Text(pDX, IDC_AREA, tmpstr);  the_projectile.extension.radius=(short) strtonum(tmpstr);  RetrieveResref(tmpstr, the_projectile.extension.wavc1);  DDX_Text(pDX, IDC_SOUND, tmpstr);  DDV_MaxChars(pDX, tmpstr, 8);  StoreResref(tmpstr, the_projectile.extension.wavc1);  DDX_Text(pDX, IDC_DELAY, the_projectile.extension.delay);  tmpstr.Format("0x%04x %s",the_projectile.extension.fragmentanim,IDSToken("ANIMATE",the_projectile.extension.fragmentanim, false) );  DDX_Text(pDX, IDC_FRAGMENT, tmpstr);  k=IDSKey2("ANIMATE", tmpstr);  the_projectile.extension.fragmentanim=(unsigned short) k;  DDX_Text(pDX, IDC_DURATION, the_projectile.extension.duration);  if(pDX->m_bSaveAndValidate==UD_DISPLAY)  {    cb2=(CComboBox *) GetDlgItem(IDC_EXPLOSION);    tmpstr.Format("0x%02x",the_projectile.extension.expgr2);    k=cb2->SelectString(0,tmpstr);    if(k==-1)    {      tmpstr.Format("0x%02x unknown",the_projectile.extension.expgr2);    }    else    {      cb2->GetLBText(k,tmpstr);    }  }  DDX_Text(pDX, IDC_EXPLOSION, tmpstr); //first projectile  the_projectile.extension.expgr2=(unsigned char) strtonum(tmpstr);  tmpstr=colortitle(the_projectile.extension.expclr);  DDX_Text(pDX, IDC_COLOR, tmpstr);  the_projectile.extension.expclr=(short) strtonum(tmpstr);  tmpstr=get_projectile_id(the_projectile.extension.proref+1,1);  DDX_Text(pDX, IDC_UNKNOWN14, tmpstr);  the_projectile.extension.proref=(short) strtonum(tmpstr);  tmpstr=get_projectile_id(the_projectile.extension.projectile,0);  DDX_Text(pDX, IDC_PROJECTILE, tmpstr);  the_projectile.extension.projectile=(short) strtonum(tmpstr);  RetrieveResref(tmpstr, the_projectile.extension.vvc);  DDX_Text(pDX, IDC_VVC, tmpstr);  DDV_MaxChars(pDX, tmpstr, 8);  StoreResref(tmpstr, the_projectile.extension.vvc);  tmpstr=convert_degree(the_projectile.extension.conewidth);  DDX_Text(pDX, IDC_CONESIZE, tmpstr);  the_projectile.extension.conewidth=(short) strtonum(tmpstr);  j=1;  for(i=0;i<16;i++)  {    cb=(CButton *) GetDlgItem(IDC_ATTR1+i);    flg=!!(the_projectile.extension.aoe&j);    cb->SetCheck(flg);    j<<=1;    if(extensioncontrols[i])    {      for(k=0;extensioncontrols[i][k];k++)      {        cw=GetDlgItem(extensioncontrols[i][k]);        cw->EnableWindow(flg);      }    }  }  if(memcmp(&tmp,&the_projectile.extension,sizeof(proj_extension)))  {//.........这里部分代码省略.........
开发者ID:TeoTwawki,项目名称:dltcep,代码行数:101,


示例2: main

intmain(int argc, char *argv[]){	struct rlimit rlp;	struct addrinfo hints, *res;	struct event ev_sighup, ev_sigint, ev_sigterm;	int ch, error, listenfd, on;	const char *errstr;	/* Defaults. */	anonymous_only	= 0;	daemonize	= 1;	fixed_proxy	= NULL;	fixed_server	= NULL;	fixed_server_port = "21";	ipv6_mode	= 0;	listen_ip	= NULL;	listen_port	= "8021";	loglevel	= LOG_NOTICE;	max_sessions	= 100;	qname		= NULL;	rfc_mode	= 0;	tagname		= NULL;	timeout		= 24 * 3600;	verbose		= 0;	/* Other initialization. */	id_count	= 1;	session_count	= 0;	while ((ch = getopt(argc, argv, "6Aa:b:D:dm:P:p:q:R:rT:t:v")) != -1) {		switch (ch) {		case '6':			ipv6_mode = 1;			break;		case 'A':			anonymous_only = 1;			break;		case 'a':			fixed_proxy = optarg;			break;		case 'b':			listen_ip = optarg;			break;		case 'D':			loglevel = strtonum(optarg, LOG_EMERG, LOG_DEBUG,			    &errstr);			if (errstr)				errx(1, "loglevel %s", errstr);			break;		case 'd':			daemonize = 0;			break;		case 'm':			max_sessions = strtonum(optarg, 1, 500, &errstr);			if (errstr)				errx(1, "max sessions %s", errstr);			break;		case 'P':			fixed_server_port = optarg;			break;		case 'p':			listen_port = optarg;			break;		case 'q':			if (strlen(optarg) >= PF_QNAME_SIZE)				errx(1, "queuename too long");			qname = optarg;			break;		case 'R':			fixed_server = optarg;			break;		case 'r':			rfc_mode = 1;			break;		case 'T':			if (strlen(optarg) >= PF_TAG_NAME_SIZE)				errx(1, "tagname too long");			tagname = optarg;			break;		case 't':			timeout = strtonum(optarg, 0, 86400, &errstr);			if (errstr)				errx(1, "timeout %s", errstr);			break;		case 'v':			verbose++;			if (verbose > 2)				usage();			break;		default:			usage();		}	}	if (listen_ip == NULL)		listen_ip = ipv6_mode ? "::1" : "127.0.0.1";	/* Check for root to save the user from cryptic failure messages. */	if (getuid() != 0)//.........这里部分代码省略.........
开发者ID:SylvestreG,项目名称:bitrig,代码行数:101,


示例3: ocsp_main

intocsp_main(int argc, char **argv){	char **args;	char *host = NULL, *port = NULL, *path = "/";	char *reqin = NULL, *respin = NULL;	char *reqout = NULL, *respout = NULL;	char *signfile = NULL, *keyfile = NULL;	char *rsignfile = NULL, *rkeyfile = NULL;	char *outfile = NULL;	int add_nonce = 1, noverify = 0, use_ssl = -1;	STACK_OF(CONF_VALUE) * headers = NULL;	OCSP_REQUEST *req = NULL;	OCSP_RESPONSE *resp = NULL;	OCSP_BASICRESP *bs = NULL;	X509 *issuer = NULL, *cert = NULL;	X509 *signer = NULL, *rsigner = NULL;	EVP_PKEY *key = NULL, *rkey = NULL;	BIO *acbio = NULL, *cbio = NULL;	BIO *derbio = NULL;	BIO *out = NULL;	int req_timeout = -1;	int req_text = 0, resp_text = 0;	long nsec = MAX_VALIDITY_PERIOD, maxage = -1;	char *CAfile = NULL, *CApath = NULL;	X509_STORE *store = NULL;	STACK_OF(X509) * sign_other = NULL, *verify_other = NULL, *rother = NULL;	char *sign_certfile = NULL, *verify_certfile = NULL, *rcertfile = NULL;	unsigned long sign_flags = 0, verify_flags = 0, rflags = 0;	int ret = 1;	int accept_count = -1;	int badarg = 0;	int i;	int ignore_err = 0;	STACK_OF(OPENSSL_STRING) * reqnames = NULL;	STACK_OF(OCSP_CERTID) * ids = NULL;	X509 *rca_cert = NULL;	char *ridx_filename = NULL;	char *rca_filename = NULL;	CA_DB *rdb = NULL;	int nmin = 0, ndays = -1;	const EVP_MD *cert_id_md = NULL;	const char *errstr = NULL;	if (single_execution) {		if (pledge("stdio inet rpath wpath cpath", NULL) == -1) {			perror("pledge");			exit(1);		}	}	args = argv + 1;	reqnames = sk_OPENSSL_STRING_new_null();	ids = sk_OCSP_CERTID_new_null();	while (!badarg && *args && *args[0] == '-') {		if (!strcmp(*args, "-out")) {			if (args[1]) {				args++;				outfile = *args;			} else				badarg = 1;		} else if (!strcmp(*args, "-timeout")) {			if (args[1]) {				args++;				req_timeout = strtonum(*args, 0,				    INT_MAX, &errstr);				if (errstr) {					BIO_printf(bio_err,					    "Illegal timeout value %s: %s/n",					    *args, errstr);					badarg = 1;				}			} else				badarg = 1;		} else if (!strcmp(*args, "-url")) {			if (args[1]) {				args++;				if (!OCSP_parse_url(*args, &host, &port, &path, &use_ssl)) {					BIO_printf(bio_err, "Error parsing URL/n");					badarg = 1;				}			} else				badarg = 1;		} else if (!strcmp(*args, "-host")) {			if (args[1]) {				args++;				host = *args;			} else				badarg = 1;		} else if (!strcmp(*args, "-port")) {			if (args[1]) {				args++;				port = *args;			} else				badarg = 1;		} else if (!strcmp(*args, "-header")) {			if (args[1] && args[2]) {				if (!X509V3_add_value(args[1], args[2], &headers))					goto end;				args += 2;//.........这里部分代码省略.........
开发者ID:darksoul42,项目名称:bitrig,代码行数:101,


示例4: parse_prime

static intparse_prime(int linenum, char *line, struct dhgroup *dhg){	char *cp, *arg;	char *strsize, *gen, *prime;	const char *errstr = NULL;	long long n;	dhg->p = dhg->g = NULL;	cp = line;	if ((arg = strdelim(&cp)) == NULL)		return 0;	/* Ignore leading whitespace */	if (*arg == '/0')		arg = strdelim(&cp);	if (!arg || !*arg || *arg == '#')		return 0;	/* time */	if (cp == NULL || *arg == '/0')		goto truncated;	arg = strsep(&cp, " "); /* type */	if (cp == NULL || *arg == '/0')		goto truncated;	/* Ensure this is a safe prime */	n = strtonum(arg, 0, 5, &errstr);	if (errstr != NULL || n != MODULI_TYPE_SAFE) {		error("moduli:%d: type is not %d", linenum, MODULI_TYPE_SAFE);		goto fail;	}	arg = strsep(&cp, " "); /* tests */	if (cp == NULL || *arg == '/0')		goto truncated;	/* Ensure prime has been tested and is not composite */	n = strtonum(arg, 0, 0x1f, &errstr);	if (errstr != NULL ||	    (n & MODULI_TESTS_COMPOSITE) || !(n & ~MODULI_TESTS_COMPOSITE)) {		error("moduli:%d: invalid moduli tests flag", linenum);		goto fail;	}	arg = strsep(&cp, " "); /* tries */	if (cp == NULL || *arg == '/0')		goto truncated;	n = strtonum(arg, 0, 1<<30, &errstr);	if (errstr != NULL || n == 0) {		error("moduli:%d: invalid primality trial count", linenum);		goto fail;	}	strsize = strsep(&cp, " "); /* size */	if (cp == NULL || *strsize == '/0' ||	    (dhg->size = (int)strtonum(strsize, 0, 64*1024, &errstr)) == 0 ||	    errstr) {		error("moduli:%d: invalid prime length", linenum);		goto fail;	}	/* The whole group is one bit larger */	dhg->size++;	gen = strsep(&cp, " "); /* gen */	if (cp == NULL || *gen == '/0')		goto truncated;	prime = strsep(&cp, " "); /* prime */	if (cp != NULL || *prime == '/0') { truncated:		error("moduli:%d: truncated", linenum);		goto fail;	}	if ((dhg->g = BN_new()) == NULL)		fatal("parse_prime: BN_new failed");	if ((dhg->p = BN_new()) == NULL)		fatal("parse_prime: BN_new failed");	if (BN_hex2bn(&dhg->g, gen) == 0) {		error("moduli:%d: could not parse generator value", linenum);		goto fail;	}	if (BN_hex2bn(&dhg->p, prime) == 0) {		error("moduli:%d: could not parse prime value", linenum);		goto fail;	}	if (BN_num_bits(dhg->p) != dhg->size) {		error("moduli:%d: prime has wrong size: actual %d listed %d",		    linenum, BN_num_bits(dhg->p), dhg->size - 1);		goto fail;	}	if (BN_cmp(dhg->g, BN_value_one()) <= 0) {		error("moduli:%d: generator is invalid", linenum);		goto fail;	}	return 1; fail:	if (dhg->g != NULL)		BN_clear_free(dhg->g);	if (dhg->p != NULL)		BN_clear_free(dhg->p);	dhg->g = dhg->p = NULL;	error("Bad prime description in line %d", linenum);	return 0;}
开发者ID:enukane,项目名称:netbsd-src,代码行数:100,


示例5: main

intmain(int argc, char *argv[]){	struct timezone tz;	const char *errstr;	struct tm *tp;	int ch, rflag;	char *format, buf[1024], *outzone = NULL;	setlocale(LC_ALL, "");	tz.tz_dsttime = tz.tz_minuteswest = 0;	rflag = 0;	while ((ch = getopt(argc, argv, "ad:jr:ut:z:")) != -1)		switch(ch) {		case 'd':		/* daylight saving time */			tz.tz_dsttime = atoi(optarg) ? 1 : 0;			break;		case 'a':			slidetime = 1;			break;		case 'j':		/* don't set */			jflag = 1;			break;		case 'r':		/* user specified seconds */			rflag = 1;			tval = atoll(optarg);			break;		case 'u':		/* do everything in UTC */			if (setenv("TZ", "UTC", 1) == -1)				err(1, "cannot unsetenv TZ");			break;		case 't':		/* minutes west of GMT */			tz.tz_minuteswest = strtonum(optarg, 0, 24*60-1, &errstr);			if (errstr)				errx(1, "-t %s: %s", optarg, errstr);			break;		case 'z':			outzone = optarg;			break;		default:			usage();		}	argc -= optind;	argv += optind;	/*	 * If -d or -t, set the timezone or daylight saving time; this	 * doesn't belong here, the kernel should not know about either.	 */	if ((tz.tz_minuteswest || tz.tz_dsttime) &&	    settimeofday(NULL, &tz))		err(1, "settimeofday");	if (!rflag && time(&tval) == -1)		err(1, "time");	format = "%a %b %e %H:%M:%S %Z %Y";	/* allow the operands in any order */	if (*argv && **argv == '+') {		format = *argv + 1;		argv++;		argc--;	}	if (*argv) {		setthetime(*argv);		argv++;		argc--;	}	if (pledge("stdio rpath wpath", NULL) == -1)		err(1, "pledge");	if (*argv && **argv == '+') {		format = *argv + 1;		argc--;	}	if (argc > 0)		errx(1, "too many arguments");	if (outzone)		setenv("TZ", outzone, 1);	tp = localtime(&tval);	if (tp == NULL)		errx(1, "conversion error");	(void)strftime(buf, sizeof(buf), format, tp);	(void)printf("%s/n", buf);	exit(0);}
开发者ID:radixo,项目名称:openbsd-src,代码行数:93,


示例6: main

/* * Nfs server daemon mostly just a user context for nfssvc() * * 1 - do file descriptor and signal cleanup * 2 - fork the nfsd(s) * 3 - create server socket(s) * 4 - register socket with portmap * * For connectionless protocols, just pass the socket into the kernel via. * nfssvc(). * For connection based sockets, loop doing accepts. When you get a new * socket from accept, pass the msgsock into the kernel via. nfssvc(). * The arguments are: *	-r - reregister with portmapper *	-t - support tcp nfs clients *	-u - support udp nfs clients * followed by "n" which is the number of nfsds' to fork off */intmain(int argc, char *argv[]){	struct nfsd_args nfsdargs;	struct sockaddr_in inetaddr, inetpeer;	fd_set *ready, *sockbits;	size_t fd_size;	int ch, connect_type_cnt, i, maxsock = 0, msgsock;	int nfsdcnt = DEFNFSDCNT, on, reregister = 0, sock;	int udpflag = 0, tcpflag = 0, tcpsock;	const char *errstr = NULL;	socklen_t len;	/* Start by writing to both console and log. */	openlog("nfsd", LOG_PID | LOG_PERROR, LOG_DAEMON);	if (argc == 1)		udpflag = 1;	while ((ch = getopt(argc, argv, "n:rtu")) != -1)		switch (ch) {		case 'n':			nfsdcnt = strtonum(optarg, 1, MAXNFSDCNT, &errstr);			if (errstr) {				syslog(LOG_ERR, "nfsd count is %s: %s", errstr, optarg);				return(1);			}			break;		case 'r':			reregister = 1;			break;		case 't':			tcpflag = 1;			break;		case 'u':			udpflag = 1;			break;		default:			usage();		};	argv += optind;	argc -= optind;	/*	 * XXX	 * Backward compatibility, trailing number is the count of daemons.	 */	if (argc > 1)		usage();	if (argc == 1) {		nfsdcnt = strtonum(argv[0], 1, MAXNFSDCNT, &errstr);		if (errstr) {			syslog(LOG_ERR, "nfsd count is %s: %s", errstr, optarg);			return(1);		}	}	if (debug == 0) {		daemon(0, 0);		(void)signal(SIGHUP, SIG_IGN);		(void)signal(SIGINT, SIG_IGN);		(void)signal(SIGQUIT, SIG_IGN);		(void)signal(SIGSYS, nonfs);	}	(void)signal(SIGCHLD, reapchild);	if (reregister) {		if (udpflag &&		    (!pmap_set(RPCPROG_NFS, 2, IPPROTO_UDP, NFS_PORT) ||		     !pmap_set(RPCPROG_NFS, 3, IPPROTO_UDP, NFS_PORT))) {			syslog(LOG_ERR, "can't register with portmap for UDP (%m).");			return (1);		}		if (tcpflag &&		    (!pmap_set(RPCPROG_NFS, 2, IPPROTO_TCP, NFS_PORT) ||		     !pmap_set(RPCPROG_NFS, 3, IPPROTO_TCP, NFS_PORT))) {			syslog(LOG_ERR, "can't register with portmap for TCP (%m).");			return (1);		}		return (0);	}	/* Cut back to writing to log only. *///.........这里部分代码省略.........
开发者ID:appleorange1,项目名称:bitrig,代码行数:101,


示例7: parseArgs

/*********************************************************************** * parseArgs - Parse command line arguments and initialize data * * Returns 0 if ok, -1 on bad args */static int parseArgs(int argc, char **argv){	int badop = 0;	const char *errstr;	verify_depth = 0;	verify_error = X509_V_OK;	argc--;	argv++;	while (argc >= 1) {		if (strcmp(*argv, "-connect") == 0) {			if (--argc < 1)				goto bad;			host = *(++argv);		}#if 0		else if (strcmp(*argv, "-host") == 0) {			if (--argc < 1)				goto bad;			host = *(++argv);		} else if (strcmp(*argv, "-port") == 0) {			if (--argc < 1)				goto bad;			port = *(++argv);		}#endif		else if (strcmp(*argv, "-reuse") == 0)			perform = 2;		else if (strcmp(*argv, "-new") == 0)			perform = 1;		else if (strcmp(*argv, "-verify") == 0) {			const char *errstr;			tm_verify = SSL_VERIFY_PEER | SSL_VERIFY_CLIENT_ONCE;			if (--argc < 1)				goto bad;			verify_depth = strtonum(*(++argv), 0, INT_MAX, &errstr);			if (errstr)				goto bad;			BIO_printf(bio_err, "verify depth is %d/n", verify_depth);		} else if (strcmp(*argv, "-cert") == 0) {			if (--argc < 1)				goto bad;			t_cert_file = *(++argv);		} else if (strcmp(*argv, "-key") == 0) {			if (--argc < 1)				goto bad;			t_key_file = *(++argv);		} else if (strcmp(*argv, "-CApath") == 0) {			if (--argc < 1)				goto bad;			CApath = *(++argv);		} else if (strcmp(*argv, "-CAfile") == 0) {			if (--argc < 1)				goto bad;			CAfile = *(++argv);		} else if (strcmp(*argv, "-cipher") == 0) {			if (--argc < 1)				goto bad;			tm_cipher = *(++argv);		}		else if (strcmp(*argv, "-nbio") == 0) {			t_nbio = 1;		}		else if (strcmp(*argv, "-www") == 0) {			if (--argc < 1)				goto bad;			s_www_path = *(++argv);			if (strlen(s_www_path) > MYBUFSIZ - 100) {				BIO_printf(bio_err, "-www option too long/n");				badop = 1;			}		} else if (strcmp(*argv, "-bugs") == 0)			st_bugs = 1;		else if (strcmp(*argv, "-ssl3") == 0)			s_time_meth = SSLv3_client_method();		else if (strcmp(*argv, "-time") == 0) {			if (--argc < 1)				goto bad;			maxTime = strtonum(*(++argv), 0, INT_MAX, &errstr);			if (errstr)//.........这里部分代码省略.........
开发者ID:DiamondLovesYou,项目名称:libressl-pnacl-sys,代码行数:101,


示例8: intmetric

intintmetric(char *ifname, int ifs, int argc, char **argv){	struct ifreq ifr;	int set, max;	unsigned long theioctl;	char *type;	const char *errmsg = NULL;	if (NO_ARG(argv[0])) {		set = 0;		argc--;		argv++;	} else		set = 1;	if (isprefix(argv[0], "metric")) {		type = "metric";		max = INT_MAX;		theioctl = SIOCSIFMETRIC;	} else if (isprefix(argv[0], "priority")) {		type = "priority";		max = 15;		theioctl = SIOCSIFPRIORITY;	} else {		printf("%% intmetric internal failure/n");		return(0);	}	argc--;	argv++;	if ((!set && argc > 1) || (set && argc != 1)) {		printf("%% %s <%s>/n", type, type);		printf("%% no %s [%s]/n", type, type);		return(0);	}	if (set) {		int num;		num = strtonum(argv[0], 0, max, &errmsg);		if (errmsg) {			printf("%% Invalid %s %s: %s/n", type, argv[0],			    errmsg);			return(0);		}		ifr.ifr_metric = num;	} else {		ifr.ifr_metric = 0;	}	if (errmsg) {		printf("%% Invalid %s %s: %s/n", type, argv[0], errmsg);		return(0);	}	strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));	if (ioctl(ifs, theioctl, (caddr_t)&ifr) < 0)		printf("%% intmetric: SIOCSIF%s: %s/n", type,		    strerror(errno));	return(0);}
开发者ID:yellowman,项目名称:nsh,代码行数:64,


示例9: intvlan

intintvlan(char *ifname, int ifs, int argc, char **argv){#ifndef SIOCSIFPARENT /* 5.9- */	const char *errmsg = NULL;	struct ifreq ifr;	struct vlanreq vreq;#endif	int set;	if (NO_ARG(argv[0])) {		set = 0;		argc--;		argv++;	} else		set = 1;	argc--;	argv++;	if ((set && argc != 3) || (!set && argc > 3) ||	    (argc == 3 && !isprefix(argv[1], "parent"))) {		printf("%% vlan <tag> parent <parent interface>/n");		printf("%% no vlan [tag] [parent <parent interface>]/n");		return 0;	}#ifndef SIOCSIFPARENT /* 5.9- */	strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));	bzero(&vreq, sizeof(vreq));	ifr.ifr_data = (caddr_t)&vreq;	if (ioctl(ifs, SIOCGETVLAN, (caddr_t)&ifr) == -1) {		switch(errno) {		case ENOTTY:			printf("%% This interface does not support vlan"			    " tagging/n");			break;		default:			printf("%% intvlan: SIOCGETVLAN: %s/n",			    strerror(errno));		}		return(0);	}#endif	if (set) {		if (!is_valid_ifname(argv[2]) || is_bridge(ifs, argv[2])) {			printf("%% Invalid vlan parent %s/n", argv[2]);			return 0;		}#ifndef SIOCSIFPARENT	/* 5.9- */		strlcpy(vreq.vlr_parent, argv[2], sizeof(vreq.vlr_parent));		vreq.vlr_tag = strtonum(argv[0], 0, 4095, &errmsg);		if (errmsg) {			printf("%% Invalid vlan tag %s: %s", argv[0], errmsg);			return 0;		}		if (vreq.vlr_tag != EVL_VLANOFTAG(vreq.vlr_tag)) {			printf("%% Invalid vlan tag %s/n", argv[0]);			return 0;		}	} else {		bzero(&vreq.vlr_parent, sizeof(vreq.vlr_parent));		vreq.vlr_tag = 0;#endif	}#ifdef SIOCSIFPARENT	/* 6.0+ */	if (set) {		char *vnet_argv[] = { "vnetid", argv[0], '/0' };		char *par_argv[] = { "parent", argv[2], '/0' };		intparent(ifname, ifs, 2, par_argv);		intvnetid(ifname, ifs, 2, vnet_argv);	} else {		char *vnet_argv[] = { "no", "vnetid" };		char *par_argv[] = { "no", "parent" };		intparent(ifname, ifs, 2, par_argv);		intvnetid(ifname, ifs, 2, vnet_argv);	}#else	if (ioctl(ifs, SIOCSETVLAN, (caddr_t)&ifr) == -1) {		switch(errno) {		case EBUSY:			printf("%% Please disconnect the current vlan parent"			    " before setting a new one/n");			return 0;			break;		default:			printf("%% intvlan: SIOCSETVLAN: %s/n",			    strerror(errno));			return 0;		}	}#endif//.........这里部分代码省略.........
开发者ID:yellowman,项目名称:nsh,代码行数:101,


示例10: cmd_resize_pane_exec

enum cmd_retvalcmd_resize_pane_exec(struct cmd *self, struct cmd_q *cmdq){	struct args		*args = self->args;	struct winlink		*wl;	struct window		*w;	const char	       	*errstr;	char			*cause;	struct window_pane	*wp;	u_int			 adjust;	int			 x, y;	if ((wl = cmd_find_pane(cmdq, args_get(args, 't'), NULL, &wp)) == NULL)		return (CMD_RETURN_ERROR);	w = wl->window;	if (args_has(args, 'Z')) {		if (w->flags & WINDOW_ZOOMED)			window_unzoom(w);		else			window_zoom(wp);		server_redraw_window(w);		server_status_window(w);		return (CMD_RETURN_NORMAL);	}	server_unzoom_window(w);	if (args->argc == 0)		adjust = 1;	else {		adjust = strtonum(args->argv[0], 1, INT_MAX, &errstr);		if (errstr != NULL) {			cmdq_error(cmdq, "adjustment %s", errstr);			return (CMD_RETURN_ERROR);		}	}	if (args_has(self->args, 'x')) {		x = args_strtonum(self->args, 'x', PANE_MINIMUM, INT_MAX,		    &cause);		if (cause != NULL) {			cmdq_error(cmdq, "width %s", cause);			free(cause);			return (CMD_RETURN_ERROR);		}		layout_resize_pane_to(wp, LAYOUT_LEFTRIGHT, x);	}	if (args_has(self->args, 'y')) {		y = args_strtonum(self->args, 'y', PANE_MINIMUM, INT_MAX,		    &cause);		if (cause != NULL) {			cmdq_error(cmdq, "height %s", cause);			free(cause);			return (CMD_RETURN_ERROR);		}		layout_resize_pane_to(wp, LAYOUT_TOPBOTTOM, y);	}	if (args_has(self->args, 'L'))		layout_resize_pane(wp, LAYOUT_LEFTRIGHT, -adjust);	else if (args_has(self->args, 'R'))		layout_resize_pane(wp, LAYOUT_LEFTRIGHT, adjust);	else if (args_has(self->args, 'U'))		layout_resize_pane(wp, LAYOUT_TOPBOTTOM, -adjust);	else if (args_has(self->args, 'D'))		layout_resize_pane(wp, LAYOUT_TOPBOTTOM, adjust);	server_redraw_window(wl->window);	return (CMD_RETURN_NORMAL);}
开发者ID:Stichting-MINIX-Research-Foundation,项目名称:minix,代码行数:70,


示例11: intmpw

/* from ifconfig.c */intintmpw(char *ifname, int ifs, int argc, char **argv){	int set;	struct sockaddr_in *sin, *sinn;	struct ifmpwreq imr;	struct ifreq ifr;	struct mpwc *x;	const char *errstr;	bzero(&imr, sizeof(imr));	bzero(&ifr, sizeof(ifr));	strlcpy(ifr.ifr_name, ifname, IFNAMSIZ);	if (NO_ARG(argv[0])) {		set = 0;		argc--;		argv++;	} else		set = 1;	x=(struct mpwc *) genget(argv[0], (char **)mpwcs, sizeof(struct mpwc));	if (x == 0) {		printf("%% Internal error - Invalid argument %s/n", argv[0]);		return 0;	} else if (Ambiguous(x)) {		printf("%% Internal error - Ambiguous argument %s/n", argv[0]);		return 0;	}	argc--;	argv++;	if (x->args == 2 && ((!set && argc > 2) || (set && argc != 2))) {		printf("%% %s <%s> <%s>/n", x->name, x->descr, x->descr2);		printf("%% no %s [%s] [%s]/n", x->name, x->descr, x->descr2);		return(0);	}	if (x->args == 1 && ((!set && argc > 1) || (set && argc != 1))) {		printf("%% %s <%s>/n", x->name, x->descr);		printf("%% no %s [%s]/n", x->name, x->descr);		return(0);	}	if (!x->args && argc) {		printf("%% %s/n", x->name);		printf("%% no %s/n", x->name);		return(0);	}	switch(x->type) {	case MPWLABEL:		if (!set) {			imrsave.imr_lshim.shim_label = 0;			imrsave.imr_rshim.shim_label = 0;			break;		}		imrsave.imr_lshim.shim_label = strtonum(argv[0],		    (MPLS_LABEL_RESERVED_MAX + 1), MPLS_LABEL_MAX, &errstr);		if (errstr != NULL) {			printf("%% invalid local label: %s/n", errstr);			return 0;		}		imrsave.imr_rshim.shim_label = strtonum(argv[1],		    (MPLS_LABEL_RESERVED_MAX + 1), MPLS_LABEL_MAX, &errstr);		if (errstr != NULL) {			printf("%% invalid remote label: %s/n", errstr);			return 0;		}	break;	case MPWNEIGHBOR:		sin = (struct sockaddr_in *) &imrsave.imr_nexthop;		if (set && inet_aton(argv[0], &sin->sin_addr) == 0) {			printf("%% invalid neighbor addresses/n");			return 0;		}		if (!set) {			sin->sin_addr.s_addr = 0;		}		sin->sin_family = AF_INET;	break;	case MPWCONTROLWORD:		if (set)			imrsave.imr_flags |= IMR_FLAG_CONTROLWORD;		else			imrsave.imr_flags &= ~IMR_FLAG_CONTROLWORD;	break;	case MPWENCAP:		if (!set) {			imrsave.imr_type = UINT32_MAX;			break;		}		if (isprefix(argv[0], "ethernet")) {			imrsave.imr_type = IMR_TYPE_ETHERNET;		} else if (isprefix(argv[0], "ethernet-tagged")) {			imrsave.imr_type = IMR_TYPE_ETHERNET_TAGGED;		} else {			printf("%% invalid mpw encapsulation type/n");//.........这里部分代码省略.........
开发者ID:yellowman,项目名称:nsh,代码行数:101,


示例12: main

intmain(int argc, char *argv[]){	int ch, fd, error;	int i_flag = 0, m_flag = 0, u_flag = 0;	int c_arg = 0, h_arg = 0, s_arg = 0;	struct disk disk;	u_int32_t l_arg = 0;#ifdef HAS_MBR	char *mbrfile = _PATH_MBR;#else	char *mbrfile = NULL;#endif	struct mbr mbr;	struct dos_mbr dos_mbr;	while ((ch = getopt(argc, argv, "ieguf:c:h:s:l:y")) != -1) {		const char *errstr;		switch(ch) {		case 'i':			i_flag = 1;			break;		case 'u':			u_flag = 1;			break;		case 'e':			m_flag = 1;			break;		case 'f':			mbrfile = optarg;			break;		case 'c':			c_arg = strtonum(optarg, 1, 262144, &errstr);			if (errstr)				errx(1, "Cylinder argument %s [1..262144].",				    errstr);			break;		case 'h':			h_arg = strtonum(optarg, 1, 256, &errstr);			if (errstr)				errx(1, "Head argument %s [1..256].", errstr);			break;		case 's':			s_arg = strtonum(optarg, 1, 63, &errstr);			if (errstr)				errx(1, "Sector argument %s [1..63].", errstr);			break;		case 'g':			g_flag = 1;			break;		case 'l':			l_arg = strtonum(optarg, 64, UINT32_MAX, &errstr);			if (errstr)				errx(1, "Block argument %s [64..%u].", errstr,				    UINT32_MAX);			break;		case 'y':			y_flag = 1;			break;		default:			usage();		}	}	argc -= optind;	argv += optind;	memset(&disk, 0, sizeof(disk));	/* Argument checking */	if (argc != 1)		usage();	else		disk.name = argv[0];	if (g_flag != 0 && i_flag == 0) {		warnx("-g specified without -i");		usage();	}	/* Start with the disklabel geometry and get the sector size. */	DISK_getlabelgeometry(&disk);	if (c_arg | h_arg | s_arg) {		/* Use supplied geometry if it is completely specified. */		if (c_arg && h_arg && s_arg) {			disk.cylinders = c_arg;			disk.heads = h_arg;			disk.sectors = s_arg;			disk.size = c_arg * h_arg * s_arg;		} else			errx(1, "Please specify a full geometry with [-chs].");	} else if (l_arg) {		/* Use supplied size to calculate a geometry. */		disk.cylinders = l_arg / 64;		disk.heads = 1;		disk.sectors = 64;		disk.size = l_arg;	}//.........这里部分代码省略.........
开发者ID:appleorange1,项目名称:bitrig,代码行数:101,


示例13: skeygetent

/* * Get an entry in the One-time Password database and lock it. * * Return codes: * -1: error in opening database or unable to lock entry *  0: entry found, file R/W pointer positioned at beginning of record *  1: entry not found */static intskeygetent(int fd, struct skey *mp, const char *name){	char *cp, filename[PATH_MAX], *last;	struct stat statbuf;	const char *errstr;	size_t nread;	FILE *keyfile;	/* Check to see that /etc/skey has not been disabled. */	if (stat(_PATH_SKEYDIR, &statbuf) != 0)		return (-1);	if ((statbuf.st_mode & ALLPERMS) == 0) {		errno = EPERM;		return (-1);	}	if (fd == -1) {		/* Open the user's databse entry, creating it as needed. */		if (snprintf(filename, sizeof(filename), "%s/%s", _PATH_SKEYDIR,		    name) >= sizeof(filename)) {			errno = ENAMETOOLONG;			return (-1);		}		if ((fd = open(filename, O_RDWR | O_NOFOLLOW | O_NONBLOCK,		    S_IRUSR | S_IWUSR)) == -1) {			if (errno == ENOENT)				goto not_found;			return (-1);		}	}	/* Lock and stat the user's skey file. */	if (flock(fd, LOCK_EX) != 0 || fstat(fd, &statbuf) != 0) {		close(fd);		return (-1);	}	if (statbuf.st_size == 0)		goto not_found;	/* Sanity checks. */	if ((statbuf.st_mode & ALLPERMS) != (S_IRUSR | S_IWUSR) ||	    !S_ISREG(statbuf.st_mode) || statbuf.st_nlink != 1 ||	    (keyfile = fdopen(fd, "r+")) == NULL) {		close(fd);		return (-1);	}	/* At this point, we are committed. */	mp->keyfile = keyfile;	if ((nread = fread(mp->buf, 1, sizeof(mp->buf), keyfile)) == 0 ||	    !isspace((unsigned char)mp->buf[nread - 1]))		goto bad_keyfile;	mp->buf[nread - 1] = '/0';	if ((mp->logname = strtok_r(mp->buf, " /t/n/r", &last)) == NULL ||	    strcmp(mp->logname, name) != 0)		goto bad_keyfile;	if ((cp = strtok_r(NULL, " /t/n/r", &last)) == NULL)		goto bad_keyfile;	if (skey_set_algorithm(cp) == NULL)		goto bad_keyfile;	if ((cp = strtok_r(NULL, " /t/n/r", &last)) == NULL)		goto bad_keyfile;	mp->n = strtonum(cp, 0, UINT_MAX, &errstr);	if (errstr)		goto bad_keyfile;	if ((mp->seed = strtok_r(NULL, " /t/n/r", &last)) == NULL)		goto bad_keyfile;	if ((mp->val = strtok_r(NULL, " /t/n/r", &last)) == NULL)		goto bad_keyfile;	(void)fseek(keyfile, 0L, SEEK_SET);	return (0);    bad_keyfile:	fclose(keyfile);	return (-1);    not_found:	/* No existing entry, fill in what we can and return */	memset(mp, 0, sizeof(*mp));	strlcpy(mp->buf, name, sizeof(mp->buf));	mp->logname = mp->buf;	if (fd != -1)		close(fd);	return (1);}
开发者ID:darksoul42,项目名称:bitrig,代码行数:97,


示例14: main

intmain(int argc, char **argv){	const char	*errstr;	char		*tmp, *s, *host;	int		 opt, i;	if (isatty(STDIN_FILENO) && tcgetattr(STDIN_FILENO, &saved_tio) != 0)		err(1, "tcgetattr");	/*	 * Convert obsolescent -### speed to modern -s### syntax which getopt()	 * can handle.	 */	for (i = 1; i < argc; i++) {		if (strcmp("--", argv[i]) == 0)			break;		if (argv[i][0] != '-' || !isdigit((unsigned char)argv[i][1]))			continue;		if (asprintf(&argv[i], "-s%s", &argv[i][1]) == -1)			errx(1, "speed asprintf");	}	while ((opt = getopt(argc, argv, "l:s:")) != -1) {		switch (opt) {		case 'l':			line_path = optarg;			break;		case 's':			line_speed = strtonum(optarg, 0, INT_MAX, &errstr);			if (errstr != NULL)				errx(1, "speed is %s: %s", errstr, optarg);			break;		default:			usage();		}	}	argc -= optind;	argv += optind;	if (argc != 0 && argc != 1)		usage();	if (argc == 1)		host = argv[0];	else		host = getenv("HOST");	if (host != NULL && *host != '/0') {		if (*host == '/')			line_path = host;		else {			s = getenv("REMOTE");			if (s != NULL && *s == '/')				try_remote(host, s, NULL);			else				try_remote(host, NULL, s);		}	}	if (line_path == NULL)		line_path = "/dev/cua00";	if (line_speed == -1)		line_speed = 9600;	if (strchr(line_path, '/') == NULL) {		if (asprintf(&tmp, "%s%s", _PATH_DEV, line_path) == -1)			err(1, "asprintf");		line_path = tmp;	}	line_fd = open(line_path, O_RDWR);	if (line_fd < 0)		err(1, "open(/"%s/")", line_path);	if (ioctl(line_fd, TIOCEXCL) != 0)		err(1, "ioctl(TIOCEXCL)");	if (tcgetattr(line_fd, &line_tio) != 0)		err(1, "tcgetattr");	if (set_line(line_speed) != 0)		err(1, "tcsetattr");	event_init();	signal_set(&sigterm_ev, SIGTERM, signal_event, NULL);	signal_add(&sigterm_ev, NULL);	signal_set(&sighup_ev, SIGHUP, signal_event, NULL);	signal_add(&sighup_ev, NULL);	if (signal(SIGINT, SIG_IGN) == SIG_ERR)		err(1, "signal");	if (signal(SIGQUIT, SIG_IGN) == SIG_ERR)		err(1, "signal");	set_termios(); /* after this use cu_err and friends */	/* stdin and stdout get separate events */	input_ev = bufferevent_new(STDIN_FILENO, stream_read, NULL,	    stream_error, NULL);	bufferevent_enable(input_ev, EV_READ);	output_ev = bufferevent_new(STDOUT_FILENO, NULL, NULL, stream_error,	    NULL);	bufferevent_enable(output_ev, EV_WRITE);//.........这里部分代码省略.........
开发者ID:appleorange1,项目名称:bitrig,代码行数:101,


示例15: intlink

intintlink(char *ifname, int ifs, int argc, char **argv){	const char *errmsg = NULL;	int set, i, flags, value = 0;	if (NO_ARG(argv[0])) {		set = 0;		argv++;		argc--;	} else		set = 1;	argv++;	argc--;	if ((set && argc < 1) || argc > 3) {		printf("%% link <012>/n");		printf("%% no link [012]/n");		return(0);	}	flags = get_ifflags(ifname, ifs);	if (!set && argc == 0) {		/*		 * just 'no link' was specified.  so we remove all flags		 */		flags &= ~IFF_LINK0 & ~IFF_LINK1 & ~IFF_LINK2;	} else 	for (i = 0; i < argc; i++) {		int a;		a = strtonum(argv[i], 0, 2, &errmsg);		if (errmsg) {			printf("%% Invalid link flag %s: %s/n", argv[i],			    errmsg);			return(0);		}		switch(a) {		case 0:			value = IFF_LINK0;			break;		case 1:			value = IFF_LINK1;			break;		case 2:			value = IFF_LINK2;			break;		}		if (set)			flags |= value;		else			flags &= ~value;	}	set_ifflags(ifname, ifs, flags);	return(0);}
开发者ID:yellowman,项目名称:nsh,代码行数:61,


示例16: intmedia

intintmedia(char *ifname, int ifs, int argc, char **argv){	const char *errmsg = NULL;	uint64_t set, media_current, type, subtype, inst;	if (NO_ARG(argv[0])) {		set = 0;		argc--;		argv++;	} else		set = 1;	argv++;	argc--;	if ((set && (argc < 1 || argc > 2)) || (!set && argc > 2)) {		printf("%% media <type> [instance]/n");		printf("%% no media [type] [instance]/n");		media_supported(ifs, ifname, "% ", "%   ");		return(0);	}	media_current = init_current_media(ifs, ifname);	if (media_current == -1) {		if (errno == EINVAL)			printf("%% This device does not support "			    "media commands./n");		else			printf("%% Failed to initialize media: %s/n",			    strerror(errno));		return(0);	}	if (argc == 2) {		inst = strtonum(argv[1], 0, IFM_INST_MAX, &errmsg);		if (errmsg) {			printf("%% Invalid media instance: %s: %s/n", argv[1],			    errmsg);			return(0);		}	} else {		inst = IFM_INST(media_current);	}	type = IFM_TYPE(media_current);	/* Look up the subtype */	if (set)		subtype = get_media_subtype(type, argv[0]);	else		subtype = get_media_subtype(type, DEFAULT_MEDIA_TYPE);	if (subtype == -1)		return(0);	/* Build the new media_current word */	media_current = IFM_MAKEWORD(type, subtype, 0, inst);	process_media_commands(ifs, ifname, media_current);	return(0);}
开发者ID:muhammadn,项目名称:nsh,代码行数:63,


示例17: intpflow

/* * addr/port parsing lifted from sbin/ifconfig/ifconfig.c */intintpflow(char *ifname, int ifs, int argc, char **argv){	struct ifreq ifr;	struct pflowreq preq;	int set;	const char *errmsg = NULL;	if (NO_ARG(argv[0])) {		set = 0;		argc--;		argv++;	} else		set = 1;	argc--;	argv++;	/* XXX fucking makes my eyes bleed. learn how to use yacc ? */	if ((set && argc < 4) || (set && argc == 5) || (set &&	    (argc == 4 || argc == 6) && (!isprefix(argv[0], "sender") ||	    !isprefix(argv[2], "receiver") ||	    (argc == 6 && !isprefix(argv[4], "version"))))) {		printf("%% pflow sender <x.x.x.x> receiver <x.x.x.x:port> "		    "[version 5|9|10]/n"		    "%% no pflow [sender x.x.x.x receiver x.x.x.x:port "		    "version 5|9|10]/n");		return(0);	}	if (set) {	        if (strchr(argv[3], ':') == NULL) {			printf("%% Receiver has no port specified/n");			return(0);		}	}	bzero(&ifr, sizeof(ifr));     	strlcpy(ifr.ifr_name, ifname, IFNAMSIZ);	bzero(&preq, sizeof(struct pflowreq));	ifr.ifr_data = (caddr_t)&preq;	preq.addrmask = PFLOW_MASK_SRCIP | PFLOW_MASK_DSTIP;	if (set) {		pflow_addr(argv[1], &preq.flowsrc);		pflow_addr(argv[3], &preq.flowdst);		if (argc == 6) {			preq.version = strtonum(argv[5], 5, PFLOW_PROTO_MAX,			    &errmsg);			preq.addrmask |= PFLOW_MASK_VERSION;	                if (errmsg) {				printf("%% Invalid pflow version %s: %s/n",				    argv[0], errmsg);				return(0);			}                }	}	if (ioctl(ifs, SIOCSETPFLOW, (caddr_t)&ifr) == -1)		printf("%% Unable to set pflow parameters: %s/n",		    strerror(errno));	return(0);}
开发者ID:yellowman,项目名称:nsh,代码行数:68,


示例18: cmd_resize_pane_down_exec

intcmd_resize_pane_down_exec(struct cmd *self, struct cmd_ctx *ctx){	struct cmd_pane_data	*data = self->data;	struct winlink		*wl;	const char	       	*errstr;	struct window_pane	*wp, *wq;	u_int			 adjust;		if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL)		return (-1);	if (wl->window->layout != 0) {		ctx->error(ctx, "window not in manual layout");		return (-1);	}	if (data->pane == -1)		wp = wl->window->active;	else {		wp = window_pane_at_index(wl->window, data->pane);		if (wp == NULL) {			ctx->error(ctx, "no pane: %d", data->pane);			return (-1);		}	}	if (data->arg == NULL)		adjust = 1;	else {		adjust = strtonum(data->arg, 1, INT_MAX, &errstr);		if (errstr != NULL) {			ctx->error(ctx, "adjustment %s: %s", errstr, data->arg);			return (-1);		}	}	/*	 * If this is not the last window, keep trying to increase size and	 * remove it from the next windows. If it is the last, do so on the	 * previous window.	 */	if (TAILQ_NEXT(wp, entry) == NULL) {		if (wp == TAILQ_FIRST(&wl->window->panes)) {			/* Only one pane. */			return (0);		}		wp = TAILQ_PREV(wp, window_panes, entry);	}	while (adjust-- > 0) {		wq = wp;		while ((wq = TAILQ_NEXT(wq, entry)) != NULL) {			if (wq->sy > PANE_MINIMUM) {				window_pane_resize(wq, wq->sx, wq->sy - 1);				break;			}		}		if (wq == NULL)			break;		window_pane_resize(wp, wp->sx, wp->sy + 1);	}	window_update_panes(wl->window);	server_redraw_window(wl->window);	return (0);}
开发者ID:ThomasAdam,项目名称:tmux-ARCHIVED,代码行数:66,


示例19: DDX_Control

void CAreaSong::DoDataExchange(CDataExchange* pDX){  CString tmpstr;	CDialog::DoDataExchange(pDX);	//{{AFX_DATA_MAP(CAreaSong)	DDX_Control(pDX, IDC_ALT5, m_alt5control);	DDX_Control(pDX, IDC_ALT4, m_alt4control);	DDX_Control(pDX, IDC_ALT3, m_alt3control);	DDX_Control(pDX, IDC_ALT2, m_alt2control);	DDX_Control(pDX, IDC_ALT1, m_alt1control);	DDX_Control(pDX, IDC_BATTLE, m_battlecontrol);	DDX_Control(pDX, IDC_UNKNOWN2, m_u2control);	DDX_Control(pDX, IDC_UNKNOWN1, m_u1control);	DDX_Control(pDX, IDC_NIGHT, m_nightcontrol);	DDX_Control(pDX, IDC_DAY, m_daycontrol);	//}}AFX_DATA_MAP  tmpstr=get_songname(the_area.songheader.songs[0]);  DDX_Text(pDX, IDC_DAY, tmpstr);  the_area.songheader.songs[0]=strtonum(tmpstr);  tmpstr=get_songname(the_area.songheader.songs[1]);  DDX_Text(pDX, IDC_NIGHT, tmpstr);  the_area.songheader.songs[1]=strtonum(tmpstr);  tmpstr=get_songname(the_area.songheader.songs[2]);  DDX_Text(pDX, IDC_UNKNOWN1, tmpstr);  the_area.songheader.songs[2]=strtonum(tmpstr);  tmpstr=get_songname(the_area.songheader.songs[3]);  DDX_Text(pDX, IDC_BATTLE, tmpstr);  the_area.songheader.songs[3]=strtonum(tmpstr);  tmpstr=get_songname(the_area.songheader.songs[4]);  DDX_Text(pDX, IDC_UNKNOWN2,tmpstr);  the_area.songheader.songs[4]=strtonum(tmpstr);  tmpstr=get_songname(the_area.songheader.songs[5]);  DDX_Text(pDX, IDC_ALT1,tmpstr);  the_area.songheader.songs[5]=strtonum(tmpstr);  tmpstr=get_songname(the_area.songheader.songs[6]);  DDX_Text(pDX, IDC_ALT2,tmpstr);  the_area.songheader.songs[6]=strtonum(tmpstr);  tmpstr=get_songname(the_area.songheader.songs[7]);  DDX_Text(pDX, IDC_ALT3,tmpstr);  the_area.songheader.songs[7]=strtonum(tmpstr);  tmpstr=get_songname(the_area.songheader.songs[8]);  DDX_Text(pDX, IDC_ALT4,tmpstr);  the_area.songheader.songs[8]=strtonum(tmpstr);  tmpstr=get_songname(the_area.songheader.songs[9]);  DDX_Text(pDX, IDC_ALT5,tmpstr);  the_area.songheader.songs[9]=strtonum(tmpstr);  /*  DDX_Text(pDX, IDC_UNKNOWN3, the_area.songheader.songs[5]);  DDX_Text(pDX, IDC_UNKNOWN4, the_area.songheader.songs[6]);  DDX_Text(pDX, IDC_UNKNOWN5, the_area.songheader.songs[7]);  DDX_Text(pDX, IDC_UNKNOWN6, the_area.songheader.songs[8]);  DDX_Text(pDX, IDC_UNKNOWN7, the_area.songheader.songs[9]);*/  RetrieveResref(tmpstr,the_area.songheader.dayambi1);  DDX_Text(pDX, IDC_AMBI1D, tmpstr);  DDV_MaxChars(pDX, tmpstr, 8);  StoreResref(tmpstr,the_area.songheader.dayambi1);  RetrieveResref(tmpstr,the_area.songheader.dayambi2);  DDX_Text(pDX, IDC_AMBI2D, tmpstr);  DDV_MaxChars(pDX, tmpstr, 8);  StoreResref(tmpstr,the_area.songheader.dayambi2);  RetrieveResref(tmpstr,the_area.songheader.nightambi1);  DDX_Text(pDX, IDC_AMBI1N, tmpstr);  DDV_MaxChars(pDX, tmpstr, 8);  StoreResref(tmpstr,the_area.songheader.nightambi1);  RetrieveResref(tmpstr,the_area.songheader.nightambi2);  DDX_Text(pDX, IDC_AMBI2N, tmpstr);  DDV_MaxChars(pDX, tmpstr, 8);  StoreResref(tmpstr,the_area.songheader.nightambi2);  DDX_Text(pDX, IDC_VOLUMED, the_area.songheader.volumed);  DDX_Text(pDX, IDC_VOLUMEN, the_area.songheader.volumen);  DDX_Text(pDX, IDC_FLAGS, the_area.songheader.songflag);}
开发者ID:TeoTwawki,项目名称:dltcep,代码行数:87,


示例20: cmd_new_session_exec

//.........这里部分代码省略.........	 * the terminal as that calls tcsetattr() to prepare for tmux taking	 * over.	 */	if (!detached && !already_attached && c->tty.fd != -1) {		if (server_client_check_nested(cmdq->client)) {			cmdq_error(cmdq, "sessions should be nested with care, "			    "unset $TMUX to force");			return (CMD_RETURN_ERROR);		}		if (tcgetattr(c->tty.fd, &tio) != 0)			fatal("tcgetattr failed");		tiop = &tio;	} else		tiop = NULL;	/* Open the terminal if necessary. */	if (!detached && !already_attached) {		if (server_client_open(c, &cause) != 0) {			cmdq_error(cmdq, "open terminal failed: %s", cause);			free(cause);			goto error;		}	}	/* Find new session size. */	if (c != NULL) {		sx = c->tty.sx;		sy = c->tty.sy;	} else {		sx = 80;		sy = 24;	}	if (detached && args_has(args, 'x')) {		sx = strtonum(args_get(args, 'x'), 1, USHRT_MAX, &errstr);		if (errstr != NULL) {			cmdq_error(cmdq, "width %s", errstr);			goto error;		}	}	if (detached && args_has(args, 'y')) {		sy = strtonum(args_get(args, 'y'), 1, USHRT_MAX, &errstr);		if (errstr != NULL) {			cmdq_error(cmdq, "height %s", errstr);			goto error;		}	}	if (sy > 0 && options_get_number(global_s_options, "status"))		sy--;	if (sx == 0)		sx = 1;	if (sy == 0)		sy = 1;	/* Figure out the command for the new window. */	argc = -1;	argv = NULL;	if (!args_has(args, 't') && args->argc != 0) {		argc = args->argc;		argv = args->argv;	} else if (target == NULL) {		cmd = options_get_string(global_s_options, "default-command");		if (cmd != NULL && *cmd != '/0') {			argc = 1;			argv = &cmd;		} else {			argc = 0;
开发者ID:abergmann,项目名称:tmate-slave,代码行数:67,


示例21: pkg_sshserve

intpkg_sshserve(int fd){	struct stat st;	char *line = NULL;	char *file, *age;	size_t linecap = 0, r;	ssize_t linelen;	time_t mtime = 0;	const char *errstr;	int ffd;	char buf[BUFSIZ];	char fpath[MAXPATHLEN];	const char *restricted = NULL;	restricted = pkg_object_string(pkg_config_get("SSH_RESTRICT_DIR"));	printf("ok: pkg "PKGVERSION"/n");	for (;;) {		if ((linelen = getline(&line, &linecap, stdin)) <= 0)			continue;		/* trim cr */		if (line[linelen - 1] == '/n')			line[linelen - 1] = '/0';		if (strcmp(line, "quit") == 0)			return (EPKG_OK);		if (strncmp(line, "get ", 4) != 0) {			printf("ko: unknown command '%s'/n", line);			continue;		}		file = line + 4;		if (*file == '/')			file++;		age = file;		while (!isspace(*age)) {			if (*age == '/0') {				age = NULL;				break;			}			age++;		}		if (age == NULL) {			printf("ko: bad command get, expecting 'get file age'/n");			continue;		}		*age = '/0';		age++;		while (isspace(*age)) {			if (*age == '/0') {				age = NULL;				break;			}			age++;		}		if (age == NULL) {			printf("ko: bad command get, expecting 'get file age'/n");			continue;		}		mtime = strtonum(age, 0, LONG_MAX, &errstr);		if (errstr) {			printf("ko: bad number %s: %s/n", age, errstr);			continue;		}#ifdef HAVE_CAPSICUM		if (!cap_sandboxed() && restricted != NULL) {#else		if (restricted != NULL) {#endif			chdir(restricted);			file = realpath(file, fpath);			if (strncmp(file, restricted, strlen(restricted)) != 0) {				printf("ko: file not found/n");				continue;			}		}		if (fstatat(fd, file, &st, AT_SYMLINK_NOFOLLOW) == -1) {			printf("ko: file not found/n");			continue;		}		if (!S_ISREG(st.st_mode)) {			printf("ko: not a file/n");			continue;		}		if (st.st_mtime <= mtime) {			printf("ok: 0/n");//.........这里部分代码省略.........
开发者ID:AlexanderThaller,项目名称:pkg,代码行数:101,


示例22: cmd_split_window_parse

intcmd_split_window_parse(struct cmd *self, int argc, char **argv, char **cause){	struct cmd_split_window_data	*data;	int				 opt;	const char			*errstr;	self->entry->init(self, 0);	data = self->data;	while ((opt = getopt(argc, argv, "dhl:p:t:v")) != -1) {		switch (opt) {		case 'd':			data->flag_detached = 1;			break;		case 'h':			data->flag_horizontal = 1;			break;		case 't':			if (data->target == NULL)				data->target = xstrdup(optarg);			break;		case 'l':			if (data->percentage != -1 || data->size != -1)				break;			data->size = strtonum(optarg, 1, INT_MAX, &errstr);			if (errstr != NULL) {				xasprintf(cause, "size %s", errstr);				goto error;			}			break;		case 'p':			if (data->size != -1 || data->percentage != -1)				break;			data->percentage = strtonum(optarg, 1, 100, &errstr);			if (errstr != NULL) {				xasprintf(cause, "percentage %s", errstr);				goto error;			}			break;		case 'v':			data->flag_horizontal = 0;			break;		default:			goto usage;		}	}	argc -= optind;	argv += optind;	if (argc != 0 && argc != 1)		goto usage;	if (argc == 1)		data->cmd = xstrdup(argv[0]);	return (0);usage:	xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage);error:	self->entry->free(self);	return (-1);}
开发者ID:ThomasAdam,项目名称:tmux-ARCHIVED,代码行数:64,


示例23: j_lookup

/* Convert % sequence to job * * If jobs are compiled in then this routine expects sigchld to be blocked. */static Job *j_lookup(const char *cp, int *ecodep){	Job		*j, *last_match;	const char	*errstr;	Proc		*p;	int		len, job = 0;	if (digit(*cp)) {		job = strtonum(cp, 1, INT_MAX, &errstr);		if (errstr) {			if (ecodep)				*ecodep = JL_NOSUCH;			return NULL;		}		/* Look for last_proc->pid (what $! returns) first... */		for (j = job_list; j != NULL; j = j->next)			if (j->last_proc && j->last_proc->pid == job)				return j;		/* ...then look for process group (this is non-POSIX),		 * but should not break anything (so FPOSIX isn't used).		 */		for (j = job_list; j != NULL; j = j->next)			if (j->pgrp && j->pgrp == job)				return j;		if (ecodep)			*ecodep = JL_NOSUCH;		return NULL;	}	if (*cp != '%') {		if (ecodep)			*ecodep = JL_INVALID;		return NULL;	}	switch (*++cp) {	case '/0': /* non-standard */	case '+':	case '%':		if (job_list != NULL)			return job_list;		break;	case '-':		if (job_list != NULL && job_list->next)			return job_list->next;		break;	case '0': case '1': case '2': case '3': case '4':	case '5': case '6': case '7': case '8': case '9':		job = strtonum(cp, 1, INT_MAX, &errstr);		if (errstr)			break;		for (j = job_list; j != NULL; j = j->next)			if (j->job == job)				return j;		break;	case '?':		/* %?string */		last_match = NULL;		for (j = job_list; j != NULL; j = j->next)			for (p = j->proc_list; p != NULL; p = p->next)				if (strstr(p->command, cp+1) != NULL) {					if (last_match) {						if (ecodep)							*ecodep = JL_AMBIG;						return NULL;					}					last_match = j;				}		if (last_match)			return last_match;		break;	default:		/* %string */		len = strlen(cp);		last_match = NULL;		for (j = job_list; j != NULL; j = j->next)			if (strncmp(cp, j->proc_list->command, len) == 0) {				if (last_match) {					if (ecodep)						*ecodep = JL_AMBIG;					return NULL;				}				last_match = j;			}		if (last_match)			return last_match;		break;	}	if (ecodep)		*ecodep = JL_NOSUCH;	return NULL;}
开发者ID:Open343,项目名称:bitrig,代码行数:97,


示例24: manconf_output

intmanconf_output(struct manoutput *conf, const char *cp, int fromfile){	const char *const toks[] = {	    "includes", "man", "paper", "style",	    "indent", "width", "fragment", "mdoc", "noval"	};	const char	*errstr;	char		*oldval;	size_t		 len, tok;	for (tok = 0; tok < sizeof(toks)/sizeof(toks[0]); tok++) {		len = strlen(toks[tok]);		if ( ! strncmp(cp, toks[tok], len) &&		    strchr(" =	", cp[len]) != NULL) {			cp += len;			if (*cp == '=')				cp++;			while (isspace((unsigned char)*cp))				cp++;			break;		}	}	if (tok < 6 && *cp == '/0') {		warnx("-O %s=?: Missing argument value", toks[tok]);		return -1;	}	if ((tok == 6 || tok == 7) && *cp != '/0') {		warnx("-O %s: Does not take a value: %s", toks[tok], cp);		return -1;	}	switch (tok) {	case 0:		if (conf->includes != NULL) {			oldval = mandoc_strdup(conf->includes);			break;		}		conf->includes = mandoc_strdup(cp);		return 0;	case 1:		if (conf->man != NULL) {			oldval = mandoc_strdup(conf->man);			break;		}		conf->man = mandoc_strdup(cp);		return 0;	case 2:		if (conf->paper != NULL) {			oldval = mandoc_strdup(conf->paper);			break;		}		conf->paper = mandoc_strdup(cp);		return 0;	case 3:		if (conf->style != NULL) {			oldval = mandoc_strdup(conf->style);			break;		}		conf->style = mandoc_strdup(cp);		return 0;	case 4:		if (conf->indent) {			mandoc_asprintf(&oldval, "%zu", conf->indent);			break;		}		conf->indent = strtonum(cp, 0, 1000, &errstr);		if (errstr == NULL)			return 0;		warnx("-O indent=%s is %s", cp, errstr);		return -1;	case 5:		if (conf->width) {			mandoc_asprintf(&oldval, "%zu", conf->width);			break;		}		conf->width = strtonum(cp, 58, 1000, &errstr);		if (errstr == NULL)			return 0;		warnx("-O width=%s is %s", cp, errstr);		return -1;	case 6:		conf->fragment = 1;		return 0;	case 7:		conf->mdoc = 1;		return 0;	case 8:		conf->noval = 1;		return 0;	default:		if (fromfile)			warnx("-O %s: Bad argument", cp);		return -1;	}	if (fromfile == 0)		warnx("-O %s=%s: Option already set to %s",		    toks[tok], cp, oldval);//.........这里部分代码省略.........
开发者ID:glasspelican,项目名称:illumos-joyent,代码行数:101,


示例25: main

intmain(int argc, const char *argv[]){	int		 fflag;	int		 wflag;	int		 ch;	char		*fname;	const char	*errstr;	char		*word1;	char		*word2;	setlocale(LC_ALL, "");	dflag = fflag = iflag = wflag = ch = 0;	fname = word1 = word2 = NULL;	if (argc < 3)		usage();	while ((ch = getopt(argc, (char *const *)argv, "d:f:iw:")) != -1) {		switch ((char)ch) {		case 'd': /* difference can be wdist <= distance */			dflag = 1;			wdist = strtonum(optarg, 0, 128, &errstr);			if (errstr)				errx(1, "Error: %s/nOut of range: %s", errstr, optarg);			break;		case 'f':			fflag = 1;			fname = optarg;			/* TODO add support to stdin */			break;		case 'i':			iflag = 1;			break;		case 'w':			wflag = 1;			word1 = optarg;			break;		case '?':			if (optopt == 'f')				(void)fprintf(stderr, "Missing file argument/n");			else if (optopt == 'w')				(void)fprintf(stderr, "Missing word argument/n");			exit(1);		default:			usage();		}	}	word2 = (char *const)argv[argc-1];	if (iflag) {		if (!fflag)			convertlowercase(word1, sizeof(word1));		convertlowercase(word2, sizeof(word2));	}	if (fflag)		comparefile(fname, word2, strlen(word2));	else if (wflag) {		int diff;		diff = levensteinDistance(word1, strlen(word1), word2, strlen(word2));		if (!dflag)			(void)fprintf(stdout, "%-10s %5s %2d/n", word1, word2, diff);		else if (diff <= wdist)			(void)fprintf(stdout, "%-10s %5s %2d/n", word1, word2, diff);	}	else		usage();	return (0);}
开发者ID:weezel,项目名称:spellcheck,代码行数:75,


示例26: s_client_main

ints_client_main(int argc, char **argv){	unsigned int off = 0, clr = 0;	SSL *con = NULL;	int s, k, width, state = 0, af = AF_UNSPEC;	char *cbuf = NULL, *sbuf = NULL, *mbuf = NULL;	int cbuf_len, cbuf_off;	int sbuf_len, sbuf_off;	fd_set readfds, writefds;	char *port = PORT_STR;	int full_log = 1;	char *host = SSL_HOST_NAME;	char *cert_file = NULL, *key_file = NULL;	int cert_format = FORMAT_PEM, key_format = FORMAT_PEM;	char *passarg = NULL, *pass = NULL;	X509 *cert = NULL;	EVP_PKEY *key = NULL;	char *CApath = NULL, *CAfile = NULL, *cipher = NULL;	int reconnect = 0, badop = 0, verify = SSL_VERIFY_NONE, bugs = 0;	int crlf = 0;	int write_tty, read_tty, write_ssl, read_ssl, tty_on, ssl_pending;	SSL_CTX *ctx = NULL;	int ret = 1, in_init = 1, i, nbio_test = 0;	int starttls_proto = PROTO_OFF;	int prexit = 0;	X509_VERIFY_PARAM *vpm = NULL;	int badarg = 0;	const SSL_METHOD *meth = NULL;	int socket_type = SOCK_STREAM;	BIO *sbio;	int mbuf_len = 0;	struct timeval timeout, *timeoutp;	const char *errstr = NULL;#ifndef OPENSSL_NO_ENGINE	char *engine_id = NULL;	char *ssl_client_engine_id = NULL;	ENGINE *ssl_client_engine = NULL;#endif	ENGINE *e = NULL;	char *servername = NULL;	tlsextctx tlsextcbp =	{NULL, 0};#ifndef OPENSSL_NO_NEXTPROTONEG	const char *next_proto_neg_in = NULL;#endif	char *sess_in = NULL;	char *sess_out = NULL;	struct sockaddr peer;	int peerlen = sizeof(peer);	int enable_timeouts = 0;	long socket_mtu = 0;	meth = SSLv23_client_method();	c_Pause = 0;	c_quiet = 0;	c_ign_eof = 0;	c_debug = 0;	c_msg = 0;	c_showcerts = 0;	if (((cbuf = malloc(BUFSIZZ)) == NULL) ||	    ((sbuf = malloc(BUFSIZZ)) == NULL) ||	    ((mbuf = malloc(BUFSIZZ + 1)) == NULL)) {	/* NUL byte */		BIO_printf(bio_err, "out of memory/n");		goto end;	}	verify_depth = 0;	verify_error = X509_V_OK;	c_nbio = 0;	argc--;	argv++;	while (argc >= 1) {		if (strcmp(*argv, "-host") == 0) {			if (--argc < 1)				goto bad;			host = *(++argv);		} else if (strcmp(*argv, "-port") == 0) {			if (--argc < 1)				goto bad;			port = *(++argv);			if (port == NULL || *port == '/0')				goto bad;		} else if (strcmp(*argv, "-connect") == 0) {			if (--argc < 1)				goto bad;			if (!extract_host_port(*(++argv), &host, NULL, &port))				goto bad;		} else if (strcmp(*argv, "-verify") == 0) {			verify = SSL_VERIFY_PEER;			if (--argc < 1)				goto bad;			verify_depth = strtonum(*(++argv), 0, INT_MAX, &errstr);			if (errstr)				goto bad;			BIO_printf(bio_err, "verify depth is %d/n", verify_depth);		} else if (strcmp(*argv, "-cert") == 0) {			if (--argc < 1)//.........这里部分代码省略.........
开发者ID:Basskrapfen,项目名称:openbsd,代码行数:101,


示例27: expand_builtin

/* * expand_builtin - evaluate built-in macros. */voidexpand_builtin(const char *argv[], int argc, int td){	int c, n;	int ac;	static int sysval = 0;#ifdef DEBUG	printf("argc = %d/n", argc);	for (n = 0; n < argc; n++)		printf("argv[%d] = %s/n", n, argv[n]);	fflush(stdout);#endif /*  * if argc == 3 and argv[2] is null, then we  * have macro-or-builtin() type call. We adjust  * argc to avoid further checking..  */ /* we keep the initial value for those built-ins that differentiate  * between builtin() and builtin.  */	ac = argc;	if (argc == 3 && !*(argv[2]) && !mimic_gnu)		argc--;	switch (td & TYPEMASK) {	case DEFITYPE:		if (argc > 2)			dodefine(argv[2], (argc > 3) ? argv[3] : null);		break;	case PUSDTYPE:		if (argc > 2)			dopushdef(argv[2], (argc > 3) ? argv[3] : null);		break;	case DUMPTYPE:		dodump(argv, argc);		break;	case TRACEONTYPE:		dotrace(argv, argc, 1);		break;	case TRACEOFFTYPE:		dotrace(argv, argc, 0);		break;	case EXPRTYPE:	/*	 * doexpr - evaluate arithmetic	 * expression	 */	{		int base = 10;		int maxdigits = 0;		const char *errstr;		if (argc > 3) {			base = strtonum(argv[3], 2, 36, &errstr);			if (errstr) {				m4errx(1, "expr: base %s invalid.", argv[3]);			}		}		if (argc > 4) {			maxdigits = strtonum(argv[4], 0, INT_MAX, &errstr);			if (errstr) {				m4errx(1, "expr: maxdigits %s invalid.", argv[4]);			}		}		if (argc > 2)			pbnumbase(expr(argv[2]), base, maxdigits);		break;	}	case IFELTYPE:		if (argc > 4)			doifelse(argv, argc);		break;	case IFDFTYPE:	/*	 * doifdef - select one of two	 * alternatives based on the existence of	 * another definition	 */		if (argc > 3) {			if (lookup_macro_definition(argv[2]) != NULL)				pbstr(argv[3]);			else if (argc > 4)				pbstr(argv[4]);		}		break;//.........这里部分代码省略.........
开发者ID:coyizumi,项目名称:cs111,代码行数:101,


示例28: main

intmain(int argc, char *argv[]){	static char dot[] = ".", *dotav[] = {dot, NULL};	struct winsize win;	int ch, fts_options, notused;	char *p;	const char *errstr = NULL;#ifdef COLORLS	char termcapbuf[1024];	/* termcap definition buffer */	char tcapbuf[512];	/* capability buffer */	char *bp = tcapbuf;#endif	(void)setlocale(LC_ALL, "");	/* Terminal defaults to -Cq, non-terminal defaults to -1. */	if (isatty(STDOUT_FILENO)) {		termwidth = 80;		if ((p = getenv("COLUMNS")) != NULL && *p != '/0')			termwidth = strtonum(p, 0, INT_MAX, &errstr);		else if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &win) != -1 &&		    win.ws_col > 0)			termwidth = win.ws_col;		f_nonprint = 1;	} else {		f_singlecol = 1;		/* retrieve environment variable, in case of explicit -C */		p = getenv("COLUMNS");		if (p)			termwidth = strtonum(p, 0, INT_MAX, &errstr);	}	if (errstr)		termwidth = 80;	fts_options = FTS_PHYSICAL;	if (getenv("LS_SAMESORT"))		f_samesort = 1;	argc = xo_parse_args(argc, argv);	if (argc < 0)		return (1);	xo_set_flags(NULL, XOF_COLUMNS);	while ((ch = getopt(argc, argv,	    "1ABCD:FGHILPRSTUWXZabcdfghiklmnopqrstuwxy,")) != -1) {		switch (ch) {		/*		 * The -1, -C, -x and -l options all override each other so		 * shell aliasing works right.		 */		case '1':			f_singlecol = 1;			f_longform = 0;			f_stream = 0;			break;		case 'C':			f_sortacross = f_longform = f_singlecol = 0;			break;		case 'l':			f_longform = 1;			f_singlecol = 0;			f_stream = 0;			break;		case 'x':			f_sortacross = 1;			f_longform = 0;			f_singlecol = 0;			break;		/* The -c, -u, and -U options override each other. */		case 'c':			f_statustime = 1;			f_accesstime = 0;			f_birthtime = 0;			break;		case 'u':			f_accesstime = 1;			f_statustime = 0;			f_birthtime = 0;			break;		case 'U':			f_birthtime = 1;			f_accesstime = 0;			f_statustime = 0;			break;		case 'f':			f_nosort = 1;		       /* FALLTHROUGH */		case 'a':			fts_options |= FTS_SEEDOT;			/* FALLTHROUGH */		case 'A':			f_listdot = 1;			break;		/* The -t and -S options override each other. */		case 'S':			f_sizesort = 1;			f_timesort = 0;			break;//.........这里部分代码省略.........
开发者ID:newdispatcher,项目名称:freebsd,代码行数:101,


示例29: main

intmain(int argc, char *argv[]){	double		x;	double		y;	long		i;	unsigned int	mask = 0;	int		n = 0;	int		ch;	const	char	*errstr;	while ((ch = getopt(argc, argv, "rb:w:cs:np:")) != -1)		switch (ch) {		case 'r':			randomize = true;			break;		case 'c':			chardata = true;			break;		case 'n':			finalnl = false;			break;		case 'b':			boring = true;			if (strlcpy(format, optarg, sizeof(format)) >=			    sizeof(format))				errx(1, "-b word too long");			break;		case 'w':			if (strlcpy(format, optarg, sizeof(format)) >=			    sizeof(format))				errx(1, "-w word too long");			break;		case 's':			if (strlcpy(sepstring, optarg, sizeof(sepstring)) >=			    sizeof(sepstring))				errx(1, "-s word too long");			break;		case 'p':			prec = strtonum(optarg, 0, INT_MAX, &errstr);			if (errstr != NULL)				errx(1, "bad precision value, %s: %s", errstr, 					optarg);			break;		default:			usage();		}	argc -= optind;	argv += optind;	switch (argc) {	/* examine args right to left, falling thru cases */	case 4:		if (!is_default(argv[3])) {			if (!sscanf(argv[3], "%lf", &s))				errx(1, "Bad s value:  %s", argv[3]);			mask |= 01;			if (randomize)				warnx("random seeding not supported");		}	case 3:		if (!is_default(argv[2])) {			if (!sscanf(argv[2], "%lf", &ender))				ender = argv[2][strlen(argv[2])-1];			mask |= 02;			if (prec == -1)				n = getprec(argv[2]);		}	case 2:		if (!is_default(argv[1])) {			if (!sscanf(argv[1], "%lf", &begin))				begin = argv[1][strlen(argv[1])-1];			mask |= 04;			if (prec == -1)				prec = getprec(argv[1]);			if (n > prec)		/* maximum precision */				prec = n;		}	case 1:		if (!is_default(argv[0])) {			if (!sscanf(argv[0], "%ld", &reps))				errx(1, "Bad reps value:  %s", argv[0]);			mask |= 010;			if (prec == -1)				prec = 0;		}		break;	case 0:		usage();		break;	default:		errx(1, "Too many arguments.  What do you mean by %s?",		    argv[4]);	}	getformat();	while (mask)	/* 4 bit mask has 1's where last 4 args were given */		switch (mask) {	/* fill in the 0's by default or computation */		case 001:			reps = REPS_DEF;			mask = 011;			break;//.........这里部分代码省略.........
开发者ID:repos-holder,项目名称:openbsd-patches,代码行数:101,



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


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