/*--------------------------------------------------------------------*/ /* m k t e m p n m . c */ /* */ /* Host Support routines for UUPC/extended */ /* */ /* Changes Copyright 1990, 1991 (c) Andrew H. Derbyshire */ /* */ /* History: */ /* 21Nov1991 Break out of hlib.c ahd */ /*--------------------------------------------------------------------*/ #include #include #include #include #include #ifdef __GNUC__ #include #else #include #endif /*--------------------------------------------------------------------*/ /* RCS Information */ /*--------------------------------------------------------------------*/ /* * $Id: MKTEMPNM.C 1.3 1993/04/11 00:31:04 ahd Exp $ * * Revision history: * $Log: MKTEMPNM.C $ * Revision 1.3 1993/04/11 00:31:04 ahd * Global edits for year, TEXT, etc. * * Revision 1.2 1992/11/19 02:57:07 ahd * drop rcsid * * Revision 1.1 1992/11/16 05:00:26 ahd * Initial revision * */ /*--------------------------------------------------------------------*/ /* UUPC/extended include files */ /*--------------------------------------------------------------------*/ #include "lib.h" #include "hlib.h" /*--------------------------------------------------------------------*/ /* Global variables */ /*--------------------------------------------------------------------*/ currentfile(); /*--------------------------------------------------------------------*/ /* m k t e m p n a m e */ /* */ /* Generate a temporary name with a pre-defined extension */ /*--------------------------------------------------------------------*/ char *mktempname( char *buf, char *extension) { static size_t file = 0; if (buf == NULL) /* Do we need to allocate buffer? */ { buf = malloc( FILENAME_MAX ); checkref(buf); } /* if */ for (file++ ; file < INT_MAX ; file++ ) { sprintf(buf,"%s/uupc%04.4x.%s", E_tempdir, file, extension); if ( access( buf, 0 )) /* Does the host file exist? */ break; /* No --> Use the name */ } /* for */ printmsg(5,"Generated temporary name: %s",buf); return buf; } /* mktempname */