#include <unistd.h>
#endif
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-
-#ifdef NEED_SNPRINTF_H
-# include "snprintf.h"
-#endif
-
-#ifdef NEED_MKSTEMP
-#include "mkstemp.h"
-#endif
-
-#ifdef HAVE_IO_H
-#include <io.h>
-#ifndef __MINGW32__
-typedef int mode_t; /* for win32 */
-#endif /* __MINGW32__ */
-#endif /* HAVE_IO_H */
+#include "file_util.h"
+#include <epan/address.h>
#include <epan/addr_resolv.h>
/*
return argstring;
}
-static char *
-setup_tmpdir(char *dir)
+static const char *
+setup_tmpdir(const char *dir)
{
- int len = strlen(dir);
+ size_t len = strlen(dir);
char *newdir;
/* Append path separator if necessary */
- if (dir[len - 1] == G_DIR_SEPARATOR) {
- newdir = dir;
+ if (len != 0 && dir[len - 1] == G_DIR_SEPARATOR) {
+ return dir;
}
else {
newdir = g_malloc(len + 2);
strcpy(newdir, dir);
strcat(newdir, G_DIR_SEPARATOR_S);
+ return newdir;
}
- return newdir;
}
static int
{
static const char suffix[] = "XXXXXXXXXX";
int namelen = strlen(dir) + strlen(pfx) + sizeof suffix;
- mode_t old_umask;
+ int old_umask;
int tmp_fd;
if (namebuflen < namelen) {
/* Stick in a truncated name, so that if this error is
reported with the file name, you at least get
something. */
- snprintf(namebuf, namebuflen, "%s%s%s", dir, pfx, suffix);
+ g_snprintf(namebuf, namebuflen, "%s%s%s", dir, pfx, suffix);
errno = ENAMETOOLONG;
return -1;
}
permissions, attempt to create the file, and then put
the umask back. */
old_umask = umask(0077);
- tmp_fd = mkstemp(namebuf);
+ tmp_fd = eth_mkstemp(namebuf);
umask(old_umask);
return tmp_fd;
}
-static char *tmpdir = NULL;
+static const char *tmpdir = NULL;
#ifdef _WIN32
static char *temp = NULL;
#endif
-static char *E_tmpdir;
+static const char *E_tmpdir;
#ifndef P_tmpdir
#define P_tmpdir "/var/tmp"
CLIENTNAME (terminal server): <remote name>
*/
-gchar *get_conn_cfilter(void) {
+const gchar *get_conn_cfilter(void) {
static GString *filter_str = NULL;
gchar *env, **tokens;