home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / os / vms / 13868 < prev    next >
Encoding:
Text File  |  1992-08-19  |  2.1 KB  |  65 lines

  1. Newsgroups: comp.os.vms
  2. Path: sparky!uunet!haven.umd.edu!darwin.sura.net!mips!mips!decwrl!csus.edu!netcom.com!shepperd
  3. From: shepperd@netcom.com (David Shepperd)
  4. Subject: Re: PSM$REPLACE with VAXC
  5. Message-ID: <l+#n1nj.shepperd@netcom.com>
  6. Date: Thu, 20 Aug 92 03:17:10 GMT
  7. Organization: Netcom - Online Communication Services  (408 241-9760 guest) 
  8. References: <19AUG199210515152@ariel.lerc.nasa.gov>
  9. X-Newsreader: Tin 1.1 PL4
  10. Lines: 53
  11.  
  12. uugblum@ariel.lerc.nasa.gov (VMScluster Administrator) writes:
  13. : Does anyone have an example of how to use the PSM$REPLACE routine from VAX C?
  14.  
  15. Yep:
  16.  
  17. [...bla_bla...]
  18.  
  19. long streams=16;
  20. long buf_size=4096;
  21. long wk_size=sizeof(WORK_area);
  22. int code;
  23.  
  24. int file_setup_2(
  25.    int *rqst_id,                /* symbiont context */
  26.    WORK_area *wk_area,          /* user context (ptr to work area) */
  27.    int *func,                   /* input routine function code */
  28.    void *func_descrip,          /* ptr to descriptor */
  29.    int *func_arg)               /* function argument */
  30. {
  31.     ...program...
  32. }
  33.  
  34. int start_c()
  35. {
  36.    int sts;
  37.    code = PSM$K_FILE_SETUP_2;
  38.    sts = psm$replace(&code,file_setup_2);
  39.    if ((sts&1) == 0) return sts;
  40.    return psm$print(&streams,&buf_size,&wk_size);
  41. }
  42.  
  43. The main thing you need to know is that you cannot have a main() function
  44. defined anywhere in your C code. Having a main() causes the program to call a
  45. bunch of startup code in the VAXCRTL which will die a miserable death because
  46. the symbiont doesn't have the command intrepreter. This means you have to get
  47. control transferred to the C code in another manner. I cheap out and do this
  48. with the following 4 line MACRO32 program:
  49.  
  50. .entry tek_main,^M<>
  51.    calls #0,start_c
  52.    ret
  53. .end tek_main
  54.  
  55. Don't use any builtin VAXCRTL I/O (like fopen, fread, etc.) or process
  56. functions (fork, etc). They probably won't work because the VAXCRTL startup
  57. code hasn't been executed. I believe you are confined to using RMS,
  58. QIO's, SYS$ and LIB$ calls directly.
  59.  
  60.  
  61. -- 
  62. Dave Shepperd.          shepperd@netcom.COM  or  netcom.netcom.com!shepperd
  63. The company probably doesn't know what I say or do, but they pay me anyway.
  64.  
  65.