home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / pc / c / cbase.zoo / rolodeck.zoo / krtmp.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-21  |  1.5 KB  |  83 lines

  1. /*    Copyright (c) 1989 Citadel    */
  2. /*       All Rights Reserved        */
  3.  
  4. /* #ident    "@(#)krtmp.c    1.4 - 90/06/21" */
  5.  
  6. #include <blkio.h>    /* ansi compatibility macros */
  7.  
  8. /* ansi headers */
  9. #include <errno.h>
  10. /*#include <stddef.h>*/
  11. #include <stdio.h>
  12.  
  13. /*man---------------------------------------------------------------------------
  14. NAME
  15.     krtmp - K&R C temporary ANSI functions
  16.  
  17. DESCRIPTION
  18.     This file contains ANSI functions required by cbase which may not
  19.     be available with K&R compilers.
  20.  
  21. ------------------------------------------------------------------------------*/
  22. #if __STDC__ != 1
  23. /* memmove:  memory move */
  24. void *memmove(t, s, n)
  25. void *t;
  26. void *s;
  27. size_t n;
  28. {
  29.     void *buf = NULL;
  30.     if ((buf = calloc((size_t)1, n)) == NULL) return NULL;
  31.     memcpy(buf, s, n);
  32.     memcpy(t, buf, n);
  33.     free(buf);
  34.     return t;
  35. }
  36.  
  37. extern char *sys_errlist[];
  38. extern int sys_nerr;
  39.  
  40. void perror(s)
  41. char *s;
  42. {
  43.     if (s != NULL) {
  44.         fputs(s, stderr);
  45.         fputs(": ", stderr);
  46.     }
  47.     if (errno >= 0 && errno < sys_nerr) {
  48.         fprintf(stderr, "%s\n", sys_errlist[errno]);
  49.     } else {
  50.         fprintf(stderr, "Error number %d\n", errno);
  51.     }
  52.  
  53.     return;
  54. }
  55.  
  56. int link();
  57. int unlink();
  58.  
  59. int remove(filename)
  60. char *filename;
  61. {
  62.     if (unlink(filename) == -1) {
  63.         return -1;
  64.     }
  65.  
  66.     return 0;
  67. }
  68.  
  69. int rename(file1, file2)
  70. const char *file1;
  71. const char *file2;
  72. {
  73.     if (link(file1, file2) == -1) {
  74.         return -1;
  75.     }
  76.     if (unlink(file1) == -1) {
  77.         return -1;
  78.     }
  79.  
  80.     return 0;
  81. }
  82. #endif    /* #if __STDC__ != 1 */
  83.