home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 160.lha / BCPL / myendcli.c < prev    next >
C/C++ Source or Header  |  1988-04-27  |  2KB  |  66 lines

  1. /* Myendcli.c - a C language replacement for ENDCLI
  2. Compile and link with Manx 3.4:
  3.   cc myendcli
  4.   ln myendcli.o bcpllib.o -lc
  5. By Bill Kinnersley - Dec 18, 1987
  6. Mail:   Physics Dept.
  7.         Montana State University
  8.         Bozeman, MT 59717
  9. BITNET: iphwk@mtsunix1
  10. INTERNET: iphwk%mtsunix1.bitnet@cunyvm.cuny.edu
  11. UUCP: ...psuvax1!mtsunix1.bitnet!iphwk
  12. */
  13. #include <stdio.h>
  14. #include <libraries/dosextens.h>
  15. #include <functions.h>
  16. #define DOSTRUE -1
  17. struct Process *task;
  18. struct CommandLineInterface *cli;
  19. struct FileHandle *mystdin;
  20. struct DosLibrary *doslib;
  21. struct RootNode *root;
  22. struct DosInfo *dosinfo;
  23. struct foo {
  24.         BPTR    next;
  25.         long    count;
  26.         BPTR    seg;
  27.         char    length;
  28.         char    name[1];
  29. };
  30. struct foo *list;
  31. main() {
  32.         short i;
  33.         if (!(doslib = (struct DosLibrary *)OpenLibrary("dos.library",0L)))
  34.                 error("Can't open library\n");
  35.         /*printf("doslib=%lx\n",doslib);*/
  36.         root = (struct RootNode *)doslib->dl_Root;
  37.         /*printf("root=%lx\n",root);*/
  38.         dosinfo = (struct DosInfo *)BADDR(root->rn_Info);
  39.         /*printf("dosinfo=%lx\n",dosinfo);*/
  40.         list = (struct foo *)BADDR(dosinfo->di_NetHand);
  41.         task = (struct Process *)FindTask(0L);
  42.         cli = (struct CommandLineInterface *)BADDR(task->pr_CLI);
  43.         mystdin = (struct FileHandle *)BADDR(cli->cli_StandardInput);
  44.         mystdin->fh_End = 0;
  45.         cli->cli_CurrentInput = cli->cli_StandardInput;
  46.         cli->cli_Background = DOSTRUE;
  47.         if (cli->cli_Interactive)
  48.                 printf("Task %ld ending\n", task->pr_TaskNum);
  49.         Forbid();
  50.         while (list) {
  51. /*printf("list=%lx\n",list);printf("next=%lx\n",BADDR(list->next));
  52. printf("count=%ld\n",list->count);printf("seg=%lx\n",BADDR(list->seg));
  53. puts(list->name);*/
  54.                 if (strcmp("CLI",list->name)==0) break;
  55.                 list = (struct foo *)BADDR(list->next);
  56.         }
  57.         if (list) {
  58. /*printf("list=%lx\n",list);printf("next=%lx\n",BADDR(list->next));
  59. printf("count=%ld\n",list->count);printf("seg=%lx\n",BADDR(list->seg));
  60. puts(list->name);*/
  61.                 if (list->count>0) list->count--;
  62.         }
  63.         Permit();
  64. }
  65. error(s) char *s; {puts(s); exit(0);}
  66.