Commit | Line | Data |
---|---|---|
b4f997bc | 1 | #ifndef lint |
916d13a9 | 2 | static char sccsid[] = "@(#)getprm.c 5.3 (Berkeley) %G%"; |
b4f997bc SL |
3 | #endif |
4 | ||
916d13a9 | 5 | #include "uucp.h" |
b4f997bc SL |
6 | |
7 | #define LQUOTE '(' | |
8 | #define RQUOTE ')' | |
9 | #define NOSYSPART 0 | |
10 | #define HASSYSPART 1 | |
11 | ||
916d13a9 | 12 | /*LINTLIBRARY*/ |
b4f997bc | 13 | |
46b15d8a RC |
14 | /* |
15 | * get next parameter from s | |
b4f997bc SL |
16 | * |
17 | * return - pointer to next character in s | |
18 | */ | |
19 | ||
20 | char * | |
21 | getprm(s, prm) | |
22 | register char *s, *prm; | |
23 | { | |
24 | register char *c; | |
b4f997bc SL |
25 | |
26 | while (*s == ' ' || *s == '\t' || *s == '\n') | |
27 | s++; | |
28 | ||
29 | *prm = '\0'; | |
30 | if (*s == '\0') | |
46b15d8a | 31 | return NULL; |
b4f997bc SL |
32 | |
33 | if (*s == '>' || *s == '<' || *s == '|' | |
34 | || *s == ';' || *s == '&') { | |
35 | *prm++ = *s++; | |
36 | *prm = '\0'; | |
46b15d8a | 37 | return s; |
b4f997bc SL |
38 | } |
39 | ||
40 | /* look for quoted argument */ | |
41 | if (*s == LQUOTE) { | |
42 | if ((c = index(s + 1, RQUOTE)) != NULL) { | |
43 | c++; | |
44 | while (c != s) | |
45 | *prm++ = *s++; | |
46 | *prm = '\0'; | |
46b15d8a | 47 | return s; |
b4f997bc SL |
48 | } |
49 | } | |
50 | ||
51 | /* look for ` ` string */ | |
52 | if (*s == '`') { | |
53 | if ((c = index(s + 1, '`')) != NULL) { | |
54 | c++; | |
55 | while (c != s) | |
56 | *prm++ = *s++; | |
57 | *prm = '\0'; | |
46b15d8a | 58 | return s; |
b4f997bc SL |
59 | } |
60 | } | |
61 | ||
62 | while (*s != ' ' && *s != '\t' && *s != '<' | |
46b15d8a RC |
63 | && *s != '>' && *s != '|' && *s != '\0' |
64 | && *s != '&' && *s != ';' && *s != '\n') | |
b4f997bc SL |
65 | *prm++ = *s++; |
66 | *prm = '\0'; | |
67 | ||
46b15d8a | 68 | return s; |
b4f997bc SL |
69 | } |
70 | ||
46b15d8a RC |
71 | /* |
72 | * split into system and file part | |
b4f997bc SL |
73 | * |
74 | * return codes: | |
75 | * NOSYSPART | |
76 | * HASSYSPART | |
77 | */ | |
78 | ||
79 | split(name, sys, rest) | |
80 | register char *name, *rest; | |
81 | char *sys; | |
82 | { | |
83 | register char *c; | |
916d13a9 | 84 | register int i; |
b4f997bc SL |
85 | |
86 | if (*name == LQUOTE) { | |
87 | if ((c = index(name + 1, RQUOTE)) != NULL) { | |
88 | /* strip off quotes */ | |
89 | name++; | |
90 | while (c != name) | |
91 | *rest++ = *name++; | |
92 | *rest = '\0'; | |
93 | *sys = '\0'; | |
46b15d8a | 94 | return NOSYSPART; |
b4f997bc SL |
95 | } |
96 | } | |
97 | ||
98 | if ((c = index(name, '!')) == NULL) { | |
99 | strcpy(rest, name); | |
100 | *sys = '\0'; | |
46b15d8a | 101 | return NOSYSPART; |
b4f997bc SL |
102 | } |
103 | ||
916d13a9 JB |
104 | *c++ = '\0'; |
105 | strncpy(sys, name, MAXBASENAME); | |
106 | sys[MAXBASENAME] = '\0'; | |
b4f997bc | 107 | |
916d13a9 | 108 | strcpy(rest, c); |
46b15d8a | 109 | return HASSYSPART; |
b4f997bc | 110 | } |