home *** CD-ROM | disk | FTP | other *** search
/ 17 Bit Software 1: Collection A / 17Bit_Collection_A.iso / files / 1112.dms / 1112.adf / ImageEd / Source / ImageBack.c < prev    next >
C/C++ Source or Header  |  1988-07-25  |  2KB  |  57 lines

  1. /*
  2.    ImageBack - code for background task of ImageEd.
  3.  
  4.    (c) 1990  Olaf Leimann
  5. */
  6.  
  7. #include <exec/types.h>
  8. #include <workbench/startup.h>
  9.  
  10. #define MAXARG 32              /* maximum command line arguments */
  11. #define QUOTE  '"'
  12. #define isspace(c)      ((c == ' ')||(c == '\t') || (c == '\n'))
  13.  
  14. long   _stack        = 4000 ;
  15. char  *_procname     = "Image Ed v1.0" ;
  16. long   _priority     = 0 ;
  17. long   _BackGroundIO = 0 ;
  18.  
  19. int    argc ;
  20. char **targv,
  21.       *argv[MAXARG];     /* arg pointers */
  22.  
  23. extern struct WBStartup *WBenchMsg;
  24. extern void              main(int,char **);
  25.  
  26. void _main(line)
  27.    register char *line;
  28. {
  29.    register char **pargv;
  30.    while (argc < MAXARG)
  31.         {
  32.         while (isspace(*line))  line++;
  33.         if (*line == '\0')      break;
  34.         pargv = &argv[argc++];
  35.         if (*line == QUOTE)
  36.                 {
  37.                 *pargv = ++line;  /* ptr inside quoted string */
  38.                 while ((*line != '\0') && (*line != QUOTE)) line++;
  39.                 if (*line == '\0')  _exit(1);
  40.                 else                *line++ = '\0';  /* terminate arg */
  41.                 }
  42.         else            /* non-quoted arg */
  43.                 {       
  44.                 *pargv = line;
  45.                 while ((*line != '\0') && (!isspace(*line))) line++;
  46.                 if (*line == '\0')  break;
  47.                 else                *line++ = '\0';  /* terminate arg */
  48.                 }
  49.         }  /* while */
  50.    targv = (argc == 0) ? (char **)WBenchMsg : (char **)&argv[0];
  51.  
  52.  
  53.    main(argc,targv);              /* call main function */
  54.    _exit(0);
  55. }
  56.  
  57.