From: Martin Mares Date: Tue, 27 Mar 2001 10:57:33 +0000 (+0000) Subject: Removed tempfile functions (nobody uses them and they probably belong X-Git-Tag: holmes-import~1501 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=eefd20ac16e71abe3bab0583502540d1b1f498d0;p=libucw.git Removed tempfile functions (nobody uses them and they probably belong to fastbuf.c anyway). --- diff --git a/lib/Makefile b/lib/Makefile index 2a2ec59d..d8012576 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -5,7 +5,7 @@ PROGS+=obj/lib/db-rebuild obj/lib/buckettool SHLIB_OBJS=alloc.o alloc_str.o ctmatch.o db.o fastbuf.o fb-file.o fb-mem.o lists.o \ log.o log2.o md5.o md5hex.o mmap.o pagecache.o patimatch.o patmatch.o pool.o \ - prime.o random.o realloc.o regex.o temp.o timer.o url.o wildmatch.o \ + prime.o random.o realloc.o regex.o timer.o url.o wildmatch.o \ wordsplit.o str_ctype.o str_upper.o bucket.o conf.o object.o sorter.o \ finger.o proctitle.o diff --git a/lib/lib.h b/lib/lib.h index 0fe45010..dcf97932 100644 --- a/lib/lib.h +++ b/lib/lib.h @@ -33,20 +33,6 @@ #define ABS(x) ((x) < 0 ? -(x) : (x)) #define ARRAY_SIZE(a) (sizeof(a)/sizeof(*(a))) -/* Temporary Files */ - -#define TMP_DIR "tmp" -#define TMP_DIR_LEN 3 - -struct tempfile { - int fh; - byte name[32]; -}; - -void open_temp(struct tempfile *, byte *); -void delete_temp(struct tempfile *); -u32 temprand(uns); - /* Logging */ #define L_DEBUG 'D' /* Debugging messages */ diff --git a/lib/temp.c b/lib/temp.c deleted file mode 100644 index 600f317b..00000000 --- a/lib/temp.c +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Sherlock Library -- Temporary Files - * - * (c) 1997 Martin Mares - */ - -#include "lib/lib.h" - -#include -#include -#include -#include - -u32 -temprand(uns key) -{ - static int seeded = 0; - u32 rand; - - if (!seeded) - { - seeded = 1; - srand(getpid()); - } - rand = random() << 1; - rand += key * 0xdeadbeef; - return rand; -} - -void -open_temp(struct tempfile *tf, byte *tftype) -{ - int retry = 50; - while (retry--) - { - sprintf(tf->name, TMP_DIR "/%s%08x", tftype, temprand(retry)); - tf->fh = open(tf->name, O_RDWR | O_CREAT | O_EXCL, 0666); - if (tf->fh >= 0) - return; - } - die("Unable to create temporary file"); -} - -void -delete_temp(struct tempfile *tf) -{ - close(tf->fh); - unlink(tf->name); -}