$Log$
+ Revision 572.9 2000/06/28 03:42:56 ajc
+ * Changed the comments at the beginning of each file to a consistent format
+ * Improved the parameterization of commands in the IMAP module
+
Revision 572.8 2000/06/27 01:27:13 ajc
* Coupla very small changes to get on the road to IMAP support
Fri Jul 10 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
* Initial CVS import
-
auth.c chkpwd.c html.c vcard.c serv_upgrade.c \
serv_smtp.c serv_pop3.c internet_addressing.c parsedate.c genstamp.c \
domain.c clientsocket.c serv_inetcfg.c serv_rwho.c serv_bio.c \
- serv_moderate.c client_passwords.c serv_imap.c
+ serv_moderate.c client_passwords.c serv_imap.c imap_tools.c
DEP_FILES=$(SOURCES:.c=.d)
modules/serv_pop3.mo: serv_pop3.mo
ln -f serv_pop3.mo modules
-modules/serv_imap.so: serv_imap.mo
- $(LINK_SHARED) -o modules/serv_imap.so serv_imap.mo
-
-modules/serv_imap.mo: serv_imap.mo
- ln -f serv_imap.mo modules
-
modules/serv_inetcfg.so: serv_inetcfg.mo
$(LINK_SHARED) -o modules/serv_inetcfg.so serv_inetcfg.mo
modules/domain.mo: domain.mo
ln -f domain.mo modules
+modules/serv_imap.so: serv_imap.mo imap_tools.mo
+ $(LINK_SHARED) -o modules/serv_imap.so imap_tools.mo serv_imap.mo
+
+modules/serv_imap.mo: serv_imap.mo
+ ln -f serv_imap.mo modules
+
+modules/imap_tools.mo: imap_tools.mo
+ ln -f imap_tools.mo modules
+
aidepost: aidepost.o config.o $(LIBOBJS)
$(CC) aidepost.o config.o $(LIBOBJS) $(LDFLAGS) -o aidepost
-/* aidepost.c
- * This is just a little hack to copy standard input to a message in Aide>
- * v2.0
+/*
* $Id$
+ *
+ * This is just a little hack to copy standard input to a message in Aide>
*/
#include <stdlib.h>
/*
- * auth.c -- system-level password checking for autologin
+ * $Id$
+ *
+ * system-level password checking for autologin
* by Nathan Bryant, March 1999
*
- * $Id$
*/
#if defined(__linux) || defined(__sun) /* needed for crypt(): */
/*
-
- Encode or decode file as MIME base64 (RFC 1341)
-
- by John Walker
- http://www.fourmilab.ch/
-
- This program is in the public domain.
-
-Revision date: 11th August 1997
-
-Modified slightly for the Citadel/UX system, June 1999
-http://uncnsrd.mt-kisco.ny.us/citadel
-
-*/
+ * $Id$
+ *
+ * Encode or decode file as MIME base64 (RFC 1341)
+ * Public domain by John Walker, August 11 1997
+ * Modified slightly for the Citadel/UX system, June 1999
+ *
+ */
#include <stdio.h>
/*
- * chkpwd.c: a setuid helper program for machines which use shadow passwords
+ * $Id$
+ *
+ * a setuid helper program for machines which use shadow passwords
* by Nathan Bryant, March 1999
*
- * $Id$
*/
#include <pwd.h>
/*
- * Citadel/UX
- *
- * citadel.c - Main source file.
* $Id$
+ *
+ * Main source module for the client program.
*/
#include "sysdep.h"
-/* citadel.h
+/*
+ * $Id$
+ *
* main Citadel/UX header file
* see copyright.txt for copyright information
- * $Id$
*/
/* system customizations are in sysconfig.h */
/*
- *
- * Completely reworked version of "citmail"
- * This program attempts to act like a local MDA if you're using sendmail or
- * some other non-Citadel MTA. It basically just forwards the message to
- * the Citadel SMTP listener on some non-standard port.
- *
* $Id$
*
+ * This program attempts to act like a local MDA if you're using sendmail or
+ * some other non-Citadel MTA. It basically just contacts the Citadel SMTP
+ * listener on a unix domain socket and transmits the message.
+ *
*/
#include "sysdep.h"
-/* $Id$ */
+/*
+ * $Id$
+ *
+ * Main source module for the Citadel server
+ *
+ */
+
#include "sysdep.h"
#include <stdlib.h>
#include <unistd.h>
/*
- * Citadel/UX
- *
- * client_chat.c -- front end for chat mode
- * (the "single process" version - no more fork() anymore)
- *
* $Id$
*
+ * front end for chat mode
+ * (the "single process" version - no more fork() anymore)
+ *
*/
#include "sysdep.h"
+/*
+ * $Id$
+ *
+ * Functions which allow the client to remember usernames and passwords for
+ * various sites.
+ *
+ */
+
#include "sysdep.h"
#include <stdlib.h>
#include <unistd.h>
+/*
+ * $Id$
+ *
+ */
+
void determine_pwfilename(char *);
void get_stored_password(
char *host,
-/* $Id$ */
+/*
+ * $Id$
+ *
+ */
/*
* Colors for color() command
/*
+ * $Id$
+ *
* This function reads the citadel.config file. It should be called at
* the beginning of EVERY Citadel program.
*
- * $Id$
*/
#include "sysdep.h"
-/* $Id$ */
+/*
+ * $Id$
+ *
+ */
+
void get_config(void);
void put_config(void);
extern struct config config;
/*
- * control.c
+ * $Id$
*
* This module handles states which are global to the entire server.
*
- * $Id$
- *
*/
#include "sysdep.h"
/*
+ * $Id$
+ *
* This file contains a set of abstractions that allow Citadel to plug into any
* record manager or database system for its data store.
*
- * $Id$
*/
/*
+/*
+ * $Id$
+ *
+ * DNS lookup for SMTP sender
+ *
+ */
+
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
+/*
+ * $Id$
+ *
+ */
struct mx {
int pref;
-/*******************************************************
+/*
+ * $Id$
*
* Citadel Dynamic Loading Module
- * Written by Brian Costello
- * btx@calyx.net
- *
- * $Id$
+ * Written by Brian Costello <btx@calyx.net>
*
- ******************************************************/
-
+ */
#include "sysdep.h"
#include <stdio.h>
/* $Id$ */
+
void DLoader_Init(char *pathname);
int DLoader_Exec_Cmd(char *cmdbuf);
char *Dynamic_Module_Init(void);
-/* $Id$ */
+/*
+ * $Id$
+ *
+ * Server functions which handle file transfers and room directories.
+ *
+ */
+
#include "sysdep.h"
#include <stdlib.h>
#include <unistd.h>
/*
- * Function to generate RFC822-compliant textual time/date stamp
- *
* $Id$
*
+ * Function to generate RFC822-compliant textual time/date stamp
+ *
*/
#include <stdio.h>
+/*
+ * $Id$
+ *
+ */
+
void generate_rfc822_datestamp(char *buf, time_t xtime);
/*
+ * $Id$
+ *
* getutline.c: not-quite-compatible replacement for getutline(3)
* by nathan bryant, feb 1999
*
- * $Id$
*/
#include "sysdep.h"
/*
+ * $Id$
+ *
* This file contains housekeeping tasks which periodically
* need to be executed. It keeps a nice little queue...
*
- * $Id$
*/
#include "sysdep.h"
/*
- * html.c -- Functions which handle translation between HTML and plain text
* $Id$
+ *
+ * Functions which handle translation between HTML and plain text
*/
#include "sysdep.h"
+/*
+ * $Id$
+ *
+ */
+
char *html_to_ascii(char *inputmsg, int screenwidth, int do_citaformat);
--- /dev/null
+/*
+ * $Id$
+ *
+ * Utility functions for the IMAP module.
+ *
+ */
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <ctype.h>
+#include <string.h>
+#include "imap_tools.h"
+
+/*
+ * Break a command down into tokens, taking into consideration the
+ * possibility of escaping spaces using quoted tokens
+ */
+int imap_parameterize(char **args, char *buf) {
+ int num = 0;
+ int start = 0;
+ int i;
+ int in_quote = 0;
+ int original_len;
+
+ strcat(buf, " ");
+
+ original_len = strlen(buf);
+
+ for (i=0; i<original_len; ++i) {
+
+ if ( (isspace(buf[i])) && (!in_quote) ) {
+ buf[i] = 0;
+ args[num] = &buf[start];
+ start = i+1;
+ if (args[num][0] == '\"') {
+ ++args[num];
+ args[num][strlen(args[num])-1] = 0;
+ }
+ ++num;
+ }
+
+ else if ( (buf[i] == '\"') && (!in_quote) ) {
+ in_quote = 1;
+ }
+
+ else if ( (buf[i] == '\"') && (in_quote) ) {
+ in_quote = 0;
+ }
+
+ }
+
+ return(num);
+}
+
+
+
--- /dev/null
+/*
+ * $Id$
+ *
+ */
+
+int imap_parameterize(char **args, char *buf);
+/*
+ * $Id$
+ *
+ */
+
int fuzzy_match(struct usersupp *us, char *matchstring);
void process_rfc822_addr(char *rfc822, char *user, char *node, char *name);
/*
+ * $Id$
+ *
* Internet mail configurator for Citadel/UX
* see copyright.doc for copyright information
*
- * $Id$
*/
#include <stdlib.h>
/*
- * ipc_c_tcp.c
+ * $Id$
*
- * Citadel/UX client/server IPC - client module using TCP/IP
- *
- * version 1.3 $Id$
+ * Client-side IPC functions
*
*/
/*
- * locate the originating host
* $Id$
+ *
+ * locate the originating host
+ *
*/
#include "sysdep.h"
/*
- * Everything which needs some logging...
* $Id$
+ *
+ * Everything which needs some logging...
+ *
*/
#include "sysdep.h"
/*
+ * $Id$
+ *
* Citadel/UX message support routines
* see copyright.txt for copyright information
- * $Id$
*/
#include "sysdep.h"
/*
- * mime_parser.c
+ * $Id$
*
* This is a really bad attempt at writing a parser to handle MIME-encoded
* messages.
* Copyright (c) 1998-1999 by Art Cancro
* This code is distributed under the terms of the GNU General Public License.
*
- * $Id$
- *
*/
#include "sysdep.h"
+/*
+ * $Id$
+ *
+ */
+
void extract_key(char *target, char *source, char *key);
void mime_parser(char *content_start, char *content_end,
-/* $Id$ */
+/*
+ * $Id$
+ *
+ * Implements the message store.
+ *
+ */
#include "sysdep.h"
#include <stdlib.h>
/*
- * msgform.c v2.1 $Id$
- * see copyright.doc for copyright information
+ * $Id$
*
* This is simply a filter that converts Citadel binary message format
* to readable, formatted output.
* then it stops at the end of the first message it prints.
* This is used by the QWK reader for Citadel/UX during message format
* translation.
+ *
*/
#include "sysdep.h"
/*
- * netmailer for Citadel/UX
- * see copyright.doc for copyright information
+ * $Id$
*
* netproc calls this to export Citadel mail to RFC822-compliant mailers.
- * $Id$
*/
#include <stdlib.h>
-/* $Id$ */
+/*
+ * $Id$
+ *
+ * Perform data transfer between our Citadel server and another.
+ *
+ */
+
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
/*
+ * $Id$
+ *
* Citadel/UX Intelligent Network Processor for IGnet/Open networks
* See copyright.txt for copyright information
- * $Id$
+ *
*/
/* How long it takes for an old node to drop off the network map */
/*
* $Id$
*
+ * Command-line utility to manipulate network configuration files
* Copyright (c) 1998 Art Cancro
*
*/
+/*
+ * $Id$
+ *
+ */
+
time_t parsedate(char *);
-/* $Id$ */
+/*
+ * $Id$
+ *
+ * Functions which manage policy for rooms (such as message expiry)
+ */
+
#include "sysdep.h"
#include <stdlib.h>
#include <unistd.h>
/*
- * Session layer proxy for Citadel
- * (c) 1998 by Art Cancro, All Rights Reserved, released under GNU GPL v2
* $Id$
- */
-
-/*
+ *
+ * A partially functional session layer proxy for Citadel
+ * (c) 1998 by Art Cancro, All Rights Reserved, released under GNU GPL v2
* NOTE: this isn't finished, so don't use it!!
*
*/
/*
+ * $Id$
+ *
* Convert "quoted printable" encoding to binary (stdin to stdout)
* Copyright (C) 1999 by Art Cancro
* Distributed under the terms of the GNU General Public License.
-#define UNCOMPRESS "/usr/bin/gunzip"
-
-/* Citadel/UX rcit $Id$
+/* $Id$
*
* This program simply feeds its standard input to the networker. It is
* used primarily to hook up to UUCP feeds of Citadel data.
* -s Don't run netproc now, just accept the input into spoolin
*/
+#define UNCOMPRESS "/usr/bin/gunzip"
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
/*
- * readlog.c (a simple program to parse citadel.log)
* $Id$
+ *
+ * A simple program to parse citadel.log
*/
#include <stdlib.h>
-/* $Id$ */
+/*
+ * $Id$
+ *
+ * Server functions which perform operations on room objects.
+ *
+ */
#include "sysdep.h"
#include <stdlib.h>
#include <unistd.h>
-/* Citadel/UX room-oriented routines */
-/* $Id$ */
+/*
+ * $Id$
+ *
+ *
+ * Client-side functions which perform room operations
+ *
+ */
#include "sysdep.h"
#include <stdlib.h>
-/* Citadel/UX support routines */
-/* $Id$ */
+/*
+ * $Id$
+ *
+ * Client-side support functions.
+ *
+ */
#include "sysdep.h"
#include <stdlib.h>
-/* More Citadel/UX routines...
- * unlike routines.c, some of these DO use global variables.
- * $Id$
+/* $Id$
+ *
+ * More client-side support functions.
+ * Unlike routines.c, some of these DO use global variables.
+ *
*/
#include "sysdep.h"
/*
* $Id$
+ *
+ * Command-line utility to transmit a server command.
+ *
*/
/*
- * serv_chat.c
+ * $Id$
*
* This module handles all "real time" communication between users. The
* modes of communication currently supported are Chat and Paging.
*
- * $Id$
*/
#include "sysdep.h"
#include <stdlib.h>
/*
- * serv_expire.c
+ * $Id$
*
* This module handles the expiry of old messages and the purging of old users.
*
- * $Id$
*/
-/* $Id$
+/*
+ * $Id$
*
* IMAP server for the Citadel/UX system
* Copyright (C) 2000 by Art Cancro and others.
#include "tools.h"
#include "internet_addressing.h"
#include "serv_imap.h"
+#include "imap_tools.h"
long SYM_IMAP;
/*
* implements the LOGIN command (ordinary username/password login)
*/
-void imap_login(char *tag, char *cmd, char *parms) {
- char username[256];
- char password[256];
-
- extract_token(username, parms, 0, ' ');
- extract_token(password, parms, 1, ' ');
-
- if (CtdlLoginExistingUser(username) == login_ok) {
- if (CtdlTryPassword(password) == pass_ok) {
- cprintf("%s OK login successful\r\n", tag);
+void imap_login(int num_parms, char *parms[]) {
+ if (CtdlLoginExistingUser(parms[2]) == login_ok) {
+ if (CtdlTryPassword(parms[3]) == pass_ok) {
+ cprintf("%s OK login successful\r\n", parms[0]);
return;
}
}
- cprintf("%s BAD Login incorrect\r\n", tag);
+ cprintf("%s BAD Login incorrect\r\n", parms[0]);
}
/*
* implements the CAPABILITY command
*/
-void imap_capability(char *tag, char *cmd, char *parms) {
+void imap_capability(int num_parms, char *parms[]) {
cprintf("* CAPABILITY IMAP4 IMAP4REV1 AUTH=LOGIN\r\n");
- cprintf("%s OK CAPABILITY completed\r\n", tag);
+ cprintf("%s OK CAPABILITY completed\r\n", parms[0]);
}
/*
* implements the SELECT command
*/
-void imap_select(char *tag, char *cmd, char *parms) {
+void imap_select(int num_parms, char *parms[]) {
char towhere[256];
char augmented_roomname[256];
int c = 0;
struct quickroom QRscratch;
int msgs, new;
- extract_token(towhere, parms, 0, ' ');
+ strcpy(towhere, parms[2]);
/* IMAP uses the reserved name "INBOX" for the user's default incoming
* mail folder. Convert this to Citadel's reserved name "_MAIL_".
/* Fail here if no such room */
if (!ok) {
- cprintf("%s NO ... no such room, or access denied\r\n", tag);
+ cprintf("%s NO ... no such room, or access denied\r\n",
+ parms[0]);
IMAP->selected = 0;
return;
}
cprintf("* %d EXISTS\r\n", msgs);
cprintf("* %d RECENT\r\n", new);
cprintf("* OK [UIDVALIDITY 0] UIDs valid\r\n");
- cprintf("%s OK [FIXME] SELECT completed\r\n", tag);
+ cprintf("%s OK [FIXME] SELECT completed\r\n", parms[0]);
}
*/
void imap_command_loop(void) {
char cmdbuf[256];
- char tag[256];
- char cmd[256];
+ char *parms[16];
+ int num_parms;
+ int i;
time(&CC->lastcmd);
memset(cmdbuf, 0, sizeof cmdbuf); /* Clear it, just in case */
striplt(cmdbuf);
/* grab the tag */
- extract_token(tag, cmdbuf, 0, ' ');
- extract_token(cmd, cmdbuf, 1, ' ');
- remove_token(cmdbuf, 0, ' ');
- remove_token(cmdbuf, 0, ' ');
- lprintf(9, "tag=<%s> cmd=<%s> parms=<%s>\n", tag, cmd, cmdbuf);
+ num_parms = imap_parameterize(parms, cmdbuf);
+ for (i=0; i<num_parms; ++i) {
+ lprintf(9, " parms[%d]='%s'\n", i, parms[i]);
+ }
/* commands which may be executed in any state */
- if (!strcasecmp(cmd, "NOOP")) {
+ if (!strcasecmp(parms[1], "NOOP")) {
cprintf("%s OK This command successfully did nothing.\r\n",
- tag);
+ parms[0]);
}
- else if (!strcasecmp(cmd, "LOGOUT")) {
+ else if (!strcasecmp(parms[1], "LOGOUT")) {
cprintf("* BYE %s logging out\r\n", config.c_fqdn);
- cprintf("%s OK thank you for using Citadel IMAP\r\n", tag);
+ cprintf("%s OK thank you for using Citadel IMAP\r\n", parms[0]);
CC->kill_me = 1;
return;
}
- else if (!strcasecmp(cmd, "LOGIN")) {
- imap_login(tag, cmd, cmdbuf);
+ else if (!strcasecmp(parms[1], "LOGIN")) {
+ imap_login(num_parms, parms);
}
- else if (!strcasecmp(cmd, "CAPABILITY")) {
- imap_capability(tag, cmd, cmdbuf);
+ else if (!strcasecmp(parms[1], "CAPABILITY")) {
+ imap_capability(num_parms, parms);
}
else if (!CC->logged_in) {
- cprintf("%s BAD Not logged in.\r\n", tag);
+ cprintf("%s BAD Not logged in.\r\n", parms[0]);
}
/* commands requiring the client to be logged in */
- else if (!strcasecmp(cmd, "SELECT")) {
- imap_select(tag, cmd, cmdbuf);
+ else if (!strcasecmp(parms[1], "SELECT")) {
+ imap_select(num_parms, parms);
}
/* end of commands */
else {
- cprintf("%s BAD command unrecognized\r\n", tag);
+ cprintf("%s BAD command unrecognized\r\n", parms[0]);
}
}
-/* $Id$
+/*
+ * $Id$
*
* This module handles the loading/saving and maintenance of the
* system's Internet configuration. It's not an optional component; I
* wrote it as a module merely to keep things as clean and loosely coupled
* as possible.
+ *
*/
#include "sysdep.h"
/*
* $Id$
*
- * The CtdlGetServerInfo() function is useful for
+ * The CtdlGetServerInfo() function is useful for removing unsightly
+ * uranium deposits from rhinocerous aqueducts.
+ *
*/
#include <stdlib.h>
/*
* $Id$
*
+ * Server-side functions which handle message moderation.
*
*/
-/* $Id$
+/*
+ * $Id$
*
* POP3 server for the Citadel/UX system
* Copyright (C) 1998-2000 by Art Cancro and others.
+/*
+ * $Id$
+ *
+ */
struct pop3msg {
long msgnum;
-/* $Id$ */
+/*
+ * $Id$
+ *
+ * An implementation of RFC821 (Simple Mail Transfer Protocol) for the
+ * Citadel system.
+ *
+ */
#include "sysdep.h"
#include <stdlib.h>
-/* $Id$ */
+/*
+ * $Id$
+ *
+ * A skeleton module to test the dynamic loader.
+ *
+ */
+
#include "sysdep.h"
#include <stdlib.h>
#include <unistd.h>
-/* $Id$ */
+/*
+ * $Id$
+ *
+ * Transparently handle the upgrading of server data formats.
+ *
+ */
+
#include "sysdep.h"
#include <stdlib.h>
#include <unistd.h>
+/*
+ * $Id$
+ *
+ */
+
/*
* Format of a usersupp record prior to version 5.55
*/
/*
- * serv_vcard.c
+ * $Id$
*
* A server-side module for Citadel which supports address book information
* using the standard vCard format.
*
- * $Id$
- *
*/
#define ADDRESS_BOOK_ROOM "Global Address Book"
/*
- * Citadel/UX setup program
* $Id$
*
- * *** YOU MUST EDIT sysconfig.h >BEFORE< COMPILING SETUP ***
+ * Citadel/UX setup utility
+ *
*/
#include <stdlib.h>
/*
- * modified from Sten Gunterberg's BUGTRAQ post of 22 Jul 1997
- * --nathan bryant <nathan@designtrust.com>
- *
* $Id$
- */
-
-/*
+ *
* Replacements for snprintf() and vsnprintf()
*
+ * modified from Sten Gunterberg's BUGTRAQ post of 22 Jul 1997
+ * --nathan bryant <nathan@designtrust.com>
+ *
* Use it only if you have the "spare" cycles needed to effectively
* do every snprintf operation twice! Why is that? Because everything
* is first vfprintf()'d to /dev/null to determine the number of bytes.
-/* Citadel/UX call log stats program
+/*
* $Id$
+ *
+ * Citadel/UX call log stats program
+ *
*/
+
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
-/* $Id$ */
+/*
+ * $Id$
+ *
+ * Server-side utility functions
+ *
+ */
+
#include "sysdep.h"
#include <stdlib.h>
#include <unistd.h>
+/*
+ * $Id$
+ *
+ */
+
/****************************************************************************/
/* YOUR SYSTEM CONFIGURATION */
/* Set all the values in this file appropriately BEFORE compiling any of the*/
/*
+ * $Id$
+ *
* Citadel/UX "system dependent" stuff.
* See copyright.txt for copyright information.
*
- * $Id$
- *
- * Here's where we (hopefully) have all the parts of the Citadel server that
+ * Here's where we (hopefully) have most parts of the Citadel server that
* would need to be altered to run the server in a non-POSIX environment.
*
* Eventually we'll try porting to a different platform and either have
* multiple variants of this file or simply load it up with #ifdefs.
+ *
*/
/*
- * tools.c -- Miscellaneous routines used by both the client and server.
* $Id$
+ *
+ * Utility functions that are used by both the client and server.
+ *
*/
#include "sysdep.h"
-/* $Id$ */
+/*
+ * $Id$
+ *
+ * Server functions which perform operations on user objects.
+ *
+ */
#include "sysdep.h"
#include <errno.h>
-/* $Id$ */
+/*
+ * $Id$
+ *
+ * Command-line user list utility.
+ *
+ */
+
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
-/* $Id$ */
+/*
+ * $Id$
+ *
+ * Command-line "who is online?" utility
+ *
+ */
+
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>