home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / programming / gstobjects_1 / stack / Example / p / main next >
Encoding:
Text File  |  1994-09-23  |  1.3 KB  |  63 lines

  1. program test;
  2. {* main program, this will register with Adhesive, setup an
  3.    atexit handler and then call mymain which is the real program
  4. *}
  5.  
  6. #include "os.h"
  7. #include "clib.h"
  8.  
  9. #include "Adhesive.h"
  10. #include "mymain.h"
  11.  
  12.  
  13. (* external Adhesive request table created using CAHG *)
  14. var cahg_need_ObjectsNeeded : Adhesive_RequestStr; extern;
  15.  
  16.  
  17. (* global variable we use to keep our Adhesive handle in *)
  18. var userHandle : Adhesive_User;
  19.  
  20.  
  21. (* procedure to check an error *)
  22. procedure checkErr(e:error);
  23. begin
  24.   if e<>nil then begin
  25.     writeln('*** ',e^.errmess,' ***');
  26.     exit(EXIT_FAILURE);
  27.   end;
  28. end;
  29.  
  30.  
  31. (* exit handler to deregister with Adhesive *)
  32. procedure exit_handler;
  33. begin
  34.   adhesive_Deregister(userHandle);
  35. end;
  36.  
  37.  
  38.  
  39. (* main *)
  40.   var info : Adhesive_UserInfo;
  41. begin
  42.   (* initialise handle to 0 so exit_handler doesn't do anything if
  43.      an error occurs before we register with Adhesive
  44.   *)
  45.   new(userHandle);
  46.   userHandle^ := 0;
  47.  
  48.   (* use atexit handler so we always deregister with Adhesive *)
  49.   atexit(exit_handler);
  50.  
  51.   (* register and request objects *)
  52.   new(info);
  53.   info^.flags := 0;
  54.   info^.name  := 'Pascal User';
  55.   checkErr(adhesive_Register(userHandle,info));
  56.   checkErr(adhesive_Request(userHandle,
  57.                       address(cahg_need_ObjectsNeeded))
  58.         );
  59.  
  60.   (* call real program *)
  61.   mymain;
  62. end.
  63.