home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 3 / PDCD_3.iso / languages / c / oslib / Examples / p3-246 < prev    next >
Encoding:
Text File  |  1995-02-16  |  761 b   |  32 lines

  1. /*This is a version using OSLib rather than RISC_OSLib. It emits the '/'
  2.    ("run") (referred to in the text), checks that the environment variable
  3.    exists before it dereferences it, and checks for the string being empty.*/
  4.  
  5. #include <stdlib.h>
  6.  
  7. #include "fileswitch.h"
  8. #include "macros.h"
  9. #include "os.h"
  10. #include "wimp.h"
  11.  
  12. os_error *save_desktop (os_f handle)
  13.  
  14. {  char *ptr;
  15.    os_error *error = NULL;
  16.  
  17.    if ((ptr = getenv ("Edit$Dir")) != NULL && !EMPTY (ptr))
  18.    {  if ((error = xos_bput ('/', handle)) != NULL)
  19.          goto finish;
  20.  
  21.       while (*ptr != '\0')
  22.          if ((error = xos_bput (*ptr++, handle)) != NULL)
  23.             goto finish;
  24.  
  25.       if ((error = xos_bput ('\n', handle)) != NULL)
  26.          goto finish;
  27.    }
  28.  
  29. finish:
  30.    return error;
  31. }
  32.