[Info-vax] Porting logical name applications to Unix

Steven Schweda sms.antinode at gmail.com
Fri Sep 25 22:27:37 EDT 2009


JF Mezei wrote:
> Ok, this is a generic question.
>
> Say I have a VMS application that uses logical names to point to files,
> devices etc.
>
> When porting to a Unix system, is the following the best way to mimic
> this : ?

   You can't really mimic logical names.  You can do things
differently, using environment variables to let the user
provide info to a program.

> - use getenv to translate a symbol to some value stored in a local variable
> - use that variable instead of a quoted string when calling the file
> open, or open some serial device or whatever ?

   Something like that.  For example, on VMS, Wget can look
for an initialization file as "SYS$LOGIN:.wgetrc", so it might
do something like:

      FILE *fp;
      fp = fopen( "SYS$LOGIN:.wgetrc", ...);

On a UNIX system, it might look more like this:

      FILE *fp;
      char name[ FILENAME_MAX+ 1];
      strcpy( name, getenv( "HOME"));
      strcat( name, "/.wgetrc");
      fp = fopen( name, ...);

(Adding some error checking would be good, too.)

> Or is there a better or different way to mimic logical names which most
> Unix based people would use ?

   Have you thought about looking at the actual code used in
some actual programs which work on VMS and UNIX?

Arne Vajhøj wrote:
> But you would only use a few of them and instead put the
> majority of the paths in a text config file.

   The same as you would use a logical name to point to a
config file on VMS instead of using dozens of logical names.
A config file can be used on any OS.



More information about the Info-vax mailing list