home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 552.lha / PatchReq_v1.4 / PatchReq.c < prev    next >
C/C++ Source or Header  |  1991-09-08  |  2KB  |  74 lines

  1. /*
  2.  *    PatchReq.c - Copyright © 1991 by Devil's child.
  3.  *
  4.  *    Created:    25 Jan 1991  19:44:11
  5.  *    Modified:    25 Jul 1991  19:15:27
  6.  *
  7.  *    Make>> cc -qf -ps -so -sb -wu -wd -wp -md -hi ram:small.sym <file>.c
  8.  *    Make>> ln -m <file>.o -larpsc
  9.  */
  10.  
  11. #include <dos_functions.h>
  12. #include <arpdos_pragmas.h>
  13.  
  14. extern struct ArpBase *ArpBase;
  15. extern int _argc;
  16. extern char **_argv;
  17.  
  18. #define    DIR_CACHE    1
  19. #define NOAUTOREQ    2
  20.  
  21.  
  22. void main(int argc, char *argv[])
  23. {
  24.     struct ReqLib *ReqBase;
  25.     PVF *FuncTab;
  26.     long (*OldTextRequest)();
  27.     long (*OldAutoRequest)();
  28.     BPTR Segment;
  29.     PVF *(*Setup)(struct ArpBase *, struct ReqLib *, long (*)(), long (*)(), short);
  30.     short Flags = 0;
  31.  
  32.     if (!(ReqBase = (struct ReqLib *)OpenLibrary("req.library", 1))) {
  33.         Printf("You need req.library\n");
  34.         ArpExit(20,0);
  35.     }
  36.     if ((Segment = LoadSeg("PatchReq-Seg")) || (Segment = LoadSeg("L:PatchReq-Seg"))) {
  37.         Printf("PatchReq V1.4 Copyright © 1991 by P.C.\nArp FileRequest() Patched.\n");
  38.         if (argv[1])
  39.             Flags |= NOAUTOREQ;
  40.         else
  41.             Printf("AutoRequest() Patched.\n");
  42.         if (argv[0]) {
  43.             Flags |= DIR_CACHE;
  44.             Printf("Directory cache on.\n");
  45.         }
  46.         Setup = (PVF *(*)())((Segment << 2) + 4);
  47.         Forbid();
  48.         OldTextRequest = (long (*)())SetFunction((struct Library *)ReqBase, -0xAE, NULL);                /* Get Old function to give to Setup() */
  49.         OldAutoRequest = (long (*)())SetFunction((struct Library *)ReqBase->IntuiLib, -0x15C, NULL);    /* Get Old function to give to Setup() */
  50.         FuncTab = Setup(ArpBase, ReqBase, OldTextRequest, OldAutoRequest, Flags);
  51.         SetFunction((struct Library *)ReqBase->IntuiLib, -0x15C, FuncTab[0]);    /* NewAutoRequest() */
  52.         SetFunction((struct Library *)ReqBase, -0xAE, FuncTab[1]);                /* NewTextRequest() */
  53.         SetFunction((struct Library *)ArpBase, -0x126, FuncTab[2]);                /* NewFileRequest() */
  54.         Permit();
  55.     }
  56.     else {
  57.         Printf("Couldn't load PatchReq-Seg\n");
  58.         ArpExit(20,0);
  59.     }
  60. }
  61.  
  62.  
  63. void _cli_parse(struct Process *pp, long alen, char *aptr)
  64. {
  65.     _argv = ArpAlloc(12);
  66.     _argc = (int)GADS(aptr, alen, "Usage: PatchReq [CACHE] [NOAUTOREQ]", _argv, "CACHE/s,NOAUTOREQ/s");
  67.     if (_argc < 0) {
  68.         Puts(_argv[0]);
  69.         ArpExit(20L, ERROR_LINE_TOO_LONG);
  70.     }
  71. }
  72.  
  73.  
  74.