client: combine client_open() and client_parse_config()
[paraslash.git] / dbadm.c
diff --git a/dbadm.c b/dbadm.c
index 5e7bf6e1d44f1750a2649514693f265a6f548b0d..4772c969d1a6bf71d052121b4c4241426a557d12 100644 (file)
--- a/dbadm.c
+++ b/dbadm.c
@@ -37,7 +37,7 @@ WINDOW *att_win;
 static char **choices;
 
 /* no looging */
 static char **choices;
 
 /* no looging */
-void para_log(__unused int ll, __unused const char *fmt,...)
+void para_log(__a_unused int ll, __a_unused const char *fmt,...)
 {
 }
 
 {
 }
 
@@ -56,19 +56,19 @@ static int client_cmd(const char *cmd)
 static char **get_all_atts(int *num_atts)
 {
        int fd = client_cmd("laa");
 static char **get_all_atts(int *num_atts)
 {
        int fd = client_cmd("laa");
-       FILE *pipe;
+       FILE *f;
        char **ret = NULL, *buf;
 
        if (fd < 0)
                return NULL;
        char **ret = NULL, *buf;
 
        if (fd < 0)
                return NULL;
-       pipe = fdopen(fd, "r");
-       if (!pipe) {
+       f = fdopen(fd, "r");
+       if (!f) {
                close(fd);
                return NULL;
        }
        *num_atts = 0;
        buf = para_malloc(MAXLINE * sizeof(char));
                close(fd);
                return NULL;
        }
        *num_atts = 0;
        buf = para_malloc(MAXLINE * sizeof(char));
-       while (fgets(buf, MAXLINE - 1, pipe) && *buf) {
+       while (fgets(buf, MAXLINE - 1, f) && *buf) {
                size_t n = strlen(buf);
                buf[n - 1] = '\0';
                if (choice_len < n - 1)
                size_t n = strlen(buf);
                buf[n - 1] = '\0';
                if (choice_len < n - 1)
@@ -99,7 +99,7 @@ static char *get_atts(char *filename)
        return buf;
 }
 
        return buf;
 }
 
-static void _item_init(__unused MENU* menu)
+static void _item_init(__a_unused MENU* menu)
 {
 //     static int subsequent_run;
        int i, n;
 {
 //     static int subsequent_run;
        int i, n;
@@ -150,6 +150,8 @@ static int commit_changes(char *filename)
 //     ITEM **items;
        int i;
        char buf[MAXLINE] = "para_client sa ";
 //     ITEM **items;
        int i;
        char buf[MAXLINE] = "para_client sa ";
+       int fds[3] = {0, 0, 0};
+       pid_t pid;
 
        for (i = 0; i < n_choices; ++i) {
                strcat(buf, item_name(my_items[i]));
 
        for (i = 0; i < n_choices; ++i) {
                strcat(buf, item_name(my_items[i]));
@@ -162,7 +164,7 @@ static int commit_changes(char *filename)
        strcat(buf, filename);
        //printf("old atts: %s\n", atts);
        //printf("%s\n", buf);
        strcat(buf, filename);
        //printf("old atts: %s\n", atts);
        //printf("%s\n", buf);
-       return system(buf);
+       return para_exec_cmdline_pid(&pid, buf, fds);
 }
 
 static char *get_current_filename(void)
 }
 
 static char *get_current_filename(void)
@@ -330,11 +332,8 @@ repeat:
                        goto repeat;
                /* Enter */
                case 10:
                        goto repeat;
                /* Enter */
                case 10:
-                       endwin();
                        if (atts_modified)
                                commit_changes(filename);
                        if (atts_modified)
                                commit_changes(filename);
-                       else
-                               printf("Attributes unchanged\n");
                        goto out;
                default:
                        goto repeat;
                        goto out;
                default:
                        goto repeat;
@@ -342,7 +341,7 @@ repeat:
 out:
        if (my_items) {
                free_item(my_items[0]);
 out:
        if (my_items) {
                free_item(my_items[0]);
-               free_item(my_items[1]);
+               free_item(my_items[1]);
        }
        for (i = 0; i < n_choices; i++)
                free(choices[i]);
        }
        for (i = 0; i < n_choices; i++)
                free(choices[i]);