]> git.ipfire.org Git - location/libloc.git/blobdiff - src/test-stringpool.c
importer: Drop EDROP as it has been merged into DROP
[location/libloc.git] / src / test-stringpool.c
index 1df7cc5285a1799c404ba8a742db0c02fdb9a02a..a94d8f8bd07815e65f6024ee6f5dc4f3d0c4c54b 100644 (file)
@@ -16,6 +16,7 @@
 
 #include <stdio.h>
 #include <stddef.h>
+#include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
 #include <fcntl.h>
 #include <errno.h>
 #include <unistd.h>
 #include <time.h>
+#include <syslog.h>
 
-#include <loc/libloc.h>
-#include <loc/stringpool.h>
+#include <libloc/libloc.h>
+#include <libloc/stringpool.h>
 
 static const char* characters = "012345789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
 
@@ -53,6 +55,9 @@ int main(int argc, char** argv) {
        if (err < 0)
                exit(EXIT_FAILURE);
 
+       // Enable debug logging
+       loc_set_log_priority(ctx, LOG_DEBUG);
+
        // Create the stringpool
        struct loc_stringpool* pool;
        err = loc_stringpool_new(ctx, &pool);
@@ -69,7 +74,7 @@ int main(int argc, char** argv) {
        // Append a string
        off_t pos = loc_stringpool_add(pool, "ABC");
        if (pos < 0) {
-               fprintf(stderr, "Could not add string: %s\n", strerror(-pos));
+               fprintf(stderr, "Could not add string: %m\n");
                exit(EXIT_FAILURE);
        }
 
@@ -103,7 +108,7 @@ int main(int argc, char** argv) {
                free(string);
 
                if (pos < 0) {
-                       fprintf(stderr, "Could not add string %d: %s\n", i, strerror(-pos));
+                       fprintf(stderr, "Could not add string %d: %m\n", i);
                        exit(EXIT_FAILURE);
                }
        }