--- path_temp.c 2002/08/03 21:00:15 1.1
+++ path_temp.c 2003/02/16 11:38:12 1.2
@@ -43,15 +43,15 @@
#include "path.h"
#include "path_util.h"
-static const char
-path_temp_padchar[] =
+static const char
+path_temp_padchar[] =
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
-path_rc_t
+path_rc_t
path_temp(
- path_temp_t id,
- const char *tmpl,
- char **res_ptr,
+ path_temp_t id,
+ const char *tmpl,
+ char **res_ptr,
size_t *res_size,
int *res_fd)
{
@@ -60,7 +60,7 @@
char *tmpdir;
size_t n;
char *user;
- char user_buf[4+((sizeof(long)*8)/3)+10];
+ char user_buf[4+((sizeof(long)*8)/3)+10];
const char *cp;
const char *cpT;
char *cpP;
@@ -97,27 +97,27 @@
user = user_buf;
}
n = strlen(tmpdir);
- path_msnprintf(tmpl_def, sizeof(tmpl_def), "%s%s%s.XXXXXXXX",
+ path_msnprintf(tmpl_def, sizeof(tmpl_def), "%s%s%s.XXXXXXXX",
tmpdir, (tmpdir[n-1] != '/' ? "/" : ""), user_buf);
- tmpl = tmpl_def;
+ tmpl = tmpl_def;
}
else if (tmpl[0] != '/') {
/* non-absolute path template */
n = strlen(tmpdir);
- path_msnprintf(tmpl_def, sizeof(tmpl_def), "%s%s%s",
+ path_msnprintf(tmpl_def, sizeof(tmpl_def), "%s%s%s",
tmpdir, (tmpdir[n-1] != '/' ? "/" : ""), tmpl);
if (strchr(tmpl_def, 'X') == NULL) {
n = strlen(tmpl_def);
path_msnprintf(tmpl_def+n, sizeof(tmpl_def)-n, ".XXXXXXXX");
}
- tmpl = tmpl_def;
+ tmpl = tmpl_def;
}
/* seed PRNG as good as possible with POSIX features */
gettimeofday(&tp, &tzp);
pid = getpid();
ppid = getppid();
- srand( (unsigned int)tp.tv_sec
+ srand( (unsigned int)tp.tv_sec
+ (unsigned int)tp.tv_usec
+ (unsigned int)uid
+ (unsigned int)pid
@@ -150,7 +150,7 @@
}
if (errno != EEXIST)
return PATH_ERR_SYS;
- }
+ }
else if (id == PATH_TEMP_DIR) {
if (mkdir(path, 0700) == 0) {
rc = PATH_OK;
@@ -158,8 +158,8 @@
}
if (errno != EEXIST)
return PATH_ERR_SYS;
- }
- else
+ }
+ else
return PATH_ERR_ARG;
/* path collision found, so cycle through namespace */
@@ -189,7 +189,7 @@
else
close(fd);
}
-
+
return rc;
}
|