dmc

dynamic mail client
git clone git://git.suckless.org/dmc
Log | Files | Refs | README | LICENSE

commit ab5c262f1c5800c2c3537b34aedf1187c3b38abe
parent e2028649dc4a9e12fd90c4642dc6b72a34b092cc
Author: nibble <unknown>
Date:   Mon, 16 Nov 2009 13:01:59 +0100

* Syntax fixes in pack.c and pop3.c
Diffstat:
pack.c | 8++++----
pop3.c | 36++++++++++++++++++------------------
2 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/pack.c b/pack.c @@ -8,14 +8,14 @@ static const char cb64[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; static const char cd64[]="|$$$}rstuvwxyz{$$$$$$$>?@ABCDEFGHIJKLMNOPQRSTUVW$$$$$$XYZ[\\]^_`abcdefghijklmnopq"; -void b64_encode(unsigned char in[3], unsigned char out[4], int len) { +static void b64_encode(unsigned char in[3], unsigned char out[4], int len) { out[0] = cb64[ in[0] >> 2 ]; out[1] = cb64[ ((in[0] & 0x03) << 4) | ((in[1] & 0xf0) >> 4) ]; out[2] = (len > 1 ? cb64[ ((in[1] & 0x0f) << 2) | ((in[2] & 0xc0) >> 6) ] : '='); out[3] = (len > 2 ? cb64[ in[2] & 0x3f ] : '='); } -int b64_decode(unsigned char in[4], unsigned char out[3]) { +static int b64_decode(unsigned char in[4], unsigned char out[3]) { unsigned char len = 3, i, v[4]; for(i=0;i<4;i++) { if (in[i]<43||in[i]>122) @@ -30,7 +30,7 @@ int b64_decode(unsigned char in[4], unsigned char out[3]) { return len; } -void mime_pack(char **files, int nfiles) { +static void mime_pack(char **files, int nfiles) { FILE *fd = NULL; char b[1024], cmd[1024], *ptr = NULL, *ptr2 = NULL; unsigned char bd[1024]; @@ -80,7 +80,7 @@ void mime_pack(char **files, int nfiles) { puts ("--dmc-multipart--"); } -void mime_unpack (int xtr) { +static void mime_unpack (int xtr) { FILE *fd = NULL; char b[1024], boundary[1024], encoding[1024], filename[1024], *ptr, *ptr2; unsigned char bd[1024]; diff --git a/pop3.c b/pop3.c @@ -14,14 +14,14 @@ static char *cmd = NULL; static char word[1024]; -static char *getword () { +static char *getword() { fscanf (stdin, "%255s", word); if (feof (stdin)) *word = '\0'; return word; } -static int waitreply (int res) { +static int waitreply(int res) { char result[1024]; char *ch, *str; int reply = -1; @@ -35,7 +35,7 @@ static int waitreply (int res) { if ((ch = strchr (str, '\r')) || (ch = strchr (str, '\n'))) { *ch = '\0'; snprintf (result, 1023, "### %s %d \"%s\"\n", cmd, reply, str); - str = ch + ((ch[1] == '\r' || ch[1] == '\n') ? 2 : 1); + str = ch + (ch[1] == '\n' ? 2 : 1); } } // TODO: Fix possible \r\n issues @@ -52,7 +52,7 @@ static int waitreply (int res) { return reply; } -static int doword (char *word) { +static int doword(char *word) { int ret = 1; free (cmd); cmd = strdup (word); @@ -68,26 +68,26 @@ static int doword (char *word) { if (!strcmp (word, "help") || !strcmp (word, "?")) { printf ("Use: ls cat head rm login exit\n"); } else - if (!strcmp(word, "ls")) { + if (!strcmp (word, "ls")) { sock_printf ("LIST\n"); waitreply (1); } else - if (!strcmp(word, "cat")) { - sock_printf ("RETR %d\n", atoi (getword())); + if (!strcmp (word, "cat")) { + sock_printf ("RETR %d\n", atoi (getword ())); waitreply (1); } else - if (!strcmp(word, "head")) { - sock_printf ("TOP %d 50\n", atoi (getword())); + if (!strcmp (word, "head")) { + sock_printf ("TOP %d 50\n", atoi (getword ())); waitreply (1); } else - if (!strcmp(word, "rm")) { - sock_printf ("DELE %d\n", atoi (getword())); + if (!strcmp (word, "rm")) { + sock_printf ("DELE %d\n", atoi (getword ())); waitreply (1); } else - if (!strcmp(word, "login")) { - sock_printf ("USER %s\n", getword()); + if (!strcmp (word, "login")) { + sock_printf ("USER %s\n", getword ()); waitreply (0); // TODO: if user fail, do not send pass - sock_printf ("PASS %s\n", getword()); + sock_printf ("PASS %s\n", getword ()); waitreply (1); } else sock_printf ("NOOP\n"); return ret; @@ -95,14 +95,14 @@ static int doword (char *word) { int main(int argc, char **argv) { int ssl = 0, ret = 1; - if (argc>2) { - if (argc>3) - ssl = (*argv[3]=='1'); + if (argc > 2) { + if (argc > 3) + ssl = (*argv[3] == '1'); if (sock_connect (argv[1], atoi (argv[2]), ssl) >= 0) { ret = atexit (sock_close); waitreply (1); while (doword (getword ())); - } else printf ("Cannot connect to %s %d\n", argv[1], atoi(argv[2])); + } else printf ("Cannot connect to %s %d\n", argv[1], atoi (argv[2])); } else printf ("Usage: dmc-pop3 host port [ssl] 2> body > fifo < input\n"); return 0; }