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

Defined functions

getprm defined in line 21; used 6 times
split defined in line 82; used 2 times

Defined variables

sccsid defined in line 2; never used

Defined macros

HASSYSPART defined in line 10; used 1 times
LQUOTE defined in line 7; used 2 times
NOSYSPART defined in line 9; used 2 times
RQUOTE defined in line 8; used 2 times
Last modified: 1983-07-27
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 692
Valid CSS Valid XHTML 1.0 Strict