#ifndef lint static char sccsid[] = "@(#)getprm.c 5.1 (Berkeley) 7/2/83"; #endif #include #define LQUOTE '(' #define RQUOTE ')' #define NOSYSPART 0 #define HASSYSPART 1 /******* * char * * getprm(s, prm) get next parameter from s * char *s, *prm; * * return - pointer to next character in s */ char * getprm(s, prm) register char *s, *prm; { register char *c; char *index(); while (*s == ' ' || *s == '\t' || *s == '\n') s++; *prm = '\0'; if (*s == '\0') return(NULL); if (*s == '>' || *s == '<' || *s == '|' || *s == ';' || *s == '&') { *prm++ = *s++; *prm = '\0'; return(s); } /* look for quoted argument */ if (*s == LQUOTE) { if ((c = index(s + 1, RQUOTE)) != NULL) { c++; while (c != s) *prm++ = *s++; *prm = '\0'; return(s); } } /* look for ` ` string */ if (*s == '`') { if ((c = index(s + 1, '`')) != NULL) { c++; while (c != s) *prm++ = *s++; *prm = '\0'; return(s); } } while (*s != ' ' && *s != '\t' && *s != '<' && *s != '>' && *s != '|' && *s != '\0' && *s != '&' && *s != ';' && *s != '\n') *prm++ = *s++; *prm = '\0'; return(s); } /*** * split(name, sys, rest) split into system and file part * char *name, *sys, *rest; * * return codes: * NOSYSPART * HASSYSPART */ split(name, sys, rest) register char *name, *rest; char *sys; { register char *c; char *index(), *strcpy(); int i; if (*name == LQUOTE) { if ((c = index(name + 1, RQUOTE)) != NULL) { /* strip off quotes */ name++; while (c != name) *rest++ = *name++; *rest = '\0'; *sys = '\0'; return(NOSYSPART); } } if ((c = index(name, '!')) == NULL) { strcpy(rest, name); *sys = '\0'; return(NOSYSPART); } *c = '\0'; for (i = 0; i < 7; i++) if ((*sys++ = *name++) == '\0') break; strcpy(rest, ++c); return(HASSYSPART); }