SERV_MODULES=modules/serv_chat.so \
modules/serv_upgrade.so modules/serv_expire.so
UTIL_TARGETS=aidepost netmailer netproc netsetup msgform readlog rcit \
- stats citmail netpoll mailinglist userlist sendcommand base64
+ stats citmail netpoll mailinglist userlist sendcommand \
+ base64 qpdecode
PROXY_TARGETS=proxy
prefix=@prefix@
room_ops.c rooms.c routines.c routines2.c serv_chat.c \
serv_info.c serv_test.c serv_upgrade.c setup.c snprintf.c stats.c \
support.c sysdep.c tools.c user_ops.c userlist.c serv_expire.c \
- whobbs.c sendcommand.c mime_parser.c base64.c
+ whobbs.c sendcommand.c mime_parser.c base64.c qpdecode.c
DEP_FILES=$(SOURCES:.c=.d)
$(CC) sendcommand.o ipc_c_tcp.o tools.o config.o \
$(SNPRINTF) $(LDFLAGS) -o sendcommand
+qpdecode: qpdecode.o
+ $(CC) qpdecode.o $(LDFLAGS) -o qpdecode
+
base64: base64.o
$(CC) base64.o $(LDFLAGS) -o base64
size_t blocksize;
int write_error = 0;
+ lprintf(9, "mime_decode() called\n");
+
+ /* Some encodings aren't really encodings */
+ if (!strcasecmp(encoding, "7bit")) strcpy(encoding, "");
+ if (!strcasecmp(encoding, "8bit")) strcpy(encoding, "");
+ if (!strcasecmp(encoding, "binary")) strcpy(encoding, "");
+
/* If this part is not encoded, send as-is */
if (strlen(encoding)==0) {
CallBack(name, filename, partnum, disposition, part_start,
}
if ( (strcasecmp(encoding, "base64"))
- && (strcasecmp(encoding, "7bit")) ) {
+ && (strcasecmp(encoding, "quoted-printable")) ) {
lprintf(5, "ERROR: unknown MIME encoding '%s'\n", encoding);
return;
}
if (pipe(recvpipe) != 0) return;
childpid = fork();
- lprintf(9, "fork() returned %d\n", childpid);
if (childpid < 0) {
phree(decoded);
return;
close(recvpipe[0]);
if (!strcasecmp(encoding, "base64"))
execlp("./base64", "base64", "-d", NULL);
- else if (!strcasecmp(encoding, "7bit")) /* just a test */
- execlp("/bin/dd", "dd", NULL);
+ else if (!strcasecmp(encoding, "quoted-printable"))
+ execlp("./qpdecode", "qpdecode", NULL);
lprintf(5, "ERROR: cannot exec decoder for %s\n", encoding);
exit(1);
}
close(sendpipe[0]); /* Close the ends we're not using */
close(recvpipe[1]);
- lprintf(9, "ready to send %d bytes\n", length);
-
while ( (bytes_sent < length) && (write_error == 0) ) {
/* Empty the input pipe FIRST */
while (fstat(recvpipe[0], &statbuf), (statbuf.st_size > 0) ) {
bytes_recv = bytes_recv + blocksize;
}
- lprintf(9, "Decoded length = %d\n", bytes_recv);
-
if (bytes_recv > 0)
CallBack(name, filename, partnum, disposition, decoded,
content_type, bytes_recv);
size_t length;
char nested_partnum[256];
+ lprintf(9, "the_mime_parser() called\n");
ptr = content_start;
memset(boundary, 0, sizeof boundary);
memset(content_type, 0, sizeof content_type);
size_t cblength)
) {
+ lprintf(9, "mime_parser() called\n");
the_mime_parser("1", content_start, content_end, CallBack);
}
/*
+ * Callback function for mime parser that simply lists the part
*/
-void part_handler(char *name, char *filename, char *partnum, char *disp,
+void list_this_part(char *name, char *filename, char *partnum, char *disp,
void *content, char *cbtype, size_t length) {
cprintf("part=%s|%s|%s|%s|%s|%d\n",
}
+/*
+ * Callback function for mime parser that wants to display text
+ */
+void fixed_output(char *name, char *filename, char *partnum, char *disp,
+ void *content, char *cbtype, size_t length) {
+
+ if (!strcasecmp(cbtype, "text/plain")) {
+ client_write(content, length);
+ }
+ else {
+ cprintf("Part %s: %s (%s) (%d bytes)\n",
+ partnum, filename, cbtype, length);
+ }
+ }
/*
/* do some sort of MIME output */
if ( (mode == MT_MIME) && (format_type == 4) ) {
- mime_parser(mptr, NULL, *part_handler);
+ mime_parser(mptr, NULL, *list_this_part);
cprintf("000\n");
cdb_free(dmsgtext);
return(xtime);
/* If the format type on disk is 1 (fixed-format), then we want
* everything to be output completely literally ... regardless of
- * what message transfer format is in use. Format type 4 is
- * temporarily being output this way as well.
+ * what message transfer format is in use.
*/
- if ( (format_type == 1) || (format_type == 4)) {
+ if (format_type == 1) {
strcpy(buf, "");
while(ch = *mptr++, ch>0) {
if (ch == 13) ch = 10;
if (format_type == 0) {
memfmout(80,mptr,0);
}
-
+ /* If the message on disk is format 4 (MIME), we've gotta hand it
+ * off to the MIME parser. The client has already been told that
+ * this message is format 1 (fixed format), so the callback function
+ * we use will display those parts as-is.
+ */
+ if (format_type == 4) {
+ mime_parser(mptr, NULL, *fixed_output);
+ }
/* now we're done */
cprintf("000\n");
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <string.h>
+
+int main(int argc, char *argv[]) {
+ char buf[80];
+ int soft_line_break = 0;
+ int ch;
+
+ while (fgets(buf, 80, stdin) != NULL) {
+ while (isspace(buf[strlen(buf)-1]))
+ buf[strlen(buf)-1] = 0;
+ soft_line_break = 0;
+
+ while (strlen(buf) > 0) {
+ if (!strcmp(buf, "=")) {
+ soft_line_break = 1;
+ strcpy(buf, "");
+ } else if ( (strlen(buf)>=3) && (buf[0]=='=') ) {
+ sscanf(&buf[1], "%02x", &ch);
+ putc(ch, stdout);
+ strcpy(buf, &buf[3]);
+ } else {
+ putc(buf[0], stdout);
+ strcpy(buf, &buf[1]);
+ }
+ }
+ if (soft_line_break == 0) printf("\r\n");
+ }
+ exit(0);
+}