Commit | Line | Data |
---|---|---|
41c799d4 C |
1 | /* tmpfil.c |
2 | Get a temporary file name. | |
3 | ||
3469b437 | 4 | Copyright (C) 1991, 1992, 1993 Ian Lance Taylor |
41c799d4 C |
5 | |
6 | This file is part of the Taylor UUCP package. | |
7 | ||
8 | This program is free software; you can redistribute it and/or | |
9 | modify it under the terms of the GNU General Public License as | |
10 | published by the Free Software Foundation; either version 2 of the | |
11 | License, or (at your option) any later version. | |
12 | ||
13 | This program is distributed in the hope that it will be useful, but | |
14 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 | General Public License for more details. | |
17 | ||
18 | You should have received a copy of the GNU General Public License | |
19 | along with this program; if not, write to the Free Software | |
20 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
21 | ||
22 | The author of the program may be contacted at ian@airs.com or | |
3469b437 | 23 | c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. |
41c799d4 C |
24 | */ |
25 | ||
26 | #include "uucp.h" | |
27 | ||
3469b437 | 28 | #include "uudefs.h" |
41c799d4 C |
29 | #include "uuconf.h" |
30 | #include "system.h" | |
31 | #include "sysdep.h" | |
32 | ||
33 | #define ZDIGS \ | |
34 | "0123456789abcdefghijklmnopqrtsuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-" | |
35 | #define CDIGS (sizeof ZDIGS - 1) | |
36 | ||
37 | /*ARGSUSED*/ | |
38 | char * | |
39 | zstemp_file (qsys) | |
40 | const struct uuconf_system *qsys; | |
41 | { | |
42 | static int icount; | |
43 | const char *const zdigs = ZDIGS; | |
44 | char ab[14]; | |
45 | pid_t ime; | |
46 | int iset; | |
47 | ||
48 | ab[0] = 'T'; | |
49 | ab[1] = 'M'; | |
50 | ab[2] = '.'; | |
51 | ||
52 | ime = getpid (); | |
53 | iset = 3; | |
54 | while (ime > 0 && iset < 10) | |
55 | { | |
56 | ab[iset] = zdigs[ime % CDIGS]; | |
57 | ime /= CDIGS; | |
58 | ++iset; | |
59 | } | |
60 | ||
61 | ab[iset] = '.'; | |
62 | ++iset; | |
63 | ||
64 | ab[iset] = zdigs[icount / CDIGS]; | |
65 | ++iset; | |
66 | ab[iset] = zdigs[icount % CDIGS]; | |
67 | ++iset; | |
68 | ||
69 | ab[iset] = '\0'; | |
70 | ||
71 | ++icount; | |
72 | if (icount >= CDIGS * CDIGS) | |
73 | icount = 0; | |
74 | ||
75 | #if SPOOLDIR_V2 || SPOOLDIR_BSD42 | |
76 | return zbufcpy (ab); | |
77 | #endif | |
78 | #if SPOOLDIR_BSD43 || SPOOLDIR_ULTRIX || SPOOLDIR_TAYLOR | |
79 | return zsysdep_in_dir (".Temp", ab); | |
80 | #endif | |
81 | #if SPOOLDIR_HDB || SPOOLDIR_SVR4 | |
82 | return zsysdep_in_dir (qsys->uuconf_zname, ab); | |
83 | #endif | |
84 | } |