-#include <unistd.h>
-#include <sys/fcntl.h>
-
-static char *temp_prefix = "/tmp/temp";
-
-static struct cf_section temp_config = {
- CF_ITEMS {
- CF_STRING("Prefix", &temp_prefix),
- CF_END
- }
-};
-
-static void CONSTRUCTOR temp_global_init(void)
-{
- cf_declare_section("Tempfiles", &temp_config, 0);
-}
-
-void
-temp_file_name(char *buf)
-{
- struct ucwlib_context *ctx = ucwlib_thread_context();
- int cnt = ++ctx->temp_counter;
- int pid = getpid();
- if (ctx->thread_id == pid)
- sprintf(buf, "%s%d-%d", temp_prefix, pid, cnt);
- else
- sprintf(buf, "%s%d-%d-%d", temp_prefix, pid, ctx->thread_id, cnt);
-}