Commit 84ace43c 84ace43c70d369c34fd8b6e4eb0c242eef859b76 by Sergey Poznyakoff

Revised use of const modifiers

1 parent e509ce1f
......@@ -253,7 +253,7 @@ _gsasl_open (stream_t stream)
}
int
_gsasl_strerror (stream_t stream, char **pstr)
_gsasl_strerror (stream_t stream, const char **pstr)
{
struct _gsasl_stream *s = stream_get_owner (stream);
*pstr = gsasl_strerror (s->last_err);
......
......@@ -85,7 +85,7 @@ _auth_lb_grow (struct _line_buffer *s, const char *ptr, size_t size)
}
int
_auth_lb_read (struct _line_buffer *s, const char *optr, size_t osize)
_auth_lb_read (struct _line_buffer *s, char *optr, size_t osize)
{
int len;
......@@ -103,7 +103,7 @@ _auth_lb_read (struct _line_buffer *s, const char *optr, size_t osize)
}
int
_auth_lb_readline (struct _line_buffer *s, const char *ptr, size_t size)
_auth_lb_readline (struct _line_buffer *s, char *ptr, size_t size)
{
char *p = strchr (s->buffer, '\n');
......
......@@ -24,9 +24,8 @@ void _auth_lb_destroy __P((struct _line_buffer **s));
void _auth_lb_drop __P((struct _line_buffer *s));
int _auth_lb_grow __P((struct _line_buffer *s, const char *ptr, size_t size));
int _auth_lb_read __P((struct _line_buffer *s, const char *ptr, size_t size));
int _auth_lb_readline __P((struct _line_buffer *s, const char *ptr,
size_t size));
int _auth_lb_read __P((struct _line_buffer *s, char *ptr, size_t size));
int _auth_lb_readline __P((struct _line_buffer *s, char *ptr, size_t size));
int _auth_lb_writelines __P((struct _line_buffer *s, const char *iptr,
size_t isize, off_t offset,
int (*wr) __PMT ((void *data, char *start,
......
......@@ -29,7 +29,8 @@
int
mysql_auth_sql_by_name (struct mu_auth_data **return_data, void *key,
mysql_auth_sql_by_name (struct mu_auth_data **return_data,
const void *key,
void *func_data ARG_UNUSED,
void *call_data ARG_UNUSED)
{
......@@ -224,7 +225,7 @@ mysql_auth_sql_by_uid (struct mu_auth_data **return_data, void *key,
int
mysql_sql_authenticate (struct mu_auth_data **return_data ARG_UNUSED,
void *key,
const void *key,
void *func_data ARG_UNUSED, void *call_data)
{
struct mu_auth_data *auth_data = key;
......
......@@ -102,11 +102,11 @@ static struct pam_conv PAM_conversation = { &mu_pam_conv, NULL };
int
mu_authenticate_pam (struct mu_auth_data **return_data ARG_UNUSED,
void *key,
const void *key,
void *func_data ARG_UNUSED,
void *call_data)
{
struct mu_auth_data *auth_data = key;
const struct mu_auth_data *auth_data = key;
char *pass = call_data;
pam_handle_t *pamh;
int pamerror;
......@@ -164,7 +164,7 @@ struct argp mu_pam_argp = {
int
mu_authenticate_pam (struct mu_auth_data **return_data ARG_UNUSED,
void *key ARG_UNUSED,
const void *key ARG_UNUSED,
void *func_data ARG_UNUSED,
void *call_data ARG_UNUSED)
{
......
......@@ -136,7 +136,8 @@ pg_auth_common (PGresult *res, char *query_str, struct mu_auth_data **auth)
}
int
pg_auth_sql_by_name (struct mu_auth_data **return_data, void *key,
pg_auth_sql_by_name (struct mu_auth_data **return_data,
const void *key,
void *func_data ARG_UNUSED,
void *call_data ARG_UNUSED)
{
......@@ -185,7 +186,8 @@ pg_auth_sql_by_name (struct mu_auth_data **return_data, void *key,
}
int
pg_auth_sql_by_uid (struct mu_auth_data **return_data, void *key,
pg_auth_sql_by_uid (struct mu_auth_data **return_data,
const void *key,
void *func_data ARG_UNUSED,
void *call_data ARG_UNUSED)
{
......@@ -235,13 +237,14 @@ pg_auth_sql_by_uid (struct mu_auth_data **return_data, void *key,
}
int
pg_sql_authenticate (struct mu_auth_data **return_data ARG_UNUSED, void *key,
pg_sql_authenticate (struct mu_auth_data **return_data ARG_UNUSED,
const void *key,
void *func_data ARG_UNUSED, void *call_data)
{
PGconn *conn;
PGresult *res = NULL;
struct mu_auth_data *auth_data = key;
const struct mu_auth_data *auth_data = key;
char *pass = call_data;
char *query_str = NULL;
int rc = 1;
......
......@@ -214,11 +214,14 @@ struct argp mu_sql_argp = {
# ifdef HAVE_MYSQL
int mysql_auth_sql_by_name __P((struct mu_auth_data **return_data, void *key,
int mysql_auth_sql_by_name __P((struct mu_auth_data **return_data,
const void *key,
void *func_data, void *call_data));
int mysql_auth_sql_by_uid __P((struct mu_auth_data **return_data, void *key,
int mysql_auth_sql_by_uid __P((struct mu_auth_data **return_data,
const void *key,
void *func_data, void *call_data));
int mysql_sql_authenticate __P((struct mu_auth_data **return_data, void *key,
int mysql_sql_authenticate __P((struct mu_auth_data **return_data,
const void *key,
void *func_data, void *call_data));
# define mu_sql_authenticate mysql_sql_authenticate
......
......@@ -534,7 +534,7 @@ _tls_open_client (stream_t stream)
}
int
_tls_strerror (stream_t stream, char **pstr)
_tls_strerror (stream_t stream, const char **pstr)
{
struct _tls_stream *s = stream_get_owner (stream);
*pstr = gnutls_strerror (s->last_err);
......
......@@ -57,7 +57,7 @@
static char *site_virtual_pwddir = SITE_VIRTUAL_PWDDIR;
static struct passwd *
getpwnam_virtual (char *u)
getpwnam_virtual (const char *u)
{
struct passwd *pw = NULL;
FILE *pfile;
......@@ -133,7 +133,8 @@ getpwnam_ip_virtual (const char *u)
/* Virtual domains */
static int
mu_auth_virt_domain_by_name (struct mu_auth_data **return_data, void *key,
mu_auth_virt_domain_by_name (struct mu_auth_data **return_data,
const void *key,
void *unused_func_data, void *unused_call_data)
{
int rc;
......@@ -202,7 +203,7 @@ struct argp mu_virt_argp = {
#else
static int
mu_auth_virt_domain_by_name (struct mu_auth_data **return_data ARG_UNUSED,
void *key ARG_UNUSED,
const void *key ARG_UNUSED,
void *func_data ARG_UNUSED,
void *call_data ARG_UNUSED)
{
......
......@@ -58,7 +58,7 @@ main (int argc, char **argv)
stream_flush (out);
if (rc)
{
char *p;
const char *p;
stream_strerror (cvt, &p);
fprintf (stderr, "error: %s / %s\n", mu_strerror (rc), p);
}
......
......@@ -39,7 +39,7 @@ create_gsasl_stream (stream_t *newstr, stream_t transport, int flags)
if ((rc = stream_open (*newstr)) != 0)
{
char *p;
const char *p;
if (stream_strerror (*newstr, &p))
p = mu_strerror (rc);
syslog (LOG_ERR, _("cannot open SASL input stream: %s"), p);
......@@ -148,7 +148,6 @@ auth_gsasl_capa_init (int disable)
{
int rc;
char *listmech, *name, *s;
size_t size;
rc = gsasl_server_mechlist (ctx, &listmech);
if (rc != GSASL_OK)
......@@ -283,9 +282,3 @@ auth_gsasl_init ()
auth_gsasl_capa_init (0);
}
wd()
{
int _st=0;
while (_st==0)
_st=_st;
}
......
......@@ -16,6 +16,9 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include "imap4d.h"
#ifdef WITH_GSASL
# include <mailutils/gsasl.h>
#endif
mailbox_t mbox;
char *homedir;
......
......@@ -471,7 +471,7 @@ imap4d_readline (void)
}
else if (rc)
{
char *p;
const char *p;
if (stream_strerror (istream, &p))
p = strerror (errno);
......@@ -1141,7 +1141,7 @@ imap4d_init_tls_server ()
if (stream_open (stream))
{
char *p;
const char *p;
stream_strerror (stream, &p);
syslog (LOG_ERR, _("cannot open TLS stream: %s"), p);
return 0;
......
......@@ -35,7 +35,7 @@ struct mu_auth_data {
};
typedef int (*mu_auth_fp) __P((struct mu_auth_data **data,
void *key,
const void *key,
void *func_data,
void *call_data));
......@@ -52,7 +52,7 @@ struct mu_auth_module {
extern int mu_auth_runlist __P((list_t flist,
struct mu_auth_data **return_data,
void *key, void *data));
const void *key, void *data));
extern struct mu_auth_data *
mu_get_auth_by_name __P ((const char *username));
......@@ -63,7 +63,7 @@ extern int
mu_authenticate __P((struct mu_auth_data *auth_data, char *pass));
extern int mu_auth_nosupport __P((struct mu_auth_data **return_data,
void *key,
const void *key,
void *func_data,
void *call_data));
......
......@@ -132,8 +132,8 @@ extern int mu_scheme_autodetect_p __P((const char *scheme, const char **path));
extern int mu_fd_wait __P((int fd, int *pflags, struct timeval *tvp));
extern int mu_decode_filter __P((stream_t *pfilter, stream_t input,
char *filter_type,
char *fromcode, char *tocode));
const char *filter_type,
const char *fromcode, const char *tocode));
extern enum mu_iconv_fallback_mode mu_default_fallback_mode;
extern int mu_set_default_fallback __P((const char *str));
......
......@@ -144,7 +144,7 @@ extern int stream_set_flush __P ((stream_t,
int (*_flush) __PMT ((stream_t)), void *owner));
extern int stream_set_strerror __P ((stream_t stream,
int (*fp) (stream_t, char **), void *owner));
int (*fp) (stream_t, const char **), void *owner));
extern int stream_set_wait __P ((stream_t stream,
int (*wait) (stream_t, int *, struct timeval *), void *owner));
......@@ -156,10 +156,10 @@ extern int stream_sequential_readline __P((stream_t stream,
char *buf, size_t size, size_t *nbytes));
extern int stream_sequential_write __P((stream_t stream,
char *buf, size_t size));
const char *buf, size_t size));
extern int stream_seek __P((stream_t stream, off_t off, int whence));
extern int stream_strerror __P((stream_t stream, char **p));
extern int stream_strerror __P((stream_t stream, const char **p));
#ifdef __cplusplus
}
......
......@@ -51,7 +51,6 @@ mu_scm_mailbox_print (SCM mailbox_smob, SCM port, scm_print_state * pstate)
struct mu_mailbox *mum = (struct mu_mailbox *) SCM_CDR (mailbox_smob);
size_t count = 0;
url_t url = NULL;
char *p;
mailbox_messages_count (mum->mbox, &count);
mailbox_get_url (mum->mbox, &url);
......@@ -65,7 +64,7 @@ mu_scm_mailbox_print (SCM mailbox_smob, SCM port, scm_print_state * pstate)
}
else
{
p = url_to_string (url);
const char *p = url_to_string (url);
if (p)
{
char buf[64];
......
......@@ -498,7 +498,7 @@ _file_open (stream_t stream)
}
int
_file_strerror (stream_t unused, char **pstr)
_file_strerror (stream_t unused, const char **pstr)
{
*pstr = strerror (errno);
return 0;
......
......@@ -352,7 +352,7 @@ _icvt_read (stream_t stream, char *optr, size_t osize,
}
int
_icvt_strerror (stream_t stream, char **pstr)
_icvt_strerror (stream_t stream, const char **pstr)
{
struct icvt_stream *s = stream_get_owner (stream);
switch (s->state)
......@@ -369,7 +369,7 @@ _icvt_strerror (stream_t stream, char **pstr)
case EILSEQ:
snprintf (s->errbuf, sizeof s->errbuf,
_("Illegal multibyte sequence near %*.*s"),
s->bufpos, s->bufpos, s->buf);
(int) s->bufpos, (int) s->bufpos, s->buf);
break;
default:
......@@ -384,7 +384,7 @@ _icvt_strerror (stream_t stream, char **pstr)
break;
default:
*pstr = (char*) mu_strerror (s->ec);
*pstr = mu_strerror (s->ec);
}
return 0;
......
......@@ -62,7 +62,7 @@ struct _stream
int (*_size) __P ((stream_t, off_t *));
int (*_flush) __P ((stream_t));
int (*_setbufsiz)__P ((stream_t, size_t));
int (*_strerror) __P ((stream_t, char **));
int (*_strerror) __P ((stream_t, const char **));
int (*_wait) __P((stream_t, int *pflags, struct timeval *tvp));
};
......
......@@ -20,4 +20,5 @@
#define CURSUF "cur"
#define NEWSUF "new"
extern char *maildir_mkfilename __P((char *dir, char *suffix, char *name));
extern char *maildir_mkfilename __P((const char *dir, const char *suffix,
const char *name));
......
......@@ -62,6 +62,7 @@
#include <mailutils/url.h>
#include <mailutils/observer.h>
#include <mailutils/errno.h>
#include <mailutils/locker.h>
#include <mailbox0.h>
#include <registrar0.h>
#include <amd.h>
......@@ -236,7 +237,7 @@ read_random (void *buf, size_t size)
}
char *
maildir_mkfilename (char *directory, char *suffix, char *name)
maildir_mkfilename (const char *directory, const char *suffix, const char *name)
{
size_t size = strlen (directory) + 1 + strlen (suffix) + 1;
char *tmp;
......
......@@ -244,7 +244,7 @@ _mapfile_get_transport2 (stream_t stream, mu_transport_t *pin, mu_transport_t *p
*pout = NULL;
if (pin)
*pin = mfs->fd;
*pin = (mu_transport_t) mfs->fd;
return 0;
}
......
......@@ -124,7 +124,7 @@ mu_insert_stack_entry (list_t *pflist, struct auth_stack_entry *entry)
int
mu_auth_runlist (list_t flist, struct mu_auth_data **return_data,
void *key, void *data)
const void *key, void *data)
{
int rc = 1;
iterator_t itr;
......@@ -149,7 +149,7 @@ mu_auth_runlist (list_t flist, struct mu_auth_data **return_data,
int
mu_auth_nosupport (struct mu_auth_data **return_data ARG_UNUSED,
void *key ARG_UNUSED,
const void *key ARG_UNUSED,
void *func_data ARG_UNUSED,
void *call_data ARG_UNUSED)
{
......
......@@ -1235,8 +1235,9 @@ mu_set_default_fallback (const char *str)
}
int
mu_decode_filter (stream_t *pfilter, stream_t input, char *filter_type,
char *fromcode, char *tocode)
mu_decode_filter (stream_t *pfilter, stream_t input,
const char *filter_type,
const char *fromcode, const char *tocode)
{
stream_t filter;
......
......@@ -663,7 +663,7 @@ stream_set_flags (stream_t stream, int fl)
int
stream_set_strerror (stream_t stream,
int (*fp) (stream_t, char **), void *owner)
int (*fp) (stream_t, const char **), void *owner)
{
if (stream == NULL)
return EINVAL;
......@@ -716,7 +716,7 @@ stream_sequential_readline (stream_t stream, char *buf, size_t size,
}
int
stream_sequential_write (stream_t stream, char *buf, size_t size)
stream_sequential_write (stream_t stream, const char *buf, size_t size)
{
if (stream == NULL)
return EINVAL;
......@@ -780,7 +780,7 @@ stream_wait (stream_t stream, int *pflags, struct timeval *tvp)
}
int
stream_strerror (stream_t stream, char **p)
stream_strerror (stream_t stream, const char **p)
{
if (stream == NULL)
return EINVAL;
......
......@@ -44,7 +44,7 @@
/* System database */
static int
mu_auth_system (struct mu_auth_data **return_data, struct passwd *pw)
mu_auth_system (struct mu_auth_data **return_data, const struct passwd *pw)
{
char *mailbox_name;
int rc;
......@@ -74,7 +74,8 @@ mu_auth_system (struct mu_auth_data **return_data, struct passwd *pw)
}
int
mu_auth_system_by_name (struct mu_auth_data **return_data, void *key,
mu_auth_system_by_name (struct mu_auth_data **return_data,
const void *key,
void *func_data ARG_UNUSED,
void *call_data ARG_UNUSED)
{
......@@ -87,7 +88,8 @@ mu_auth_system_by_name (struct mu_auth_data **return_data, void *key,
}
static int
mu_auth_system_by_uid (struct mu_auth_data **return_data, void *key,
mu_auth_system_by_uid (struct mu_auth_data **return_data,
const void *key,
void *func_data ARG_UNUSED,
void *call_data ARG_UNUSED)
{
......@@ -101,11 +103,11 @@ mu_auth_system_by_uid (struct mu_auth_data **return_data, void *key,
static int
mu_authenticate_generic (struct mu_auth_data **return_data ARG_UNUSED,
void *key,
const void *key,
void *func_data ARG_UNUSED,
void *call_data)
{
struct mu_auth_data *auth_data = key;
const struct mu_auth_data *auth_data = key;
char *pass = call_data;
return !auth_data
......@@ -116,11 +118,11 @@ mu_authenticate_generic (struct mu_auth_data **return_data ARG_UNUSED,
/* Called only if generic fails */
static int
mu_authenticate_system (struct mu_auth_data **return_data ARG_UNUSED,
void *key,
const void *key,
void *func_data ARG_UNUSED,
void *call_data)
{
struct mu_auth_data *auth_data = key;
const struct mu_auth_data *auth_data = key;
char *pass = call_data;
#ifdef HAVE_SHADOW_H
......
......@@ -1787,14 +1787,15 @@ builtin_putaddr (struct mh_machine *mach)
static void
builtin_unre (struct mh_machine *mach)
{
char *p;
const char *p;
int rc = munre_subject (strobj_ptr (&mach->arg_str), &p);
if (rc == 0 && p != strobj_ptr (&mach->arg_str))
{
p = strdup (p);
char *q = strdup (p); /* Create a copy, since strobj_create will
destroy p */
strobj_free (&mach->arg_str);
strobj_create (&mach->arg_str, p);
free (p);
strobj_create (&mach->arg_str, q);
free (q);
}
}
......
......@@ -407,34 +407,35 @@ mh_expand_name (const char *base, const char *name, int is_folder)
{
char *tmp = NULL;
char *p = NULL;
char *namep;
tmp = mu_tilde_expansion (name, "/", NULL);
if (tmp[0] == '+')
name = tmp + 1;
namep = tmp + 1;
else if (strncmp (tmp, "../", 3) == 0 || strncmp (tmp, "./", 2) == 0)
{
char *cwd = mu_getcwd ();
asprintf (&name, "%s/%s", cwd, tmp);
asprintf (&namep, "%s/%s", cwd, tmp);
free (cwd);
free (tmp);
tmp = NULL;
}
else
name = tmp;
namep = tmp;
if (!base)
base = mu_path_folder_dir;
if (is_folder)
{
if (name[0] == '/')
asprintf (&p, "mh:%s", name);
if (namep[0] == '/')
asprintf (&p, "mh:%s", namep);
else
asprintf (&p, "mh:%s/%s", base, name);
asprintf (&p, "mh:%s/%s", base, namep);
}
else if (name[0] != '/')
asprintf (&p, "%s/%s", base, name);
else if (namep[0] != '/')
asprintf (&p, "%s/%s", base, namep);
else
return name;
return namep;
free (tmp);
return p;
......
......@@ -500,6 +500,7 @@ static int
send (int argc, char **argv)
{
int i, rc;
char *p;
/* Verify all arguments */
for (i = 0; i < argc; i++)
......@@ -518,7 +519,8 @@ send (int argc, char **argv)
/* Prepend url specifier to the folder dir. We won't need this
when the default format becomes configurable */
asprintf (&mu_path_folder_dir, "mh:%s", mu_path_folder_dir);
asprintf (&p, "mh:%s", mu_path_folder_dir);
mu_path_folder_dir = p;
/* Finally, do the work */
rc = list_do (mesg_list, _action_send, NULL);
......
......@@ -161,7 +161,7 @@ pop3d_init_tls_server ()
if (stream_open (stream))
{
char *p;
const char *p;
stream_strerror (stream, &p);
syslog (LOG_ERR, _("cannot open TLS stream: %s"), p);
return 0;
......@@ -220,7 +220,7 @@ pop3d_outf (const char *fmt, ...)
free (buf);
if (rc)
{
char *p;
const char *p;
if (stream_strerror (ostream, &p))
p = strerror (errno);
......@@ -243,7 +243,7 @@ pop3d_readline (char *buffer, size_t size)
if (rc)
{
char *p;
const char *p;
if (stream_strerror (ostream, &p))
p = strerror (errno);
......