home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 13 / AACD13.ISO / AACD / Resources / System / BoingBag1 / Contributions / Workbench / RexxArpLib3p6 / src / env.c < prev    next >
C/C++ Source or Header  |  1998-06-21  |  2KB  |  83 lines

  1. /**    Env.c
  2.   *
  3.   *    Implement the Amiga environment access functions for rexxarplib.library.
  4.   *
  5.   *   AUTHOR/DATE:  W.G.J. Langeveld, November 1987.
  6.   *   ============
  7.   *
  8.   *    CURRENT VERSION:
  9.   *
  10.   *    This version has been converted to SAS C 6.5 format. It has been modified
  11.   *    for modern definition sequences for ANSI compilation. This no longer works
  12.   *    with OS versions prior to 2.04.
  13.   *
  14.   *   AUTHOR/DATE:  Joanne Dow, jdow@bix.com, June 1998.
  15.   *   ============
  16.   *
  17.   **/
  18.  
  19. #include <functions.h>
  20. #include "ralprotos.h"
  21. #include <intuition/intuitionbase.h>
  22. #include <libraries/MyARP.h>
  23. #include <proto/rexxsyslib.h>
  24. #include <dos/var.h>
  25. #include <stdlib.h>
  26. #include <string.h>
  27. #include <ctype.h>
  28. #include "rexxarplib.h"
  29.  
  30. extern struct ArpBase *ArpBase;
  31.  
  32. /**
  33.  *
  34.  *   Get an environment variable
  35.  *
  36. **/
  37. char *rxf_getenv( long *err, int n, char *args[] )
  38. {
  39.     register long exists = 0L;
  40.     char result[256];
  41.     
  42.     *err = 0L;
  43.     
  44.     exists = GetVar(args[0], result, 256L, GVF_BINARY_VAR | LV_VAR);
  45.     result[255] = 0;
  46.     if (exists != -1L)
  47.         return(CAS(result));
  48.  
  49.     exists = (long) Getenv(args[0], result, 256L);
  50.     
  51.     if (exists)
  52.         return(CAS(result));
  53.     else
  54.         return(CAS(""));
  55. }
  56.  
  57. /**
  58.  *
  59.  *   Set an environment variable
  60.  *
  61. **/
  62. char *rxf_setenv( long *err, int n, char *args[] )
  63. {
  64.     register long test = 0L;
  65.     
  66.     *err = 0L;
  67.     
  68.     if (n > 1) 
  69.     {
  70.         test = SetVar(args[0], args[1], (long) strlen(args[1]),
  71.         GVF_GLOBAL_ONLY | LV_VAR);
  72.     }
  73.     else
  74.     {
  75.         test = DeleteVar(args[0], LV_VAR);
  76.     }
  77.     
  78.     if (test)
  79.         return(CAS("1"));
  80.     
  81.     return(CAS("0"));
  82. }
  83.