Merge branch 'stable-82x' of ssh://git.citadel.org/appl/gitroot/citadel into stable-82x
authorArt Cancro <ajc@uncensored.citadel.org>
Thu, 2 Jan 2014 14:48:06 +0000 (09:48 -0500)
committerArt Cancro <ajc@uncensored.citadel.org>
Thu, 2 Jan 2014 14:48:06 +0000 (09:48 -0500)
citadel/modules/migrate/serv_migrate.c
citadel/utils/sendcommand.c
webcit/po/webcit/en_GB.po

index 41a2fdf2497d3dc323e078292367069e235eaca0..117eb21bbeea4cba0cd4acdb2ea03cb75d6de08a 100644 (file)
@@ -889,12 +889,12 @@ void migr_xml_end(void *data, const char *el) {
  * Import begins here
  */
 void migr_do_import(void) {
-       char buf[SIZ];
+       StrBuf *Buf;
        XML_Parser xp;
        int linelen;
        
        unbuffer_output();
-
+       Buf = NewStrBufPlain(NULL, SIZ);
        xp = XML_ParserCreate(NULL);
        if (!xp) {
                cprintf("%d Failed to create XML parser instance\n", ERROR+INTERNAL_ERROR);
@@ -908,22 +908,22 @@ void migr_do_import(void) {
        cprintf("%d sock it to me\n", SEND_LISTING);
        unbuffer_output();
 
-       while (client_getln(buf, sizeof buf) >= 0 && strcmp(buf, "000")) {
-               linelen = strlen(buf);
-               strcpy(&buf[linelen++], "\n");
+       while (CtdlClientGetLine(Buf) >= 0 && strcmp(ChrPtr(Buf), "000")) {
+               linelen = StrLength(Buf);
+               StrBufAppendBufPlain(Buf, HKEY("\n"), 0);
 
                if (server_shutting_down)
                        break;  // Should we break or return?
                
-               if (buf[0] == '\0')
+               if (linelen == 0)
                        continue;
 
-               XML_Parse(xp, buf, linelen, 0);
+               XML_Parse(xp, ChrPtr(Buf), linelen, 0);
        }
 
        XML_Parse(xp, "", 0, 1);
        XML_ParserFree(xp);
-       
+       FreeStrBuf(&Buf);
        rebuild_euid_index();
        rebuild_usersbynumber();
        CC->dont_term = 0;
index e97965f19b329dda6c0107549467381db21f4096..6146dbb654f7a8ae845cc9012f96dce5f84a3238 100644 (file)
@@ -12,6 +12,7 @@
  * GNU General Public License for more details.
  */
 
+#include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <sys/types.h>
@@ -27,7 +28,7 @@
 #include <sys/un.h>
 #include "citadel.h"
 #include "include/citadel_dirs.h"
-
+#include <libcitadel.h>
 
 
 int serv_sock = (-1);
@@ -178,7 +179,7 @@ int main(int argc, char **argv)
        );
        fflush(stderr);
 
-       alarm(watchdog);
+//     alarm(watchdog);
        serv_sock = uds_connectsock(file_citadel_admin_socket);
 
        serv_gets(buf);
@@ -200,19 +201,81 @@ int main(int argc, char **argv)
        xfermode = buf[0];
 
        if ((xfermode == '4') || (xfermode == '8')) {           /* send text */
-               while (fgets(buf, sizeof buf, stdin)) {
-                       buf[strlen(buf)-1] = 0;
-                       serv_puts(buf);
+               IOBuffer IOB;
+               FDIOBuffer FDIO;
+               const char *ErrStr;
+
+               memset(&IOB, 0, sizeof(0));
+               IOB.Buf = NewStrBufPlain(NULL, SIZ);
+               IOB.fd = serv_sock;
+               FDIOBufferInit(&FDIO, &IOB, fileno(stdin), -1);
+
+               while (FileSendChunked(&FDIO, &ErrStr));
                        alarm(watchdog);                        /* reset the watchdog timer */
-               }
+               FDIOBufferDelete(&FDIO);
+               FreeStrBuf(&IOB.Buf);
                serv_puts("000");
        }
 
        if ((xfermode == '1') || (xfermode == '8')) {           /* receive text */
-               while (serv_gets(buf), strcmp(buf, "000")) {
-                       printf("%s\n", buf);
-                       alarm(watchdog);                        /* reset the watchdog timer */
+               IOBuffer IOB;
+               StrBuf *Line, *OutBuf;
+               int Finished = 0;
+
+               memset(&IOB, 0, sizeof(IOB));
+               IOB.Buf = NewStrBufPlain(NULL, SIZ);
+               IOB.fd = serv_sock;
+               Line = NewStrBufPlain(NULL, SIZ);
+               OutBuf = NewStrBufPlain(NULL, SIZ * 10);
+
+               while (!Finished && (StrBuf_read_one_chunk_callback (serv_sock, 0, &IOB) >= 0))
+               {
+                       eReadState State;
+
+                       State = eReadSuccess;
+                       while (!Finished && (State == eReadSuccess))
+                       {
+                               if (IOBufferStrLength(&IOB) == 0)
+                               {
+                                       State = eMustReadMore;
+                                       break;
+                               }
+                               State = StrBufChunkSipLine(Line, &IOB);
+                               switch (State)
+                               {
+                               case eReadSuccess:
+                                       if (!strcmp(ChrPtr(Line), "000"))
+                                       {
+                                               Finished = 1;
+                                               break;
+                                       }
+                                       StrBufAppendBuf(OutBuf, Line, 0);
+                                       StrBufAppendBufPlain(OutBuf, HKEY("\n"), 0);
+//                                     alarm(watchdog);                        /* reset the watchdog timer */
+                                       break;
+                               case eBufferNotEmpty:
+                                       break;
+                               case eMustReadMore:
+                                       continue;
+                               case eReadFail:
+                                       fprintf(stderr, "WTF? Exit!\n");
+                                       exit(-1);
+                                       break;
+                               }
+                               if (StrLength(OutBuf) > 5*SIZ)
+                               {
+                                       fwrite(ChrPtr(OutBuf), 1, StrLength(OutBuf), stdout);
+                                       FlushStrBuf(OutBuf);
+                               }
+                       }
+               }
+               if (StrLength(OutBuf) > 0)
+               {
+                       fwrite(ChrPtr(OutBuf), 1, StrLength(OutBuf), stdout);
                }
+               FreeStrBuf(&Line);
+               FreeStrBuf(&OutBuf);
+               FreeStrBuf(&IOB.Buf);
        }
        
        if (xfermode == '6') {                                  /* receive binary */
index 0d0148074225c92b99e2878d96e7e2301eaf584a..2a7ee0f5e2ab7f4f256741186b49dd2094eb141e 100644 (file)
@@ -868,7 +868,7 @@ msgstr "(One per line)"
 #: ../../event.c:450 ../../static/t/edit_message.html:143
 #: ../../static/t/iconbar.html:29 ../../static/t/iconbar/edit.html:42
 msgid "Contacts"
-msgstr "Contents"
+msgstr "Contacts"
 
 #: ../../event.c:513
 msgid "Recurrence rule"