home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d1xx / d109 / uupc.lha / UUpc / Source / getargs.c < prev    next >
C/C++ Source or Header  |  1987-10-28  |  880b  |  48 lines

  1.  
  2. #include <stdio.h>
  3.  
  4. getargs(cp, flds)
  5. register char *cp;
  6. char *flds[];
  7. {
  8.     register int count = 0;
  9.  
  10.     while ( *cp != '\0' ) {
  11.         while ( *cp == ' ' || *cp == '\t')
  12.             *cp++ = '\0';
  13.         if (*cp == '\n')
  14.             *cp = '\0';
  15.         if (*cp != '\0' ) {
  16.             flds[count++] = cp;
  17.             while (*cp != ' ' && *cp != '\t' &&
  18.                      *cp != '\n' && *cp != '\0' )
  19.                 cp++;
  20.         }
  21.     }
  22.     flds[count] = NULL;
  23.     return(count);
  24. }
  25.  
  26. #ifdef testtoken
  27.     /* tokenize command line */
  28.     while ( *cp != '\0' ) {
  29.         /*debuglevelMsg("\PCheck isspace(*cp++)");*/
  30.         if ( isspace(*cp) ) {
  31.             /* terminate previous token */
  32.             *cp++ = '\0';
  33.             /* eat white space */
  34.             while ( isspace(*cp) ) cp++;
  35.         }
  36.         else {
  37.             /* put address of token into argv, inc argc */
  38.             *argvp++ = cp;
  39.             argcp++;
  40.             fprintf( stderr, "shell: token %s\n", cp );
  41.             /*debuglevelMsg("\PCheck !isspace(*cp++)");*/
  42.             while ( !isspace(*cp) ) cp++;
  43.             
  44.         }
  45.     }
  46. #endif
  47.  
  48.