]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/lib/bsys.c
Massive SD calling sequence reorganization
[bacula/bacula] / bacula / src / lib / bsys.c
index bb36376c16301ff81c75406975a0a87716506423..1aa87d9f6020db5c1a6e5c55f3b6dbf012091cd7 100644 (file)
@@ -45,6 +45,16 @@ char *bstrncpy(char *dest, const char *src, int maxlen)
    return dest;
 }
 
+/*
+ * Guarantee that the string is properly terminated */
+char *bstrncpy(char *dest, POOL_MEM &src, int maxlen)
+{
+   strncpy(dest, src.c_str(), maxlen-1);
+   dest[maxlen-1] = 0;
+   return dest;
+}
+
+
 char *bstrncat(char *dest, const char *src, int maxlen)
 {
    strncat(dest, src, maxlen-1);
@@ -52,6 +62,14 @@ char *bstrncat(char *dest, const char *src, int maxlen)
    return dest;
 }
 
+char *bstrncat(char *dest, POOL_MEM &src, int maxlen)
+{
+   strncat(dest, src.c_str(), maxlen-1);
+   dest[maxlen-1] = 0;
+   return dest;
+}
+
+
 
 #ifndef DEBUG
 void *bmalloc(size_t size)
@@ -201,13 +219,13 @@ int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result)
 #endif
 #endif /* HAVE_READDIR_R */
 
-#ifdef xxxxxxxxxx_STRERROR_R
-int strerror_r(int errnum, char *buf, size_t bufsiz)
+
+int bstrerror(int errnum, char *buf, size_t bufsiz)
 {
     static pthread_mutex_t mutex;
     static int first = 1;
     int stat = 0;
-    char *msg;
+    const char *msg;
 
     if (first) {
        pthread_mutex_init(&mutex, NULL);
@@ -224,7 +242,6 @@ int strerror_r(int errnum, char *buf, size_t bufsiz)
     V(mutex);
     return stat;
 }
-#endif /* HAVE_STRERROR_R */
 
 /*
  * These are mutex routines that do error checking