]> code.citadel.org Git - citadel.git/blobdiff - citadel/serv_upgrade.c
fixed time_t handling (have to cast it to long for printf/scanf)
[citadel.git] / citadel / serv_upgrade.c
index 01c920c5889ae4eca3e9bb65066737c12f7643cd..536dca5e808bd70407383d1415d68cc53775a609 100644 (file)
@@ -7,6 +7,7 @@
  * $Id$
  */
 
+#include "sysdep.h"
 #include <stdlib.h>
 #include <unistd.h>
 #include <stdio.h>
@@ -19,7 +20,9 @@
 #include <sys/wait.h>
 #include <string.h>
 #include <limits.h>
+#ifdef HAVE_PTHREAD_H
 #include <pthread.h>
+#endif
 #include "citadel.h"
 #include "server.h"
 #include <syslog.h>
@@ -40,8 +43,8 @@ FILE *imfp, *exfp;
 #define MODULE_NAME    "Import an unpacked system"
 #define MODULE_AUTHOR  "Art Cancro"
 #define MODULE_EMAIL   "ajc@uncnsrd.mt-kisco.ny.us"
-#define MAJOR_VERSION  0
-#define MINOR_VERSION  3
+#define MAJOR_VERSION  1
+#define MINOR_VERSION  0
 
 static struct DLModule_Info info = {
        MODULE_NAME,
@@ -73,7 +76,7 @@ void fpgetfield(FILE *fp, char *string)
 void import_message(long msgnum, long msglen) {
        char *msgtext;
 
-       msgtext = malloc(msglen);
+       msgtext = mallok(msglen);
        if (msgtext == NULL) {
                lprintf(3, "ERROR: cannot allocate memory\n");
                lprintf(3, "Your data files are now corrupt.\n");
@@ -83,7 +86,7 @@ void import_message(long msgnum, long msglen) {
 
        fread(msgtext, msglen, 1, imfp);
        cdb_store(CDB_MSGMAIN, &msgnum, sizeof(long), msgtext, msglen);
-       free(msgtext);
+       phree(msgtext);
        }
 
 void imp_floors(void) {
@@ -95,7 +98,7 @@ void imp_floors(void) {
        while(fpgetfield(imfp, key), strcasecmp(key, "endsection")) {
 
                if (!strcasecmp(key, "floor")) {
-                       bzero(&fl, sizeof(struct floor));
+                       memset(&fl, 0, sizeof(struct floor));
 
                        while(fpgetfield(imfp, tag),
                             strcasecmp(tag, "endfloor")) {
@@ -139,7 +142,7 @@ void imp_rooms(void) {
        
        while(fpgetfield(imfp, key), strcasecmp(key, "endsection")) {
                if (!strcasecmp(key, "room")) {
-                       bzero(&qr, sizeof(struct quickroom));
+                       memset(&qr, 0, sizeof(struct quickroom));
                        msglist = NULL;
                        num_msgs = 0;
                        lprintf(9, "Room ");
@@ -188,7 +191,7 @@ void imp_rooms(void) {
                                        msglen = atol(tval);
                                        import_message(msgnum, msglen);
                                        ++num_msgs;
-                                       msglist = realloc(msglist,
+                                       msglist = reallok(msglist,
                                                (sizeof(long)*num_msgs) );
                                        msglist[num_msgs - 1] = msgnum;
                                        }
@@ -206,7 +209,7 @@ void imp_rooms(void) {
                                        CC->num_msgs = num_msgs;
                                        put_msglist(&qr);
                                        }
-                               free(msglist);
+                               phree(msglist);
                                }
 
                        }
@@ -225,7 +228,7 @@ void import_a_user(void) {
        char key[256], value[256];
        struct usersupp us;
 
-       bzero(&us, sizeof(struct usersupp));    
+       memset(&us, 0, sizeof(struct usersupp));        
        while(fpgetfield(imfp, key), strcasecmp(key, "enduser")) {
                if (strcasecmp(key, "mail")) {
                        fpgetfield(imfp, value);
@@ -486,6 +489,12 @@ void import_databases(void) {
 
 void do_import(char *argbuf) {
        char import_filename[PATH_MAX];
+
+        if (CC->internal_pgm == 0) {
+                cprintf("%d This command is for internal programs only.\n",
+                        ERROR);
+                return;
+                }
        
        extract(import_filename, argbuf, 0);
        imfp = fopen(import_filename, "rb");
@@ -534,12 +543,12 @@ void export_a_room(struct quickroom *qr) {
        fprintf(exfp, "qrpasswd%c%s%c", 0, qr->QRpasswd, 0);
        fprintf(exfp, "qrroomaide%c%ld%c", 0, qr->QRroomaide, 0);
        fprintf(exfp, "qrhighest%c%ld%c", 0, qr->QRhighest, 0);
-       fprintf(exfp, "qrgen%c%ld%c", 0, qr->QRgen, 0);
+       fprintf(exfp, "qrgen%c%ld%c", 0, (long)qr->QRgen, 0);
        fprintf(exfp, "qrflags%c%d%c", 0, qr->QRflags, 0);
        fprintf(exfp, "qrdirname%c%s%c", 0, qr->QRdirname, 0);
        fprintf(exfp, "qrinfo%c%ld%c", 0, qr->QRinfo, 0);
        fprintf(exfp, "qrfloor%c%d%c", 0, qr->QRfloor, 0);
-       fprintf(exfp, "qrmtime%c%ld%c", 0, qr->QRmtime, 0);
+       fprintf(exfp, "qrmtime%c%ld%c", 0, (long)qr->QRmtime, 0);
        fprintf(exfp, "qrepmode%c%d%c", 0, qr->QRep.expire_mode, 0);
        fprintf(exfp, "qrepvalue%c%d%c", 0, qr->QRep.expire_value, 0);
 
@@ -600,7 +609,7 @@ void export_a_user(struct usersupp *us) {
        fprintf(exfp, "usscreenwidth%c%d%c", 0, us->USscreenwidth, 0);
        fprintf(exfp, "usscreenheight%c%d%c", 0, us->USscreenheight, 0);
        fprintf(exfp, "usernum%c%ld%c", 0, us->usernum, 0);
-       fprintf(exfp, "lastcall%c%ld%c", 0, us->lastcall, 0);
+       fprintf(exfp, "lastcall%c%ld%c", 0, (long)us->lastcall, 0);
        fprintf(exfp, "usname%c%s%c", 0, us->USname, 0);
        fprintf(exfp, "usaddr%c%s%c", 0, us->USaddr, 0);
        fprintf(exfp, "uscity%c%s%c", 0, us->UScity, 0);
@@ -654,6 +663,12 @@ void export_visits(void) {
 
 void do_export(char *argbuf) {
        char export_filename[PATH_MAX];
+
+        if (CC->internal_pgm == 0) {
+                cprintf("%d This command is for internal programs only.\n",
+                        ERROR);
+                return;
+                }
        
        extract(export_filename, argbuf, 0);
        exfp = fopen(export_filename, "wb");