Replaced sorter_open_tmp() by bopen_tmp().
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 ipaccess.o profile.o bitsig.o randomkey.o \
- hash-string.o hash-istring.o custom.o base224.o str_hash.o
+ hash-string.o hash-istring.o custom.o base224.o str_hash.o fb-temp.o
obj/lib/libsh.a: $(addprefix obj/lib/,$(SHLIB_OBJS))
/* FastIO on standard files */
struct fastbuf *bopen(byte *name, uns mode, uns buffer);
+struct fastbuf *bopen_tmp(uns buffer);
struct fastbuf *bfdopen(int fd, uns buffer);
void bbcopy(struct fastbuf *f, struct fastbuf *t, uns l);
--- /dev/null
+/*
+ * Sherlock Library -- Temporary Fastbufs
+ *
+ * (c) 2002 Martin Mares <mj@ucw.cz>
+ */
+
+#include "lib/lib.h"
+#include "lib/conf.h"
+#include "lib/fastbuf.h"
+
+#include <unistd.h>
+#include <sys/fcntl.h>
+
+static byte *temp_template = "/tmp/temp%d.%d";
+
+static struct cfitem temp_config[] = {
+ { "Tempfiles", CT_SECTION, NULL },
+ { "Template", CT_STRING, &temp_template },
+ { NULL, CT_STOP, NULL }
+};
+
+static void CONSTRUCTOR temp_init_config(void)
+{
+ cf_register(temp_config);
+}
+
+struct fastbuf *
+bopen_tmp(uns bufsize)
+{
+ byte buf[256];
+ struct fastbuf *f;
+ static uns temp_counter;
+
+ sprintf(buf, temp_template, (int) getpid(), temp_counter++);
+ f = bopen(buf, O_RDWR | O_CREAT | O_EXCL, bufsize);
+ f->is_temp_file = 1;
+ return f;
+}
/*
* Sherlock Library -- Universal Sorter
*
- * (c) 2001 Martin Mares <mj@ucw.cz>
+ * (c) 2001--2002 Martin Mares <mj@ucw.cz>
*/
#include "lib/lib.h"
uns sorter_trace;
uns sorter_presort_bufsize = 65536;
uns sorter_stream_bufsize = 65536;
-static byte *sorter_template = "/tmp/sort%d.%d";
static struct cfitem sorter_config[] = {
{ "Sorter", CT_SECTION, NULL },
{ "Trace", CT_INT, &sorter_trace },
{ "PresortBuffer", CT_INT, &sorter_presort_bufsize },
{ "StreamBuffer", CT_INT, &sorter_stream_bufsize },
- { "TempLate", CT_STRING, &sorter_template },
{ NULL, CT_STOP, NULL }
};
}
uns sorter_pass_counter;
-uns sorter_file_counter;
-
-struct fastbuf *
-sorter_open_tmp(void)
-{
- byte buf[256];
- struct fastbuf *f;
-
- sprintf(buf, sorter_template, (int) getpid(), sorter_file_counter++);
- f = bopen(buf, O_RDWR | O_CREAT | O_EXCL, sorter_stream_bufsize);
- f->is_temp_file = 1;
- return f;
-}
/*
* Sherlock Library -- Universal Sorter
*
- * (c) 2001 Martin Mares <mj@ucw.cz>
+ * (c) 2001--2002 Martin Mares <mj@ucw.cz>
*/
/*
extern uns sorter_presort_bufsize;
extern uns sorter_stream_bufsize;
-extern uns sorter_pass_counter, sorter_file_counter;
-struct fastbuf *sorter_open_tmp(void);
+extern uns sorter_pass_counter;
#endif /* !SORT_DECLS_READ */
struct fastbuf *t;
SWAP(out1, out2, t);
if (!out1)
- out1 = sorter_open_tmp();
+ out1 = bopen_tmp(sorter_stream_bufsize);
run_count++;
}
if (comp LESS 0)
{
SWAP(out1, out2, tbuf);
if (!out1)
- out1 = sorter_open_tmp();
+ out1 = bopen_tmp(sorter_stream_bufsize);
current = buffer;
last = &first;
if (leftover)
#endif
do P(pass)(&fb1, &fb2); while (fb1 && fb2);
if (!fb1)
- fb1 = sorter_open_tmp();
+ fb1 = bopen_tmp(sorter_stream_bufsize);
#ifdef SORT_OUTPUT_FB
return fb1;