{"thread":{"id":"14357","subject":"[PATCH 3/4] imap-send.c: Clean up coding style to better match the rest of the git codebase.","startedAt":"2008-07-08T22:18:15Z","lastAt":"2008-07-08T22:18:15Z","messageCount":1,"participants":["Robert Shearman"],"isPatch":true,"patchVersion":1,"patchTotal":4},"messages":[{"id":"82641","messageId":"1215555496-21335-3-git-send-email-robertshearman@gmail.com","threadId":"14357","inReplyTo":null,"subject":"[PATCH 3/4] imap-send.c: Clean up coding style to better match the rest of the git codebase.","fromName":"Robert Shearman","fromEmail":"robertshearman@gmail.com","sentAt":"2008-07-08T22:18:15Z","receivedAt":"2008-07-08T22:18:15Z","isPatch":true,"sender":{"key":"robertshearman@gmail.com","avatar":null},"body":"---\n imap-send.c |  631 ++++++++++++++++++++++++++++-------------------------------\n 1 files changed, 301 insertions(+), 330 deletions(-)\n\ndiff --git a/imap-send.c b/imap-send.c\nindex d138726..59ef4eb 100644\n--- a/imap-send.c\n+++ b/imap-send.c\n@@ -102,14 +102,14 @@ typedef struct {\n \n static int Verbose, Quiet;\n \n-static void imap_info( const char *, ... );\n-static void imap_warn( const char *, ... );\n+static void imap_info(const char *, ...);\n+static void imap_warn(const char *, ...);\n \n-static char *next_arg( char ** );\n+static char *next_arg(char **);\n \n-static void free_generic_messages( message_t * );\n+static void free_generic_messages(message_t *);\n \n-static int nfsnprintf( char *buf, int blen, const char *fmt, ... );\n+static int nfsnprintf(char *buf, int blen, const char *fmt, ...);\n \n static int nfvasprintf(char **strp, const char *fmt, va_list ap)\n {\n@@ -125,8 +125,8 @@ static int nfvasprintf(char **strp, const char *fmt, va_list ap)\n \treturn len;\n }\n \n-static void arc4_init( void );\n-static unsigned char arc4_getbyte( void );\n+static void arc4_init(void);\n+static unsigned char arc4_getbyte(void);\n \n typedef struct imap_server_conf {\n \tchar *name;\n@@ -187,8 +187,8 @@ typedef struct imap_store {\n } imap_store_t;\n \n struct imap_cmd_cb {\n-\tint (*cont)( imap_store_t *ctx, struct imap_cmd *cmd, const char *prompt );\n-\tvoid (*done)( imap_store_t *ctx, struct imap_cmd *cmd, int response);\n+\tint (*cont)(imap_store_t *ctx, struct imap_cmd *cmd, const char *prompt);\n+\tvoid (*done)(imap_store_t *ctx, struct imap_cmd *cmd, int response);\n \tvoid *ctx;\n \tchar *data;\n \tint dlen;\n@@ -225,7 +225,7 @@ static const char *cap_list[] = {\n #define RESP_NO    1\n #define RESP_BAD   2\n \n-static int get_cmd_result( imap_store_t *ctx, struct imap_cmd *tcmd );\n+static int get_cmd_result(imap_store_t *ctx, struct imap_cmd *tcmd);\n \n \n static const char *Flags[] = {\n@@ -243,8 +243,7 @@ static void ssl_socket_perror(const char *func)\n }\n #endif\n \n-static void\n-socket_perror( const char *func, Socket_t *sock, int ret )\n+static void socket_perror(const char *func, Socket_t *sock, int ret)\n {\n #ifndef NO_OPENSSL\n \tif (sock->ssl) {\n@@ -321,8 +320,7 @@ static int ssl_socket_connect(Socket_t *sock, int use_tls_only, int verify)\n #endif\n }\n \n-static int\n-socket_read( Socket_t *sock, char *buf, int len )\n+static int socket_read(Socket_t *sock, char *buf, int len)\n {\n \tssize_t n;\n #ifndef NO_OPENSSL\n@@ -330,17 +328,16 @@ socket_read( Socket_t *sock, char *buf, int len )\n \t\tn = SSL_read(sock->ssl, buf, len);\n \telse\n #endif\n-\t\tn = xread( sock->fd, buf, len );\n+\t\tn = xread(sock->fd, buf, len);\n \tif (n <= 0) {\n-\t\tsocket_perror( \"read\", sock, n );\n-\t\tclose( sock->fd );\n+\t\tsocket_perror(\"read\", sock, n);\n+\t\tclose(sock->fd);\n \t\tsock->fd = -1;\n \t}\n \treturn n;\n }\n \n-static int\n-socket_write( Socket_t *sock, const char *buf, int len )\n+static int socket_write(Socket_t *sock, const char *buf, int len)\n {\n \tint n;\n #ifndef NO_OPENSSL\n@@ -348,10 +345,10 @@ socket_write( Socket_t *sock, const char *buf, int len )\n \t\tn = SSL_write(sock->ssl, buf, len);\n \telse\n #endif\n-\t\tn = write_in_full( sock->fd, buf, len );\n+\t\tn = write_in_full(sock->fd, buf, len);\n \tif (n != len) {\n-\t\tsocket_perror( \"write\", sock, n );\n-\t\tclose( sock->fd );\n+\t\tsocket_perror(\"write\", sock, n);\n+\t\tclose(sock->fd);\n \t\tsock->fd = -1;\n \t}\n \treturn n;\n@@ -369,8 +366,7 @@ static void socket_shutdown(Socket_t *sock)\n }\n \n /* simple line buffering */\n-static int\n-buffer_gets( buffer_t * b, char **s )\n+static int buffer_gets(buffer_t * b, char **s)\n {\n \tint n;\n \tint start = b->offset;\n@@ -384,7 +380,7 @@ buffer_gets( buffer_t * b, char **s )\n \t\t\t\t/* shift down used bytes */\n \t\t\t\t*s = b->buf;\n \n-\t\t\t\tassert( start <= b->bytes );\n+\t\t\t\tassert(start <= b->bytes);\n \t\t\t\tn = b->bytes - start;\n \n \t\t\t\tif (n)\n@@ -394,8 +390,8 @@ buffer_gets( buffer_t * b, char **s )\n \t\t\t\tstart = 0;\n \t\t\t}\n \n-\t\t\tn = socket_read( &b->sock, b->buf + b->bytes,\n-\t\t\t\t\t sizeof(b->buf) - b->bytes );\n+\t\t\tn = socket_read(&b->sock, b->buf + b->bytes,\n+\t\t\t\t\t sizeof(b->buf) - b->bytes);\n \n \t\t\tif (n <= 0)\n \t\t\t\treturn -1;\n@@ -404,12 +400,12 @@ buffer_gets( buffer_t * b, char **s )\n \t\t}\n \n \t\tif (b->buf[b->offset] == '\\r') {\n-\t\t\tassert( b->offset + 1 < b->bytes );\n+\t\t\tassert(b->offset + 1 < b->bytes);\n \t\t\tif (b->buf[b->offset + 1] == '\\n') {\n \t\t\t\tb->buf[b->offset] = 0;  /* terminate the string */\n \t\t\t\tb->offset += 2; /* next line */\n \t\t\t\tif (Verbose)\n-\t\t\t\t\tputs( *s );\n+\t\t\t\t\tputs(*s);\n \t\t\t\treturn 0;\n \t\t\t}\n \t\t}\n@@ -419,39 +415,36 @@ buffer_gets( buffer_t * b, char **s )\n \t/* not reached */\n }\n \n-static void\n-imap_info( const char *msg, ... )\n+static void imap_info(const char *msg, ...)\n {\n \tva_list va;\n \n \tif (!Quiet) {\n-\t\tva_start( va, msg );\n-\t\tvprintf( msg, va );\n-\t\tva_end( va );\n-\t\tfflush( stdout );\n+\t\tva_start(va, msg);\n+\t\tvprintf(msg, va);\n+\t\tva_end(va);\n+\t\tfflush(stdout);\n \t}\n }\n \n-static void\n-imap_warn( const char *msg, ... )\n+static void imap_warn(const char *msg, ...)\n {\n \tva_list va;\n \n \tif (Quiet < 2) {\n-\t\tva_start( va, msg );\n-\t\tvfprintf( stderr, msg, va );\n-\t\tva_end( va );\n+\t\tva_start(va, msg);\n+\t\tvfprintf(stderr, msg, va);\n+\t\tva_end(va);\n \t}\n }\n \n-static char *\n-next_arg( char **s )\n+static char *next_arg(char **s)\n {\n \tchar *ret;\n \n \tif (!s || !*s)\n \t\treturn NULL;\n-\twhile (isspace( (unsigned char) **s ))\n+\twhile (isspace((unsigned char) **s))\n \t\t(*s)++;\n \tif (!**s) {\n \t\t*s = NULL;\n@@ -460,10 +453,10 @@ next_arg( char **s )\n \tif (**s == '\"') {\n \t\t++*s;\n \t\tret = *s;\n-\t\t*s = strchr( *s, '\"' );\n+\t\t*s = strchr(*s, '\"');\n \t} else {\n \t\tret = *s;\n-\t\twhile (**s && !isspace( (unsigned char) **s ))\n+\t\twhile (**s && !isspace((unsigned char) **s))\n \t\t\t(*s)++;\n \t}\n \tif (*s) {\n@@ -475,27 +468,25 @@ next_arg( char **s )\n \treturn ret;\n }\n \n-static void\n-free_generic_messages( message_t *msgs )\n+static void free_generic_messages(message_t *msgs)\n {\n \tmessage_t *tmsg;\n \n \tfor (; msgs; msgs = tmsg) {\n \t\ttmsg = msgs->next;\n-\t\tfree( msgs );\n+\t\tfree(msgs);\n \t}\n }\n \n-static int\n-nfsnprintf( char *buf, int blen, const char *fmt, ... )\n+static int nfsnprintf(char *buf, int blen, const char *fmt, ...)\n {\n \tint ret;\n \tva_list va;\n \n-\tva_start( va, fmt );\n-\tif (blen <= 0 || (unsigned)(ret = vsnprintf( buf, blen, fmt, va )) >= (unsigned)blen)\n-\t\tdie( \"Fatal: buffer too small. Please report a bug.\\n\");\n-\tva_end( va );\n+\tva_start(va, fmt);\n+\tif (blen <= 0 || (unsigned)(ret = vsnprintf(buf, blen, fmt, va)) >= (unsigned)blen)\n+\t\tdie(\"Fatal: buffer too small. Please report a bug.\\n\");\n+\tva_end(va);\n \treturn ret;\n }\n \n@@ -503,21 +494,20 @@ static struct {\n \tunsigned char i, j, s[256];\n } rs;\n \n-static void\n-arc4_init( void )\n+static void arc4_init(void)\n {\n \tint i, fd;\n \tunsigned char j, si, dat[128];\n \n-\tif ((fd = open( \"/dev/urandom\", O_RDONLY )) < 0 && (fd = open( \"/dev/random\", O_RDONLY )) < 0) {\n-\t\tfprintf( stderr, \"Fatal: no random number source available.\\n\" );\n-\t\texit( 3 );\n+\tif ((fd = open(\"/dev/urandom\", O_RDONLY)) < 0 && (fd = open(\"/dev/random\", O_RDONLY)) < 0) {\n+\t\tfprintf(stderr, \"Fatal: no random number source available.\\n\");\n+\t\texit(3);\n \t}\n-\tif (read_in_full( fd, dat, 128 ) != 128) {\n-\t\tfprintf( stderr, \"Fatal: cannot read random number source.\\n\" );\n-\t\texit( 3 );\n+\tif (read_in_full(fd, dat, 128) != 128) {\n+\t\tfprintf(stderr, \"Fatal: cannot read random number source.\\n\");\n+\t\texit(3);\n \t}\n-\tclose( fd );\n+\tclose(fd);\n \n \tfor (i = 0; i < 256; i++)\n \t\trs.s[i] = i;\n@@ -533,8 +523,7 @@ arc4_init( void )\n \t\tarc4_getbyte();\n }\n \n-static unsigned char\n-arc4_getbyte( void )\n+static unsigned char arc4_getbyte(void)\n {\n \tunsigned char si, sj;\n \n@@ -547,54 +536,54 @@ arc4_getbyte( void )\n \treturn rs.s[(si + sj) & 0xff];\n }\n \n-static struct imap_cmd *\n-v_issue_imap_cmd( imap_store_t *ctx, struct imap_cmd_cb *cb,\n-\t\t  const char *fmt, va_list ap )\n+static struct imap_cmd *v_issue_imap_cmd(imap_store_t *ctx,\n+\t\t\t\t\t struct imap_cmd_cb *cb,\n+\t\t\t\t\t const char *fmt, va_list ap)\n {\n \timap_t *imap = ctx->imap;\n \tstruct imap_cmd *cmd;\n \tint n, bufl;\n \tchar buf[1024];\n \n-\tcmd = xmalloc( sizeof(struct imap_cmd) );\n-\tnfvasprintf( &cmd->cmd, fmt, ap );\n+\tcmd = xmalloc(sizeof(struct imap_cmd));\n+\tnfvasprintf(&cmd->cmd, fmt, ap);\n \tcmd->tag = ++imap->nexttag;\n \n \tif (cb)\n \t\tcmd->cb = *cb;\n \telse\n-\t\tmemset( &cmd->cb, 0, sizeof(cmd->cb) );\n+\t\tmemset(&cmd->cb, 0, sizeof(cmd->cb));\n \n \twhile (imap->literal_pending)\n-\t\tget_cmd_result( ctx, NULL );\n+\t\tget_cmd_result(ctx, NULL);\n \n-\tbufl = nfsnprintf( buf, sizeof(buf), cmd->cb.data ? CAP(LITERALPLUS) ?\n+\tbufl = nfsnprintf(buf, sizeof(buf), cmd->cb.data ? CAP(LITERALPLUS) ?\n \t\t\t   \"%d %s{%d+}\\r\\n\" : \"%d %s{%d}\\r\\n\" : \"%d %s\\r\\n\",\n-\t\t\t   cmd->tag, cmd->cmd, cmd->cb.dlen );\n+\t\t\t   cmd->tag, cmd->cmd, cmd->cb.dlen);\n \tif (Verbose) {\n \t\tif (imap->num_in_progress)\n-\t\t\tprintf( \"(%d in progress) \", imap->num_in_progress );\n-\t\tif (memcmp( cmd->cmd, \"LOGIN\", 5 ))\n-\t\t\tprintf( \">>> %s\", buf );\n+\t\t\tprintf(\"(%d in progress) \", imap->num_in_progress);\n+\t\tif (memcmp(cmd->cmd, \"LOGIN\", 5))\n+\t\t\tprintf(\">>> %s\", buf);\n \t\telse\n-\t\t\tprintf( \">>> %d LOGIN <user> <pass>\\n\", cmd->tag );\n+\t\t\tprintf(\">>> %d LOGIN <user> <pass>\\n\", cmd->tag);\n \t}\n-\tif (socket_write( &imap->buf.sock, buf, bufl ) != bufl) {\n-\t\tfree( cmd->cmd );\n-\t\tfree( cmd );\n+\tif (socket_write(&imap->buf.sock, buf, bufl) != bufl) {\n+\t\tfree(cmd->cmd);\n+\t\tfree(cmd);\n \t\tif (cb)\n-\t\t\tfree( cb->data );\n+\t\t\tfree(cb->data);\n \t\treturn NULL;\n \t}\n \tif (cmd->cb.data) {\n \t\tif (CAP(LITERALPLUS)) {\n-\t\t\tn = socket_write( &imap->buf.sock, cmd->cb.data, cmd->cb.dlen );\n-\t\t\tfree( cmd->cb.data );\n+\t\t\tn = socket_write(&imap->buf.sock, cmd->cb.data, cmd->cb.dlen);\n+\t\t\tfree(cmd->cb.data);\n \t\t\tif (n != cmd->cb.dlen ||\n-\t\t\t    (n = socket_write( &imap->buf.sock, \"\\r\\n\", 2 )) != 2)\n+\t\t\t    (n = socket_write(&imap->buf.sock, \"\\r\\n\", 2)) != 2)\n \t\t\t{\n-\t\t\t\tfree( cmd->cmd );\n-\t\t\t\tfree( cmd );\n+\t\t\t\tfree(cmd->cmd);\n+\t\t\t\tfree(cmd);\n \t\t\t\treturn NULL;\n \t\t\t}\n \t\t\tcmd->cb.data = NULL;\n@@ -609,109 +598,106 @@ v_issue_imap_cmd( imap_store_t *ctx, struct imap_cmd_cb *cb,\n \treturn cmd;\n }\n \n-static struct imap_cmd *\n-issue_imap_cmd( imap_store_t *ctx, struct imap_cmd_cb *cb, const char *fmt, ... )\n+static struct imap_cmd *issue_imap_cmd(imap_store_t *ctx,\n+\t\t\t\t       struct imap_cmd_cb *cb,\n+\t\t\t\t       const char *fmt, ...)\n {\n \tstruct imap_cmd *ret;\n \tva_list ap;\n \n-\tva_start( ap, fmt );\n-\tret = v_issue_imap_cmd( ctx, cb, fmt, ap );\n-\tva_end( ap );\n+\tva_start(ap, fmt);\n+\tret = v_issue_imap_cmd(ctx, cb, fmt, ap);\n+\tva_end(ap);\n \treturn ret;\n }\n \n-static int\n-imap_exec( imap_store_t *ctx, struct imap_cmd_cb *cb, const char *fmt, ... )\n+static int imap_exec(imap_store_t *ctx, struct imap_cmd_cb *cb,\n+\t\t     const char *fmt, ...)\n {\n \tva_list ap;\n \tstruct imap_cmd *cmdp;\n \n-\tva_start( ap, fmt );\n-\tcmdp = v_issue_imap_cmd( ctx, cb, fmt, ap );\n-\tva_end( ap );\n+\tva_start(ap, fmt);\n+\tcmdp = v_issue_imap_cmd(ctx, cb, fmt, ap);\n+\tva_end(ap);\n \tif (!cmdp)\n \t\treturn RESP_BAD;\n \n-\treturn get_cmd_result( ctx, cmdp );\n+\treturn get_cmd_result(ctx, cmdp);\n }\n \n-static int\n-imap_exec_m( imap_store_t *ctx, struct imap_cmd_cb *cb, const char *fmt, ... )\n+static int imap_exec_m(imap_store_t *ctx, struct imap_cmd_cb *cb,\n+\t\t       const char *fmt, ...)\n {\n \tva_list ap;\n \tstruct imap_cmd *cmdp;\n \n-\tva_start( ap, fmt );\n-\tcmdp = v_issue_imap_cmd( ctx, cb, fmt, ap );\n-\tva_end( ap );\n+\tva_start(ap, fmt);\n+\tcmdp = v_issue_imap_cmd(ctx, cb, fmt, ap);\n+\tva_end(ap);\n \tif (!cmdp)\n \t\treturn DRV_STORE_BAD;\n \n-\tswitch (get_cmd_result( ctx, cmdp )) {\n+\tswitch (get_cmd_result(ctx, cmdp)) {\n \tcase RESP_BAD: return DRV_STORE_BAD;\n \tcase RESP_NO: return DRV_MSG_BAD;\n \tdefault: return DRV_OK;\n \t}\n }\n \n-static int\n-is_atom( list_t *list )\n+static int is_atom(list_t *list)\n {\n \treturn list && list->val && list->val != NIL && list->val != LIST;\n }\n \n-static int\n-is_list( list_t *list )\n+static int is_list(list_t *list)\n {\n \treturn list && list->val == LIST;\n }\n \n-static void\n-free_list( list_t *list )\n+static void free_list(list_t *list)\n {\n \tlist_t *tmp;\n \n \tfor (; list; list = tmp) {\n \t\ttmp = list->next;\n-\t\tif (is_list( list ))\n-\t\t\tfree_list( list->child );\n-\t\telse if (is_atom( list ))\n-\t\t\tfree( list->val );\n-\t\tfree( list );\n+\t\tif (is_list(list))\n+\t\t\tfree_list(list->child);\n+\t\telse if (is_atom(list))\n+\t\t\tfree(list->val);\n+\t\tfree(list);\n \t}\n }\n \n-static int\n-parse_imap_list_l( imap_t *imap, char **sp, list_t **curp, int level )\n+static int parse_imap_list_l(imap_t *imap, char **sp, list_t **curp, int level)\n {\n \tlist_t *cur;\n \tchar *s = *sp, *p;\n \tint n, bytes;\n \n \tfor (;;) {\n-\t\twhile (isspace( (unsigned char)*s ))\n+\t\twhile (isspace((unsigned char)*s))\n \t\t\ts++;\n \t\tif (level && *s == ')') {\n \t\t\ts++;\n \t\t\tbreak;\n \t\t}\n-\t\t*curp = cur = xmalloc( sizeof(*cur) );\n+\t\t*curp = cur = xmalloc(sizeof(*cur));\n \t\tcurp = &cur->next;\n \t\tcur->val = NULL; /* for clean bail */\n \t\tif (*s == '(') {\n \t\t\t/* sublist */\n \t\t\ts++;\n \t\t\tcur->val = LIST;\n-\t\t\tif (parse_imap_list_l( imap, &s, &cur->child, level + 1 ))\n+\t\t\tif (parse_imap_list_l(imap, &s, &cur->child, level + 1))\n \t\t\t\tgoto bail;\n \t\t} else if (imap && *s == '{') {\n \t\t\t/* literal */\n-\t\t\tbytes = cur->len = strtol( s + 1, &s, 10 );\n+\t\t\tbytes = cur->len = strtol(s + 1, &s, 10);\n \t\t\tif (*s != '}')\n \t\t\t\tgoto bail;\n \n-\t\t\ts = cur->val = xmalloc( cur->len );\n+\t\t\ts = cur->val = xmalloc(cur->len);\n \n \t\t\t/* dump whats left over in the input buffer */\n \t\t\tn = imap->buf.bytes - imap->buf.offset;\n@@ -720,7 +706,7 @@ parse_imap_list_l( imap_t *imap, char **sp, list_t **curp, int level )\n \t\t\t\t/* the entire message fit in the buffer */\n \t\t\t\tn = bytes;\n \n-\t\t\tmemcpy( s, imap->buf.buf + imap->buf.offset, n );\n+\t\t\tmemcpy(s, imap->buf.buf + imap->buf.offset, n);\n \t\t\ts += n;\n \t\t\tbytes -= n;\n \n@@ -729,13 +715,13 @@ parse_imap_list_l( imap_t *imap, char **sp, list_t **curp, int level )\n \n \t\t\t/* now read the rest of the message */\n \t\t\twhile (bytes > 0) {\n-\t\t\t\tif ((n = socket_read (&imap->buf.sock, s, bytes)) <= 0)\n+\t\t\t\tif ((n = socket_read(&imap->buf.sock, s, bytes)) <= 0)\n \t\t\t\t\tgoto bail;\n \t\t\t\ts += n;\n \t\t\t\tbytes -= n;\n \t\t\t}\n \n-\t\t\tif (buffer_gets( &imap->buf, &s ))\n+\t\t\tif (buffer_gets(&imap->buf, &s))\n \t\t\t\tgoto bail;\n \t\t} else if (*s == '\"') {\n \t\t\t/* quoted string */\n@@ -750,11 +736,11 @@ parse_imap_list_l( imap_t *imap, char **sp, list_t **curp, int level )\n \t\t} else {\n \t\t\t/* atom */\n \t\t\tp = s;\n-\t\t\tfor (; *s && !isspace( (unsigned char)*s ); s++)\n+\t\t\tfor (; *s && !isspace((unsigned char)*s); s++)\n \t\t\t\tif (level && *s == ')')\n \t\t\t\t\tbreak;\n \t\t\tcur->len = s - p;\n-\t\t\tif (cur->len == 3 && !memcmp (\"NIL\", p, 3)) {\n+\t\t\tif (cur->len == 3 && !memcmp(\"NIL\", p, 3)) {\n \t\t\t\tcur->val = NIL;\n \t\t\t} else {\n \t\t\t\tcur->val = xmemdupz(p, cur->len);\n@@ -775,39 +761,36 @@ parse_imap_list_l( imap_t *imap, char **sp, list_t **curp, int level )\n \treturn -1;\n }\n \n-static list_t *\n-parse_imap_list( imap_t *imap, char **sp )\n+static list_t *parse_imap_list(imap_t *imap, char **sp)\n {\n \tlist_t *head;\n \n-\tif (!parse_imap_list_l( imap, sp, &head, 0 ))\n+\tif (!parse_imap_list_l(imap, sp, &head, 0))\n \t\treturn head;\n-\tfree_list( head );\n+\tfree_list(head);\n \treturn NULL;\n }\n \n-static list_t *\n-parse_list( char **sp )\n+static list_t *parse_list(char **sp)\n {\n-\treturn parse_imap_list( NULL, sp );\n+\treturn parse_imap_list(NULL, sp);\n }\n \n-static void\n-parse_capability( imap_t *imap, char *cmd )\n+static void parse_capability(imap_t *imap, char *cmd)\n {\n \tchar *arg;\n \tunsigned i;\n \n \timap->caps = 0x80000000;\n-\twhile ((arg = next_arg( &cmd )))\n+\twhile ((arg = next_arg(&cmd)))\n \t\tfor (i = 0; i < ARRAY_SIZE(cap_list); i++)\n-\t\t\tif (!strcmp( cap_list[i], arg ))\n+\t\t\tif (!strcmp(cap_list[i], arg))\n \t\t\t\timap->caps |= 1 << i;\n \timap->rcaps = imap->caps;\n }\n \n-static int\n-parse_response_code( imap_store_t *ctx, struct imap_cmd_cb *cb, char *s )\n+static int parse_response_code(imap_store_t *ctx, struct imap_cmd_cb *cb,\n+\t\t\t       char *s)\n {\n \timap_t *imap = ctx->imap;\n \tchar *arg, *p;\n@@ -815,43 +798,42 @@ parse_response_code( imap_store_t *ctx, struct imap_cmd_cb *cb, char *s )\n \tif (*s != '[')\n \t\treturn RESP_OK;\t\t/* no response code */\n \ts++;\n-\tif (!(p = strchr( s, ']' ))) {\n-\t\tfprintf( stderr, \"IMAP error: malformed response code\\n\" );\n+\tif (!(p = strchr(s, ']'))) {\n+\t\tfprintf(stderr, \"IMAP error: malformed response code\\n\");\n \t\treturn RESP_BAD;\n \t}\n \t*p++ = 0;\n-\targ = next_arg( &s );\n-\tif (!strcmp( \"UIDVALIDITY\", arg )) {\n-\t\tif (!(arg = next_arg( &s )) || !(ctx->gen.uidvalidity = atoi( arg ))) {\n-\t\t\tfprintf( stderr, \"IMAP error: malformed UIDVALIDITY status\\n\" );\n+\targ = next_arg(&s);\n+\tif (!strcmp(\"UIDVALIDITY\", arg)) {\n+\t\tif (!(arg = next_arg(&s)) || !(ctx->gen.uidvalidity = atoi(arg))) {\n+\t\t\tfprintf(stderr, \"IMAP error: malformed UIDVALIDITY status\\n\");\n \t\t\treturn RESP_BAD;\n \t\t}\n-\t} else if (!strcmp( \"UIDNEXT\", arg )) {\n-\t\tif (!(arg = next_arg( &s )) || !(imap->uidnext = atoi( arg ))) {\n-\t\t\tfprintf( stderr, \"IMAP error: malformed NEXTUID status\\n\" );\n+\t} else if (!strcmp(\"UIDNEXT\", arg)) {\n+\t\tif (!(arg = next_arg(&s)) || !(imap->uidnext = atoi(arg))) {\n+\t\t\tfprintf(stderr, \"IMAP error: malformed NEXTUID status\\n\");\n \t\t\treturn RESP_BAD;\n \t\t}\n-\t} else if (!strcmp( \"CAPABILITY\", arg )) {\n-\t\tparse_capability( imap, s );\n-\t} else if (!strcmp( \"ALERT\", arg )) {\n+\t} else if (!strcmp(\"CAPABILITY\", arg)) {\n+\t\tparse_capability(imap, s);\n+\t} else if (!strcmp(\"ALERT\", arg)) {\n \t\t/* RFC2060 says that these messages MUST be displayed\n \t\t * to the user\n \t\t */\n-\t\tfor (; isspace( (unsigned char)*p ); p++);\n-\t\tfprintf( stderr, \"*** IMAP ALERT *** %s\\n\", p );\n-\t} else if (cb && cb->ctx && !strcmp( \"APPENDUID\", arg )) {\n-\t\tif (!(arg = next_arg( &s )) || !(ctx->gen.uidvalidity = atoi( arg )) ||\n-\t\t    !(arg = next_arg( &s )) || !(*(int *)cb->ctx = atoi( arg )))\n+\t\tfor (; isspace((unsigned char)*p); p++);\n+\t\tfprintf(stderr, \"*** IMAP ALERT *** %s\\n\", p);\n+\t} else if (cb && cb->ctx && !strcmp(\"APPENDUID\", arg)) {\n+\t\tif (!(arg = next_arg(&s)) || !(ctx->gen.uidvalidity = atoi(arg)) ||\n+\t\t    !(arg = next_arg(&s)) || !(*(int *)cb->ctx = atoi(arg)))\n \t\t{\n-\t\t\tfprintf( stderr, \"IMAP error: malformed APPENDUID status\\n\" );\n+\t\t\tfprintf(stderr, \"IMAP error: malformed APPENDUID status\\n\");\n \t\t\treturn RESP_BAD;\n \t\t}\n \t}\n \treturn RESP_OK;\n }\n \n-static int\n-get_cmd_result( imap_store_t *ctx, struct imap_cmd *tcmd )\n+static int get_cmd_result(imap_store_t *ctx, struct imap_cmd *tcmd)\n {\n \timap_t *imap = ctx->imap;\n \tstruct imap_cmd *cmdp, **pcmdp, *ncmdp;\n@@ -859,38 +841,38 @@ get_cmd_result( imap_store_t *ctx, struct imap_cmd *tcmd )\n \tint n, resp, resp2, tag;\n \n \tfor (;;) {\n-\t\tif (buffer_gets( &imap->buf, &cmd ))\n+\t\tif (buffer_gets(&imap->buf, &cmd))\n \t\t\treturn RESP_BAD;\n \n-\t\targ = next_arg( &cmd );\n+\t\targ = next_arg(&cmd);\n \t\tif (*arg == '*') {\n-\t\t\targ = next_arg( &cmd );\n+\t\t\targ = next_arg(&cmd);\n \t\t\tif (!arg) {\n-\t\t\t\tfprintf( stderr, \"IMAP error: unable to parse untagged response\\n\" );\n+\t\t\t\tfprintf(stderr, \"IMAP error: unable to parse untagged response\\n\");\n \t\t\t\treturn RESP_BAD;\n \t\t\t}\n \n-\t\t\tif (!strcmp( \"NAMESPACE\", arg )) {\n-\t\t\t\timap->ns_personal = parse_list( &cmd );\n-\t\t\t\timap->ns_other = parse_list( &cmd );\n-\t\t\t\timap->ns_shared = parse_list( &cmd );\n-\t\t\t} else if (!strcmp( \"OK\", arg ) || !strcmp( \"BAD\", arg ) ||\n-\t\t\t\t   !strcmp( \"NO\", arg ) || !strcmp( \"BYE\", arg )) {\n-\t\t\t\tif ((resp = parse_response_code( ctx, NULL, cmd )) != RESP_OK)\n+\t\t\tif (!strcmp(\"NAMESPACE\", arg)) {\n+\t\t\t\timap->ns_personal = parse_list(&cmd);\n+\t\t\t\timap->ns_other = parse_list(&cmd);\n+\t\t\t\timap->ns_shared = parse_list(&cmd);\n+\t\t\t} else if (!strcmp(\"OK\", arg) || !strcmp(\"BAD\", arg) ||\n+\t\t\t\t   !strcmp(\"NO\", arg) || !strcmp(\"BYE\", arg)) {\n+\t\t\t\tif ((resp = parse_response_code(ctx, NULL, cmd)) != RESP_OK)\n \t\t\t\t\treturn resp;\n-\t\t\t} else if (!strcmp( \"CAPABILITY\", arg ))\n-\t\t\t\tparse_capability( imap, cmd );\n-\t\t\telse if ((arg1 = next_arg( &cmd ))) {\n-\t\t\t\tif (!strcmp( \"EXISTS\", arg1 ))\n-\t\t\t\t\tctx->gen.count = atoi( arg );\n-\t\t\t\telse if (!strcmp( \"RECENT\", arg1 ))\n-\t\t\t\t\tctx->gen.recent = atoi( arg );\n+\t\t\t} else if (!strcmp(\"CAPABILITY\", arg))\n+\t\t\t\tparse_capability(imap, cmd);\n+\t\t\telse if ((arg1 = next_arg(&cmd))) {\n+\t\t\t\tif (!strcmp(\"EXISTS\", arg1))\n+\t\t\t\t\tctx->gen.count = atoi(arg);\n+\t\t\t\telse if (!strcmp(\"RECENT\", arg1))\n+\t\t\t\t\tctx->gen.recent = atoi(arg);\n \t\t\t} else {\n-\t\t\t\tfprintf( stderr, \"IMAP error: unable to parse untagged response\\n\" );\n+\t\t\t\tfprintf(stderr, \"IMAP error: unable to parse untagged response\\n\");\n \t\t\t\treturn RESP_BAD;\n \t\t\t}\n \t\t} else if (!imap->in_progress) {\n-\t\t\tfprintf( stderr, \"IMAP error: unexpected reply: %s %s\\n\", arg, cmd ? cmd : \"\" );\n+\t\t\tfprintf(stderr, \"IMAP error: unexpected reply: %s %s\\n\", arg, cmd ? cmd : \"\");\n \t\t\treturn RESP_BAD;\n \t\t} else if (*arg == '+') {\n \t\t\t/* This can happen only with the last command underway, as\n@@ -898,30 +880,30 @@ get_cmd_result( imap_store_t *ctx, struct imap_cmd *tcmd )\n \t\t\tcmdp = (struct imap_cmd *)((char *)imap->in_progress_append -\n \t\t\t       offsetof(struct imap_cmd, next));\n \t\t\tif (cmdp->cb.data) {\n-\t\t\t\tn = socket_write( &imap->buf.sock, cmdp->cb.data, cmdp->cb.dlen );\n-\t\t\t\tfree( cmdp->cb.data );\n+\t\t\t\tn = socket_write(&imap->buf.sock, cmdp->cb.data, cmdp->cb.dlen);\n+\t\t\t\tfree(cmdp->cb.data);\n \t\t\t\tcmdp->cb.data = NULL;\n \t\t\t\tif (n != (int)cmdp->cb.dlen)\n \t\t\t\t\treturn RESP_BAD;\n \t\t\t} else if (cmdp->cb.cont) {\n-\t\t\t\tif (cmdp->cb.cont( ctx, cmdp, cmd ))\n+\t\t\t\tif (cmdp->cb.cont(ctx, cmdp, cmd))\n \t\t\t\t\treturn RESP_BAD;\n \t\t\t} else {\n-\t\t\t\tfprintf( stderr, \"IMAP error: unexpected command continuation request\\n\" );\n+\t\t\t\tfprintf(stderr, \"IMAP error: unexpected command continuation request\\n\");\n \t\t\t\treturn RESP_BAD;\n \t\t\t}\n-\t\t\tif (socket_write( &imap->buf.sock, \"\\r\\n\", 2 ) != 2)\n+\t\t\tif (socket_write(&imap->buf.sock, \"\\r\\n\", 2) != 2)\n \t\t\t\treturn RESP_BAD;\n \t\t\tif (!cmdp->cb.cont)\n \t\t\t\timap->literal_pending = 0;\n \t\t\tif (!tcmd)\n \t\t\t\treturn DRV_OK;\n \t\t} else {\n-\t\t\ttag = atoi( arg );\n+\t\t\ttag = atoi(arg);\n \t\t\tfor (pcmdp = &imap->in_progress; (cmdp = *pcmdp); pcmdp = &cmdp->next)\n \t\t\t\tif (cmdp->tag == tag)\n \t\t\t\t\tgoto gottag;\n-\t\t\tfprintf( stderr, \"IMAP error: unexpected tag %s\\n\", arg );\n+\t\t\tfprintf(stderr, \"IMAP error: unexpected tag %s\\n\", arg);\n \t\t\treturn RESP_BAD;\n \t\t  gottag:\n \t\t\tif (!(*pcmdp = cmdp->next))\n@@ -929,26 +911,26 @@ get_cmd_result( imap_store_t *ctx, struct imap_cmd *tcmd )\n \t\t\timap->num_in_progress--;\n \t\t\tif (cmdp->cb.cont || cmdp->cb.data)\n \t\t\t\timap->literal_pending = 0;\n-\t\t\targ = next_arg( &cmd );\n-\t\t\tif (!strcmp( \"OK\", arg ))\n+\t\t\targ = next_arg(&cmd);\n+\t\t\tif (!strcmp(\"OK\", arg))\n \t\t\t\tresp = DRV_OK;\n \t\t\telse {\n-\t\t\t\tif (!strcmp( \"NO\", arg )) {\n-\t\t\t\t\tif (cmdp->cb.create && cmd && (cmdp->cb.trycreate || !memcmp( cmd, \"[TRYCREATE]\", 11 ))) { /* SELECT, APPEND or UID COPY */\n-\t\t\t\t\t\tp = strchr( cmdp->cmd, '\"' );\n-\t\t\t\t\t\tif (!issue_imap_cmd( ctx, NULL, \"CREATE \\\"%.*s\\\"\", strchr( p + 1, '\"' ) - p + 1, p )) {\n+\t\t\t\tif (!strcmp(\"NO\", arg)) {\n+\t\t\t\t\tif (cmdp->cb.create && cmd && (cmdp->cb.trycreate || !memcmp(cmd, \"[TRYCREATE]\", 11))) { /* SELECT, APPEND or UID COPY */\n+\t\t\t\t\t\tp = strchr(cmdp->cmd, '\"');\n+\t\t\t\t\t\tif (!issue_imap_cmd(ctx, NULL, \"CREATE \\\"%.*s\\\"\", strchr(p + 1, '\"') - p + 1, p)) {\n \t\t\t\t\t\t\tresp = RESP_BAD;\n \t\t\t\t\t\t\tgoto normal;\n \t\t\t\t\t\t}\n \t\t\t\t\t\t/* not waiting here violates the spec, but a server that does not\n \t\t\t\t\t\t   grok this nonetheless violates it too. */\n \t\t\t\t\t\tcmdp->cb.create = 0;\n-\t\t\t\t\t\tif (!(ncmdp = issue_imap_cmd( ctx, &cmdp->cb, \"%s\", cmdp->cmd ))) {\n+\t\t\t\t\t\tif (!(ncmdp = issue_imap_cmd(ctx, &cmdp->cb, \"%s\", cmdp->cmd))) {\n \t\t\t\t\t\t\tresp = RESP_BAD;\n \t\t\t\t\t\t\tgoto normal;\n \t\t\t\t\t\t}\n-\t\t\t\t\t\tfree( cmdp->cmd );\n-\t\t\t\t\t\tfree( cmdp );\n+\t\t\t\t\t\tfree(cmdp->cmd);\n+\t\t\t\t\t\tfree(cmdp);\n \t\t\t\t\t\tif (!tcmd)\n \t\t\t\t\t\t\treturn 0;\t/* ignored */\n \t\t\t\t\t\tif (cmdp == tcmd)\n@@ -956,21 +938,21 @@ get_cmd_result( imap_store_t *ctx, struct imap_cmd *tcmd )\n \t\t\t\t\t\tcontinue;\n \t\t\t\t\t}\n \t\t\t\t\tresp = RESP_NO;\n-\t\t\t\t} else /*if (!strcmp( \"BAD\", arg ))*/\n+\t\t\t\t} else /*if (!strcmp(\"BAD\", arg))*/\n \t\t\t\t\tresp = RESP_BAD;\n-\t\t\t\tfprintf( stderr, \"IMAP command '%s' returned response (%s) - %s\\n\",\n-\t\t\t\t\t memcmp (cmdp->cmd, \"LOGIN\", 5) ?\n+\t\t\t\tfprintf(stderr, \"IMAP command '%s' returned response (%s) - %s\\n\",\n+\t\t\t\t\t memcmp(cmdp->cmd, \"LOGIN\", 5) ?\n \t\t\t\t\t\t\tcmdp->cmd : \"LOGIN <user> <pass>\",\n \t\t\t\t\t\t\targ, cmd ? cmd : \"\");\n \t\t\t}\n-\t\t\tif ((resp2 = parse_response_code( ctx, &cmdp->cb, cmd )) > resp)\n+\t\t\tif ((resp2 = parse_response_code(ctx, &cmdp->cb, cmd)) > resp)\n \t\t\t\tresp = resp2;\n \t\t  normal:\n \t\t\tif (cmdp->cb.done)\n-\t\t\t\tcmdp->cb.done( ctx, cmdp, resp );\n-\t\t\tfree( cmdp->cb.data );\n-\t\t\tfree( cmdp->cmd );\n-\t\t\tfree( cmdp );\n+\t\t\t\tcmdp->cb.done(ctx, cmdp, resp);\n+\t\t\tfree(cmdp->cb.data);\n+\t\t\tfree(cmdp->cmd);\n+\t\t\tfree(cmdp);\n \t\t\tif (!tcmd || tcmd == cmdp)\n \t\t\t\treturn resp;\n \t\t}\n@@ -978,31 +960,28 @@ get_cmd_result( imap_store_t *ctx, struct imap_cmd *tcmd )\n \t/* not reached */\n }\n \n-static void\n-imap_close_server( imap_store_t *ictx )\n+static void imap_close_server(imap_store_t *ictx)\n {\n \timap_t *imap = ictx->imap;\n \n \tif (imap->buf.sock.fd != -1) {\n-\t\timap_exec( ictx, NULL, \"LOGOUT\" );\n-\t\tsocket_shutdown( &imap->buf.sock );\n+\t\timap_exec(ictx, NULL, \"LOGOUT\");\n+\t\tsocket_shutdown(&imap->buf.sock);\n \t}\n-\tfree_list( imap->ns_personal );\n-\tfree_list( imap->ns_other );\n-\tfree_list( imap->ns_shared );\n-\tfree( imap );\n+\tfree_list(imap->ns_personal);\n+\tfree_list(imap->ns_other);\n+\tfree_list(imap->ns_shared);\n+\tfree(imap);\n }\n \n-static void\n-imap_close_store( store_t *ctx )\n+static void imap_close_store(store_t *ctx)\n {\n-\timap_close_server( (imap_store_t *)ctx );\n-\tfree_generic_messages( ctx->msgs );\n-\tfree( ctx );\n+\timap_close_server((imap_store_t *)ctx);\n+\tfree_generic_messages(ctx->msgs);\n+\tfree(ctx);\n }\n \n-static store_t *\n-imap_open_store( imap_server_conf_t *srvc )\n+static store_t *imap_open_store(imap_server_conf_t *srvc)\n {\n \timap_store_t *ctx;\n \timap_t *imap;\n@@ -1012,9 +991,9 @@ imap_open_store( imap_server_conf_t *srvc )\n \tint s, a[2], preauth;\n \tpid_t pid;\n \n-\tctx = xcalloc( sizeof(*ctx), 1 );\n+\tctx = xcalloc(sizeof(*ctx), 1);\n \n-\tctx->imap = imap = xcalloc( sizeof(*imap), 1 );\n+\tctx->imap = imap = xcalloc(sizeof(*imap), 1);\n \timap->buf.sock.fd = -1;\n \timap->buf.sock.ssl = NULL;\n \timap->in_progress_append = &imap->in_progress;\n@@ -1022,51 +1001,51 @@ imap_open_store( imap_server_conf_t *srvc )\n \t/* open connection to IMAP server */\n \n \tif (srvc->tunnel) {\n-\t\timap_info( \"Starting tunnel '%s'... \", srvc->tunnel );\n+\t\timap_info(\"Starting tunnel '%s'... \", srvc->tunnel);\n \n-\t\tif (socketpair( PF_UNIX, SOCK_STREAM, 0, a )) {\n-\t\t\tperror( \"socketpair\" );\n-\t\t\texit( 1 );\n+\t\tif (socketpair(PF_UNIX, SOCK_STREAM, 0, a)) {\n+\t\t\tperror(\"socketpair\");\n+\t\t\texit(1);\n \t\t}\n \n \t\tpid = fork();\n \t\tif (pid < 0)\n-\t\t\t_exit( 127 );\n+\t\t\t_exit(127);\n \t\tif (!pid) {\n-\t\t\tif (dup2( a[0], 0 ) == -1 || dup2( a[0], 1 ) == -1)\n-\t\t\t\t_exit( 127 );\n-\t\t\tclose( a[0] );\n-\t\t\tclose( a[1] );\n-\t\t\texecl( \"/bin/sh\", \"sh\", \"-c\", srvc->tunnel, NULL );\n-\t\t\t_exit( 127 );\n+\t\t\tif (dup2(a[0], 0) == -1 || dup2(a[0], 1) == -1)\n+\t\t\t\t_exit(127);\n+\t\t\tclose(a[0]);\n+\t\t\tclose(a[1]);\n+\t\t\texecl(\"/bin/sh\", \"sh\", \"-c\", srvc->tunnel, NULL);\n+\t\t\t_exit(127);\n \t\t}\n \n-\t\tclose (a[0]);\n+\t\tclose(a[0]);\n \n \t\timap->buf.sock.fd = a[1];\n \n-\t\timap_info( \"ok\\n\" );\n+\t\timap_info(\"ok\\n\");\n \t} else {\n-\t\tmemset( &addr, 0, sizeof(addr) );\n-\t\taddr.sin_port = htons( srvc->port );\n+\t\tmemset(&addr, 0, sizeof(addr));\n+\t\taddr.sin_port = htons(srvc->port);\n \t\taddr.sin_family = AF_INET;\n \n-\t\timap_info( \"Resolving %s... \", srvc->host );\n-\t\the = gethostbyname( srvc->host );\n+\t\timap_info(\"Resolving %s... \", srvc->host);\n+\t\the = gethostbyname(srvc->host);\n \t\tif (!he) {\n-\t\t\tperror( \"gethostbyname\" );\n+\t\t\tperror(\"gethostbyname\");\n \t\t\tgoto bail;\n \t\t}\n-\t\timap_info( \"ok\\n\" );\n+\t\timap_info(\"ok\\n\");\n \n \t\taddr.sin_addr.s_addr = *((int *) he->h_addr_list[0]);\n \n-\t\ts = socket( PF_INET, SOCK_STREAM, 0 );\n+\t\ts = socket(PF_INET, SOCK_STREAM, 0);\n \n-\t\timap_info( \"Connecting to %s:%hu... \", inet_ntoa( addr.sin_addr ), ntohs( addr.sin_port ) );\n-\t\tif (connect( s, (struct sockaddr *)&addr, sizeof(addr) )) {\n-\t\t\tclose( s );\n-\t\t\tperror( \"connect\" );\n+\t\timap_info(\"Connecting to %s:%hu... \", inet_ntoa(addr.sin_addr), ntohs(addr.sin_port));\n+\t\tif (connect(s, (struct sockaddr *)&addr, sizeof(addr))) {\n+\t\t\tclose(s);\n+\t\t\tperror(\"connect\");\n \t\t\tgoto bail;\n \t\t}\n \t\t\n@@ -1077,28 +1056,28 @@ imap_open_store( imap_server_conf_t *srvc )\n \t\t\tclose(s);\n \t\t\tgoto bail;\n \t\t}\n-\t\timap_info( \"ok\\n\" );\n+\t\timap_info(\"ok\\n\");\n \t}\n \n \t/* read the greeting string */\n-\tif (buffer_gets( &imap->buf, &rsp )) {\n-\t\tfprintf( stderr, \"IMAP error: no greeting response\\n\" );\n+\tif (buffer_gets(&imap->buf, &rsp)) {\n+\t\tfprintf(stderr, \"IMAP error: no greeting response\\n\");\n \t\tgoto bail;\n \t}\n-\targ = next_arg( &rsp );\n-\tif (!arg || *arg != '*' || (arg = next_arg( &rsp )) == NULL) {\n-\t\tfprintf( stderr, \"IMAP error: invalid greeting response\\n\" );\n+\targ = next_arg(&rsp);\n+\tif (!arg || *arg != '*' || (arg = next_arg(&rsp)) == NULL) {\n+\t\tfprintf(stderr, \"IMAP error: invalid greeting response\\n\");\n \t\tgoto bail;\n \t}\n \tpreauth = 0;\n-\tif (!strcmp( \"PREAUTH\", arg ))\n+\tif (!strcmp(\"PREAUTH\", arg))\n \t\tpreauth = 1;\n-\telse if (strcmp( \"OK\", arg ) != 0) {\n-\t\tfprintf( stderr, \"IMAP error: unknown greeting response\\n\" );\n+\telse if (strcmp(\"OK\", arg) != 0) {\n+\t\tfprintf(stderr, \"IMAP error: unknown greeting response\\n\");\n \t\tgoto bail;\n \t}\n-\tparse_response_code( ctx, NULL, rsp );\n-\tif (!imap->caps && imap_exec( ctx, NULL, \"CAPABILITY\" ) != RESP_OK)\n+\tparse_response_code(ctx, NULL, rsp);\n+\tif (!imap->caps && imap_exec(ctx, NULL, \"CAPABILITY\") != RESP_OK)\n \t\tgoto bail;\n \n \tif (!preauth) {\n@@ -1114,38 +1093,38 @@ imap_open_store( imap_server_conf_t *srvc )\n \t\t\t\tgoto bail;\n \t\t}\n #endif\n-\t\timap_info (\"Logging in...\\n\");\n+\t\timap_info(\"Logging in...\\n\");\n \t\tif (!srvc->user) {\n-\t\t\tfprintf( stderr, \"Skipping server %s, no user\\n\", srvc->host );\n+\t\t\tfprintf(stderr, \"Skipping server %s, no user\\n\", srvc->host);\n \t\t\tgoto bail;\n \t\t}\n \t\tif (!srvc->pass) {\n \t\t\tchar prompt[80];\n-\t\t\tsprintf( prompt, \"Password (%s@%s): \", srvc->user, srvc->host );\n-\t\t\targ = getpass( prompt );\n+\t\t\tsprintf(prompt, \"Password (%s@%s): \", srvc->user, srvc->host);\n+\t\t\targ = getpass(prompt);\n \t\t\tif (!arg) {\n-\t\t\t\tperror( \"getpass\" );\n-\t\t\t\texit( 1 );\n+\t\t\t\tperror(\"getpass\");\n+\t\t\t\texit(1);\n \t\t\t}\n \t\t\tif (!*arg) {\n-\t\t\t\tfprintf( stderr, \"Skipping account %s@%s, no password\\n\", srvc->user, srvc->host );\n+\t\t\t\tfprintf(stderr, \"Skipping account %s@%s, no password\\n\", srvc->user, srvc->host);\n \t\t\t\tgoto bail;\n \t\t\t}\n \t\t\t/*\n \t\t\t * getpass() returns a pointer to a static buffer.  make a copy\n \t\t\t * for long term storage.\n \t\t\t */\n-\t\t\tsrvc->pass = xstrdup( arg );\n+\t\t\tsrvc->pass = xstrdup(arg);\n \t\t}\n \t\tif (CAP(NOLOGIN)) {\n-\t\t\tfprintf( stderr, \"Skipping account %s@%s, server forbids LOGIN\\n\", srvc->user, srvc->host );\n+\t\t\tfprintf(stderr, \"Skipping account %s@%s, server forbids LOGIN\\n\", srvc->user, srvc->host);\n \t\t\tgoto bail;\n \t\t}\n \t\tif (!imap->buf.sock.ssl)\n \t\t\timap_warn( \"*** IMAP Warning *** Password is being \"\n \t\t\t\t   \"sent in the clear\\n\" );\n-\t\tif (imap_exec( ctx, NULL, \"LOGIN \\\"%s\\\" \\\"%s\\\"\", srvc->user, srvc->pass ) != RESP_OK) {\n-\t\t\tfprintf( stderr, \"IMAP error: LOGIN failed\\n\" );\n+\t\tif (imap_exec(ctx, NULL, \"LOGIN \\\"%s\\\" \\\"%s\\\"\", srvc->user, srvc->pass) != RESP_OK) {\n+\t\t\tfprintf(stderr, \"IMAP error: LOGIN failed\\n\");\n \t\t\tgoto bail;\n \t\t}\n \t} /* !preauth */\n@@ -1155,12 +1134,11 @@ imap_open_store( imap_server_conf_t *srvc )\n \treturn (store_t *)ctx;\n \n   bail:\n-\timap_close_store( &ctx->gen );\n+\timap_close_store(&ctx->gen);\n \treturn NULL;\n }\n \n-static int\n-imap_make_flags( int flags, char *buf )\n+static int imap_make_flags(int flags, char *buf)\n {\n \tconst char *s;\n \tunsigned i, d;\n@@ -1179,8 +1157,7 @@ imap_make_flags( int flags, char *buf )\n \n #define TUIDL 8\n \n-static int\n-imap_store_msg( store_t *gctx, msg_data_t *data, int *uid )\n+static int imap_store_msg(store_t *gctx, msg_data_t *data, int *uid)\n {\n \timap_store_t *ctx = (imap_store_t *)gctx;\n \timap_t *imap = ctx->imap;\n@@ -1191,7 +1168,7 @@ imap_store_msg( store_t *gctx, msg_data_t *data, int *uid )\n \tint start, sbreak = 0, ebreak = 0;\n \tchar flagstr[128], tuid[TUIDL * 2 + 1];\n \n-\tmemset( &cb, 0, sizeof(cb) );\n+\tmemset(&cb, 0, sizeof(cb));\n \n \tfmap = data->data;\n \tlen = data->len;\n@@ -1207,18 +1184,18 @@ imap_store_msg( store_t *gctx, msg_data_t *data, int *uid )\n \t\t\t\t\tsbreak = ebreak = i - 2 + nocr;\n \t\t\t\t\tgoto mktid;\n \t\t\t\t}\n-\t\t\t\tif (!memcmp( fmap + start, \"X-TUID: \", 8 )) {\n+\t\t\t\tif (!memcmp(fmap + start, \"X-TUID: \", 8)) {\n \t\t\t\t\textra -= (ebreak = i) - (sbreak = start) + nocr;\n \t\t\t\t\tgoto mktid;\n \t\t\t\t}\n \t\t\t\tgoto nloop;\n \t\t\t}\n \t\t/* invalid message */\n-\t\tfree( fmap );\n+\t\tfree(fmap);\n \t\treturn DRV_MSG_BAD;\n \t mktid:\n \t\tfor (j = 0; j < TUIDL; j++)\n-\t\t\tsprintf( tuid + j * 2, \"%02x\", arc4_getbyte() );\n+\t\t\tsprintf(tuid + j * 2, \"%02x\", arc4_getbyte());\n \t\textra += 8 + TUIDL * 2 + 2;\n \t}\n \tif (nocr)\n@@ -1227,7 +1204,7 @@ imap_store_msg( store_t *gctx, msg_data_t *data, int *uid )\n \t\t\t\textra++;\n \n \tcb.dlen = len + extra;\n-\tbuf = cb.data = xmalloc( cb.dlen );\n+\tbuf = cb.data = xmalloc(cb.dlen);\n \ti = 0;\n \tif (!CAP(UIDPLUS) && uid) {\n \t\tif (nocr) {\n@@ -1238,12 +1215,12 @@ imap_store_msg( store_t *gctx, msg_data_t *data, int *uid )\n \t\t\t\t} else\n \t\t\t\t\t*buf++ = fmap[i];\n \t\t} else {\n-\t\t\tmemcpy( buf, fmap, sbreak );\n+\t\t\tmemcpy(buf, fmap, sbreak);\n \t\t\tbuf += sbreak;\n \t\t}\n-\t\tmemcpy( buf, \"X-TUID: \", 8 );\n+\t\tmemcpy(buf, \"X-TUID: \", 8);\n \t\tbuf += 8;\n-\t\tmemcpy( buf, tuid, TUIDL * 2 );\n+\t\tmemcpy(buf, tuid, TUIDL * 2);\n \t\tbuf += TUIDL * 2;\n \t\t*buf++ = '\\r';\n \t\t*buf++ = '\\n';\n@@ -1257,13 +1234,13 @@ imap_store_msg( store_t *gctx, msg_data_t *data, int *uid )\n \t\t\t} else\n \t\t\t\t*buf++ = fmap[i];\n \t} else\n-\t\tmemcpy( buf, fmap + i, len - i );\n+\t\tmemcpy(buf, fmap + i, len - i);\n \n-\tfree( fmap );\n+\tfree(fmap);\n \n \td = 0;\n \tif (data->flags) {\n-\t\td = imap_make_flags( data->flags, flagstr );\n+\t\td = imap_make_flags(data->flags, flagstr);\n \t\tflagstr[d++] = ' ';\n \t}\n \tflagstr[d] = 0;\n@@ -1276,11 +1253,11 @@ imap_store_msg( store_t *gctx, msg_data_t *data, int *uid )\n \t\t\timap->caps = imap->rcaps & ~(1 << LITERALPLUS);\n \t} else {\n \t\tbox = gctx->name;\n-\t\tprefix = !strcmp( box, \"INBOX\" ) ? \"\" : ctx->prefix;\n+\t\tprefix = !strcmp(box, \"INBOX\") ? \"\" : ctx->prefix;\n \t\tcb.create = 0;\n \t}\n \tcb.ctx = uid;\n-\tret = imap_exec_m( ctx, &cb, \"APPEND \\\"%s%s\\\" %s\", prefix, box, flagstr );\n+\tret = imap_exec_m(ctx, &cb, \"APPEND \\\"%s%s\\\" %s\", prefix, box, flagstr);\n \timap->caps = imap->rcaps;\n \tif (ret != DRV_OK)\n \t\treturn ret;\n@@ -1294,8 +1271,7 @@ imap_store_msg( store_t *gctx, msg_data_t *data, int *uid )\n \n #define CHUNKSIZE 0x1000\n \n-static int\n-read_message( FILE *f, msg_data_t *msg )\n+static int read_message(FILE *f, msg_data_t *msg)\n {\n \tstruct strbuf buf;\n \n@@ -1312,8 +1288,7 @@ read_message( FILE *f, msg_data_t *msg )\n \treturn msg->len;\n }\n \n-static int\n-count_messages( msg_data_t *msg )\n+static int count_messages(msg_data_t *msg)\n {\n \tint count = 0;\n \tchar *p = msg->data;\n@@ -1323,7 +1298,7 @@ count_messages( msg_data_t *msg )\n \t\t\tcount++;\n \t\t\tp += 5;\n \t\t}\n-\t\tp = strstr( p+5, \"\\nFrom \");\n+\t\tp = strstr(p+5, \"\\nFrom \");\n \t\tif (!p)\n \t\t\tbreak;\n \t\tp++;\n@@ -1331,22 +1306,21 @@ count_messages( msg_data_t *msg )\n \treturn count;\n }\n \n-static int\n-split_msg( msg_data_t *all_msgs, msg_data_t *msg, int *ofs )\n+static int split_msg(msg_data_t *all_msgs, msg_data_t *msg, int *ofs)\n {\n \tchar *p, *data;\n \n-\tmemset( msg, 0, sizeof *msg );\n+\tmemset(msg, 0, sizeof *msg);\n \tif (*ofs >= all_msgs->len)\n \t\treturn 0;\n \n-\tdata = &all_msgs->data[ *ofs ];\n+\tdata = &all_msgs->data[*ofs];\n \tmsg->len = all_msgs->len - *ofs;\n \n \tif (msg->len < 5 || prefixcmp(data, \"From \"))\n \t\treturn 0;\n \n-\tp = strchr( data, '\\n' );\n+\tp = strchr(data, '\\n');\n \tif (p) {\n \t\tp = &p[1];\n \t\tmsg->len -= p-data;\n@@ -1354,7 +1328,7 @@ split_msg( msg_data_t *all_msgs, msg_data_t *msg, int *ofs )\n \t\tdata = p;\n \t}\n \n-\tp = strstr( data, \"\\nFrom \" );\n+\tp = strstr(data, \"\\nFrom \");\n \tif (p)\n \t\tmsg->len = &p[1] - data;\n \n@@ -1363,8 +1337,7 @@ split_msg( msg_data_t *all_msgs, msg_data_t *msg, int *ofs )\n \treturn 1;\n }\n \n-static imap_server_conf_t server =\n-{\n+static imap_server_conf_t server = {\n \tNULL,\t/* name */\n \tNULL,\t/* tunnel */\n \tNULL,\t/* host */\n@@ -1377,12 +1350,11 @@ static imap_server_conf_t server =\n \n static char *imap_folder;\n \n-static int\n-git_imap_config(const char *key, const char *val, void *cb)\n+static int git_imap_config(const char *key, const char *val, void *cb)\n {\n \tchar imap_key[] = \"imap.\";\n \n-\tif (strncmp( key, imap_key, sizeof imap_key - 1 ))\n+\tif (strncmp(key, imap_key, sizeof imap_key - 1))\n \t\treturn 0;\n \n \tif (!val)\n@@ -1390,9 +1362,9 @@ git_imap_config(const char *key, const char *val, void *cb)\n \n \tkey += sizeof imap_key - 1;\n \n-\tif (!strcmp( \"folder\", key )) {\n-\t\timap_folder = xstrdup( val );\n-\t} else if (!strcmp( \"host\", key )) {\n+\tif (!strcmp(\"folder\", key)) {\n+\t\timap_folder = xstrdup(val);\n+\t} else if (!strcmp(\"host\", key)) {\n \t\tif (!prefixcmp(val, \"imap:\"))\n \t\t\tval += 5;\n \t\telse if (!prefixcmp(val, \"imaps:\")) {\n@@ -1401,23 +1373,22 @@ git_imap_config(const char *key, const char *val, void *cb)\n \t\t}\n \t\tif (!prefixcmp(val, \"//\"))\n \t\t\tval += 2;\n-\t\tserver.host = xstrdup( val );\n+\t\tserver.host = xstrdup(val);\n \t}\n-\telse if (!strcmp( \"user\", key ))\n-\t\tserver.user = xstrdup( val );\n-\telse if (!strcmp( \"pass\", key ))\n-\t\tserver.pass = xstrdup( val );\n-\telse if (!strcmp( \"port\", key ))\n-\t\tserver.port = git_config_int( key, val );\n-\telse if (!strcmp( \"tunnel\", key ))\n-\t\tserver.tunnel = xstrdup( val );\n-\telse if (!strcmp( \"ssl_verify\", key ))\n-\t\tserver.ssl_verify = git_config_bool( key, val );\n+\telse if (!strcmp(\"user\", key))\n+\t\tserver.user = xstrdup(val);\n+\telse if (!strcmp(\"pass\", key))\n+\t\tserver.pass = xstrdup(val);\n+\telse if (!strcmp(\"port\", key))\n+\t\tserver.port = git_config_int(key, val);\n+\telse if (!strcmp(\"tunnel\", key))\n+\t\tserver.tunnel = xstrdup(val);\n+\telse if (!strcmp(\"sslverify\", key))\n+\t\tserver.ssl_verify = git_config_bool(key, val);\n \treturn 0;\n }\n \n-int\n-main(int argc, char **argv)\n+int main(int argc, char **argv)\n {\n \tmsg_data_t all_msgs, msg;\n \tstore_t *ctx = NULL;\n@@ -1429,57 +1400,57 @@ main(int argc, char **argv)\n \t/* init the random number generator */\n \tarc4_init();\n \n-\tsetup_git_directory_gently( NULL );\n+\tsetup_git_directory_gently(NULL);\n \tgit_config(git_imap_config, NULL);\n \n \tif (!server.port)\n \t\tserver.port = server.use_ssl ? 993 : 143;\n \n \tif (!imap_folder) {\n-\t\tfprintf( stderr, \"no imap store specified\\n\" );\n+\t\tfprintf(stderr, \"no imap store specified\\n\");\n \t\treturn 1;\n \t}\n \tif (!server.host) {\n \t\tif (!server.tunnel) {\n-\t\t\tfprintf( stderr, \"no imap host specified\\n\" );\n+\t\t\tfprintf(stderr, \"no imap host specified\\n\");\n \t\t\treturn 1;\n \t\t}\n \t\tserver.host = \"tunnel\";\n \t}\n \n \t/* read the messages */\n-\tif (!read_message( stdin, &all_msgs )) {\n+\tif (!read_message(stdin, &all_msgs)) {\n \t\tfprintf(stderr,\"nothing to send\\n\");\n \t\treturn 1;\n \t}\n \n-\ttotal = count_messages( &all_msgs );\n+\ttotal = count_messages(&all_msgs);\n \tif (!total) {\n \t\tfprintf(stderr,\"no messages to send\\n\");\n \t\treturn 1;\n \t}\n \n \t/* write it to the imap server */\n-\tctx = imap_open_store( &server );\n+\tctx = imap_open_store(&server);\n \tif (!ctx) {\n-\t\tfprintf( stderr,\"failed to open store\\n\");\n+\t\tfprintf(stderr,\"failed to open store\\n\");\n \t\treturn 1;\n \t}\n \n-\tfprintf( stderr, \"sending %d message%s\\n\", total, (total!=1)?\"s\":\"\" );\n+\tfprintf(stderr, \"sending %d message%s\\n\", total, (total!=1)?\"s\":\"\");\n \tctx->name = imap_folder;\n \twhile (1) {\n \t\tunsigned percent = n * 100 / total;\n-\t\tfprintf( stderr, \"%4u%% (%d/%d) done\\r\", percent, n, total );\n-\t\tif (!split_msg( &all_msgs, &msg, &ofs ))\n+\t\tfprintf(stderr, \"%4u%% (%d/%d) done\\r\", percent, n, total);\n+\t\tif (!split_msg(&all_msgs, &msg, &ofs))\n \t\t\tbreak;\n-\t\tr = imap_store_msg( ctx, &msg, &uid );\n+\t\tr = imap_store_msg(ctx, &msg, &uid);\n \t\tif (r != DRV_OK) break;\n \t\tn++;\n \t}\n-\tfprintf( stderr,\"\\n\" );\n+\tfprintf(stderr, \"\\n\");\n \n-\timap_close_store( ctx );\n+\timap_close_store(ctx);\n \n \treturn 0;\n }\n-- \n1.5.6.GIT\n"}]}