[comp.sys.dec] Porting to VMS-C

milo@ndmath.UUCP (03/22/87)

I am about to undertake the porting of a large Unix program I wrote in C
to VMS-C.  I don't have any previous experience with VMS-C (although I have
worked with VAX/VMS before) so I would appreciate any comments from people who
might have ported applications from Unix-C to VMS-C.

The application I am moving uses very few system calls...the primary ones
are used to switch from normal to RAW mode and back, vanilla fork&exec calls
for loading up various utility programs and a few misc system calls for finding
tty names and file modification dates.  All file IO is done with unbuffered
read and write calls.

I'm trying to get a VMS-C manual so I can read up on it...but comments from
someone who has actually ported a program would be much more useful.

Thanks in advance...

Greg Corson
...seismo!iuvax!kangaro!milo 

jt@nrcvax.UUCP (03/25/87)

In article <199@ndmath.UUCP> milo@ndmath.UUCP (Greg Corson) writes:

>The application I am moving uses very few system calls...

That should make it easier...

>...the primary ones
>are used to switch from normal to RAW mode and back...

You lose.  Don't expect any help from the C runtime library.  Prepare to get
intimate with the I/O Users manual, in which the terminal driver programmer
interface is described.

> ..., vanilla fork&exec calls
>for loading up various utility programs...

You lose.  By "vanilla" you mean "unix-like".  On VMS you have vfork and
exec.  The vfork is really a setjmp, and the exec is a longjmp.  Between the
vfork and the exec, anything you do (like closes and dups) affect both the
parent and the child.  You MUST exec to ever get back to being the parent.
Prepare to get intimate with LIB$SPAWN and SYS$CREPRC if vfork and exec are
too wimpy for what you are trying to do.

> ... and a few misc system calls for finding
>tty names...

If you mean the name of a tty associated with an open file pointer, you win!
fgetname() will do the trick, you just have to clean up some VMS debris that
comes along with the name.

>... and file modification dates.

No sweat.  A semi-real stat() is standard equipment.  (It wasn't in VMS 3, but
you don't want to hear about that.)

>  All file IO is done with unbuffered
>read and write calls.

Good move.  Avoid standard I/O like the plague, and watch out for weird
behavior on reads when dealing with non-STREAM file types.  For example,
when reading text files (record format: variable, record attribute: cr), a
read will return a line of text at a time.  If file processing speed is any
consideration, prepare to get intimate with direct use of file QIOs.

Good luck.

-- 
=========================    `` ''    ====================================
Jerry Toporek               <`@-@'>             Network Research Corp.
ihnp4!nrcvax!jt              ( > )              1620 Federal Ave. Suite #2
ucbvax!calma!nrcvax!jt        \~/               LA, CA, 90025, USA
{sdcsvax,hplabs}!sdcrdcf!psivax!nrcvax!jt       (213) 479-6436