From: Art Cancro Date: Thu, 2 Jan 2014 14:48:06 +0000 (-0500) Subject: Merge branch 'stable-82x' of ssh://git.citadel.org/appl/gitroot/citadel into stable-82x X-Git-Tag: v8.24~10 X-Git-Url: https://code.citadel.org/?a=commitdiff_plain;h=03c05b7e8b6670d8d0a2737840d4bf18f810431b;hp=1cc036dfd97eb78144040b27ade8662ea82a56cc;p=citadel.git Merge branch 'stable-82x' of ssh://git.citadel.org/appl/gitroot/citadel into stable-82x --- diff --git a/citadel/modules/migrate/serv_migrate.c b/citadel/modules/migrate/serv_migrate.c index 41a2fdf24..117eb21bb 100644 --- a/citadel/modules/migrate/serv_migrate.c +++ b/citadel/modules/migrate/serv_migrate.c @@ -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; diff --git a/citadel/utils/sendcommand.c b/citadel/utils/sendcommand.c index e97965f19..6146dbb65 100644 --- a/citadel/utils/sendcommand.c +++ b/citadel/utils/sendcommand.c @@ -12,6 +12,7 @@ * GNU General Public License for more details. */ +#include #include #include #include @@ -27,7 +28,7 @@ #include #include "citadel.h" #include "include/citadel_dirs.h" - +#include 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 */ diff --git a/webcit/po/webcit/en_GB.po b/webcit/po/webcit/en_GB.po index 0d0148074..2a7ee0f5e 100644 --- a/webcit/po/webcit/en_GB.po +++ b/webcit/po/webcit/en_GB.po @@ -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"