]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/lib/bsys.c
const char * additions
[bacula/bacula] / bacula / src / lib / bsys.c
index 5a39359605ca39c5fa36e155313a12a775677bd7..57a7c02ab0536b88ea307da1997f8ecc01c5f8d7 100644 (file)
@@ -66,7 +66,7 @@ void *bmalloc(size_t size)
 }
 #endif
 
-void *b_malloc(char *file, int line, size_t size)
+void *b_malloc(const char *file, int line, size_t size)
 {
   void *buf;
 
@@ -108,7 +108,7 @@ void *bcalloc (size_t size1, size_t size2)
 /*
  * Implement snprintf
  */
-int bsnprintf(char *str, size_t size, const  char  *fmt,  ...) 
+int bsnprintf(char *str, int32_t size, const char *fmt,  ...) 
 {
 #ifdef HAVE_VSNPRINTF
    va_list   arg_ptr;
@@ -143,7 +143,7 @@ int bsnprintf(char *str, size_t size, const  char  *fmt,  ...)
 /*
  * Implement vsnprintf()
  */
-int bvsnprintf(char *str, size_t size, const char  *format, va_list ap)
+int bvsnprintf(char *str, int32_t size, const char  *format, va_list ap)
 {
 #ifdef HAVE_VSNPRINTF
    int len;
@@ -190,7 +190,7 @@ struct tm *localtime_r(const time_t *timep, struct tm *tm)
 #endif /* HAVE_LOCALTIME_R */
 
 #ifndef HAVE_READDIR_R
-
+#ifndef HAVE_WIN32
 #include <dirent.h>
 
 int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result)
@@ -217,8 +217,9 @@ int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result)
     }
     V(mutex);
     return stat;
-}
 
+}
+#endif
 #endif /* HAVE_READDIR_R */
 
 #ifdef xxxxxxxxxx_STRERROR_R
@@ -282,7 +283,7 @@ void _v(char *file, int line, pthread_mutex_t *m)
 }
 #endif /* DEBUG_MUTEX */
 
-#ifndef HAVE_CYGWIN
+#if !defined(HAVE_CYGWIN) && !defined(HAVE_WIN32)
 static int del_pid_file_ok = FALSE;
 #endif
 
@@ -291,7 +292,7 @@ static int del_pid_file_ok = FALSE;
  */
 void create_pid_file(char *dir, char *progname, int port)
 {
-#ifndef HAVE_CYGWIN
+#if !defined(HAVE_CYGWIN) && !defined(HAVE_WIN32)
    int pidfd, len;
    int oldpid;
    char  pidbuf[20];
@@ -333,7 +334,7 @@ void create_pid_file(char *dir, char *progname, int port)
  */
 int delete_pid_file(char *dir, char *progname, int port)
 {
-#ifndef HAVE_CYGWIN
+#if !defined(HAVE_CYGWIN)  && !defined(HAVE_WIN32)
    POOLMEM *fname = get_pool_memory(PM_FNAME);
 
    if (!del_pid_file_ok) {
@@ -389,12 +390,12 @@ static pthread_mutex_t timer_mutex = PTHREAD_MUTEX_INITIALIZER;
 static pthread_cond_t timer = PTHREAD_COND_INITIALIZER;
 
 /*
- * This routine will sleep (sec, msec).  Note, however, that if a 
+ * This routine will sleep (sec, microsec).  Note, however, that if a 
  *   signal occurs, it will return early.  It is up to the caller
  *   to recall this routine if he/she REALLY wants to sleep the
  *   requested time.
  */
-int bmicrosleep(time_t sec, long msec)
+int bmicrosleep(time_t sec, long usec)
 {
    struct timespec timeout;
    struct timeval tv;
@@ -402,7 +403,7 @@ int bmicrosleep(time_t sec, long msec)
    int stat;
 
    timeout.tv_sec = sec;
-   timeout.tv_nsec = msec * 1000;
+   timeout.tv_nsec = usec * 1000;
 
 #ifdef HAVE_NANOSLEEP
    stat = nanosleep(&timeout, NULL);
@@ -443,7 +444,7 @@ strtoll(const char *ptr, char **endptr, int base)
  * Bacula's implementation of fgets(). The difference is that it handles
  *   being interrupted by a signal (e.g. a SIGCHLD).
  */
-#undef bfgets
+#undef fgetc
 char *bfgets(char *s, int size, FILE *fd)
 {
    char *p = s;
@@ -469,3 +470,15 @@ char *bfgets(char *s, int size, FILE *fd)
    }
    return s;
 }
+
+/*
+ * Make a "unique" filename.  It is important that if
+ *   called again with the same "what" that the result
+ *   will be identical. This allows us to use the file
+ *   without saving its name, and re-generate the name
+ *   so that it can be deleted.
+ */
+void make_unique_filename(POOLMEM **name, int Id, char *what)
+{
+   Mmsg(name, "%s/%s.%s.%d.tmp", working_directory, my_name, what, Id);
+}