From: Art Cancro Date: Wed, 3 Mar 2021 00:43:56 +0000 (-0500) Subject: remove_any_whitespace_to_the_left_or_right_of_at_symbol() is awesomized and no longer... X-Git-Tag: v939~102 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=b9a2089d59579d13694e08b299c2aaf44ef9df6c remove_any_whitespace_to_the_left_or_right_of_at_symbol() is awesomized and no longer throws a compiler warning --- diff --git a/citadel/Makefile.in b/citadel/Makefile.in index ce3229e06..c21e3dc6d 100644 --- a/citadel/Makefile.in +++ b/citadel/Makefile.in @@ -70,7 +70,7 @@ LOCALEDIR=@LOCALEDIR@ SOURCES=utils/citmail.c utils/setup.c utils/chkpw.c \ utils/sendcommand.c utils/ctdlmigrate.c utils/chkpwd.c \ - utillib/citadel_dirs.c \ + citadel_dirs.c \ citserver.c clientsocket.c config.c control.c $(DATABASE) \ domain.c serv_extensions.c genstamp.c \ housekeeping.c default_timezone.c internet_addressing.c \ @@ -93,7 +93,7 @@ mkdir-init: @for d in `/bin/ls $(VPATH)/user_modules/`; do \ (mkdir -p user_modules/$$d ) ; \ done - mkdir -p utils utillib + mkdir -p utils mkdir locale svn_revision.c: ${SOURCES} @@ -119,7 +119,7 @@ Make_modules: modules_init.c modules_upgrade.c: modules_init.c -SERV_OBJS = server_main.o utillib/citadel_dirs.o \ +SERV_OBJS = server_main.o citadel_dirs.o \ user_ops.o citserver.o sysdep.o serv_extensions.o \ $(DATABASE:.c=.o) domain.o \ control.o config.o support.o room_ops.o \ @@ -137,28 +137,28 @@ citserver$(EXEEXT): $(SERV_OBJS) echo "CC $<" $(CC) $(CFLAGS) $(CPPFLAGS) $(DEFS) -c $< -o $@ -citmail$(EXEEXT): utils/citmail.o utillib/citadel_dirs.o - $(CC) utils/citmail.o utillib/citadel_dirs.o \ +citmail$(EXEEXT): utils/citmail.o citadel_dirs.o + $(CC) utils/citmail.o citadel_dirs.o \ $(LDFLAGS) -o citmail$(EXEEXT) $(LIBS) # setup does need LIBS defined, because it uses network functions which are in -lsocket -lnsl on Solaris. -setup$(EXEEXT): utils/setup.o utillib/citadel_dirs.o - $(CC) utils/setup.o utillib/citadel_dirs.o \ +setup$(EXEEXT): utils/setup.o citadel_dirs.o + $(CC) utils/setup.o citadel_dirs.o \ $(LDFLAGS) -o setup$(EXEEXT) $(LIBS) $(SETUP_LIBS) -ctdlmigrate$(EXEEXT): utils/ctdlmigrate.o utillib/citadel_dirs.o - $(CC) utils/ctdlmigrate.o utillib/citadel_dirs.o \ +ctdlmigrate$(EXEEXT): utils/ctdlmigrate.o citadel_dirs.o + $(CC) utils/ctdlmigrate.o citadel_dirs.o \ $(LDFLAGS) -o ctdlmigrate$(EXEEXT) $(LIBS) chkpwd$(EXEEXT): utils/chkpwd.o auth.o $(CC) utils/chkpwd.o auth.o $(LDFLAGS) -o chkpwd$(EXEEXT) $(chkpwd_LIBS) -chkpw$(EXEEXT): utils/chkpw.o auth.o utillib/citadel_dirs.o - $(CC) utils/chkpw.o auth.o utillib/citadel_dirs.o \ +chkpw$(EXEEXT): utils/chkpw.o auth.o citadel_dirs.o + $(CC) utils/chkpw.o auth.o citadel_dirs.o \ $(LDFLAGS) -o chkpw$(EXEEXT) $(chkpwd_LIBS) -sendcommand$(EXEEXT): utils/sendcommand.o utillib/citadel_dirs.o $(LIBOBJS) - $(CC) utils/sendcommand.o utillib/citadel_dirs.o \ +sendcommand$(EXEEXT): utils/sendcommand.o citadel_dirs.o $(LIBOBJS) + $(CC) utils/sendcommand.o citadel_dirs.o \ $(LIBOBJS) $(LDFLAGS) -o sendcommand$(EXEEXT) $(LIBS) .PHONY: install-data install-doc install-exec clean cleaner distclean @@ -290,7 +290,7 @@ clean: rm -vfr locale/* rm -vf *.o rm -vf utils/*.o ;\ - rm -vf utillib/*.o ;\ + rm -vf *.o ;\ for i in $(srcdir)/modules/* ; do \ rm -vf $$i/*.o ;\ done @@ -310,7 +310,6 @@ distclean: cleaner rm -vf po/Makefile rm -vf Makefile configure sysdep.h config.cache config.log config.status *.d package-version.txt rm -vf utils/*.d ; - rm -vf utillib/*.d ; for i in $(srcdir)/modules/* ; do \ rm -vf $$i/*.d ;\ done diff --git a/citadel/citadel_dirs.c b/citadel/citadel_dirs.c new file mode 100644 index 000000000..f1fb3e9a6 --- /dev/null +++ b/citadel/citadel_dirs.c @@ -0,0 +1,72 @@ +/* + * citadel_dirs.c : calculate pathnames for various files used in the Citadel system + * + * 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. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "citadel.h" +#include "citadel_dirs.h" + +/* + * Generate an associated file name for a room + */ +size_t assoc_file_name(char *buf, size_t n, struct ctdlroom *qrbuf, const char *prefix) { + return snprintf(buf, n, "%s%ld", prefix, qrbuf->QRnumber); +} + + +int create_dir(char *which, long ACCESS, long UID, long GID) { + int rv; + rv = mkdir(which, ACCESS); + if ((rv == -1) && (errno != EEXIST)) { + syslog(LOG_ERR, + "failed to create directory %s: %s", + which, + strerror(errno)); + return rv; + } + rv = chmod(which, ACCESS); + if (rv == -1) { + syslog(LOG_ERR, + "failed to set permissions for directory %s: %s", + which, + strerror(errno)); + return rv; + } + rv = chown(which, UID, GID); + if (rv == -1) { + syslog(LOG_ERR, + "failed to set owner for directory %s: %s", + which, + strerror(errno)); + return rv; + } + return rv; +} + + +int create_run_directories(long UID, long GID) { + int rv = 0; + rv += create_dir(ctdl_message_dir , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1); + rv += create_dir(ctdl_file_dir , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1); + rv += create_dir(ctdl_key_dir , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1); + rv += create_dir(ctdl_run_dir , S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH, UID, GID); + return rv; +} diff --git a/citadel/internet_addressing.c b/citadel/internet_addressing.c index 95350afc7..68daf8854 100644 --- a/citadel/internet_addressing.c +++ b/citadel/internet_addressing.c @@ -375,17 +375,16 @@ void sanitize_truncated_recipient(char *str) * (What can I say, I'm in a weird mood today...) */ void remove_any_whitespace_to_the_left_or_right_of_at_symbol(char *name) { - unsigned int i; + char *ptr; + if (!name) return; - for (i = 0; i < strlen(name); ++i) { - if (name[i] == '@') { - while (isspace(name[i - 1]) && i > 0) { - strcpy(&name[i - 1], &name[i]); - --i; - } - while (isspace(name[i + 1])) { - strcpy(&name[i + 1], &name[i + 2]); - } + for (ptr=name; *ptr; ++ptr) { + while ( (isspace(*ptr)) && (*(ptr+1)=='@') ) { + strcpy(ptr, ptr+1); + if (ptr > name) --ptr; + } + while ( (*ptr=='@') && (*(ptr+1)!=0) && (isspace(*(ptr+1))) ) { + strcpy(ptr+1, ptr+2); } } } diff --git a/citadel/utillib/citadel_dirs.c b/citadel/utillib/citadel_dirs.c deleted file mode 100644 index f1fb3e9a6..000000000 --- a/citadel/utillib/citadel_dirs.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - * citadel_dirs.c : calculate pathnames for various files used in the Citadel system - * - * 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. - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "citadel.h" -#include "citadel_dirs.h" - -/* - * Generate an associated file name for a room - */ -size_t assoc_file_name(char *buf, size_t n, struct ctdlroom *qrbuf, const char *prefix) { - return snprintf(buf, n, "%s%ld", prefix, qrbuf->QRnumber); -} - - -int create_dir(char *which, long ACCESS, long UID, long GID) { - int rv; - rv = mkdir(which, ACCESS); - if ((rv == -1) && (errno != EEXIST)) { - syslog(LOG_ERR, - "failed to create directory %s: %s", - which, - strerror(errno)); - return rv; - } - rv = chmod(which, ACCESS); - if (rv == -1) { - syslog(LOG_ERR, - "failed to set permissions for directory %s: %s", - which, - strerror(errno)); - return rv; - } - rv = chown(which, UID, GID); - if (rv == -1) { - syslog(LOG_ERR, - "failed to set owner for directory %s: %s", - which, - strerror(errno)); - return rv; - } - return rv; -} - - -int create_run_directories(long UID, long GID) { - int rv = 0; - rv += create_dir(ctdl_message_dir , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1); - rv += create_dir(ctdl_file_dir , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1); - rv += create_dir(ctdl_key_dir , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1); - rv += create_dir(ctdl_run_dir , S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH, UID, GID); - return rv; -}