remove list_repositories() config.c function in favor of a cmd_list_repositories() function in main.c

Sun, 17 Dec 2023 15:03:01 +0100

author
Mike Becker <universe@uap-core.de>
date
Sun, 17 Dec 2023 15:03:01 +0100
changeset 798
d7f5067a27ce
parent 797
edbb20b1438d
child 799
d479b5e25b6e

remove list_repositories() config.c function in favor of a cmd_list_repositories() function in main.c

dav/config.c file | annotate | diff | comparison | revisions
dav/config.h file | annotate | diff | comparison | revisions
dav/main.c file | annotate | diff | comparison | revisions
dav/main.h file | annotate | diff | comparison | revisions
--- a/dav/config.c	Sun Dec 17 14:25:34 2023 +0100
+++ b/dav/config.c	Sun Dec 17 15:03:01 2023 +0100
@@ -228,16 +228,6 @@
     return k;
 }
 
-int list_repositories(void) {
-    if(!davconfig) {
-        return 1;
-    }
-    for(DavCfgRepository *repo=davconfig->repositories;repo;repo=repo->next) {
-        printf("%.*s\n", (int)repo->name.value.length, repo->name.value.ptr);
-    }
-    return 0;
-}
-
 static char* get_attr_content(xmlNode *node) {
     // TODO: remove code duplication (util_xml_get_text)
     while(node) {
--- a/dav/config.h	Sun Dec 17 14:25:34 2023 +0100
+++ b/dav/config.h	Sun Dec 17 15:03:01 2023 +0100
@@ -59,8 +59,6 @@
 
 cxmutstr load_key_file(const char *filename);
 
-int list_repositories(void);
-
 PwdStore* get_pwdstore(void);
 int pwdstore_save(PwdStore *pwdstore);
 
--- a/dav/main.c	Sun Dec 17 14:25:34 2023 +0100
+++ b/dav/main.c	Sun Dec 17 15:03:01 2023 +0100
@@ -223,7 +223,7 @@
             ret = cmd_remove_repository(args);
         } else if(!strcasecmp(cmd, "list-repositories")
                 || !strcasecmp(cmd, "list-repos")) {
-            ret = list_repositories();
+            ret = cmd_list_repositories();
         } else if(!strcasecmp(cmd, "repository-url")
                 || !strcasecmp(cmd, "repo-url")) {
             ret = cmd_repository_url(args);
@@ -2502,6 +2502,17 @@
     }
 }
 
+int cmd_list_repositories(void) {
+    DavConfig *config = get_config();
+    if(!config) {
+        return 1;
+    }
+    for(DavCfgRepository *repo=config->repositories;repo;repo=repo->next) {
+        printf("%.*s\n", (int)repo->name.value.length, repo->name.value.ptr);
+    }
+    return 0;
+}
+
 int cmd_repository_url(CmdArgs *args) {
     if(args->argc != 1) {
         fprintf(stderr, "Too few arguments\n");
--- a/dav/main.h	Sun Dec 17 14:25:34 2023 +0100
+++ b/dav/main.h	Sun Dec 17 15:03:01 2023 +0100
@@ -128,6 +128,7 @@
 
 int cmd_add_repository(CmdArgs *args);
 int cmd_remove_repository(CmdArgs *args);
+int cmd_list_repositories(void);
 
 int cmd_repository_url(CmdArgs *args);
 

mercurial