net.h: add missing __printf_2_3 attribute to send_va_buffer()
[paraslash.git] / dbadm.c
diff --git a/dbadm.c b/dbadm.c
index 6b5a3e989f3f30eb82b272d57682b2cbdbddc2ee..f48c6b209e0bfe142740f715400ef6a5cffd517f 100644 (file)
--- a/dbadm.c
+++ b/dbadm.c
@@ -1,19 +1,7 @@
 /*
  * Copyright (C) 2004-2006 Andre Noll <maan@systemlinux.org>
  *
- *     This program is free software; you can redistribute it and/or modify
- *     it under the terms of the GNU General Public License as published by
- *     the Free Software Foundation; either version 2 of the License, or
- *     (at your option) any later version.
- *
- *     This program is distributed in the hope that it will be useful,
- *     but WITHOUT ANY WARRANTY; without even the implied warranty of
- *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *     GNU General Public License for more details.
- *
- *     You should have received a copy of the GNU General Public License
- *     along with this program; if not, write to the Free Software
- *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ * Licensed under the GPL v2. For licencing details see COPYING.
  */
 
 /** \file dbadm.c simple attribute setting utility for the mysql selector */
@@ -56,19 +44,19 @@ static int client_cmd(const char *cmd)
 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;
-       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));
-       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)
@@ -150,6 +138,8 @@ static int commit_changes(char *filename)
 //     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]));
@@ -162,7 +152,7 @@ static int commit_changes(char *filename)
        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)
@@ -330,11 +320,8 @@ repeat:
                        goto repeat;
                /* Enter */
                case 10:
-                       endwin();
                        if (atts_modified)
                                commit_changes(filename);
-                       else
-                               printf("Attributes unchanged\n");
                        goto out;
                default:
                        goto repeat;
@@ -342,7 +329,7 @@ repeat:
 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]);