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 a0a537336009f27ac86f9654581186de3d338f2b
parent 535143e5642d255782af28d9f6cce4521f275802
Author: Christoph Lohmann <20h@r-36.net>
Date:   Sun, 22 Jan 2012 17:51:03 +0100

Add podcast support and rename rpuopen -> rpopen.

Diffstat:
bin/rpopen | 24++++++++++++++++++++++++
bin/rppodplay | 30++++++++++++++++++++++++++++++
bin/rpuopen | 24------------------------
config.mk | 2+-
ind.c | 3++-
llist.c | 8++++++--
meta.c | 11++++++++---
mime.c | 11+++++------
8 files changed, 76 insertions(+), 37 deletions(-)

diff --git a/bin/rpopen b/bin/rpopen @@ -0,0 +1,24 @@ +#!/bin/sh + +if [ $# -lt 1 ]; +then + echo "usage: `basename $0` msgid" + exit 1 +fi + +if [ -z "$BROWSER" ]; +then + echo -n "\$BROWSER must be set to the command which invokes" + echo " your URL handler." + exit 1 +fi + +msgid="$*" + +url=`rpview $msgid | awk '/URL:/ {print $2}' | tr -d '\r'` +for i in $url +do + echo $i + $BROWSER "$i" +done + diff --git a/bin/rppodplay b/bin/rppodplay @@ -0,0 +1,30 @@ +#!/bin/sh + +if [ $# -lt 1 ]; +then + echo "usage: `basename $0` msgid" + exit 1 +fi + +if [ -z "$AUDIOPLAYER" ]; +then + if [ -z "$MEDIAPLAYER" ]; + then + echo "\$MEDIAPLAYER or \$AUDIOPLAYER should be set for" \ + "playing the media." + exit 1 + fi + player="$MEDIAPLAYER" +else + player="$AUDIOPLAYER" +fi + +msgid="$*" + +url=`rpview $msgid | awk '/Enclosure:/ {print $2}' | tr -d '\r'` +for i in $url +do + echo $i + $player "$i" +done + diff --git a/bin/rpuopen b/bin/rpuopen @@ -1,24 +0,0 @@ -#!/bin/sh - -if [ $# -lt 1 ]; -then - echo "usage: `basename $0` msgid" - exit 1 -fi - -if [ -z "$BROWSER" ]; -then - echo -n "\$BROWSER must be set to the command which invokes" - echo " your URL handler." - exit 1 -fi - -msgid="$*" - -url=`rpview $msgid | awk '/URL:/ {print $2}' | tr -d '\r'` -for i in $url -do - echo $i - $BROWSER "$i" -done - diff --git a/config.mk b/config.mk @@ -5,7 +5,7 @@ VERSION = 0.3 # Customize below to fit your system # paths -PREFIX ?= /usr +PREFIX = /usr/local MANPREFIX = ${PREFIX}/share/man # includes and libs diff --git a/ind.c b/ind.c @@ -11,6 +11,7 @@ #include <string.h> #include <strings.h> #include <errno.h> +#include <ctype.h> #include <sys/types.h> #include <sys/stat.h> #include <time.h> @@ -491,7 +492,7 @@ strisascii(char *str) char * findlimitws(char *str, int limit) { - int i, len; + int len; char *ptr; len = strlen(str); diff --git a/llist.c b/llist.c @@ -30,11 +30,15 @@ llistelemvalue_internfree(llistelem_t *elem, int mode) else llist_efree((llist_t *)elem->data); } else { - if (elem->data != NULL && !(mode & FREE_BARE)) + if (elem->data != NULL && !(mode & FREE_BARE)) { free(elem->data); + elem->data = NULL; + } } - if (elem->key != NULL && !(mode & FREE_BARE)) + if (elem->key != NULL && !(mode & FREE_BARE)) { free(elem->key); + elem->key = NULL; + } } void diff --git a/meta.c b/meta.c @@ -20,13 +20,18 @@ mime2meta(mime_t *mime) meta_t * meta_headers2mime(meta_t *meta) { - llistelem_t *param, *header; + llistelem_t *header; char *enc; forllist(meta->hdrs, header) { - if(!strisascii(header->value)) { - } + enc = mime_encodeheader(header->key, header->value); + + free(header->value); + header->value = enc; + header->datalen = strlen(enc); } + + return meta; } meta_t * diff --git a/mime.c b/mime.c @@ -334,7 +334,7 @@ char * mime_encodeheader(char *header, char *value) { char *ret, *b64, *p, *mp, *str; - int len, hlen, lmax, isascii = 0, firstline; + int len, hlen, lmax, isascii = 0, firstline, slen; /* * RFC 2047: @@ -351,10 +351,10 @@ mime_encodeheader(char *header, char *value) slen = strlen(value); ret = NULL; - for (p = value, firstline = 0; slen > 0; slen -= lmax, p = mp) { - if (firstline == 1) { + for (p = value, firstline = 1; slen > 0; slen -= lmax, p = mp) { + if (firstline) { lmax += hlen; - firstline++; + firstline = 0; } mp = findlimitws(p, lmax); @@ -1078,8 +1078,7 @@ mime_decodepartencoding(mime_t *mime, int *len) if (!strcasecmp(mime->cte, "base64")) { *len = mime->bodylen; ret = b64dec(mime->body, len); - } - if (!strcasecmp(mime->cte, "quoted-printable")) { + } else if (!strcasecmp(mime->cte, "quoted-printable")) { *len = mime->bodylen; ret = qpdec(mime->body, len, 0); }