home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / gnustuff / minix / libsrc~1.z / libsrc~1 / mktemp.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-12-28  |  434 b   |  22 lines

  1. #include "lib.h"
  2. /* mktemp - make a name for a temporary file */
  3.  
  4. char *mktemp(template)
  5. char *template;
  6. {
  7.   int pid;
  8.   char *p;
  9.  
  10.   pid = getpid();        /* get process id as semi-unique number */
  11.   p = template;
  12.   while (*p++) ;        /* find end of string */
  13.   p--;                /* backup to last character */
  14.  
  15.   /* Replace XXXXXX at end of template with pid. */
  16.   while (*--p == 'X') {
  17.     *p = '0' + (pid % 10);
  18.     pid = pid/10;
  19.   }
  20.   return(template);
  21. }
  22.