cliargs.c

来自「unix环境编程」· C语言 代码 · 共 52 行

C
52
字号
#include	"calld.h"/* * This function is called by buf_args(), which is called by loop(). * buf_args() has broken up the client's buffer into an argv[] style * array, which is now processed. */intcli_args(int argc, char **argv){	int		c;	if (argc < 2 || strcmp(argv[0], CL_CALL) != 0) {		strcpy(errmsg, "usage: call <options> <hostname>");		return(-1);	}	Debug = 0;		/* option defaults */	parity = NONE;	speed = NULL;	opterr = 0;		/* don't want getopt() writing to stderr */	optind = 1;		/* since we call getopt() multiple times */	while ((c = getopt(argc, argv, "des:o")) != EOF) {		switch (c) {		case 'd':			Debug = 1;	/* client wants DEBUG() output */			break;		case 'e':		/* even parity */			parity = EVEN;			break;		case 'o':		/* odd parity */			parity = ODD;			break;		case 's':		/* speed */			speed = optarg;			break;		case '?':			sprintf(errmsg, "unrecognized option: -%c\n", optopt);			return(-1);		}	}	if (optind >= argc) {		sprintf(errmsg, "missing <hostname> to call\n");		return(-1);	}	sysname = argv[optind];		/* name of host to call */	return(0);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?