home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.os.vms
- Path: sparky!uunet!haven.umd.edu!darwin.sura.net!mips!mips!decwrl!csus.edu!netcom.com!shepperd
- From: shepperd@netcom.com (David Shepperd)
- Subject: Re: PSM$REPLACE with VAXC
- Message-ID: <l+#n1nj.shepperd@netcom.com>
- Date: Thu, 20 Aug 92 03:17:10 GMT
- Organization: Netcom - Online Communication Services (408 241-9760 guest)
- References: <19AUG199210515152@ariel.lerc.nasa.gov>
- X-Newsreader: Tin 1.1 PL4
- Lines: 53
-
- uugblum@ariel.lerc.nasa.gov (VMScluster Administrator) writes:
- : Does anyone have an example of how to use the PSM$REPLACE routine from VAX C?
-
- Yep:
-
- [...bla_bla...]
-
- long streams=16;
- long buf_size=4096;
- long wk_size=sizeof(WORK_area);
- int code;
-
- int file_setup_2(
- int *rqst_id, /* symbiont context */
- WORK_area *wk_area, /* user context (ptr to work area) */
- int *func, /* input routine function code */
- void *func_descrip, /* ptr to descriptor */
- int *func_arg) /* function argument */
- {
- ...program...
- }
-
- int start_c()
- {
- int sts;
- code = PSM$K_FILE_SETUP_2;
- sts = psm$replace(&code,file_setup_2);
- if ((sts&1) == 0) return sts;
- return psm$print(&streams,&buf_size,&wk_size);
- }
-
- The main thing you need to know is that you cannot have a main() function
- defined anywhere in your C code. Having a main() causes the program to call a
- bunch of startup code in the VAXCRTL which will die a miserable death because
- the symbiont doesn't have the command intrepreter. This means you have to get
- control transferred to the C code in another manner. I cheap out and do this
- with the following 4 line MACRO32 program:
-
- .entry tek_main,^M<>
- calls #0,start_c
- ret
- .end tek_main
-
- Don't use any builtin VAXCRTL I/O (like fopen, fread, etc.) or process
- functions (fork, etc). They probably won't work because the VAXCRTL startup
- code hasn't been executed. I believe you are confined to using RMS,
- QIO's, SYS$ and LIB$ calls directly.
-
-
- --
- Dave Shepperd. shepperd@netcom.COM or netcom.netcom.com!shepperd
- The company probably doesn't know what I say or do, but they pay me anyway.
-
-