| [2] | 1 | /* Utility to pick a temporary filename prefix.
|
|---|
| 2 | Copyright (C) 1996, 1997, 1998, 2001 Free Software Foundation, Inc.
|
|---|
| 3 |
|
|---|
| 4 | This file is part of the libiberty library.
|
|---|
| 5 | Libiberty is free software; you can redistribute it and/or
|
|---|
| 6 | modify it under the terms of the GNU Library General Public
|
|---|
| 7 | License as published by the Free Software Foundation; either
|
|---|
| 8 | version 2 of the License, or (at your option) any later version.
|
|---|
| 9 |
|
|---|
| 10 | Libiberty is distributed in the hope that it will be useful,
|
|---|
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|---|
| 13 | Library General Public License for more details.
|
|---|
| 14 |
|
|---|
| 15 | You should have received a copy of the GNU Library General Public
|
|---|
| 16 | License along with libiberty; see the file COPYING.LIB. If not,
|
|---|
| 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|---|
| 18 | Boston, MA 02111-1307, USA. */
|
|---|
| 19 |
|
|---|
| 20 | #ifdef HAVE_CONFIG_H
|
|---|
| 21 | #include "config.h"
|
|---|
| 22 | #endif
|
|---|
| 23 |
|
|---|
| 24 | #include <stdio.h> /* May get P_tmpdir. */
|
|---|
| 25 | #include <sys/types.h>
|
|---|
| 26 | #ifdef HAVE_UNISTD_H
|
|---|
| 27 | #include <unistd.h>
|
|---|
| 28 | #endif
|
|---|
| 29 | #ifdef HAVE_STDLIB_H
|
|---|
| 30 | #include <stdlib.h>
|
|---|
| 31 | #endif
|
|---|
| 32 | #ifdef HAVE_STRING_H
|
|---|
| 33 | #include <string.h>
|
|---|
| 34 | #endif
|
|---|
| 35 | #ifdef HAVE_SYS_FILE_H
|
|---|
| 36 | #include <sys/file.h> /* May get R_OK, etc. on some systems. */
|
|---|
| 37 | #endif
|
|---|
| 38 |
|
|---|
| 39 | #ifndef R_OK
|
|---|
| 40 | #define R_OK 4
|
|---|
| 41 | #define W_OK 2
|
|---|
| 42 | #define X_OK 1
|
|---|
| 43 | #endif
|
|---|
| 44 |
|
|---|
| 45 | #include "libiberty.h"
|
|---|
| 46 | extern int mkstemps PARAMS ((char *, int));
|
|---|
| 47 |
|
|---|
| 48 | /* '/' works just fine on MS-DOS based systems. */
|
|---|
| 49 | #ifndef DIR_SEPARATOR
|
|---|
| 50 | #define DIR_SEPARATOR '/'
|
|---|
| 51 | #endif
|
|---|
| 52 |
|
|---|
| 53 | /* Name of temporary file.
|
|---|
| 54 | mktemp requires 6 trailing X's. */
|
|---|
| 55 | #define TEMP_FILE "ccXXXXXX"
|
|---|
| 56 | #define TEMP_FILE_LEN (sizeof(TEMP_FILE) - 1)
|
|---|
| 57 |
|
|---|
| 58 | /* Subroutine of choose_tmpdir.
|
|---|
| |
|---|