Mercurial > hg > mlmmj
changeset 20:a642323b9d02
Remove strip_file_to_fd
author | mmj |
---|---|
date | Thu, 22 Apr 2004 23:46:17 +1000 |
parents | bad8b9b378a0 |
children | bbc5ef57652e |
files | include/strip_file_to_fd.h src/Makefile.am src/Makefile.in src/mylocking.c src/strip_file_to_fd.c |
diffstat | 5 files changed, 25 insertions(+), 154 deletions(-) [+] |
line wrap: on
line diff
--- a/include/strip_file_to_fd.h Thu Apr 22 23:46:04 2004 +1000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,19 +0,0 @@ -/* Copyright (C) 2002, 2003 Mads Martin Joergensen <mmj at mmj.dk> - * - * $Id$ - * - * This file is redistributable under version 2 of the GNU General - * Public License as described at http://www.gnu.org/licenses/gpl.txt - */ - -#ifndef STRIP_FILE_TO_FD_H -#define STRIP_FILE_TO_FD_H - -#include <stdio.h> - -char *strip_headers(char *readbuf, const char **headers_to_strip); -int custom_lines(int fd, FILE *infile); -void strip_file_to_fd(FILE *in, int out_fd, const char **headers_to_strip, - FILE *headerfile, FILE *footerfile, char *toheader); - -#endif /* STRIP_FILE_TO_FD_H */
--- a/src/Makefile.am Thu Apr 22 23:46:04 2004 +1000 +++ b/src/Makefile.am Thu Apr 22 23:46:17 2004 +1000 @@ -17,16 +17,15 @@ mylocking.c init_sockfd.c strgen.c random-int.c \ print-version.c -mlmmj_recieve_SOURCES = mlmmj-recieve.c writen.c strip_file_to_fd.c \ - random-int.c header_token.c getlistaddr.c chomp.c \ - strgen.c print-version.c mygetline.c +mlmmj_recieve_SOURCES = mlmmj-recieve.c writen.c random-int.c header_token.c \ + getlistaddr.c chomp.c strgen.c print-version.c \ + mygetline.c -mlmmj_process_SOURCES = mlmmj-process.c writen.c strip_file_to_fd.c \ - find_email_adr.c incindexfile.c itoa.c \ - getlistaddr.c chomp.c mylocking.c listcontrol.c \ - random-int.c strgen.c header_token.c print-version.c \ - send_help.c do_all_the_voodo_here.c mygetline.c \ - gethdrline.c +mlmmj_process_SOURCES = mlmmj-process.c writen.c find_email_adr.c \ + incindexfile.c itoa.c getlistaddr.c chomp.c \ + mylocking.c listcontrol.c random-int.c strgen.c i\ + header_token.c print-version.c send_help.c \ + do_all_the_voodo_here.c mygetline.c gethdrline.c mlmmj_subscribe_SOURCES = mlmmj-subscribe.c writen.c mylocking.c \ getlistaddr.c chomp.c random-int.c strgen.c \
--- a/src/Makefile.in Thu Apr 22 23:46:04 2004 +1000 +++ b/src/Makefile.in Thu Apr 22 23:46:17 2004 +1000 @@ -55,19 +55,18 @@ binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) PROGRAMS = $(bin_PROGRAMS) am_mlmmj_process_OBJECTS = mlmmj-process.$(OBJEXT) writen.$(OBJEXT) \ - strip_file_to_fd.$(OBJEXT) find_email_adr.$(OBJEXT) \ - incindexfile.$(OBJEXT) itoa.$(OBJEXT) getlistaddr.$(OBJEXT) \ - chomp.$(OBJEXT) mylocking.$(OBJEXT) listcontrol.$(OBJEXT) \ - random-int.$(OBJEXT) strgen.$(OBJEXT) header_token.$(OBJEXT) \ - print-version.$(OBJEXT) send_help.$(OBJEXT) \ - do_all_the_voodo_here.$(OBJEXT) mygetline.$(OBJEXT) \ - gethdrline.$(OBJEXT) + find_email_adr.$(OBJEXT) incindexfile.$(OBJEXT) itoa.$(OBJEXT) \ + getlistaddr.$(OBJEXT) chomp.$(OBJEXT) mylocking.$(OBJEXT) \ + listcontrol.$(OBJEXT) random-int.$(OBJEXT) strgen.$(OBJEXT) \ + header_token.$(OBJEXT) print-version.$(OBJEXT) \ + send_help.$(OBJEXT) do_all_the_voodo_here.$(OBJEXT) \ + mygetline.$(OBJEXT) gethdrline.$(OBJEXT) mlmmj_process_OBJECTS = $(am_mlmmj_process_OBJECTS) mlmmj_process_LDADD = $(LDADD) am_mlmmj_recieve_OBJECTS = mlmmj-recieve.$(OBJEXT) writen.$(OBJEXT) \ - strip_file_to_fd.$(OBJEXT) random-int.$(OBJEXT) \ - header_token.$(OBJEXT) getlistaddr.$(OBJEXT) chomp.$(OBJEXT) \ - strgen.$(OBJEXT) print-version.$(OBJEXT) mygetline.$(OBJEXT) + random-int.$(OBJEXT) header_token.$(OBJEXT) \ + getlistaddr.$(OBJEXT) chomp.$(OBJEXT) strgen.$(OBJEXT) \ + print-version.$(OBJEXT) mygetline.$(OBJEXT) mlmmj_recieve_OBJECTS = $(am_mlmmj_recieve_OBJECTS) mlmmj_recieve_LDADD = $(LDADD) am_mlmmj_send_OBJECTS = mlmmj-send.$(OBJEXT) writen.$(OBJEXT) \ @@ -117,7 +116,6 @@ @AMDEP_TRUE@ ./$(DEPDIR)/print-version.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/random-int.Po ./$(DEPDIR)/readln.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/send_help.Po ./$(DEPDIR)/strgen.Po \ -@AMDEP_TRUE@ ./$(DEPDIR)/strip_file_to_fd.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/subscriberfuncs.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/writen.Po COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ @@ -211,16 +209,15 @@ mylocking.c init_sockfd.c strgen.c random-int.c \ print-version.c -mlmmj_recieve_SOURCES = mlmmj-recieve.c writen.c strip_file_to_fd.c \ - random-int.c header_token.c getlistaddr.c chomp.c \ - strgen.c print-version.c mygetline.c +mlmmj_recieve_SOURCES = mlmmj-recieve.c writen.c random-int.c header_token.c \ + getlistaddr.c chomp.c strgen.c print-version.c \ + mygetline.c -mlmmj_process_SOURCES = mlmmj-process.c writen.c strip_file_to_fd.c \ - find_email_adr.c incindexfile.c itoa.c \ - getlistaddr.c chomp.c mylocking.c listcontrol.c \ - random-int.c strgen.c header_token.c print-version.c \ - send_help.c do_all_the_voodo_here.c mygetline.c \ - gethdrline.c +mlmmj_process_SOURCES = mlmmj-process.c writen.c find_email_adr.c \ + incindexfile.c itoa.c getlistaddr.c chomp.c \ + mylocking.c listcontrol.c random-int.c strgen.c i\ + header_token.c print-version.c send_help.c \ + do_all_the_voodo_here.c mygetline.c gethdrline.c mlmmj_subscribe_SOURCES = mlmmj-subscribe.c writen.c mylocking.c \ getlistaddr.c chomp.c random-int.c strgen.c \ @@ -351,7 +348,6 @@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/readln.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/send_help.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strgen.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strip_file_to_fd.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/subscriberfuncs.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/writen.Po@am__quote@
--- a/src/mylocking.c Thu Apr 22 23:46:04 2004 +1000 +++ b/src/mylocking.c Thu Apr 22 23:46:17 2004 +1000 @@ -34,6 +34,3 @@ return myunlock; } - - -
--- a/src/strip_file_to_fd.c Thu Apr 22 23:46:04 2004 +1000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,102 +0,0 @@ -/* Copyright (C) 2002, 2003 Mads Martin Joergensen <mmj at mmj.dk> - * - * $Id$ - * - * This file is redistributable under version 2 of the GNU General - * Public License as described at http://www.gnu.org/licenses/gpl.txt - */ - -#include <stdio.h> -#include <stdlib.h> -#include <errno.h> -#include <string.h> - -#include "strip_file_to_fd.h" -#include "mlmmj.h" -#include "wrappers.h" - -#include "log_error.c" - -char *strip_headers(char *buf, const char **headers) -{ - int i = 0; - - if(buf[0] == '\t' || headers == 0) - return buf; - while(headers[i]) { - if(strncmp(buf, headers[i], strlen(headers[i])) == 0) - buf[0] = 0; - i++; - } - return buf; -} - -/* This function just adds the custom lines such as header, footer */ -int custom_lines(int fd, FILE *infile) -{ - int ch; - - while((ch = fgetc(infile)) != -1) - writen(fd, &ch, 1); - - return 0; -} - -/* strip_file_to_fd reads a complete mail from in_fd, strips all headers in - headers_to_strip from it, and saves it to out_fd. If headerfile is not 0 it - will write this file in the headers. If we meet the To: header, we copy it - to toheader. - */ -void strip_file_to_fd(FILE *in, int out_fd, const char **headers_to_strip, - FILE *headerfile, FILE *footerfile, char *toheader) -{ - char buf[READ_BUFSIZE]; - signed char readbuf[2]; - int bytes_written; - int buf_count = 0; - - memset(buf, 0, READ_BUFSIZE); - while((readbuf[0]=fgetc(in)) != -1) { - if(readbuf[0] == '\n') { - readbuf[1]=fgetc(in); - if(readbuf[1] != -1) - ungetc(readbuf[1], in); - else if(ferror(in)) - exit(EXIT_FAILURE); - } - if(readbuf[0] != '\n') - buf[buf_count++] = readbuf[0]; - else if(readbuf[1] == '\t') { - buf[buf_count++] = readbuf[0]; - buf[buf_count] = readbuf[1]; - memset(readbuf, 0, 2); - } else { /* readbuf[0] == '\n' */ - if (readbuf[1] == '\n' && headerfile) - custom_lines(out_fd, headerfile); - buf[buf_count] = readbuf[0]; - if(buf_count == 0) /* headers are done */ - headers_to_strip = 0; - /* XXX:free_str_array(headers_to_strip);*/ - if(headers_to_strip) {/* only strip if still headers */ - strip_headers(buf, headers_to_strip); - if(toheader && (strncmp(buf, "To: ", 4) == 0)) - sprintf(toheader, "%s", buf); - } - if(buf[0]) { - bytes_written = writen(out_fd, buf, strlen(buf)); - if(bytes_written == -1) { - log_error("error writing to fd"); - exit(EXIT_FAILURE); - } - } - memset(buf, 0, READ_BUFSIZE); - buf_count = 0; - } - } - if(footerfile) - custom_lines(out_fd, footerfile); - - if(ferror(in)) - exit(EXIT_FAILURE); -} -