rohrpost

A commandline mail client to change the world as we see it.
git clone git://r-36.net/rohrpost
Log | Files | Refs | LICENSE

commit e9669700f573edf50514963613f16a0c70207cd9
parent d4ac42e7501be1c72f7136ad42f74f05b71328c9
Author: Christoph Lohmann <20h@r-36.net>
Date:   Sat, 31 Mar 2012 21:25:06 +0200

Adding news and some meta improvements.

Diffstat:
bin/rpnews | 12++++++++++++
meta.c | 59++++++++++++++++++++++++++++++++++++-----------------------
meta.h | 2+-
mime.c | 2+-
test/Makefile | 24++++++++++++++++++++----
5 files changed, 70 insertions(+), 29 deletions(-)

diff --git a/bin/rpnews b/bin/rpnews @@ -0,0 +1,12 @@ +#!/bin/sh + +args="$*" +echo $args +if [ -z "$args" ]; +then + args="unseen" +fi + +rpscan $args | $HOME/.rohrpost/tmpl/news.sh \ + | eval $PAGER + diff --git a/meta.c b/meta.c @@ -3,6 +3,10 @@ * by 20h */ +#include <unistd.h> +#include <stdlib.h> +#include <string.h> + #include "ind.h" #include "mime.h" #include "meta.h" @@ -32,7 +36,7 @@ meta_mimedup(mime_t *mime) if (meta->parts->len > 0) { forllist(mime->parts, part) { - mpart = meta_mimedup((mime_t *)part->value); + mpart = meta_mimedup((mime_t *)part->data); llist_addraw(meta->parts, NULL, mpart, sizeof(mpart)); } } @@ -40,65 +44,74 @@ meta_mimedup(mime_t *mime) return meta; } -meta_t * -meta_headers2mime(meta_t *meta) +llist_t * +meta_headers2mime(mime_t *mime) { llistelem_t *header; + llist_t *mhdrs; char *enc; - mime_t *mime; - - mime = meta_metadup(meta); - forllist(mime->hdrs, header) { - enc = mime_encodeheader(header->key, header->value); + rhdr = llist_new(); + forllist(meta->hdrs, header) { + enc = mime_encodeheader(header->data); + if (enc == NULL) + continue; - free(header->value); - header->value = enc; - header->datalen = strlen(enc); + llist_add(mhdrs, header->key, enc, strlen(enc)+1); + free(enc); } - return mime; + return mhdrs; } -meta_t * +llist_t * meta_headers2meta(mime_t *mime) { llistelem_t *header; + llist_t *mhdrs; char *enc; - meta_t *meta; - - meta = meta_mimedup(mime); - forllist(meta->headers, header) { - enc = mime_decodeheader(header->value); + rhdr = llist_new(); + forllist(meta->hdrs, header) { + enc = mime_decodeheader(header->data); + if (enc == NULL) + continue; - free(header->value); - header->value = enc; - header->datalen = strlen(enc); + llist_add(mhdrs, header->key, enc, strlen(enc)+1); + free(enc); } - return meta; + return mhdrs; } mime_t * meta2mime(meta_t *meta) { + mime_t *mime; + + mime = NULL; + + return mime; } meta_t * mime2meta(mime_t *mime) { llistelem_t *part; + llist_t *nhdrs; mime_t *mpart; meta_t *meta; meta = meta_mimedup(mime); forllist(mime->parts, part) { - mpart = (mime_t *)part->value; + mpart = (mime_t *)part->data; + meta = meta_headers2meta(mpart); } + + return meta; } meta_t * diff --git a/meta.h b/meta.h @@ -8,7 +8,7 @@ #include "mime.h" -typedef meta_t mime_t; +typedef mime_t meta_t; mime_t *meta2mime(meta_t *meta); meta_t *mime2meta(mime_t *mime); diff --git a/mime.c b/mime.c @@ -337,7 +337,7 @@ char * mime_encodeheader(char *header, char *value) { char *ret, *b64, *p, *mp, *str; - int len, hlen, lmax, isascii, firstline, slen; + int hlen, lmax, isascii, firstline, slen; isascii = 0; diff --git a/test/Makefile b/test/Makefile @@ -1,5 +1,7 @@ all: @echo Possible options are: + @echo ' make alltest' + @echo @echo ' make parsetest' @echo ' make mimetest' @echo ' make llistsort' @@ -7,9 +9,13 @@ all: @echo ' make b64test' @echo ' make pqtest' @echo ' make printtest' + @echo ' make encodetest' + +alltest: parsetest mimetest llistsort parsetest b64test pqtest printtest \ + encodetest parsetest: - gcc -g -std=gnu99 -I.. -lssl -o parsetest parsetest.c \ + gcc -g -std=gnu99 -I.. -lssl -lcrypto -o parsetest parsetest.c \ ../net.c ../ind.c ../llist.c ../parser.c ../strio.c \ ../base64.c @echo Now run in one terminal: @@ -19,7 +25,8 @@ parsetest: @echo './parsetest tcp!localhost!5600' mimetest: - gcc -g -pedantic -Wall -std=gnu99 -I.. -lssl -o mimetest mimetest.c \ + gcc -g -pedantic -Wall -std=gnu99 -I.. -lssl -lcrypto -o mimetest \ + mimetest.c \ ../ind.c ../llist.c ../mime.c ../parser.c ../net.c \ ../strio.c ../base64.c ../quote.c ../param.c -D_XOPEN_SOURCE @echo Now you can run: @@ -35,7 +42,7 @@ imaptest: gcc -g -std=gnu99 -I.. -o imaptest imaptest.c ../ind.c ../llist.c \ ../mime.c ../parser.c ../net.c ../strio.c ../base64.c \ ../imap.c ../mark.c ../txtdb.c ../cfg.c ../inc.c ../flag.c \ - ../print.c ../quote.c ../param.c -l ssl -D_XOPEN_SOURCE + ../print.c ../quote.c ../param.c -lssl -lcrypto -D_XOPEN_SOURCE @echo Now run ./imaptest user pass 'tpcs!host!imaps' b64test: @@ -50,5 +57,14 @@ printtest: gcc -g -std=gnu99 -I.. -o printtest printtest.c ../print.c ../ind.c @echo Now run ./printtest -.PHONY: all imaptest llistsort mimetest parsetest b64test pqtest printtest +encodetest: + gcc -g -pedantic -Wall -std=gnu99 -I.. -lcrypto -lssl -o encodetest \ + encodetest.c \ + ../ind.c ../llist.c ../mime.c ../parser.c ../net.c \ + ../strio.c ../base64.c ../quote.c ../param.c ../meta.c \ + -D_XOPEN_SOURCE + @echo Now run ./encodetest + +.PHONY: all alltest imaptest llistsort mimetest parsetest b64test pqtest \ + printtest encodetest