home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 122.lha / Arp_v1.1 / Libraries / Manx_SRC / _arpmain.c < prev    next >
Encoding:
C/C++ Source or Header  |  1986-11-21  |  1.6 KB  |  69 lines

  1. /* Created 11/08/87 by -=+SDB+=- from file _main.c provided by Manx */
  2. /* Copyright (C) 1987 by Scott Ballantyne */
  3. /* May be freely used by ARP users/supporters */
  4. /* Memory is allocated for the MANX device buffers, etc., but the 
  5.  * ARP tracking functions are used.
  6.  */
  7.  
  8. #include <fcntl.h>
  9. #include <exec/alerts.h>
  10. #include <exec/memory.h>
  11. #include <libraries/dosextens.h>
  12. #include <libraries/dos.h>
  13. #include <workbench/startup.h>
  14.  
  15. extern long _savsp, _stkbase;
  16.  
  17. extern int errno, Enable_Abort;
  18.  
  19. extern int _argc;
  20. extern char **_argv;
  21. extern struct WBStartup *WBenchMsg;
  22.  
  23. extern struct _dev *_devtab;
  24. extern short _numdev;
  25.  
  26. _main(alen, aptr)
  27. long alen;
  28. char *aptr;
  29. {
  30.     register struct Process *pp, *_FindTask();
  31.     void *_GetMsg(), *ArpAlloc();
  32.     long _Input(), _Output(), _Open();
  33.  
  34.  
  35.     if ( (_devtab = ArpAlloc( _numdev*(long)sizeof(struct _dev))) == 0)
  36.     {
  37.         Alert(AG_NoMemory, 0L);
  38.         ArpExit(20L, ERROR_NO_FREE_STORE );
  39.     }
  40.  
  41.     _devtab[0].mode = O_RDONLY;
  42.     _devtab[1].mode = _devtab[2].mode = O_WRONLY;
  43.  
  44.     _stkbase = _savsp - *((long *)_savsp+1) + 8;
  45.     *(long *)_stkbase = 0x4d414e58L;
  46.  
  47.     pp = _FindTask(0L);
  48.     if (pp->pr_CLI) {
  49.         _cli_parse(pp, alen, aptr);
  50.         Enable_Abort = 1;
  51.         _devtab[0].mode |= O_STDIO;        /* shouldn't close if CLI */
  52.         _devtab[1].mode |= O_STDIO;
  53.     }
  54.     else {
  55.         _WaitPort(&pp->pr_MsgPort);
  56.         WBenchMsg = _GetMsg(&pp->pr_MsgPort);
  57.         if (WBenchMsg->sm_ArgList)
  58.             _CurrentDir(WBenchMsg->sm_ArgList->wa_Lock);
  59.         _wb_parse(pp, WBenchMsg);
  60.         _argv = (char **)WBenchMsg;
  61.     }
  62.     _devtab[0].fd = _Input();
  63.     if (_devtab[1].fd = _Output())
  64.         _devtab[2].fd = _Open("*", MODE_OLDFILE);
  65.     main(_argc, _argv);
  66.     exit(0);    /* Need to also close files, etc. */
  67. }
  68.  
  69.