]> git.ipfire.org Git - people/ms/libloc.git/blobdiff - src/test-database.c
Add license attribute to the database
[people/ms/libloc.git] / src / test-database.c
index b8890cba154f942f44f7f022e2da95014a76ac0a..74e83ee08115976c262818e564419042e4b51406 100644 (file)
@@ -35,6 +35,7 @@ const char* DESCRIPTION =
        "tempor felis enim. Integer congue nisi in maximus pretium. "
        "Pellentesque et turpis elementum, luctus mi at, interdum erat. "
        "Maecenas ut venenatis nunc.";
+const char* LICENSE = "CC";
 
 int main(int argc, char** argv) {
        int err;
@@ -82,6 +83,22 @@ int main(int argc, char** argv) {
                exit(EXIT_FAILURE);
        }
 
+       // Set a license
+       err = loc_writer_set_license(writer, LICENSE);
+       if (err) {
+               fprintf(stderr, "Could not set license\n");
+               exit(EXIT_FAILURE);
+       }
+
+       // Retrieve license
+       const char* license = loc_writer_get_license(writer);
+       if (license) {
+               printf("License is: %s\n", license);
+       } else {
+               fprintf(stderr, "Could not retrieve license\n");
+               exit(EXIT_FAILURE);
+       }
+
        FILE* f = fopen("test.db", "w");
        if (!f) {
                fprintf(stderr, "Could not open file for writing: %s\n", strerror(errno));