2 * Sherlock Library -- Temporary Fastbufs
4 * (c) 2002 Martin Mares <mj@ucw.cz>
6 * This software may be freely distributed and used according to the terms
7 * of the GNU Lesser General Public License.
12 #include "lib/fastbuf.h"
15 #include <sys/fcntl.h>
17 static byte *temp_template = "/tmp/temp%d.%d";
19 static struct cfitem temp_config[] = {
20 { "Tempfiles", CT_SECTION, NULL },
21 { "Template", CT_STRING, &temp_template },
22 { NULL, CT_STOP, NULL }
25 static void CONSTRUCTOR temp_init_config(void)
27 cf_register(temp_config);
31 bopen_tmp(uns bufsize)
35 static uns temp_counter;
37 sprintf(buf, temp_template, (int) getpid(), temp_counter++);
38 f = bopen(buf, O_RDWR | O_CREAT | O_EXCL, bufsize);
39 bconfig(f, BCONFIG_IS_TEMP_FILE, 1);