1 /* $Id$ 2 * Provides temp files & directories operating functions 3 * 4 * (c) Stas Degteff <g@grumbler.org>, 2:5080/102@fidonet 5 * 6 * Latest version may be foind on http://husky.sourceforge.net 7 * 8 * 9 * HUSKYLIB: common defines, types and functions for HUSKY 10 * 11 * This is part of The HUSKY Fidonet Software project: 12 * see http://husky.sourceforge.net for details 13 * 14 * 15 * HUSKYLIB is free software; you can redistribute it and/or 16 * modify it under the terms of the GNU Lesser General Public 17 * License as published by the Free Software Foundation; either 18 * version 2 of the License, or (at your option) any later version. 19 * 20 * HUSKYLIB is distributed in the hope that it will be useful, 21 * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 23 * General Public License for more details. 24 * 25 * You should have received a copy of the GNU Lesser General Public 26 * License along with this library; see file COPYING. If not, write to the 27 * Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 28 * 29 * See also http://www.gnu.org, license may be found here. 30 */ 31 32 #ifndef HUSKY_TEMP_H__ 33 #define HUSKY_TEMP_H__ 34 35 /* standard headers */ 36 #include <stdio.h> 37 38 /* huskylib: compiler.h */ 39 #include "compiler.h" 40 41 /* huskylib headers */ 42 #include "huskyext.h" 43 44 /*** Declarations & defines ***********************************************/ 45 46 /* Default temporary files suffix (==extension in DOS-like OS) 47 * (re)define it in your program source if want other. 48 */ 49 #ifndef TEMPFILESUFFIX 50 #define TEMPFILESUFFIX "tmp" 51 #endif 52 53 54 /* Create new file with random name & specified suffix in specified directory. 55 * path = temporary directory 56 * ext = file name suffix 57 * mode = 'w' or 'b' - file open mode (text or binary); default = fopen() default 58 * Place to 'name' variable name of created file (from malloc() memory pool), 59 * if name is not NULL its free(). 60 * Return file descriptor or NULL 61 */ 62 HUSKYEXT FILE *createTempFileIn(const char *path, const char *ext, char mode, char **name); 63 64 65 /* Create new file with random name & default suffix (tmp) in text mode. 66 * pconfig = fidoconfig structure pointer 67 * Place to 'name' variable name of created file (from malloc() memory pool), 68 * if name is not NULL its free(). 69 * Return file descriptor or NULL 70 */ 71 HUSKYEXT FILE *createTempTextFile(char *tempDir, char **name); 72 73 74 /* Create new file with random name & default suffix (tmp) in binary mode. 75 * pconfig = fidoconfig structure pointer 76 * Place to 'name' variable name of created file (from malloc() memory pool), 77 * if name is not NULL its free(). 78 * Return file descriptor or NULL 79 */ 80 81 HUSKYEXT FILE *createTempBinFile(char *tempDir, char **name); 82 /* Create new file with random name & default suffix (binary mode). 83 * pconfig = fidoconfig structure pointer 84 * Place to 'name' variable name of created file (from malloc() memory pool), 85 * if name is not NULL its free(). 86 * Return file descriptor or NULL 87 */ 88 #define createTempFile(pconfig,name) (createTempBinFile(pconfig,name)) 89 90 #endif 91