]> code.citadel.org Git - citadel.git/blobdiff - citadel/migratenet.c
removed all references to sprintf from several files (not all files yet)
[citadel.git] / citadel / migratenet.c
index 74219ae58e050f36e3c329fe1aa35174b2170aba..1ecf2c1e705f0d0b9ffa19b3aa16b823322e692e 100644 (file)
@@ -12,6 +12,9 @@
 #include <sys/types.h>
 #include <dirent.h>
 #include <errno.h>
+#ifdef HAVE_LIMITS_H
+#include <limits.h>
+#endif
 #include "citadel.h"
 #include "ipc.h"
 #include "tools.h"
@@ -66,7 +69,7 @@ int main(int argc, char **argv)
                logoff(atoi(buf));
        }
 
-       sprintf(buf, "IPGM %d", config.c_ipgm_secret);
+       snprintf(buf, sizeof buf, "IPGM %d", config.c_ipgm_secret);
        serv_puts(buf);
        serv_gets(buf);
        fprintf(stderr, "%s\n", &buf[4]);
@@ -114,7 +117,7 @@ int main(int argc, char **argv)
                        fprintf(nodefp, "%s|", buf);
                        printf("Enter host name/IP : ");
                        gets(buf);
-                       if (buf[0] == 0) sprintf(buf, "%s.citadel.org",
+                       if (buf[0] == 0) snprintf(buf, sizeof buf, "%s.citadel.org",
                                d->d_name);
                        fprintf(nodefp, "%s|", buf);
                        printf("Enter port number  : ");
@@ -146,7 +149,7 @@ int main(int argc, char **argv)
 
        /* Set up the node table */
        printf("Creating neighbor node table\n");
-       sprintf(buf, "CONF putsys|%s", IGNETCFG);
+       snprintf(buf, sizeof buf, "CONF putsys|%s", IGNETCFG);
        serv_puts(buf);
        serv_gets(buf);
        if (buf[0] == '4') {
@@ -167,7 +170,7 @@ int main(int argc, char **argv)
 
        /* Now go through the table looking for node names to enter */
 
-       sprintf(buf, "cat %s |awk '{ FS=\"|\"; print $2 }' |sort -f |uniq -i",
+       snprintf(buf, sizeof buf, "cat %s |awk -F \"|\" '{ print $2 }' |sort -f |uniq -i",
                roomfilename);
        roomfp = popen(buf, "r");
        if (roomfp == NULL) {
@@ -192,16 +195,17 @@ int main(int argc, char **argv)
        while (mn != NULL) {
                printf("Room <%s>\n", mn->roomname);
 
-               sprintf(buf, "GOTO %s", mn->roomname);
+               snprintf(buf, sizeof buf, "GOTO %s", mn->roomname);
                serv_puts(buf);
                serv_gets(buf);
+               printf("%s\n", &buf[4]);
                if (buf[0] != '2') goto roomerror;
 
                serv_puts("SNET");
                serv_gets(buf);
                if (buf[0] != '4') goto roomerror;
 
-               sprintf(buf, "lastsent|%ld", highest);
+               snprintf(buf, sizeof buf, "lastsent|%ld", highest);
                serv_puts(buf);
 
                roomfp = fopen(roomfilename, "r");
@@ -211,7 +215,7 @@ int main(int argc, char **argv)
                                extract(node, buf, 0);
                                extract(room, buf, 1);
                                if (!strcasecmp(room, mn->roomname)) {
-                                       sprintf(buf, 
+                                       snprintf(buf, sizeof buf,
                                                "ignet_push_share|%s", node);
                                        serv_puts(buf);
                                }
@@ -229,5 +233,19 @@ roomerror: /* free this record */
 
        unlink(roomfilename);
        unlink(nodefilename);
-       return(0);
+
+       printf("\n\n"
+               "If this conversion was successful, you do not need your\n"
+               "old network configuration files.  Delete them now? "
+       );
+
+       gets(buf);
+       if (tolower(buf[0]) != 'y') exit(0);
+
+       get_config();
+       system("rm -fr ./network/systems");
+       system("rm -f ./network/mail.sysinfo");
+       system("rm -f ./network/internetmail.config");
+
+       exit(0);
 }