rp

simple email tools
git clone https://git.parazyd.org/rp
Log | Files | Refs | README | LICENSE

commit 84deac9c1fb49d742aa0b8877fee60c34b5b5855
parent a5ffe13b1502e01adb7da16b879eb99e3c55d49d
Author: parazyd <parazyd@dyne.org>
Date:   Thu,  1 Mar 2018 00:56:44 +0100

Remove tls.sh, bring back colorful messages.

Diffstat:
Mbin/rpsend | 3+--
Mind.c | 20++++++++++++++++++++
Mind.h | 2++
Drplib/tls.sh | 10----------
Msieve.c | 10+++++-----
5 files changed, 28 insertions(+), 17 deletions(-)

diff --git a/bin/rpsend b/bin/rpsend @@ -3,7 +3,6 @@ profile="${RPPROFILE:-$HOME/.rp/default}" . "$HOME"/.rp/rplib/common.sh . "$HOME"/.rp/rplib/pass.sh -. "$HOME"/.rp/rplib/tls.sh . "$profile"/config @@ -56,7 +55,7 @@ if ! [ -f "$profile/smtp-fingerprint" ]; then fi known="$(cat $profile/smtp-fingerprint)" -served="$(getfingerprint $imap1host 587)" +served="$(rpnet -f $imap1host 587)" einfo "known fingerprint: $known" einfo "served fingerprint: $served" diff --git a/ind.c b/ind.c @@ -12,6 +12,7 @@ void edie(char *fmt, ...) { va_list fmtargs; va_start(fmtargs, fmt); + fprintf(stderr, " \033[31m*\033[0m "); vfprintf(stderr, fmt, fmtargs); va_end(fmtargs); fprintf(stderr, ": "); @@ -25,8 +26,27 @@ void die(char *fmt, ...) { va_list fmtargs; va_start(fmtargs, fmt); + fprintf(stderr, " \033[31m*\033[0m "); vfprintf(stderr, fmt, fmtargs); va_end(fmtargs); exit(1); } + +void warn(char *fmt, ...) { + va_list fmtargs; + + va_start(fmtargs, fmt); + fprintf(stderr, " \033[33m*\033[0m "); + vfprintf(stderr, fmt, fmtargs); + va_end(fmtargs); +} + +void info(char *fmt, ...) { + va_list fmtargs; + + va_start(fmtargs, fmt); + fprintf(stderr, " \033[32m*\033[0m "); + vfprintf(stderr, fmt, fmtargs); + va_end(fmtargs); +} diff --git a/ind.h b/ind.h @@ -12,5 +12,7 @@ void edie(char *fmt, ...); void die(char *fmt, ...); +void warn(char *fmt, ...); +void info(char *fmt, ...); #endif diff --git a/rplib/tls.sh b/rplib/tls.sh @@ -1,10 +0,0 @@ -#!/bin/sh - -getfingerprint() { - host="$1" - port="$2" - - echo QUIT | openssl s_client -starttls smtp -connect $host:$port \ - -showcerts 2>/dev/null | \ - openssl x509 -fingerprint -sha1 -noout | cut -d'=' -f2 -} diff --git a/sieve.c b/sieve.c @@ -29,7 +29,7 @@ int gento(char *line) { printf("if header :contains [ \"To\",\"Cc\" ] \"%s\"", email); printf(" { fileinto :create \"%s\"; stop; }\n", mbox); - fprintf(stderr, "to: %s -> %s\n", email, mbox); + info("to: %s -> %s\n", email, mbox); return 0; } @@ -52,7 +52,7 @@ int genfrom(char *line) { printf("if header :contains \"From\" \"%s\"", email); printf(" { fileinto :create \"%s\"; stop; }\n", mbox); - fprintf(stderr, "from: %s -> %s\n", email, mbox); + info("from: %s -> %s\n", email, mbox); return 0; } @@ -67,7 +67,7 @@ int genabook(char *line) { printf("if header :contains \"From\" \"%s\"", email); printf(" { fileinto :create \"INBOX\"; stop; }\n"); - fprintf(stderr, "from: %s -> INBOX\n", email); + info("from: %s -> INBOX\n", email); return 0; } @@ -81,11 +81,11 @@ int sievemain(int argc, char *argv[]) { strtok(l, "\n"); if (!strncmp("to", l, 2)) { if (gento(l)) - fprintf(stderr, "\033[33m * invalid line: %d\033[0m\n", c); + warn("invalid line: %d\n", c); } else if (!strncmp("from", l, 4)) { if (genfrom(l)) - fprintf(stderr, "\033[33m * invalid line: %d\033[0m\n", c); + warn("invalid line: %d\n", c); } else if (!strncmp("email=", l, 6)) {