⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ipfe.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 5 页
字号:
 *	get_cmd_args:		get cmd_line arguments *	gca:			label for editing * ****************************************************************/get_cmd_args(argc, argv)	int	argc;	char	*argv[];{	long	val, val1, d;	int	arg, opt, opt_len, ch_ctr, neg_flag, sep_flag, retcd;	int	err_flag = FLAG_OFF;	char	ch, sep_char, msg[128];		for (arg=1; arg < argc; arg++)	/* look for cmd_arguments */	{	    switch		(argv[arg][0])	    {		case ('-'):		    opt_len = strlen(argv[arg]);  /* because arg can be */						  /*   modified below   */		    for (opt=1; opt < opt_len; opt++)		    {			switch			    (argv[arg][opt])			{			    case ('-'):				opt = opt_len;	/* to handle '--' switch */				break;			    case ('a'):				if  (strlen(&(argv[arg][opt])) > 1)				    ++opt;				else				{				    ++arg;				    opt = 0;				    opt_len = strlen(argv[arg]);				}				proc_alias(&(argv[arg][opt]));				opt = opt_len;	/* to get out of loop */				break;			    case ('b'):				if  (strlen(&(argv[arg][opt])) > 1)				    ++opt;				else				{				    ++arg;				    opt = 0;				    opt_len = strlen(argv[arg]);				}/* *  binding offset:unit */				val = val1 = d = ch_ctr = 0;				neg_flag = FLAG_OFF;				while				    (opt < opt_len)				{				    ch = argv[arg][opt++];				    if  ((ch == '-') && (ch_ctr == 0))					neg_flag = FLAG_ON;				    else				    if ((ch >= '0') && (ch <= '9'))				    {					ch = ch - '0';					if  (d == 0)					    val = (val * 10) + ch;					else					if  (d <= 1000)  /* prec = 10**(-3)							    truncated */					{					    val1 = (val1 * 10) + ch;					    d = d * 10;					}				    }				    else				    if (ch == '.')					d = 1;				    else				    {					if  ((ch == ':') && (opt < opt_len))					    ch = argv[arg][opt++];					break;		/* exit loop */				    }				    ++ch_ctr;				}/*				end while (opt < opt_len) */				if  (d == 0)				    d = 1;				else				    val = (val * d) + val1;				if  (val != 0)				{				    if  (neg_flag == FLAG_ON)					val = -(val);				    switch					(ch)				    {					case ('c'):					    d = d * 100;					    break;					case ('i'):					    val = val * 254;					    d = d * 10000;					    break;					case ('p'):					    val = val * 254;					    d = ((d * 720000) & 0x7fffffff);					    break;					case ('P'):					    val = val * 254;					    d = ((d * 60000) & 0x7fffffff);					    break;					default:					    d = d * 100;  /* def=cm */					    break;				    }/*				    end switch (ch) */				    if  (d != 0)  /* last chk for div						     by 0 just in case						     of ovflw */				    {					boff_num = val;					boff_den = d;					proc_flag[BINDING_OFFSET] =						FLAG_ON;				    }				}				else				{				    (void)sprintf(msg,		"--ipfe:  No binding offset value specified in (%s)\n",						  argv[arg]);				    pip_error(msg);				    err_flag = FLAG_ON;				}				--opt;	/* to parse cur ch at cmd line */				break;			    case ('c'):				if  (strlen(&(argv[arg][opt])) > 1)				    ++opt;				else				{				    ++arg;				    opt = 0;				    opt_len = strlen(argv[arg]);				}				ch = val = 0;				while				    (opt < opt_len)				{				    ch = argv[arg][opt];				    if  ((ch >= '0') && (ch <= '9'))				    {					ch = ch - '0';					val = (val * 10) + ch;					++opt;				    }				    else					break;				}				if  (val == 0)				{				    (void)sprintf(msg,		      "--ipfe:  No length specified for chapterize in %s\n",					argv[arg]);				    pip_error(msg);				    err_flag = FLAG_ON;				}				else				{				    if  ((ch == ':') && (opt < opt_len))					ch = argv[arg][++opt];				    switch					(ch)				    {					case ('p'):					    proc_flag[CHAPTERIZE] = FLAG_ON;					    chap_type = CH_PAGES;					    chap_val = val;					    break;					case ('k'):					    proc_flag[CHAPTERIZE] = FLAG_ON;					    chap_type = CH_KBYTES;					    chap_val = val * 1024;					    break;					case ('m'):					    proc_flag[CHAPTERIZE] = FLAG_ON;					    chap_type = CH_MBYTES;					    chap_val = ((val * 1048576) &							0x7fffffff);					    break;					default:					    (void)sprintf(msg,			"--ipfe:  No unit specified for chapterize in %s\n",						argv[arg]);					    pip_error(msg);					    err_flag = FLAG_ON;					    --opt;	/* parse opt again */					    break;				    }				}				break;			    case ('d'):				proc_flag[DUPLEX] = FLAG_ON;				break;			    case ('D'):				proc_flag[DEBUG] = FLAG_ON;				break;			    case ('i'):				proc_flag[INSERT_OVLY] = FLAG_ON;				break;			    case ('l'):				proc_flag[PROC_LOG] = FLAG_ON;				if  (strlen(&(argv[arg][opt])) > 1)				    ++opt;				else				{				    ++arg;				    opt = 0;				    opt_len = strlen(argv[arg]);				}				ch = argv[arg][opt];				if  ((ch != ':') && (ch != '-'))				{				    logfilename = &(argv[arg][opt]);				    opt = opt_len;  /* to get out of lp */				}				open_logfile(argc, argv);				break;			    case ('L'):				rot_deg = 90;				rxoff_num = rxoff_den = 0;				ryoff_num = -(2794);				ryoff_den = 10000;				proc_flag[LANDSCAPE] = FLAG_ON;				break;			    case ('o'):				if  (strlen(&(argv[arg][opt])) > 1)				    outputname = &(argv[arg][opt+1]);				else				    outputname = argv[++arg];				opt = opt_len;	  /* to get out of loop */				break;			    case ('p'):				proc_flag[PROPERTIES] = FLAG_ON;				if  (strlen(&(argv[arg][opt])) > 1)				    ++opt;				else				{				    ++arg;				    opt = 0;				    opt_len = strlen(argv[arg]);				}				ch = argv[arg][opt];				if  ((ch != ':') && (ch != '-'))				{				    if  ((ch >= '0') && (ch <= '9'))				    {					prop_level = ch - '0';					++opt;					if  (argv[arg][opt] == ':')					    ++opt;					if  (opt < opt_len)					    propfname = &(argv[arg][opt]);					opt = opt_len;	/* to exit loop */				    }				    else				    {					(void)sprintf(msg,	    "--ipfe:  *** warning -- property level not specified in %s\n",						argv[arg]);					pip_error(msg);					err_flag = FLAG_ON;					propfname = &(argv[arg][opt]);					opt = opt_len;	/* to exit loop */				    }				}				break;			    case ('q'):				proc_flag[QUIET] = FLAG_ON;				break;			    case ('r'):				proc_flag[REMOVE_SIFS] = FLAG_ON;				break;			    case ('R'):				rot_deg = -(90);				rxoff_num = -(2477);	/* xOff = -(9 3/4") */				ryoff_num = -(318);	/* yOff = -(1 1/4") */				rxoff_den = ryoff_den = 10000;				proc_flag[ROTATE] = FLAG_ON;				break;			    case ('s'):				proc_flag[SATISFY_SIFS] = FLAG_ON;				break;			    case ('S'):				if  (strlen(&(argv[arg][opt])) > 1)				    ++opt;				else				{				    ++arg;				    opt = 0;				    opt_len = strlen(argv[arg]);				}/* *  scale */				val = val1 = d = ch_ctr = 0;				neg_flag = sep_flag = FLAG_OFF;				while				    (opt < opt_len)				{				    ch = argv[arg][opt++];				    if  ((ch == '-') && (ch_ctr == 0))					neg_flag = FLAG_ON;				    else				    if ((ch >= '0') && (ch <= '9'))				    {					ch = ch - '0';					if  (d == 0)					    val = (val * 10) + ch;					else					if  (d <= 1000)  /* prec = 10**(-3)							    truncated */					{					    val1 = (val1 * 10) + ch;					    d = d * 10;					}				    }				    else				    if ((ch == '.') || (ch == '/'))				    {					if  (sep_flag == FLAG_OFF)					{					    d = 1;					    sep_char = ch;					    sep_flag = FLAG_ON;					}					else					{					    (void)sprintf(msg,	"--ipfe:  Scale factor cannot have BOTH a '.' AND a '/' in (%s)\n",						  argv[arg]);					    pip_error(msg);					    err_flag = FLAG_ON;					    break;	/* exit loop */					}				    }				    else				    {					if  ((ch == ':') && (opt < opt_len))					    ch = argv[arg][opt++];					break;		/* exit loop */				    }				    ++ch_ctr;				}/*				end while (opt < opt_len) */				if  (d == 0)				    d = 1;				else				if  (sep_char == '/')				    d = val1;				else				    val = (val * d) + val1;				if  ((val != 0) && (err_flag == FLAG_OFF))				{				    if  (neg_flag == FLAG_ON)					val = -(val);				    if  (d != 0)  /* last chk for div						     by 0 just in case						     of ovflw */				    {					scale_num = val;					scale_den = d;					proc_flag[SCALE] = FLAG_ON;				    }				}				else				{				    (void)sprintf(msg,		"--ipfe:  No scale factor value specified in (%s)\n",						  argv[arg]);				    pip_error(msg);				    err_flag = FLAG_ON;				}				--opt;	/* to parse cur ch at cmd line */				break;			    case ('X'):				if  (strlen(&(argv[arg][opt])) > 1)				    ++opt;				else				{				    ++arg;				    opt = 0;				    opt_len = strlen(argv[arg]);				}/* *  xOffset:unit */				val = val1 = d = ch_ctr = 0;				neg_flag = FLAG_OFF;				while				    (opt < opt_len)				{				    ch = argv[arg][opt++];				    if  ((ch == '-') && (ch_ctr == 0))					neg_flag = FLAG_ON;				    else				    if ((ch >= '0') && (ch <= '9'))				    {					ch = ch - '0';					if  (d == 0)					    val = (val * 10) + ch;					else					if  (d <= 1000)  /* prec = 10**(-3)							    truncated */					{					    val1 = (val1 * 10) + ch;					    d = d * 10;					}				    }				    else				    if (ch == '.')				    {					d = 1;					val1 = 0;				    }				    else				    {					if  ((ch == ':') && (opt < opt_len))					    ch = argv[arg][opt++];					break;		/* exit loop */				    }				    ++ch_ctr;				}/*				end while (opt < opt_len) */				if  (d == 0)				    d = 1;				else				    val = (val * d) + val1;				if  (val != 0)				{				    if  (neg_flag == FLAG_ON)					val = -(val);				    switch					(ch)				    {					case ('c'):					    d = d * 100;					    break;					case ('i'):					    val = val * 254;					    d = d * 10000;					    break;					case ('p'):					    val = val * 254;					    d = ((d * 720000) & 0x7fffffff);					    break;					case ('P'):					    val = val * 254;					    d = ((d * 60000) & 0x7fffffff);					    break;					default:					    d = d * 100;  /* def=cm */					    break;				    }/*				    end switch (ch) */				    if  (d != 0)  /* last chk for div						     by 0 just in case						     of ovflw */				    {					xoff_num = val;					xoff_den = d;					proc_flag[X_OFFSET] = FLAG_ON;				    }				}				else				{				    (void)sprintf(msg,			"--ipfe:  No xOffset value specified in (%s)\n",						  argv[arg]);				    pip_error(msg);				    err_flag = FLAG_ON;				}				--opt;	/* to parse cur ch at cmd line */				break;			    case ('Y'):				if  (strlen(&(argv[arg][opt])) > 1)				    ++opt;				else				{				    ++arg;				    opt = 0;				    opt_len = strlen(argv[arg]);				}/* *  yOffset:unit */				val = val1 = d = ch_ctr = 0;				neg_flag = FLAG_OFF;				while				    (opt < opt_len)				{				    ch = argv[arg][opt++];				    if  ((ch == '-') && (ch_ctr == 0))					neg_flag = FLAG_ON;				    else				    if ((ch >= '0') && (ch <= '9'))				    {					ch = ch - '0';					if  (d == 0)					    val = (val * 10) + ch;					else					if  (d <= 1000)  /* prec = 10**(-3)							    truncated */					{					    val1 = (val1 * 10) + ch;					    d = d * 10;					}				    }				    else				    if (ch == '.')				    {					d = 1;					val1 = 0;				    }				    else				    {					if  ((ch == ':') && (opt < opt_len))					    ch = argv[arg][opt++];					break;		/* exit loop */				    }				    ++ch_ctr;				}/*				end while (opt < opt_len) */				if  (d == 0)				    d = 1;				else				    val = (val * d) + val1;				if  (val != 0)				{				    if  (neg_flag == FLAG_ON)					val = -(val);				    switch					(ch)				    {					case ('c'):					    d = d * 100;					    break;					case ('i'):					    val = val * 254;					    d = d * 10000;

⌨️ 快捷键说明

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