wmbiff: stop hiding pointers behind typedefs.

Signed-off-by: Jeremy Sowden <jeremy@azazel.net>
This commit is contained in:
Jeremy Sowden 2019-07-02 20:53:41 +01:00 committed by Carlos R. Mafra
parent dc66a3de45
commit b055b12fa5
14 changed files with 112 additions and 104 deletions

View file

@ -11,6 +11,7 @@
#ifndef CLIENT #ifndef CLIENT
#define CLIENT #define CLIENT
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include <config.h> #include <config.h>
#endif #endif
@ -34,8 +35,8 @@ typedef unsigned int off_t;
#define BUF_SIZE 1024 #define BUF_SIZE 1024
struct msglst; struct msglst;
typedef struct _mbox_t *Pop3;
typedef struct _mbox_t { typedef struct Pop3_ {
char label[BUF_SMALL]; /* Printed at left; max 5 chars */ char label[BUF_SMALL]; /* Printed at left; max 5 chars */
char path[BUF_BIG]; /* Path to mailbox */ char path[BUF_BIG]; /* Path to mailbox */
char notify[BUF_BIG]; /* Program to notify mail arrivation */ char notify[BUF_BIG]; /* Program to notify mail arrivation */
@ -92,12 +93,12 @@ typedef struct _mbox_t {
} pop_imap; } pop_imap;
} u; } u;
int (*checkMail) ( /*@notnull@ */ Pop3); int (*checkMail) ( /*@notnull@ */ struct Pop3_ *);
/* collect the headers to show in a pop up */ /* collect the headers to show in a pop up */
struct msglst *(*getHeaders) ( /*@notnull@ */ Pop3); struct msglst *(*getHeaders) ( /*@notnull@ */ struct Pop3_ *);
/* allow the client to free the headers, or keep them cached */ /* allow the client to free the headers, or keep them cached */
void (*releaseHeaders) ( /*@notnull@ */ Pop3, struct msglst * ml); void (*releaseHeaders) ( /*@notnull@ */ struct Pop3_ *, struct msglst * ml);
time_t prevtime; time_t prevtime;
time_t prevfetch_time; time_t prevfetch_time;
@ -105,24 +106,24 @@ typedef struct _mbox_t {
/* command to execute to get a password, if needed */ /* command to execute to get a password, if needed */
const char *askpass; const char *askpass;
} mbox_t; } Pop3;
/* creation calls must have this prototype */ /* creation calls must have this prototype */
int pop3Create( /*@notnull@ */ Pop3 pc, const char *str); int pop3Create( /*@notnull@ */ Pop3 *pc, const char *str);
int imap4Create( /*@notnull@ */ Pop3 pc, const char *str); int imap4Create( /*@notnull@ */ Pop3 *pc, const char *str);
int shellCreate( /*@notnull@ */ Pop3 pc, const char *str); int shellCreate( /*@notnull@ */ Pop3 *pc, const char *str);
int mboxCreate( /*@notnull@ */ Pop3 pc, const char *str); int mboxCreate( /*@notnull@ */ Pop3 *pc, const char *str);
int maildirCreate( /*@notnull@ */ Pop3 pc, const char *str); int maildirCreate( /*@notnull@ */ Pop3 *pc, const char *str);
int sock_connect(const char *hostname, uint16_t port); int sock_connect(const char *hostname, uint16_t port);
FILE *openMailbox(Pop3 pc, const char *mbox_filename); FILE *openMailbox(Pop3 *pc, const char *mbox_filename);
/* backtickExpand returns null on failure */ /* backtickExpand returns null on failure */
/*@null@ */ /*@null@ */
char *backtickExpand(Pop3 pc, const char *path); char *backtickExpand(Pop3 *pc, const char *path);
int fileHasChanged(const char *mbox_filename, time_t * atime, int fileHasChanged(const char *mbox_filename, time_t * atime,
time_t * mtime, off_t * size); time_t * mtime, off_t * size);
int grabCommandOutput(Pop3 pc, const char *command, int grabCommandOutput(Pop3 *pc, const char *command,
/*@out@ */ char **output, /*@out@ */ char **output,
/*@out@ *//*@null@ */ char **details); /*@out@ *//*@null@ */ char **details);
int exists(const char *filename); /* test -f */ int exists(const char *filename); /* test -f */

View file

@ -55,16 +55,16 @@ static struct fdmap_struct {
/*@owned@ */ struct connection_state *cs; /*@owned@ */ struct connection_state *cs;
} fdmap[FDMAP_SIZE]; } fdmap[FDMAP_SIZE];
static void ask_user_for_password( /*@notnull@ */ Pop3 pc, static void ask_user_for_password( /*@notnull@ */ Pop3 *pc,
int bFlushCache); int bFlushCache);
/* authentication callbacks */ /* authentication callbacks */
#ifdef HAVE_GCRYPT_H #ifdef HAVE_GCRYPT_H
static int authenticate_md5( /*@notnull@ */ Pop3 pc, static int authenticate_md5( /*@notnull@ */ Pop3 *pc,
struct connection_state *scs, struct connection_state *scs,
const char *capabilities); const char *capabilities);
#endif #endif
static int authenticate_plaintext( /*@notnull@ */ Pop3 pc, static int authenticate_plaintext( /*@notnull@ */ Pop3 *pc,
struct connection_state *scs, struct connection_state *scs,
const char *capabilities); const char *capabilities);
@ -73,7 +73,7 @@ static int authenticate_plaintext( /*@notnull@ */ Pop3 pc,
static struct imap_authentication_method { static struct imap_authentication_method {
const char *name; const char *name;
/* callback returns 1 if successful, 0 if failed */ /* callback returns 1 if successful, 0 if failed */
int (*auth_callback) ( /*@notnull@ */ Pop3 pc, int (*auth_callback) ( /*@notnull@ */ Pop3 *pc,
struct connection_state * scs, struct connection_state * scs,
const char *capabilities); const char *capabilities);
} auth_methods[] = { } auth_methods[] = {
@ -89,7 +89,7 @@ static struct imap_authentication_method {
/* recover a socket from the connection cache */ /* recover a socket from the connection cache */
/*@null@*/ /*@null@*/
/*@dependent@*/ /*@dependent@*/
static struct connection_state *state_for_pcu(Pop3 pc) static struct connection_state *state_for_pcu(Pop3 *pc)
{ {
char *connection_id; char *connection_id;
struct connection_state *retval = NULL; struct connection_state *retval = NULL;
@ -108,7 +108,7 @@ static struct connection_state *state_for_pcu(Pop3 pc)
} }
/* bind to the connection cache */ /* bind to the connection cache */
static void bind_state_to_pcu(Pop3 pc, static void bind_state_to_pcu(Pop3 *pc,
/*@owned@ */ struct connection_state *scs) /*@owned@ */ struct connection_state *scs)
{ {
char *connection_id; char *connection_id;
@ -156,7 +156,7 @@ struct connection_state *unbind(
/* creates a connection to the server, if a matching one doesn't exist. */ /* creates a connection to the server, if a matching one doesn't exist. */
/* *always* returns null, just declared this wasy to match other protocols. */ /* *always* returns null, just declared this wasy to match other protocols. */
/*@null@*/ /*@null@*/
FILE *imap_open(Pop3 pc) FILE *imap_open(Pop3 *pc)
{ {
static int complained_already; /* we have to succeed once before static int complained_already; /* we have to succeed once before
complaining again about failure */ complaining again about failure */
@ -287,9 +287,9 @@ FILE *imap_open(Pop3 pc)
} }
void imap_cacheHeaders( /*@notnull@ */ Pop3 pc); void imap_cacheHeaders( /*@notnull@ */ Pop3 *pc);
int imap_checkmail( /*@notnull@ */ Pop3 pc) int imap_checkmail( /*@notnull@ */ Pop3 *pc)
{ {
/* recover connection state from the cache */ /* recover connection state from the cache */
struct connection_state *scs = state_for_pcu(pc); struct connection_state *scs = state_for_pcu(pc);
@ -358,7 +358,7 @@ int imap_checkmail( /*@notnull@ */ Pop3 pc)
} }
void void
imap_releaseHeaders(Pop3 pc __attribute__ ((unused)), struct msglst *h) imap_releaseHeaders(Pop3 *pc __attribute__((unused)), struct msglst *h)
{ {
assert(h != NULL); assert(h != NULL);
/* allow the list to be released next time around */ /* allow the list to be released next time around */
@ -374,7 +374,7 @@ imap_releaseHeaders(Pop3 pc __attribute__ ((unused)), struct msglst *h)
} }
} }
void imap_cacheHeaders( /*@notnull@ */ Pop3 pc) void imap_cacheHeaders( /*@notnull@ */ Pop3 *pc)
{ {
struct connection_state *scs = state_for_pcu(pc); struct connection_state *scs = state_for_pcu(pc);
char *msgid; char *msgid;
@ -479,7 +479,7 @@ void imap_cacheHeaders( /*@notnull@ */ Pop3 pc)
/* a client is asking for the headers, hand em a reference, increase the /* a client is asking for the headers, hand em a reference, increase the
one-bit reference counter */ one-bit reference counter */
struct msglst *imap_getHeaders( /*@notnull@ */ Pop3 pc) struct msglst *imap_getHeaders( /*@notnull@ */ Pop3 *pc)
{ {
if (pc->headerCache == NULL) if (pc->headerCache == NULL)
imap_cacheHeaders(pc); imap_cacheHeaders(pc);
@ -489,7 +489,7 @@ struct msglst *imap_getHeaders( /*@notnull@ */ Pop3 pc)
} }
/* parse the config line to setup the Pop3 structure */ /* parse the config line to setup the Pop3 structure */
int imap4Create( /*@notnull@ */ Pop3 pc, const char *const str) int imap4Create( /*@notnull@ */ Pop3 *pc, const char *const str)
{ {
int i; int i;
int matchedchars; int matchedchars;
@ -603,7 +603,7 @@ int imap4Create( /*@notnull@ */ Pop3 pc, const char *const str)
return 0; return 0;
} }
static int authenticate_plaintext( /*@notnull@ */ Pop3 pc, static int authenticate_plaintext( /*@notnull@ */ Pop3 *pc,
struct connection_state *scs, struct connection_state *scs,
const char *capabilities) const char *capabilities)
{ {
@ -652,7 +652,7 @@ static int authenticate_plaintext( /*@notnull@ */ Pop3 pc,
#ifdef HAVE_GCRYPT_H #ifdef HAVE_GCRYPT_H
static int static int
authenticate_md5(Pop3 pc, authenticate_md5(Pop3 *pc,
struct connection_state *scs, const char *capabilities) struct connection_state *scs, const char *capabilities)
{ {
char buf[BUF_SIZE]; char buf[BUF_SIZE];
@ -715,7 +715,7 @@ authenticate_md5(Pop3 pc,
} }
#endif #endif
static void ask_user_for_password( /*@notnull@ */ Pop3 pc, int bFlushCache) static void ask_user_for_password( /*@notnull@ */ Pop3 *pc, int bFlushCache)
{ {
/* see if we already have a password, as provided in the config file, or /* see if we already have a password, as provided in the config file, or
already requested from the user. */ already requested from the user. */

View file

@ -32,7 +32,7 @@ static int fontHeight;
extern const char *foreground; extern const char *foreground;
extern const char *background; extern const char *background;
Pop3 Active_pc; Pop3 *Active_pc;
static int loadFont(const char *fontname) static int loadFont(const char *fontname)
{ {
@ -63,7 +63,7 @@ static int flush_expose(Window w)
} }
struct msglst *Headers; struct msglst *Headers;
void msglst_show(Pop3 pc, int x, int y) void msglst_show(Pop3 *pc, int x, int y)
{ {
int maxfrm = 0; int maxfrm = 0;
int maxsubj = 0; int maxsubj = 0;

View file

@ -8,6 +8,6 @@ struct msglst {
unsigned int in_use:1; unsigned int in_use:1;
}; };
void msglst_show(Pop3 pc, int x, int y); void msglst_show(Pop3 *pc, int x, int y);
void msglst_hide(void); void msglst_hide(void);
void msglst_redraw(void); void msglst_redraw(void);

View file

@ -28,33 +28,37 @@
extern int Relax; extern int Relax;
/* temp */ /* temp */
static void ask_user_for_password( /*@notnull@ */ Pop3 pc, int bFlushCache); static void ask_user_for_password( /*@notnull@ */ Pop3 *pc, int bFlushCache);
#define PCU (pc->u).pop_imap #define PCU (pc->u).pop_imap
#define POP_DM(pc, lvl, args...) DM(pc, lvl, "pop3: " args) #define POP_DM(pc, lvl, args...) DM(pc, lvl, "pop3: " args)
#ifdef HAVE_GCRYPT_H #ifdef HAVE_GCRYPT_H
static struct connection_state *authenticate_md5( /*@notnull@ */ Pop3 pc, struct connection_state * scs, static struct connection_state *authenticate_md5( /*@notnull@ */ Pop3 *pc,
struct connection_state *scs,
char *unused); char *unused);
static struct connection_state *authenticate_apop( /*@notnull@ */ Pop3 pc, struct connection_state * scs, static struct connection_state *authenticate_apop( /*@notnull@ */ Pop3 *pc,
struct connection_state *scs,
char *apop_str); char *apop_str);
#endif #endif
static struct connection_state *authenticate_plaintext( /*@notnull@ */ Pop3 pc, struct connection_state * scs, static struct connection_state *authenticate_plaintext( /*@notnull@ */ Pop3 *pc,
struct connection_state *scs,
char *unused); char *unused);
void pop3_cacheHeaders( /*@notnull@ */ Pop3 pc); void pop3_cacheHeaders( /*@notnull@ */ Pop3 *pc);
extern void imap_releaseHeaders(Pop3 pc extern void imap_releaseHeaders(Pop3 *pc __attribute__((unused)),
__attribute__ ((unused)),
struct msglst *h); struct msglst *h);
extern struct connection_state *state_for_pcu(Pop3 pc); extern struct connection_state *state_for_pcu(Pop3 *pc);
static struct authentication_method { static struct authentication_method {
const char *name; const char *name;
/* callback returns the connection state pointer if successful, /* callback returns the connection state pointer if successful,
NULL if failed */ NULL if failed */
struct connection_state *(*auth_callback) (Pop3 pc, struct connection_state * scs, char *apop_str); struct connection_state *(*auth_callback) (Pop3 *pc,
struct connection_state *scs,
char *apop_str);
} auth_methods[] = { } auth_methods[] = {
{ {
#ifdef HAVE_GCRYPT_H #ifdef HAVE_GCRYPT_H
@ -66,7 +70,7 @@ static struct authentication_method {
}; };
/*@null@*/ /*@null@*/
struct connection_state *pop3Login(Pop3 pc) struct connection_state *pop3Login(Pop3 *pc)
{ {
int fd; int fd;
char buf[BUF_SIZE]; char buf[BUF_SIZE];
@ -134,7 +138,7 @@ struct connection_state *pop3Login(Pop3 pc)
return NULL; return NULL;
} }
int pop3CheckMail( /*@notnull@ */ Pop3 pc) int pop3CheckMail( /*@notnull@ */ Pop3 *pc)
{ {
struct connection_state *scs; struct connection_state *scs;
int read; int read;
@ -182,7 +186,7 @@ int pop3CheckMail( /*@notnull@ */ Pop3 pc)
} }
struct msglst *pop_getHeaders( /*@notnull@ */ Pop3 pc) struct msglst *pop_getHeaders( /*@notnull@ */ Pop3 *pc)
{ {
if (pc->headerCache == NULL) if (pc->headerCache == NULL)
pop3_cacheHeaders(pc); pop3_cacheHeaders(pc);
@ -193,7 +197,7 @@ struct msglst *pop_getHeaders( /*@notnull@ */ Pop3 pc)
int pop3Create(Pop3 pc, const char *str) int pop3Create(Pop3 *pc, const char *str)
{ {
/* POP3 format: pop3:user:password@server[:port] */ /* POP3 format: pop3:user:password@server[:port] */
/* new POP3 format: pop3:user password server [port] */ /* new POP3 format: pop3:user password server [port] */
@ -291,8 +295,9 @@ int pop3Create(Pop3 pc, const char *str)
#ifdef HAVE_GCRYPT_H #ifdef HAVE_GCRYPT_H
static struct connection_state *authenticate_md5(Pop3 pc, struct connection_state * scs, char *apop_str static struct connection_state *authenticate_md5(Pop3 *pc,
__attribute__ ((unused))) struct connection_state *scs,
char *apop_str __attribute__((unused)))
{ {
char buf[BUF_SIZE]; char buf[BUF_SIZE];
char buf2[BUF_SIZE]; char buf2[BUF_SIZE];
@ -349,7 +354,9 @@ static struct connection_state *authenticate_md5(Pop3 pc, struct connection_stat
} }
} }
static struct connection_state *authenticate_apop(Pop3 pc, struct connection_state * scs, char *apop_str) static struct connection_state *authenticate_apop(Pop3 *pc,
struct connection_state *scs,
char *apop_str)
{ {
gcry_md_hd_t gmh; gcry_md_hd_t gmh;
gcry_error_t rc; gcry_error_t rc;
@ -392,9 +399,9 @@ static struct connection_state *authenticate_apop(Pop3 pc, struct connection_sta
#endif /* HAVE_GCRYPT_H */ #endif /* HAVE_GCRYPT_H */
/*@null@*/ /*@null@*/
static struct connection_state *authenticate_plaintext( /*@notnull@ */ Pop3 pc, static struct connection_state *authenticate_plaintext( /*@notnull@ */ Pop3 *pc,
struct connection_state * scs, char *apop_str struct connection_state *scs,
__attribute__ ((unused))) char *apop_str __attribute__((unused)))
{ {
char buf[BUF_SIZE]; char buf[BUF_SIZE];
@ -448,7 +455,7 @@ static struct connection_state *authenticate_plaintext( /*@notnull@ */ Pop3 pc,
return scs; return scs;
} }
void pop3_cacheHeaders( /*@notnull@ */ Pop3 pc) void pop3_cacheHeaders( /*@notnull@ */ Pop3 *pc)
{ {
char buf[BUF_SIZE]; char buf[BUF_SIZE];
struct connection_state *scs; struct connection_state *scs;
@ -502,7 +509,7 @@ void pop3_cacheHeaders( /*@notnull@ */ Pop3 pc)
} }
/* vim:set ts=4: */ /* vim:set ts=4: */
static void ask_user_for_password( /*@notnull@ */ Pop3 pc, int bFlushCache) static void ask_user_for_password( /*@notnull@ */ Pop3 *pc, int bFlushCache)
{ {
/* see if we already have a password, as provided in the config file, or /* see if we already have a password, as provided in the config file, or
already requested from the user. */ already requested from the user. */

View file

@ -63,7 +63,7 @@ FILE *kind_popen(const char *command, const char *type)
/* returns as a mailcheck function does: -1 on fail, 0 on success */ /* returns as a mailcheck function does: -1 on fail, 0 on success */
static int kind_pclose( /*@only@ */ FILE * F, static int kind_pclose( /*@only@ */ FILE * F,
const char *command, const char *command,
/*@null@ */ Pop3 pc) /*@null@ */ Pop3 *pc)
{ {
int exit_status = pclose(F); int exit_status = pclose(F);
@ -87,7 +87,7 @@ static int kind_pclose( /*@only@ */ FILE * F,
return (exit_status); return (exit_status);
} }
int grabCommandOutput(Pop3 pc, const char *command, /*@out@ */ int grabCommandOutput(Pop3 *pc, const char *command, /*@out@ */
char **output, /*@out@ *//*@null@ */ char **details) char **output, /*@out@ *//*@null@ */ char **details)
{ {
FILE *F; FILE *F;
@ -121,7 +121,7 @@ int grabCommandOutput(Pop3 pc, const char *command, /*@out@ */
/* returns null on failure */ /* returns null on failure */
/*@null@*/ /*@null@*/
char *backtickExpand(Pop3 pc, const char *path) char *backtickExpand(Pop3 *pc, const char *path)
{ {
char bigbuffer[1024]; char bigbuffer[1024];
const char *tickstart; const char *tickstart;
@ -152,7 +152,7 @@ char *backtickExpand(Pop3 pc, const char *path)
return (strdup_ordie(bigbuffer)); return (strdup_ordie(bigbuffer));
} }
int shellCmdCheck(Pop3 pc) int shellCmdCheck(Pop3 *pc)
{ {
int count_status = 0; int count_status = 0;
char *commandOutput; char *commandOutput;
@ -220,7 +220,7 @@ int shellCmdCheck(Pop3 pc)
return (0); return (0);
} }
struct msglst *shell_getHeaders( /*@notnull@ */ Pop3 pc) struct msglst *shell_getHeaders( /*@notnull@ */ Pop3 *pc)
{ {
struct msglst *message_list = NULL; struct msglst *message_list = NULL;
@ -247,7 +247,7 @@ struct msglst *shell_getHeaders( /*@notnull@ */ Pop3 pc)
} }
void void
shell_releaseHeaders(Pop3 pc __attribute__ ((unused)), struct msglst *h) shell_releaseHeaders(Pop3 *pc __attribute__((unused)), struct msglst *h)
{ {
for (; h != NULL;) { for (; h != NULL;) {
struct msglst *n = h->next; struct msglst *n = h->next;
@ -256,7 +256,7 @@ shell_releaseHeaders(Pop3 pc __attribute__ ((unused)), struct msglst *h)
} }
} }
int shellCreate( /*@notnull@ */ Pop3 pc, const char *str) int shellCreate( /*@notnull@ */ Pop3 *pc, const char *str)
{ {
/* SHELL format: shell:::/path/to/script */ /* SHELL format: shell:::/path/to/script */
const char *reserved1, *reserved2, *commandline; const char *reserved1, *reserved2, *commandline;

View file

@ -50,7 +50,7 @@ static int count_msgs(char *path)
return count; return count;
} }
int maildirCheckHistory(Pop3 pc) int maildirCheckHistory(Pop3 *pc)
{ {
struct stat st_new; struct stat st_new;
struct stat st_cur; struct stat st_cur;
@ -137,7 +137,7 @@ int maildirCheckHistory(Pop3 pc)
return 0; return 0;
} }
int maildirCreate(Pop3 pc, const char *str) int maildirCreate(Pop3 *pc, const char *str)
{ {
int i; int i;
char c; char c;

View file

@ -26,7 +26,7 @@
#define FROM_STR "From " #define FROM_STR "From "
#define STATUS_STR "Status: " #define STATUS_STR "Status: "
FILE *openMailbox(Pop3 pc, const char *mbox_filename) FILE *openMailbox(Pop3 *pc, const char *mbox_filename)
{ {
FILE *mailbox; FILE *mailbox;
@ -40,7 +40,7 @@ FILE *openMailbox(Pop3 pc, const char *mbox_filename)
} }
/* count the messages in a mailbox */ /* count the messages in a mailbox */
static void countMessages(Pop3 pc, const char *mbox_filename) static void countMessages(Pop3 *pc, const char *mbox_filename)
{ {
FILE *F; FILE *F;
char buf[BUF_SIZE]; char buf[BUF_SIZE];
@ -126,7 +126,7 @@ fileHasChanged(const char *mbox_filename, time_t * atime,
return 0; return 0;
} }
int mboxCheckHistory(Pop3 pc) int mboxCheckHistory(Pop3 *pc)
{ {
char *mbox_filename = backtickExpand(pc, pc->path); char *mbox_filename = backtickExpand(pc, pc->path);
struct utimbuf ut; struct utimbuf ut;
@ -147,7 +147,7 @@ int mboxCheckHistory(Pop3 pc)
return 0; return 0;
} }
int mboxCreate(Pop3 pc, const char *str) int mboxCreate(Pop3 *pc, const char *str)
{ {
/* MBOX format: mbox:fullpathname */ /* MBOX format: mbox:fullpathname */

View file

@ -46,22 +46,22 @@
#define ENFROB(x) #define ENFROB(x)
#endif #endif
typedef struct password_binding_struct { typedef struct password_binding_ {
struct password_binding_struct *next; struct password_binding_ *next;
char user[BUF_SMALL]; char user[BUF_SMALL];
char server[BUF_BIG]; char server[BUF_BIG];
char password[BUF_SMALL]; /* may be frobnicated */ char password[BUF_SMALL]; /* may be frobnicated */
size_t password_len; /* frobnicated *'s are nulls */ size_t password_len; /* frobnicated *'s are nulls */
} *password_binding; } password_binding;
static password_binding pass_list = NULL; static password_binding *pass_list;
/* verifies that askpass_fname, if it has no spaces, exists as /* verifies that askpass_fname, if it has no spaces, exists as
a file, is owned by the user or by root, and is not world a file, is owned by the user or by root, and is not world
writeable. This is just a sanity check, and is not intended writeable. This is just a sanity check, and is not intended
to ensure the integrity of the password-asking program. */ to ensure the integrity of the password-asking program. */
/* would be static, but used in test_wmbiff */ /* would be static, but used in test_wmbiff */
int permissions_ok(Pop3 pc, const char *askpass_fname) int permissions_ok(Pop3 *pc, const char *askpass_fname)
{ {
struct stat st; struct stat st;
if (index(askpass_fname, ' ')) { if (index(askpass_fname, ' ')) {
@ -110,7 +110,7 @@ int permissions_ok(Pop3 pc, const char *askpass_fname)
#include<Security/Security.h> #include<Security/Security.h>
static void static void
get_password_from_keychain(Pop3 pc, const char *username, get_password_from_keychain(Pop3 *pc, const char *username,
const char *servername, const char *servername,
/*@out@ */ char *password, /*@out@ */ char *password,
/*@out@ */ size_t *password_len) /*@out@ */ size_t *password_len)
@ -154,7 +154,7 @@ get_password_from_keychain(Pop3 pc, const char *username,
static void static void
get_password_from_command(Pop3 pc, const char *username, get_password_from_command(Pop3 *pc, const char *username,
const char *servername, const char *servername,
/*@out@ */ char *password, /*@out@ */ char *password,
/*@out@ */ /*@out@ */
@ -208,19 +208,18 @@ get_password_from_command(Pop3 pc, const char *username,
} }
} }
char *passwordFor(const char *username, char *passwordFor(const char *username, const char *servername, Pop3 *pc,
const char *servername, Pop3 pc, int bFlushCache) int bFlushCache)
{ {
password_binding p; password_binding *p;
assert(username != NULL); assert(username != NULL);
assert(username[0] != '\0'); assert(username[0] != '\0');
/* find the binding */ /* find the binding */
for (p = pass_list; for (p = pass_list;
p != NULL p != NULL && (strcmp(username, p->user) != 0 ||
&& (strcmp(username, p->user) != 0 ||
strcmp(servername, p->server) != 0); p = p->next); strcmp(servername, p->server) != 0); p = p->next);
/* if so, return the password */ /* if so, return the password */
@ -241,8 +240,7 @@ char *passwordFor(const char *username,
return (NULL); return (NULL);
} }
} else { } else {
p = (password_binding) p = malloc(sizeof *p);
malloc(sizeof(struct password_binding_struct));
} }
/* else, try to get it. */ /* else, try to get it. */

View file

@ -1,8 +1,8 @@
#include "Client.h" #include "Client.h"
/*@mustfree@*/ char *passwordFor(const char *username, /*@mustfree@*/
const char *servername, Pop3 pc, char *passwordFor(const char *username, const char *servername, Pop3 *pc,
int bFlushCache); int bFlushCache);
/* tested by test_wmbiff; don't use this for anything. */ /* tested by test_wmbiff; don't use this for anything. */
int permissions_ok(Pop3 pc, const char *askpass_fname); int permissions_ok(Pop3 *pc, const char *askpass_fname);

View file

@ -75,7 +75,7 @@ printf("FAILED: expected '" #shouldbe "' but got '%s'\n", x); \
int test_passwordMgr(void) int test_passwordMgr(void)
{ {
const char *b; const char *b;
mbox_t m; Pop3 m;
strcpy(m.label, "x"); strcpy(m.label, "x");
/* sh is almost certainly conforming; owned by root, etc. */ /* sh is almost certainly conforming; owned by root, etc. */
@ -183,7 +183,7 @@ printf("Failed: expected '" #shouldbe "' but got '%d'\n", x); \
return 1; } return 1; }
int test_imap4creator(void) int test_imap4creator(void)
{ {
mbox_t m; Pop3 m;
if (imap4Create(&m, "imap:foo:@bar/mybox")) { if (imap4Create(&m, "imap:foo:@bar/mybox")) {
return 1; return 1;

View file

@ -65,7 +65,7 @@ struct connection_state {
/*@null@ */ void *xcred; /*@null@ */ void *xcred;
#endif #endif
char unprocessed[BUF_SIZE]; char unprocessed[BUF_SIZE];
Pop3 pc; /* mailbox handle for debugging messages */ Pop3 *pc; /* mailbox handle for debugging messages */
}; };
/* gotta do our own line buffering, sigh */ /* gotta do our own line buffering, sigh */
@ -200,7 +200,7 @@ getline_from_buffer(char *readbuffer, char *linebuffer, int linebuflen)
/* return the length of the line */ /* return the length of the line */
} }
if (i < 0 || i > linebuflen) { if (i < 0 || i > linebuflen) {
DM((Pop3) NULL, DEBUG_ERROR, "bork bork bork!: %d %d\n", i, DM((Pop3 *) NULL, DEBUG_ERROR, "bork bork bork!: %d %d\n", i,
linebuflen); linebuflen);
} }
return i; return i;
@ -541,7 +541,7 @@ tls_check_certificate(struct connection_state *scs,
return; return;
} }
struct connection_state *initialize_gnutls(intptr_t sd, char *name, Pop3 pc, struct connection_state *initialize_gnutls(intptr_t sd, char *name, Pop3 *pc,
const char *remote_hostname) const char *remote_hostname)
{ {
static int gnutls_initialized; static int gnutls_initialized;
@ -661,7 +661,7 @@ void handle_gnutls_read_error(int readbytes, struct connection_state *scs)
/* declare stubs when tls isn't compiled in */ /* declare stubs when tls isn't compiled in */
struct connection_state *initialize_gnutls(UNUSED(intptr_t sd), struct connection_state *initialize_gnutls(UNUSED(intptr_t sd),
UNUSED(char *name), UNUSED(char *name),
UNUSED(Pop3 pc), UNUSED(Pop3 *pc),
UNUSED(const char UNUSED(const char
*remote_hostname)) *remote_hostname))
{ {
@ -674,7 +674,7 @@ struct connection_state *initialize_gnutls(UNUSED(intptr_t sd),
/* either way: */ /* either way: */
struct connection_state *initialize_unencrypted(int sd, struct connection_state *initialize_unencrypted(int sd,
/*@only@ */ char *name, /*@only@ */ char *name,
Pop3 pc) Pop3 *pc)
{ {
struct connection_state *ret = malloc(sizeof(struct connection_state)); struct connection_state *ret = malloc(sizeof(struct connection_state));
assert(sd >= 0); assert(sd >= 0);

View file

@ -20,14 +20,16 @@ struct connection_state;
/* take a socket descriptor and negotiate a TLS connection /* take a socket descriptor and negotiate a TLS connection
over it */ over it */
/*@only@*/ /*@only@*/
struct connection_state *initialize_gnutls(intptr_t sd, /*@only@ */ char *name, struct connection_state *initialize_gnutls(intptr_t sd,
Pop3 pc, const char *hostname); /* @only@ */ char *name,
Pop3 *pc,
const char *hostname);
/* take a socket descriptor and bundle it into a connection /* take a socket descriptor and bundle it into a connection
state structure for later communication */ state structure for later communication */
/*@only@*/ /*@only@*/
struct connection_state *initialize_unencrypted(int sd, /*@only@ */ struct connection_state *initialize_unencrypted(int sd, /*@only@ */
char *name, Pop3 pc); char *name, Pop3 * pc);
/* store a binding when connect() times out. these should be /* store a binding when connect() times out. these should be
skipped when trying to check mail so that other mailboxes skipped when trying to check mail so that other mailboxes

View file

@ -55,7 +55,7 @@ static const int wmbiff_mask_width = 64;
#define DEFAULT_LOOP 5 #define DEFAULT_LOOP 5
#define MAX_NUM_MAILBOXES 40 #define MAX_NUM_MAILBOXES 40
static mbox_t mbox[MAX_NUM_MAILBOXES]; static Pop3 mbox[MAX_NUM_MAILBOXES];
/* this is the normal pixmap. */ /* this is the normal pixmap. */
static const char *skin_filename = "wmbiff-master-led.xpm"; static const char *skin_filename = "wmbiff-master-led.xpm";
@ -191,7 +191,7 @@ static int ReadLine(FILE * fp, /*@out@ */ char *setting,
struct path_demultiplexer { struct path_demultiplexer {
const char *id; /* followed by a colon */ const char *id; /* followed by a colon */
int (*creator) ( /*@notnull@ */ Pop3 pc, const char *path); int (*creator)( /*@notnull@ */ Pop3 *pc, const char *path);
}; };
static struct path_demultiplexer paths[] = { static struct path_demultiplexer paths[] = {