home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 3 / goldfish_volume_3.bin / files / gfx / misc / imagefx_sdk / sas / scanlib / argv.c next >
Encoding:
C/C++ Source or Header  |  1994-04-28  |  996 b   |  57 lines

  1. /*
  2.  * Scan an argc/argv array (as passed to a Hook) using 2.0 ReadArgs().
  3.  *
  4.  */
  5.  
  6. #include <exec/types.h>
  7. #include <exec/memory.h>
  8. #include <dos/rdargs.h>
  9. #include <clib/exec_protos.h>
  10. #include <clib/dos_protos.h>
  11. #include <string.h>
  12. #include <stdlib.h>
  13. #include <stdio.h>
  14. #include <ctype.h>
  15.  
  16.  
  17.  
  18. #define MAX_ARGS  (32)
  19.  
  20.  
  21.  
  22. struct RDArgs *ReadArgv (int argc, char **argv, char *template, LONG *array)
  23. {
  24.    char *buf;
  25.    struct RDArgs *rdargs, *rda;
  26.    int i;
  27.  
  28.    buf = AllocMem(4096, MEMF_CLEAR);
  29.    if (!buf) return(NULL);
  30.  
  31.    for (i = 1; i < argc; i++) {
  32.       strcat(buf, argv[i]);
  33.       strcat(buf, " ");
  34.    }
  35.    strcat(buf, "\n");
  36.  
  37.    rdargs = AllocDosObject(DOS_RDARGS, NULL);
  38.    if (rdargs == NULL) return(NULL);
  39.  
  40.    rdargs->RDA_Source.CS_Buffer = buf;
  41.    rdargs->RDA_Source.CS_Length = strlen(buf);
  42.  
  43.    rda = ReadArgs(template, array, rdargs);
  44.  
  45.    FreeMem(buf, 4096);
  46.  
  47.    return(rda);
  48. }
  49.  
  50.  
  51. void FreeArgv (struct RDArgs *rdargs)
  52. {
  53.    FreeArgs(rdargs);
  54.    FreeDosObject(DOS_RDARGS, rdargs);
  55. }
  56.  
  57.