bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: pwd.h on VMS


From: John E. Malmberg
Subject: Re: pwd.h on VMS
Date: Mon, 03 Mar 2008 21:30:55 -0600
User-agent: Mozilla/5.0 (X11; U; OpenVMS AlphaServer_DS10_617_MHz; en-US; rv:1.7) Gecko/20040621

Bruno Haible wrote:
John E. Malmberg wrote:

For situations like this, gnulib usually "overloads" the system provided
function, so that it has the POSIX specified prototype and behaves like
POSIX says. This allows programmers to write code for POSIX systems, without
#ifdefs, and it still compiles and runs well on weird systems like yours.

Here, the overloading would imply to create a substitute <pwd.h> file, that
is generated from pwd.in.h. (There are numerous examples of this technique
in gnulib.) The essential code will be something like:

lib/pwd.in.h:

   #define getpwnam rpl_getpwnam
   extern struct passwd *getpwnam(const char *name);

lib/getpwnam.c:

   struct passwd *getpwnam(const char *name)
   #undef getpwnam
   {
     /* Put here the implementation of POSIX compliant getpwnam, based on
        the system's getpwnam.  */
   }

Then you can leave tar's src/names.c alone, unmodified.

I expect that the header files will be getting a new variant in the future, as there is a bug in the VMS passwd structure where it is missing some members.

The <pwd.h> replacement file can also override 'struct passwd' with a
struct that contains all the necessary fields. See e.g. how we deal with
broken 'struct timespec' in lib/time.in.h.

Ok, I added the file src/gnv$names.c_first file. The GNV CC build environment on VMS uses this file before processing the rest of the source file.

I have a number of these files in the tar build, which are used to hide differences the VMS environment.

So with this hack, I no longer need a change to the src/names.c module.

EAGLE> type [.src]gnv$names.c_first
#define getpwnam hide_getpwnam
#include <vms_sys_library/pwd.h>
#undef getpwnam

#pragma extern_prefix NOCRTL (getpwnam)

struct passwd * decc$__long_gid_getpwnam(const char * name);

struct passwd * getpwnam(const char * name)
{
    return decc$__long_gid_getpwnam(name);
}

-John
address@hidden
Personal Opinion Only




reply via email to

[Prev in Thread] Current Thread [Next in Thread]