home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / p / psh / c / osgetenv < prev    next >
Text File  |  1995-05-08  |  577b  |  33 lines

  1. /* vi:tabstop=4:shiftwidth=4:smartindent
  2.  *
  3.  * osgetenv.c - Get a variable value, using the OS calls, as
  4.  *              UnixLib maintains copies of the env. when it
  5.  *              starts up, so getenv can return wrong values.
  6.  */
  7.  
  8. #include <sys/os.h>
  9. #include "psh.h"
  10.  
  11. char *osgetenv(char *var)
  12. {
  13.     static char    p[MAXLEN];
  14.     int            r[10];
  15.  
  16.     /* getenv isn't good enough, as Unixlib reads the env.
  17.      * when it starts.
  18.      */
  19.     r[0] = (int) var;
  20.     r[1] = (int) p;
  21.     r[2] = MAXLEN;
  22.     r[3] = 0;
  23.     r[4] = 3;
  24.  
  25.     if (os_swi(OS_ReadVarVal, r))
  26.     {
  27.         return NULL;
  28.     }
  29.  
  30.     p[r[2]] = '\0';
  31.     return p;
  32. }
  33.