home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Libraries / XL 1.0 / XLTest.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-28  |  1.3 KB  |  69 lines  |  [TEXT/MPS ]

  1. /*********************************************************************
  2. Project    :    XL                -    XCMDs for everyone
  3. File        :    XLTest.c        -    The testing gear
  4. Author    :    Matthias Neeracher
  5. Started    :    10Sep92                                Language    :    MPW C
  6. Modified    :    10Sep92    MN    
  7. Last        :    10Sep92
  8. *********************************************************************/
  9.  
  10. #include <Files.h>
  11. #include <Memory.h>
  12. #include <QuickDraw.h>
  13. #include <Resources.h>
  14.  
  15. #include    <stdio.h>
  16.  
  17. #include "XL.h"
  18.  
  19. void main(int argc, char ** argv)
  20. {
  21.     short                    res;
  22.     struct XCmdBlock     cmd;
  23.     Handle                xcmd;
  24.     Boolean                fn;
  25.     
  26.     InitGraf((Ptr) &qd.thePort);
  27.     
  28. #ifdef XLDEBUG
  29.     XLDebug = xl_DebugAll;
  30. #endif
  31.  
  32.     if (argc < 3) {
  33.         fprintf(stderr, "Usage: XLTest file (xcmd|xfcn) [args...].\n");
  34.         
  35.         exit(1);
  36.     }
  37.         
  38.     res = openrfperm(argv[1], 0, fsRdPerm);
  39.     
  40.     if (res == -1) {
  41.         fprintf(stderr, "# File not found: %s\n", argv[1]);
  42.         
  43.         exit(1);
  44.     }
  45.     
  46.     if (xcmd = get1namedresource('XCMD', argv[2]))
  47.         fn = false;
  48.     else if (xcmd = get1namedresource('XFCN', argv[2]))
  49.         fn = true;
  50.     else {
  51.         fprintf(stderr, "# Resource not found: %s\n", argv[2]);
  52.         
  53.         CloseResFile(res);
  54.         
  55.         exit(1);
  56.     }
  57.  
  58.     cmd.paramCount = 0;
  59.     for (argv += 3; *argv; ++argv)
  60.         PtrToHand(*argv, cmd.params+cmd.paramCount++, strlen(*argv)+1);
  61.         
  62.     XLCall(xcmd, XLDefaultGlue, &cmd);
  63.     
  64.     if (cmd.returnValue)    {
  65.         HLock(cmd.returnValue);
  66.         printf("Function returned %s.\n", *cmd.returnValue);
  67.     }
  68. }
  69.