source: trunk/minix/commands/yap/options.c@ 11

Last change on this file since 11 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 1.4 KB
Line 
1/* Copyright (c) 1985 Ceriel J.H. Jacobs */
2
3# ifndef lint
4static char rcsid[] = "$Header: /cvsup/minix/src/commands/yap/options.c,v 1.1.1.1 2005/04/21 14:55:40 beng Exp $";
5# endif
6
7# define _OPTIONS_
8
9# include "in_all.h"
10# include "options.h"
11# include "output.h"
12# include "display.h"
13# include <ctype.h>
14
15STATIC int parsopt();
16char *getenv();
17
18/*
19 * Read the options. Return the argv pointer following them if there were
20 * no errors, otherwise return 0.
21 */
22
23char **
24readoptions(argv) char ** argv; {
25
26 register char ** av = argv+1;
27 register char *p;
28
29 if (p = getenv("YAP")) {
30 (VOID) parsopt(p);
31 }
32 while (*av && **av == '-') {
33 if (parsopt(*av)) {
34 /*
35 * Error in option
36 */
37 putline(*av);
38 putline(": illegal option\n");
39 return (char **) 0;
40 }
41 av++;
42 }
43 if (*av && **av == '+') {
44 /*
45 * Command in command line
46 */
47 startcomm = *av + 1;
48 av++;
49 }
50 return av;
51}
52
53STATIC int
54parsopt(s) register char *s; {
55 register i;
56
57 if (*s == '-') s++;
58 if (isdigit(*s)) {
59 /*
60 * pagesize option
61 */
62 i = 0;
63 do {
64 i = i * 10 + *s++ - '0';
65 } while (isdigit(*s));
66 if (i < MINPAGESIZE) i = MINPAGESIZE;
67 pagesize = i;
68 }
69 while (*s) {
70 switch(*s++) {
71 case 'c' :
72 cflag++;
73 break;
74 case 'n' :
75 nflag++;
76 break;
77 case 'u' :
78 uflag++;
79 break;
80 case 'q' :
81 qflag++;
82 break;
83 default :
84 return 1;
85 }
86 }
87 return 0;
88}
Note: See TracBrowser for help on using the repository browser.