home *** CD-ROM | disk | FTP | other *** search
/ RISC DISC 1 / RISC_DISC_1.iso / pd_share / code / oslib / Examples / p3-246 < prev    next >
Encoding:
Text File  |  1994-05-11  |  741 b   |  31 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 "os.h"
  9. #include "wimp.h"
  10.  
  11. os_error *save_desktop (os_f handle)
  12.  
  13. {  char *ptr;
  14.    os_error *error = NULL;
  15.  
  16.    if ((ptr = getenv ("Edit$Dir")) != NULL && !EMPTY (ptr))
  17.    {  if ((error = xos_bput ('/', handle)) != NULL)
  18.          goto finish;
  19.  
  20.       while (*ptr != '\0')
  21.          if ((error = xos_bput (*ptr++, handle)) != NULL)
  22.             goto finish;
  23.  
  24.       if ((error = xos_bput ('\n', handle)) != NULL)
  25.          goto finish;
  26.    }
  27.  
  28. finish:
  29.    return error;
  30. }
  31.