home *** CD-ROM | disk | FTP | other *** search
/ RISCWORLD 7 / RISCWORLD_VOL7.iso / Software / Toolbox / UnixHome / !UnixHome / c / SetHome
Encoding:
Text File  |  2005-05-16  |  562 b   |  32 lines

  1.  
  2.  
  3. /*  Set HOME variable, given a RISC OS directory path */
  4.  
  5. #define __UNIXLIB_INTERNALS
  6.  
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #include <string.h>
  10. #include <unixlib/unix.h>
  11. #include <unixlib/local.h>
  12.  
  13.  
  14. int main(int argc, char *argv[]) {
  15.   char buffer[256];
  16.   char *value;
  17.  
  18.   if (argc < 2) {
  19.     fprintf(stderr, "SetHome must be given a path\n");
  20.     exit(EXIT_FAILURE);
  21.   }
  22.  
  23.   value = getenv(argv[1]);
  24.  
  25.   __unixify(value, 0, buffer, sizeof(buffer) - (sizeof("/home") - 1), 0xfff);
  26.   strcat(buffer, "/home");
  27.  
  28.   setenv("UnixEnv$HOME", buffer, 1);
  29.  
  30.   return 0;
  31. }
  32.