From dbed85c6d6552ab0e6299669f759a39abb7557ae Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Sun, 5 Jun 2022 13:02:46 -0400 Subject: [PATCH] Converted two more utilities: ctdlmigrate and sendcommand --- citadel/COPYING | 3 +- citadel/Makefile | 8 ++++- citadel/packageversion | 2 +- citadel/utils/ctdlmigrate.c | 10 +++--- citadel/utils/sendcommand.c | 67 ++++++++++++++----------------------- 5 files changed, 40 insertions(+), 50 deletions(-) diff --git a/citadel/COPYING b/citadel/COPYING index 97eb78723..91923405c 100644 --- a/citadel/COPYING +++ b/citadel/COPYING @@ -1,7 +1,7 @@ Copyright: (C) 1987-2022 Citadel development team; GPL V3 -* In addition, as a special exception, we hereby declare that our +* As a special exception, it is officialy resolved that our favorite type of software is called "open source" -- NOT "free software" -- and that our favorite operating system is called "Linux" -- NOT "GNU/Linux". @@ -14,7 +14,6 @@ Copyright: (C) 1987-2022 Citadel development team; GPL V3 libraries, including OpenSSL, in the sole case that such linking is done to build the Citadel system itself. - GENERAL PUBLIC LICENSE Version 3, 29 June 2007 diff --git a/citadel/Makefile b/citadel/Makefile index bf4b39b6e..fa46fa7ea 100644 --- a/citadel/Makefile +++ b/citadel/Makefile @@ -17,7 +17,7 @@ # config.mk is generated by ./configure include config.mk -all: citserver setup +all: citserver setup ctdlmigrate sendcommand citserver: server/*.c server/modules/*/*.c config.mk server/*.h cc ${CFLAGS} \ @@ -28,6 +28,12 @@ citserver: server/*.c server/modules/*/*.c config.mk server/*.h setup: utils/setup.c server/citadel_dirs.c utils/*.h server/*.h cc ${CFLAGS} utils/setup.c -lcitadel -o setup +ctdlmigrate: utils/ctdlmigrate.c server/citadel_dirs.c utils/*.h server/*.h + cc ${CFLAGS} utils/ctdlmigrate.c -lcitadel -lreadline -o ctdlmigrate + +sendcommand: utils/sendcommand.c server/citadel_dirs.c utils/*.h server/*.h + cc ${CFLAGS} utils/sendcommand.c -lcitadel -o sendcommand + config.mk: configure ./configure diff --git a/citadel/packageversion b/citadel/packageversion index d00491fd7..b8626c4cf 100644 --- a/citadel/packageversion +++ b/citadel/packageversion @@ -1 +1 @@ -1 +4 diff --git a/citadel/utils/ctdlmigrate.c b/citadel/utils/ctdlmigrate.c index 5d8601179..8c1f18a53 100644 --- a/citadel/utils/ctdlmigrate.c +++ b/citadel/utils/ctdlmigrate.c @@ -1,6 +1,6 @@ // Across-the-wire migration utility for Citadel // -// Copyright (c) 2009-2021 citadel.org +// Copyright (c) 2009-2022 citadel.org // // This program is open source software; you can redistribute it and/or modify // it under the terms of the GNU General Public License version 3. @@ -30,11 +30,11 @@ #include #include #include -#include "citadel.h" +#include "../server/citadel.h" #include "axdefs.h" -#include "sysdep.h" -#include "config.h" -#include "citadel_dirs.h" +#include "../server/sysdep.h" +#include "../server/config.h" +#include "../server/citadel_dirs.h" // support for getz() -- (globals would not be appropriate in a multithreaded program) diff --git a/citadel/utils/sendcommand.c b/citadel/utils/sendcommand.c index bd87ff3b4..6971d60a4 100644 --- a/citadel/utils/sendcommand.c +++ b/citadel/utils/sendcommand.c @@ -1,16 +1,14 @@ -/* - * Command-line utility to transmit a server command. - * - * Copyright (c) 1987-2021 by the citadel.org team - * - * This program is open source software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 3. - * - * 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. - */ +// Command-line utility to transmit a server command. +// +// Copyright (c) 1987-2022 by the citadel.org team +// +// This program is open source software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 3. +// +// 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. #include #include @@ -26,8 +24,8 @@ #include #include #include -#include "citadel.h" -#include "citadel_dirs.h" +#include "../server/citadel.h" +#include "../server/citadel_dirs.h" #include int serv_sock = (-1); @@ -56,9 +54,7 @@ int uds_connectsock(char *sockpath) { } -/* - * input binary data from socket - */ +// input binary data from socket void serv_read(char *buf, int bytes) { int len, rlen; @@ -73,9 +69,7 @@ void serv_read(char *buf, int bytes) { } -/* - * send binary to server - */ +// send binary to server void serv_write(char *buf, int nbytes) { int bytes_written = 0; int retval; @@ -89,46 +83,37 @@ void serv_write(char *buf, int nbytes) { } -/* - * input string from socket - implemented in terms of serv_read() - */ +// input string from socket - implemented in terms of serv_read() void serv_gets(char *buf) { int i; - /* Read one character at a time. - */ + // Read one character at a time. for (i = 0;; i++) { serv_read(&buf[i], 1); if (buf[i] == '\n' || i == (SIZ-1)) break; } - /* If we got a long line, discard characters until the newline. - */ + // If we got a long line, discard characters until the newline. if (i == (SIZ-1)) { while (buf[i] != '\n') { serv_read(&buf[i], 1); } } - /* Strip all trailing nonprintables (crlf) - */ + // Strip all trailing nonprintables (crlf) buf[i] = 0; } -/* - * send line to server - implemented in terms of serv_write() - */ +// send line to server - implemented in terms of serv_write() void serv_puts(char *buf) { serv_write(buf, strlen(buf)); serv_write("\n", 1); } -/* - * Main loop. Do things and have fun. - */ +// Main loop. Do things and have fun. int main(int argc, char **argv) { int a; int watchdog = 60; @@ -136,7 +121,7 @@ int main(int argc, char **argv) { int xfermode = 0; char ctdldir[PATH_MAX]=CTDLDIR; - /* Parse command line */ + // Parse command line while ((a = getopt(argc, argv, "h:w:")) != EOF) { switch (a) { case 'h': @@ -182,7 +167,7 @@ int main(int argc, char **argv) { xfermode = buf[0]; - if ((xfermode == '4') || (xfermode == '8')) { /* send text */ + if ((xfermode == '4') || (xfermode == '8')) { // send text while (fgets(buf, sizeof buf, stdin) > 0) { if (buf[strlen(buf)-1] == '\n') { buf[strlen(buf)-1] = 0; @@ -192,13 +177,13 @@ int main(int argc, char **argv) { serv_puts("000"); } - if ((xfermode == '1') || (xfermode == '8')) { /* receive text */ + if ((xfermode == '1') || (xfermode == '8')) { // receive text while(serv_gets(buf), strcmp(buf, "000")) { printf("%s\n", buf); } } - if (xfermode == '6') { /* receive binary */ + if (xfermode == '6') { // receive binary size_t len = atoi(&buf[4]); size_t bytes_remaining = len; @@ -212,7 +197,7 @@ int main(int argc, char **argv) { } close(serv_sock); - alarm(0); /* cancel the watchdog timer */ + alarm(0); // cancel the watchdog timer fprintf(stderr, "sendcommand: processing ended.\n"); if (xfermode == '5') { -- 2.30.2