home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Applications / Utilities / RemoteCommand / Source / execServer.subproj / RemoteRunServer.m < prev    next >
Encoding:
Text File  |  1993-06-09  |  2.0 KB  |  73 lines

  1. // -------------------------------------------------------------------------------------
  2. // RemoteRunServer
  3. // This server performs tasks (executes commands) sent to it by the main app.
  4. // -------------------------------------------------------------------------------------
  5. // Permission is granted to freely redistribute this source code, and to use fragments
  6. // of this code in your own applications if you find them to be useful.  This class,
  7. // along with the source code, come with no warranty of any kind, and the user assumes
  8. // all responsibility for its use.
  9. // -------------------------------------------------------------------------------------
  10.  
  11. #import <appkit/appkit.h>
  12. #import <libc.h>
  13. #import <stdlib.h>
  14. #import <string.h>
  15. #import <pwd.h>
  16. #import <sys/param.h>
  17. #import <sys/types.h>
  18. #import <sys/time.h>
  19. #import <sys/dir.h>
  20. #import "ExecServer.h"
  21.  
  22. /* main entry point */
  23. void main(int argc, char *argv[])
  24. {
  25.     int        a;
  26.     id        rs;
  27.     
  28.     /* check number fo args */
  29.     if (argc < 2) {
  30.         fprintf(stderr,
  31.             "usage: ExecServer [-e] "
  32.             "[-r <remoteServer>] "
  33.             "[-m <mainAppServer> [<mainAppHost>]] "
  34.             "[-c <commandPath>] "
  35.             "\n");
  36.         exit(1);
  37.     }
  38.     
  39.     /* ExecServer init */
  40.     rs = [[ExecServer alloc] init];
  41. //    [rs setMethodDelegate:[<OtherMethods> class]];
  42. //    [rs setLoggingDelegate:[<Logging> class]];
  43.  
  44.     /* command arguments */
  45.     for (a = 1; (a < argc) && (*argv[a] == '-'); a++) {
  46.         switch (argv[a][1]) {
  47.             case 'e':    // 'exitWhenDone' flag
  48.                 [rs setExitWhenDone:YES];
  49.                 break;
  50.             case 'r':    // remote server name
  51.                 if ((a + 1) < argc) [rs setRemoteServerName:argv[++a]];
  52.                 break;
  53.             case 'm':    // main app server
  54.                 if ((a + 1) < argc) {
  55.                     char *mainAppServer = argv[++a], *mainAppHost = (char*)nil;
  56.                     if (((a + 1) < argc) && (*argv[a + 1] != '-')) mainAppHost = argv[++a];
  57.                     [rs setMainAppServerName:mainAppServer host:mainAppHost];
  58.                 }
  59.                 break;
  60.             case 'c':
  61.                 if ((a + 1) < argc) [rs setMainAppPath:argv[++a]];
  62.                 break;
  63.             default:
  64.                 break;
  65.         }
  66.     }
  67.     
  68.     /* start remote object server (does not return) */
  69.     [rs _runServer];
  70.     exit(0);
  71.     
  72. }
  73.