home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Libraries / stdwin / Ports / mac / argcargv.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-04-06  |  1.2 KB  |  55 lines  |  [TEXT/????]

  1. /* MAC STDWIN -- GET ARGC/ARGV. */
  2.  
  3. /* Copy the arguments passed from the finder into argc/argv.
  4.    Neither MPW nor THINK C does this, making argc/argv pretty
  5.    useless.  By using winitargs(&argc, &argv) you get the arguments
  6.    that you expect.  When called to print, a "-p" flag is passed
  7.    before the first argument.
  8. */
  9.  
  10. #include "macwin.h"
  11. #ifdef MPW
  12. #include <SegLoad.h>
  13. #endif
  14. #ifdef THINK_C_PRE_5_0
  15. #include <SegmentLdr.h>
  16. #endif
  17.  
  18. void
  19. wargs(pargc, pargv)
  20.     int *pargc;
  21.     char ***pargv;
  22. {
  23.     L_DECLARE(argc, argv, char *);
  24.     char apname[256];
  25.     char buf[256];
  26.     short aprefnum;
  27.     Handle apparam;
  28.     short message;
  29.     short count;
  30.     short i;
  31.     
  32.     GetAppParms(apname, &aprefnum, &apparam);
  33. #ifndef CLEVERGLUE
  34.     PtoCstr(apname);
  35. #endif
  36.     L_APPEND(argc, argv, char *, strdup(apname));
  37.     
  38.     CountAppFiles(&message, &count);
  39.     if (message == appPrint) { /* Must have braces around L_*! */
  40.         L_APPEND(argc, argv, char *, "-p");
  41.     }
  42.     
  43.     for (i = 1; i <= count; ++i) {
  44.         AppFile thefile;
  45.         GetAppFiles(i, &thefile);
  46.         fullpath(buf, thefile.vRefNum,
  47.             p2cstr((char*)&thefile.fName));
  48.         L_APPEND(argc, argv, char *, strdup(buf));
  49.     }
  50.     
  51.     L_APPEND(argc, argv, char *, NULL);
  52.     *pargc = argc - 1;
  53.     *pargv = argv;
  54. }
  55.