home *** CD-ROM | disk | FTP | other *** search
/ back2roots/padua / padua.7z / padua / uucp / duucp-1.17 / AU-117b4-src.lha / src / lib / tmpfile.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-24  |  624 b   |  35 lines

  1. /*
  2.  *  TMPFILE.C
  3.  *
  4.  *  (C) Copyright 1989-1990 by Matthew Dillon,    All Rights Reserved.
  5.  *
  6.  *  create a temporary file
  7.  *
  8.  *  template limited to 16 chars
  9.  */
  10.  
  11. #include <string.h>
  12. #include <stdio.h>
  13. #include "config.h"
  14.  
  15. Prototype char *TmpFileName (const char *);
  16.  
  17. char *
  18. TmpFileName (const char *template)
  19. {
  20.     static char
  21.         Template [256];
  22.     static unsigned short
  23.         Idx;
  24.     const char
  25.         *ptr;
  26.  
  27.     for (ptr = template + strlen (template); ptr >= template && *ptr != ':' && *ptr != '/'; --ptr)
  28.         ;
  29.     ++ptr;
  30.  
  31.     sprintf (Template, "%.*sTMP%08lx.%s", ptr - template, template, (long) FindTask (NULL) + Idx++, ptr);
  32.  
  33.     return Template;
  34. }
  35.