home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / unix / gawk.sit / source / missing.d / tmpnam.c < prev    next >
Text File  |  1990-07-29  |  484b  |  28 lines

  1. /*
  2.  * tmpnam - an implementation for systems lacking a library version
  3.  *        this version does not rely on the P_tmpdir and L_tmpnam constants.
  4.  */
  5.  
  6. #ifndef NULL
  7. #define NULL    0
  8. #endif
  9.  
  10. static char template[] = "/tmp/gawkXXXXXX";
  11.  
  12. char *
  13. tmpnam(tmp)
  14. char *tmp;
  15. {
  16.     static char tmpbuf[sizeof(template)];
  17.     
  18.     if (tmp == NULL) {
  19.         (void) strcpy(tmpbuf, template);
  20.         (void) mktemp(tmpbuf);
  21.         return tmpbuf;
  22.     } else {
  23.         (void) strcpy(tmp, template);
  24.         (void) mktemp(tmp);
  25.         return tmp;
  26.     }
  27. }
  28.