]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
BEE Backport lib files
authorEric Bollengier <eric@baculasystems.com>
Wed, 6 Sep 2023 10:08:13 +0000 (12:08 +0200)
committerEric Bollengier <eric@baculasystems.com>
Thu, 14 Sep 2023 11:57:02 +0000 (13:57 +0200)
bacula/src/lib/bcollector.c
bacula/src/lib/bsys.c
bacula/src/lib/htable.c
bacula/src/lib/output.h
bacula/src/lib/status.h

index b2a3a85ba096fa37e0abdbc4eff2e27ef50d0437..5fa2e8dea4c9f2ec5f815fc4b3cf850134060462 100644 (file)
@@ -28,7 +28,6 @@
 #include "bacula.h"
 #include "parse_conf.h"
 #include "jcr.h"
-#define STATUS_FUNCTIONS
 #include "status.h"
 #include <time.h>
 
index 1211fb1c96c36c6080efe5d3703bd22406b6838b..c708164510103c5144596c8a463955c01fa3cde2 100644 (file)
@@ -1941,29 +1941,6 @@ int get_home_directories(const char *grpname, alist *dirs)
    return (dirs->size() > 0) ? 0 : -1;
 }
 
-/* Implementation of strcasestr() for non-gnu platforms */
-char *bstrcasestr(const char *haystack, const char *needle)
-{
-  int needle_len;               /* Length of needle.  */
-  int haystack_len;             /* Known minimum length of haystack.  */
-
-  if (!needle || needle[0] == '\0') {
-     return (char *)haystack;
-  }
-  needle_len = strlen (needle);
-  haystack_len = strlen (haystack);
-
-  const char *p = haystack;
-  while (p && *p && haystack_len >= needle_len) {
-     if (strncasecmp(needle, p, needle_len) == 0) {
-        return (char *)p;
-     }
-     p++;
-     haystack_len--;
-  }
-  return NULL;
-}
-
 void b_uname(POOLMEM *&un)
 {
    if (un) {
@@ -2093,6 +2070,29 @@ void get_path_and_fname(const char *name, char **path, char **fname)
    }
 }
 
+/* Implementation of strcasestr() for non-gnu platforms */
+char *bstrcasestr(const char *haystack, const char *needle)
+{
+  int needle_len;               /* Length of needle.  */
+  int haystack_len;             /* Known minimum length of haystack.  */
+
+  if (!needle || needle[0] == '\0') {
+     return (char *)haystack;
+  }
+  needle_len = strlen (needle);
+  haystack_len = strlen (haystack);
+
+  const char *p = haystack;
+  while (p && *p && haystack_len >= needle_len) {
+     if (strncasecmp(needle, p, needle_len) == 0) {
+        return (char *)p;
+     }
+     p++;
+     haystack_len--;
+  }
+  return NULL;
+}
+
 #ifdef TEST_PROGRAM
 
 #include "unittests.h"
@@ -2352,17 +2352,6 @@ int main(int argc, char **argv)
       i++;
    }
 
-   // Test bstrcasestr()
-   {
-      const char *p1 = "This is a test";
-      ok(bstrcasestr(p1, "toto") == NULL, "Test with non existing string");
-      ok(bstrcasestr(p1, NULL) == p1, "Test with NULL string");
-      ok(bstrcasestr(p1, "") == p1, "Test with empty string");
-      is(bstrcasestr(p1, "TEST"), "test", "Test with upper string at the end");
-      is(bstrcasestr(p1, "this"), p1, "Test with lower string at the start");
-      ok(bstrcasestr(p1, "xxxxxxxxxxxxxxxxxxxxxxxxx") == NULL, "Test with non existing string");
-      is(bstrcasestr(p1, " iS"), " is a test", "Test with a middle string");
-   }
    {
       char *fname = NULL;
       char *path = NULL;
@@ -2388,6 +2377,18 @@ int main(int argc, char **argv)
       free(path);
       free(fname);
    }
+
+   // Test bstrcasestr()
+   {
+      const char *p1 = "This is a test";
+      ok(bstrcasestr(p1, "toto") == NULL, "Test with non existing string");
+      ok(bstrcasestr(p1, NULL) == p1, "Test with NULL string");
+      ok(bstrcasestr(p1, "") == p1, "Test with empty string");
+      is(bstrcasestr(p1, "TEST"), "test", "Test with upper string at the end");
+      is(bstrcasestr(p1, "this"), p1, "Test with lower string at the start");
+      ok(bstrcasestr(p1, "xxxxxxxxxxxxxxxxxxxxxxxxx") == NULL, "Test with non existing string");
+      is(bstrcasestr(p1, " iS"), " is a test", "Test with a middle string");
+   }
    return report();
 }
 #endif
index 9931b587f180c89c9139ce1cf3a65671a10ef6b7..3f67fde2548ac7b47024ebbcc06897f333ac4f6f 100644 (file)
@@ -225,7 +225,7 @@ void htable::grow_table()
    Dmsg1(100, "Grow called old size = %d\n", buckets);
    /* Setup a bigger table */
    htable *big = (htable *)malloc(sizeof(htable));
-   memcpy((void *)big, (void *)this, sizeof(htable));  /* start with original class data */
+   memcpy((void*)big, (void*)this, sizeof(htable));  /* start with original class data */
    big->loffset = loffset;
    big->mask = mask<<1 | 1;
    big->rshift = rshift - 1;
index 289d8e659a753273a10be41e052f90daf53066d8..dc83599e3ca86036d8a3a20293fbef3c425f794f 100644 (file)
@@ -25,6 +25,9 @@
 
 #include "bacula.h"
 
+/* define some standard error code to use in OutputWriter::set_error() */
+#define OWE_NO_DATA     501
+
 enum _OutputType {
    OT_INT,                      /* Integer */
    OT_SIZE,                     /* int64 size */
index 9c04390d064daf8430da36343ca1c05054c60875..1a0d9b023d881861d6d7d45eed3bb28b876b7ada 100644 (file)
@@ -37,9 +37,6 @@
 
 extern void output_status(STATUS_PKT *sp);
 
-#ifndef STATUS_FUNCTIONS
-#define STATUS_FUNCTIONS
-
 /*
  * Send to bsock (Director or Console)
  */
@@ -56,6 +53,9 @@ static void sendit(const char *msg, int len, STATUS_PKT *sp)
    }
 }
 
+#ifndef STATUS_FUNCTIONS
+#define STATUS_FUNCTIONS
+
 /* common to SD/FD */
 #ifdef USE_LIST_TERMINATED_JOBS
 static void list_terminated_jobs(STATUS_PKT *sp)