home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 378.lha / GoWB / GoWB.c < prev    next >
C/C++ Source or Header  |  1990-05-06  |  3KB  |  113 lines

  1. /*
  2.     Replacement for
  3.     LOADWB
  4.     ENDCLI >nil:
  5.  
  6.     use Lettuce-C V5.04
  7.  
  8.     don't link with "c.o", it's not neccessary!
  9.  
  10.     don't use GO, there seems to be a serious bug in the
  11.     lettuce package which causes a CXERR25 on LC2.
  12.  
  13.     Freeware, © 1989 by
  14.           Oliver Wagner
  15.           Landsberge 5
  16.           4322 Sprockhövel
  17.           West Germany
  18.  
  19.     All Rights Reserved!
  20.  
  21.     Dieses Programm darf nicht von juristischen Personen genutzt
  22.     werden, die auf der "Schwarzen Liste" der PD-Anbieter stehen.
  23.  
  24. */
  25.  
  26. #include <proto/exec.h>
  27. #include <proto/dos.h>
  28.  
  29. /*
  30.  
  31.     this structure is the msg send to the newly
  32.     created "workbench.task" process to start
  33.     up. LockList is not used in this context.
  34.  
  35.     Please, don't use in any other code -
  36.     this is undocumented!!!!
  37.  
  38.     All this information has been gathered by analyzing
  39.     the original CBM "LoadWB" (by the way: LoadWB is a C-programm
  40.     which has got all the necessary startup stuff to be run
  41.     from - Workbench :-) and the ARP "EndCLI" using the demonstration
  42.     version of "ReSource", an interactive disassembler.
  43.  
  44. */
  45.  
  46. struct wbgo {
  47.  struct Message wbm;
  48.  struct Locklist *locks;
  49.  long debug;
  50. };
  51.  
  52.  
  53. /* proto */
  54.  
  55. void main(void);
  56.  
  57. void main()
  58. {
  59.     /* open DOS */
  60.     struct Library *DOSBase=OldOpenLibrary("dos.library");
  61.  
  62.     /* find the Workbench in ROM */
  63.     struct Resident *wbres=FindResident("workbench.task");
  64.  
  65.     /* my process */
  66.     struct Process *pr=(struct Process*)FindTask(0);
  67.  
  68.     /* my CLI */
  69.     struct CommandLineInterface *mycli=(struct CommandLineInterface*)(BADDR(pr->pr_CLI));
  70.  
  71.     /* CLI-Output (must be closed for EndCLI */
  72.     BPTR cfh=mycli->cli_CurrentInput;
  73.     BPTR sfh=mycli->cli_StandardInput;
  74.     struct FileHandle *mfh=(struct FileHandle*)BADDR(sfh);
  75.  
  76.     /* start workbench task */
  77.     struct Port *newproc=CreateProc("workbench.task",0,((long)wbres+0x2a)>>2,5000);
  78.  
  79.     /* my very own process msg-port */
  80.     struct Port *myport=&pr->pr_MsgPort;
  81.  
  82.     /* startup message */
  83.     struct wbgo wbmsg;
  84.  
  85.     /* initialize startup message */
  86.     wbmsg.wbm.mn_ReplyPort=myport;
  87.  
  88.     /* not used, for additional information only */
  89.     wbmsg.locks=0;
  90.     wbmsg.debug=0;
  91.  
  92.     /* send Msg and wait for reply */
  93.     PutMsg(newproc,&wbmsg);
  94.     WaitPort(myport);
  95.     GetMsg(myport);
  96.  
  97.  
  98. /* EndCLI */
  99.  
  100.     /* close Input() and Output(), Batch-file */
  101.     mfh->fh_Pos=mfh->fh_End;
  102.     mfh->fh_End=0;
  103.     if(sfh!=cfh) {
  104.     mycli->cli_CurrentInput=sfh;
  105.     Close(cfh);
  106.     }
  107.  
  108.     /* cancel CLI */
  109.     mycli->cli_Background=-1;
  110.     Exit(0);
  111. }
  112.  
  113.