home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 9 Archive / 09-Archive.zip / ZOO21E.EXE / OPTIONS.C < prev    next >
C/C++ Source or Header  |  1991-07-11  |  2KB  |  73 lines

  1. #ifndef LINT
  2. static char sccsid[]="@(#) options.c 2.1 87/12/25 12:23:56";
  3. #endif /* LINT */
  4.  
  5. /*
  6. Copyright (C) 1986, 1987 Rahul Dhesi -- All rights reserved
  7. */
  8. /*
  9. Here we define routines specific to only a few systems.  Routines are
  10. selected based on defined symbols.  Routines specific to only one
  11. system are in machine.c for the appropriate system.
  12. */
  13.  
  14. #include "options.h"
  15. #include "zooio.h"
  16. #include "various.h"
  17. #include "zoo.h"
  18. #include "zoofns.h"
  19. #include "errors.i"
  20.  
  21. #ifdef REN_LINK
  22. /* rename using link() followed by unlink() */
  23. /*
  24. The following code assumes that if unlink() returns nonzero, then the
  25. attempt to unlink failed.  If unlink() ever returns nonzero after actually
  26. unlinking the file, then the file being renamed will be lost!!!  Test this
  27. thoroughly.  It is assumed that link() and unlink() return zero if no
  28. error else nonzero.
  29. */
  30. int chname (newname, oldname)
  31. char *newname, *oldname;
  32. {
  33.    int status;
  34.    if (link (oldname, newname) == 0) { /* if we can create new name */
  35.       status = unlink (oldname);          /*   unlink old one */
  36.       if (status != 0) {                  /*   if unlink of old name failed */
  37.          unlink (newname);                /*     cancel new link */
  38.          return (-1);                     /*     return error */
  39.       } else
  40.          return (0);
  41.    }
  42.    else                    /* couldn't create new link */
  43.       return (-1);
  44. }
  45. #else
  46. /* else not REN_LINK */
  47.  
  48. int chname (newname, oldname)
  49. char *newname, *oldname;
  50. {
  51. #ifdef REN_STDC
  52.    if (rename(oldname, newname) != 0)     /* ANSI standard */
  53. #else
  54.    if (rename(newname, oldname) != 0)     /* its reverse */
  55. #endif
  56.       return (-1);
  57.    else
  58.       return (0);
  59. }
  60. #endif /* end of not REN_LINK */
  61.  
  62. /*
  63. Standard exit handler;  not used if specific system defines its
  64. own.
  65. */
  66. #ifndef SPECEXIT
  67. void zooexit (status)
  68. int status;
  69. {
  70.     exit (status);
  71. }
  72. #endif
  73.