Commit 6e835d05 6e835d05151eb2f9523d34611e6f5b04b50780bf by Sergey Poznyakoff

Minor changes.

* guimb/main.c (main_sym): Remove const qualifier.
* imap4d/imap4d.h (util_getfullpath): 1st arg is const.
* imap4d/util.c: Likewise.
* include/mailutils/guile.h (mu_guile_load): 1st arg is const.
* include/mailutils/sql.h (mu_sql_get_field): 3rd arg is const.
* libmu_auth/radius.c: Cleanup trailing whitespace.
* libmu_scm/mu_guile.c (mu_guile_load): 1st arg is const.
(struct load_closure): Filename is const. All uses updated.
* mailbox/monitor.c (RWLOCK_TRYRDLOCK, RWLOCK_TRYWRLOCK): Remove
[!WITH_PTHREAD] (RWLOCK_DESTROY): Empty define.
* mailbox/mutil.c (mu_aget_user_email_domain): Minor fix.
* sql/sql.c (mu_sql_get_field): 3rd arg is const.
1 parent 558a5b14
......@@ -146,7 +146,7 @@ static const char *guimb_argp_capa[] = {
NULL
};
const char *main_sym = "mailutils-main";
char *main_sym = "mailutils-main";
int
main (int argc, char *argv[])
......
......@@ -338,7 +338,7 @@ extern int util_finish (struct imap4d_command *, int, const char *, ...)
extern int util_getstate (void);
extern int util_do_command (imap4d_tokbuf_t);
extern char *util_tilde_expansion (const char *, const char *);
extern char *util_getfullpath (char *, const char *);
extern char *util_getfullpath (const char *, const char *);
extern int util_msgset (char *, size_t **, int *, int);
extern int util_upper (char *);
extern struct imap4d_command *util_getcommand (char *,
......
......@@ -36,7 +36,7 @@ util_tilde_expansion (const char *ref, const char *delim)
/* Get the absolute path. */
/* NOTE: Path is allocated and must be free()d by the caller. */
char *
util_getfullpath (char *name, const char *delim)
util_getfullpath (const char *name, const char *delim)
{
char *p = util_tilde_expansion (name, delim);
if (*p != delim[0])
......
......@@ -74,9 +74,9 @@ extern void mu_scm_mutil_init (void);
SCM mu_scm_make_debug_port (mu_debug_t debug, mu_log_level_t level);
void mu_scm_debug_port_init (void);
extern void mu_guile_init (int debug);
extern int mu_guile_load (char *filename, int argc, char **argv);
extern int mu_guile_load (const char *filename, int argc, char **argv);
extern int mu_guile_eval (const char *string);
extern int mu_guile_mailbox_apply (mu_mailbox_t mbx, char *funcname);
extern int mu_guile_message_apply (mu_message_t msg, char *funcname);
......@@ -84,9 +84,9 @@ extern int mu_guile_message_apply (mu_message_t msg, char *funcname);
extern int mu_guile_safe_exec (SCM (*handler) (void *data), void *data,
SCM *result);
extern int mu_guile_safe_proc_call (SCM proc, SCM arglist, SCM *presult);
#ifdef __cplusplus
}
#endif
#endif
#endif
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc.
Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
......@@ -33,7 +33,7 @@ struct mu_sql_module_config
char *getpwnam_query;
char *getpass_query;
char *getpwuid_query;
char *host;
char *host;
char *user;
char *passwd;
char *db;
......@@ -51,7 +51,7 @@ struct mu_internal_sql_config
char *getpwnam_query;
char *getpass_query;
char *getpwuid_query;
char *host;
char *host;
char *user;
char *passwd;
char *db;
......@@ -64,7 +64,7 @@ struct mu_internal_sql_config
extern struct mu_internal_sql_config mu_sql_module_config;
/* Loadable Modules Support */
#define __s_cat2__(a,b) a ## b
#define __s_cat2__(a,b) a ## b
#define __s_cat3__(a,b,c) a ## b ## c
#define RDL_EXPORT(module,name) __s_cat3__(module,_LTX_,name)
......@@ -107,7 +107,7 @@ struct mu_sql_dispatch
{
char *name;
int port;
int (*init) (mu_sql_connection_t conn);
int (*destroy) (mu_sql_connection_t conn);
......@@ -117,7 +117,7 @@ struct mu_sql_dispatch
int (*query) (mu_sql_connection_t conn, char *query);
int (*store_result) (mu_sql_connection_t conn);
int (*release_result) (mu_sql_connection_t conn);
int (*num_tuples) (mu_sql_connection_t conn, size_t *np);
int (*num_columns) (mu_sql_connection_t conn, size_t *np);
......@@ -126,7 +126,7 @@ struct mu_sql_dispatch
int (*get_field_number) (mu_sql_connection_t conn, const char *fname,
size_t *fno);
const char *(*errstr) (mu_sql_connection_t conn);
};
......@@ -151,7 +151,7 @@ int mu_sql_num_columns (mu_sql_connection_t conn, size_t *np);
int mu_sql_get_column (mu_sql_connection_t conn, size_t nrow, size_t ncol,
char **pdata);
int mu_sql_get_field (mu_sql_connection_t conn, size_t nrow, char *fname,
int mu_sql_get_field (mu_sql_connection_t conn, size_t nrow, const char *fname,
char **pdata);
const char *mu_sql_strerror (mu_sql_connection_t conn);
......
......@@ -50,13 +50,13 @@
static int radius_auth_enabled;
static int MU_User_Name;
static int MU_UID;
static int MU_GID;
static int MU_GECOS;
static int MU_Dir;
static int MU_Shell;
static int MU_Mailbox;
static int MU_User_Name;
static int MU_UID;
static int MU_GID;
static int MU_GECOS;
static int MU_Dir;
static int MU_Shell;
static int MU_Mailbox;
static grad_avp_t *auth_request;
static grad_avp_t *getpwnam_request;
......@@ -78,8 +78,8 @@ get_attribute (int *pattr, char *name)
enum parse_state
{
state_lhs,
state_op,
state_lhs,
state_op,
state_rhs,
state_delim
};
......@@ -97,7 +97,7 @@ parse_pairlist (grad_avp_t **plist, char *input)
if (!input)
return 1;
if ((rc = mu_argcv_get (input, ",", NULL, &argc, &argv)))
{
mu_error (_("Cannot parse input `%s': %s"), input, mu_strerror (rc));
......@@ -106,23 +106,23 @@ parse_pairlist (grad_avp_t **plist, char *input)
loc.file = "<configuration>"; /*FIXME*/
loc.line = 0;
for (i = 0, state = state_lhs; i < argc; i++)
{
grad_avp_t *pair;
switch (state)
{
case state_lhs:
name = argv[i];
state = state_op;
break;
case state_op:
op = argv[i];
state = state_rhs;
break;
case state_rhs:
loc.line = i; /* Just to keep track of error location */
pair = grad_create_pair (&loc, name, grad_operator_equal, argv[i]);
......@@ -150,7 +150,7 @@ parse_pairlist (grad_avp_t **plist, char *input)
mu_error (_("malformed radius A/V list"));
return 1;
}
mu_argcv_free (argc, argv);
return 0;
}
......@@ -205,13 +205,13 @@ mu_radius_module_init (enum mu_gocs_op op, void *data)
return 0;
if (!NEED_RADIUS_P (cfg))
return 0;
grad_set_logger (mu_grad_logger);
grad_config_dir = grad_estrdup (cfg->config_dir);
grad_path_init ();
srand (time (NULL) + getpid ());
if (grad_dict_init ())
{
mu_error (_("Cannot read radius dictionaries"));
......@@ -227,7 +227,7 @@ mu_radius_module_init (enum mu_gocs_op op, void *data)
|| get_attribute (&MU_Shell, "MU-Shell")
|| get_attribute (&MU_Mailbox, "MU-Mailbox"))
return 1;
/* Parse saved requests */
if (parse_pairlist (&auth_request, cfg->auth_request)
|| parse_pairlist (&getpwnam_request, cfg->getpwnam_request)
......@@ -236,7 +236,7 @@ mu_radius_module_init (enum mu_gocs_op op, void *data)
radius_auth_enabled = 1;
return 0;
}
}
static char *
_expand_query (const char *query, const char *ustr, const char *passwd)
......@@ -244,7 +244,7 @@ _expand_query (const char *query, const char *ustr, const char *passwd)
int rc;
mu_vartab_t vtab;
char *str, *ret;
if (!query)
return NULL;
......@@ -254,7 +254,7 @@ _expand_query (const char *query, const char *ustr, const char *passwd)
mu_vartab_define (vtab, "user", ustr, 1);
mu_vartab_define (vtab, "u", ustr, 1);
}
if (passwd)
{
mu_vartab_define (vtab, "passwd", passwd, 1);
......@@ -325,7 +325,7 @@ decode_reply (grad_request_t *reply, const char *user_name, char *password,
{
grad_avp_t *p;
int rc;
uid_t uid = -1;
gid_t gid = -1;
char *gecos = "RADIUS User";
......@@ -345,7 +345,7 @@ decode_reply (grad_request_t *reply, const char *user_name, char *password,
mu_error (_("Radius did not return UID for `%s'"), user_name);
return -1;
}
p = grad_avl_find (reply->avlist, MU_GID);
if (p)
gid = p->avp_lvalue;
......@@ -354,11 +354,11 @@ decode_reply (grad_request_t *reply, const char *user_name, char *password,
mu_error (_("Radius did not return GID for `%s'"), user_name);
return -1;
}
p = grad_avl_find (reply->avlist, MU_GECOS);
if (p)
gecos = p->avp_strvalue;
p = grad_avl_find (reply->avlist, MU_Dir);
if (p)
dir = strdup (p->avp_strvalue);
......@@ -369,13 +369,13 @@ decode_reply (grad_request_t *reply, const char *user_name, char *password,
return 1;
strcat (strcpy (dir, DEFAULT_HOME_PREFIX), user_name);
}
p = grad_avl_find (reply->avlist, MU_Shell);
if (p)
shell = p->avp_strvalue;
else
shell = DEFAULT_SHELL;
p = grad_avl_find (reply->avlist, MU_Mailbox);
if (p)
mailbox = strdup (p->avp_strvalue);
......@@ -385,7 +385,7 @@ decode_reply (grad_request_t *reply, const char *user_name, char *password,
if (rc)
return rc;
}
rc = mu_auth_data_alloc (return_data,
user_name,
password,
......@@ -396,7 +396,7 @@ decode_reply (grad_request_t *reply, const char *user_name, char *password,
shell,
mailbox,
1);
free (dir);
free (mailbox);
return rc;
......@@ -413,13 +413,13 @@ mu_radius_authenticate (struct mu_auth_data **return_data MU_ARG_UNUSED,
if (!radius_auth_enabled)
return ENOSYS;
if (!auth_request)
{
mu_error (_("radius request for auth is not specified"));
return EINVAL;
}
reply = send_request (auth_request, RT_ACCESS_REQUEST,
auth_data->name, (char*) call_data);
if (!reply)
......@@ -435,7 +435,7 @@ mu_radius_authenticate (struct mu_auth_data **return_data MU_ARG_UNUSED,
default:
rc = MU_ERR_AUTH_FAILURE;
}
grad_request_free (reply);
return rc;
......@@ -448,7 +448,7 @@ mu_auth_radius_user_by_name (struct mu_auth_data **return_data,
{
int rc = MU_ERR_AUTH_FAILURE;
grad_request_t *reply;
if (!radius_auth_enabled)
return ENOSYS;
......@@ -457,7 +457,7 @@ mu_auth_radius_user_by_name (struct mu_auth_data **return_data,
mu_error (_("radius request for getpwnam is not specified"));
return MU_ERR_FAILURE;
}
reply = send_request (getpwnam_request, RT_ACCESS_REQUEST, key, NULL);
if (!reply)
{
......@@ -472,7 +472,7 @@ mu_auth_radius_user_by_name (struct mu_auth_data **return_data,
grad_request_code_to_name (reply->code));
else
rc = decode_reply (reply, key, "x", return_data);
grad_request_free (reply);
}
return rc;
......@@ -486,7 +486,7 @@ mu_auth_radius_user_by_uid (struct mu_auth_data **return_data,
int rc = MU_ERR_AUTH_FAILURE;
grad_request_t *reply;
char uidstr[64];
if (!radius_auth_enabled)
return ENOSYS;
......@@ -498,7 +498,7 @@ mu_auth_radius_user_by_uid (struct mu_auth_data **return_data,
mu_error (_("radius request for getpwuid is not specified"));
return MU_ERR_FAILURE;
}
snprintf (uidstr, sizeof (uidstr), "%u", *(uid_t*)key);
reply = send_request (getpwuid_request, RT_ACCESS_REQUEST, uidstr, NULL);
if (!reply)
......@@ -559,4 +559,3 @@ struct mu_auth_module mu_auth_radius_module = {
mu_auth_radius_user_by_uid,
NULL
};
......
......@@ -51,7 +51,7 @@ mu_guile_safe_exec (SCM (*handler) (void *data), void *data, SCM *result)
{
jmp_buf jmp_env;
struct scheme_exec_data ed;
if (setjmp (jmp_env))
return 1;
ed.handler = handler;
......@@ -85,10 +85,10 @@ mu_guile_safe_proc_call (SCM proc, SCM arglist, SCM *presult)
{
jmp_buf jmp_env;
SCM cell, result;
if (setjmp (jmp_env))
return 1;
cell = scm_cons (proc, arglist);
result = scm_internal_lazy_catch (SCM_BOOL_T,
eval_catch_body, cell,
......@@ -119,7 +119,7 @@ mu_guile_init (int debug)
struct load_closure
{
char *filename;
const char *filename;
int argc;
char **argv;
};
......@@ -128,14 +128,14 @@ static SCM
load_path_handler (void *data)
{
struct load_closure *lp = data;
scm_set_program_arguments (lp->argc, lp->argv, lp->filename);
scm_set_program_arguments (lp->argc, lp->argv, (char*)lp->filename);
scm_primitive_load (scm_makfrom0str (lp->filename));
return SCM_UNDEFINED;
}
int
mu_guile_load (char *filename, int argc, char **argv)
mu_guile_load (const char *filename, int argc, char **argv)
{
struct load_closure lc;
lc.filename = filename;
......@@ -161,7 +161,7 @@ mu_guile_eval (const char *string)
/* See comment on this function in mu_mailbox.c */
extern SCM mu_scm_mailbox_create0 (mu_mailbox_t mbox, int noclose);
int
mu_guile_mailbox_apply (mu_mailbox_t mbx, char *funcname)
{
......
......@@ -42,7 +42,7 @@ pthread_mutex_t monitor_lock = PTHREAD_MUTEX_INITIALIZER;
# define STATIC_UNLOCK(m) pthread_mutex_unlock(m)
#else
# define STATIC_LOCK(m) 0
# define STATIC_UNLOCK(m)
# define STATIC_UNLOCK(m)
int monitor_lock;
#endif
......@@ -212,29 +212,23 @@ mu_monitor_notify (mu_monitor_t monitor MU_ARG_UNUSED)
# define RWLOCK_INIT(rwl, attr) pthread_rwlock_init (rwl, attr)
# define RWLOCK_DESTROY(rwl) pthread_rwlock_destroy (rwl)
# define RWLOCK_RDLOCK(rwl) pthread_rwlock_rdlock (rwl)
# define RWLOCK_TRYRDLOCK(rwl) pthread_rwlock_tryrdlock (rwl)
# define RWLOCK_WRLOCK(rwl) pthread_rwlock_wrlock (rwl)
# define RWLOCK_TRYWRLOCK(rwl) pthread_rwlock_trywrlock (rwl)
# define RWLOCK_UNLOCK(rwl) pthread_rwlock_unlock (rwl)
# else
# define RWLOCK_INIT(rwl, attr) pthread_mutex_init (rwl, attr)
# define RWLOCK_DESTROY(rwl) pthread_mutex_destroy (rwl)
# define RWLOCK_RDLOCK(rwl) pthread_mutex_lock (rwl)
# define RWLOCK_TRYRDLOCK(rwl) pthread_mutex_trylock (rwl)
# define RWLOCK_WRLOCK(rwl) pthread_mutex_lock (rwl)
# define RWLOCK_TRYWRLOCK(rwl) pthread_mutex_trylock (rwl)
# define RWLOCK_UNLOCK(rwl) pthread_mutex_unlock (rwl)
# endif
#else
# define RWLOCK_INIT(rwl, attr) 0
# define RWLOCK_DESTROY(rwl) 0
# define RWLOCK_DESTROY(rwl)
# define RWLOCK_RDLOCK(rwl) 0
# define RWLOCK_TRYRDLOCK(rwl) 0
# define RWLOCK_WRLOCK(rwl) 0
# define RWLOCK_TRYWRLOCK(rwl) 0
# define RWLOCK_UNLOCK(rwl) 0
# define flockfile(arg) 0
# define funlockfile(arg) 0
# define flockfile(arg)
# define funlockfile(arg)
#endif
......
......@@ -437,7 +437,7 @@ mu_aget_user_email_domain (char **pdomain)
if (status)
return status;
if (domain == NULL)
*pdomain = domain;
*pdomain = NULL;
else
{
*pdomain = strdup (domain);
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
Copyright (C) 2004, 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
......@@ -56,7 +56,7 @@ add_disptab (mu_sql_dispatch_t *tab)
if (sql_disptab_next == sql_disptab_size)
{
mu_sql_dispatch_t **tmp;
tmp = realloc (sql_disptab, sql_disptab_size + 4);
if (!tmp)
return ENOMEM;
......@@ -73,7 +73,7 @@ mu_sql_interface_index (char *name)
{
int i;
//mu_sql_dispatch_t *tab;
init_disptab ();
for (i = 1; i < sql_disptab_next; i++)
if (sql_disptab[i] && (!name || strcmp (sql_disptab[i]->name, name) == 0))
......@@ -81,7 +81,7 @@ mu_sql_interface_index (char *name)
/* FIXME: For dynamic loading
if (name && mu_sql_load_ext (name, "dispatch_tab", &tab))
return add_disptab (tab);
*/
*/
return 0;
}
......@@ -116,7 +116,7 @@ mu_sql_connection_init (mu_sql_connection_t *pconn, int interface,
{
static mu_sql_dispatch_t *tab;
mu_sql_connection_t conn;
tab = get_sql_entry (interface);
if (!tab)
return MU_ERR_NO_INTERFACE;
......@@ -161,7 +161,7 @@ int
mu_sql_connect (mu_sql_connection_t conn)
{
int rc;
if (!conn)
return EINVAL;
......@@ -173,7 +173,7 @@ mu_sql_connect (mu_sql_connection_t conn)
case mu_sql_connected:
case mu_sql_query_run:
return MU_ERR_DB_ALREADY_CONNECTED;
case mu_sql_result_available:
return MU_ERR_RESULT_NOT_RELEASED;
}
......@@ -187,7 +187,7 @@ int
mu_sql_disconnect (mu_sql_connection_t conn)
{
int rc;
if (!conn)
return EINVAL;
......@@ -199,7 +199,7 @@ mu_sql_disconnect (mu_sql_connection_t conn)
case mu_sql_connected:
case mu_sql_query_run:
break;
case mu_sql_result_available:
return MU_ERR_RESULT_NOT_RELEASED;
}
......@@ -229,7 +229,7 @@ mu_sql_query (mu_sql_connection_t conn, char *query)
case mu_sql_result_available:
return MU_ERR_RESULT_NOT_RELEASED;
}
rc = SQL_F (conn, query) (conn, query);
if (rc == 0)
conn->state = mu_sql_query_run;
......@@ -240,7 +240,7 @@ int
mu_sql_store_result (mu_sql_connection_t conn)
{
int rc;
if (!conn)
return EINVAL;
......@@ -251,14 +251,14 @@ mu_sql_store_result (mu_sql_connection_t conn)
case mu_sql_connected:
return MU_ERR_NO_QUERY;
case mu_sql_query_run:
break;
case mu_sql_result_available:
return MU_ERR_RESULT_NOT_RELEASED;
}
rc = SQL_F (conn, store_result) (conn);
if (rc == 0)
conn->state = mu_sql_result_available;
......@@ -269,7 +269,7 @@ int
mu_sql_release_result (mu_sql_connection_t conn)
{
int rc;
if (!conn)
return EINVAL;
......@@ -280,14 +280,14 @@ mu_sql_release_result (mu_sql_connection_t conn)
case mu_sql_connected:
return MU_ERR_NO_QUERY;
case mu_sql_query_run:
return MU_ERR_NO_RESULT;
case mu_sql_result_available:
break;
}
rc = SQL_F (conn, release_result) (conn);
if (rc == 0)
conn->state = mu_sql_connected;
......@@ -307,7 +307,7 @@ mu_sql_num_tuples (mu_sql_connection_t conn, size_t *np)
case mu_sql_connected:
return MU_ERR_NO_QUERY;
case mu_sql_query_run:
return MU_ERR_NO_RESULT;
......@@ -330,7 +330,7 @@ mu_sql_num_columns (mu_sql_connection_t conn, size_t *np)
case mu_sql_connected:
return MU_ERR_NO_QUERY;
case mu_sql_query_run:
return MU_ERR_NO_RESULT;
......@@ -339,7 +339,7 @@ mu_sql_num_columns (mu_sql_connection_t conn, size_t *np)
}
return SQL_F (conn, num_columns) (conn, np);
}
int
mu_sql_get_column (mu_sql_connection_t conn, size_t nrow, size_t ncol,
......@@ -354,7 +354,7 @@ mu_sql_get_column (mu_sql_connection_t conn, size_t nrow, size_t ncol,
case mu_sql_connected:
return MU_ERR_NO_QUERY;
case mu_sql_query_run:
return MU_ERR_NO_RESULT;
......@@ -365,12 +365,12 @@ mu_sql_get_column (mu_sql_connection_t conn, size_t nrow, size_t ncol,
}
int
mu_sql_get_field (mu_sql_connection_t conn, size_t nrow, char *fname,
mu_sql_get_field (mu_sql_connection_t conn, size_t nrow, const char *fname,
char **pdata)
{
int rc;
size_t fno;
if (!conn)
return EINVAL;
......@@ -381,7 +381,7 @@ mu_sql_get_field (mu_sql_connection_t conn, size_t nrow, char *fname,
case mu_sql_connected:
return MU_ERR_NO_QUERY;
case mu_sql_query_run:
return MU_ERR_NO_RESULT;
......@@ -402,4 +402,3 @@ mu_sql_strerror (mu_sql_connection_t conn)
return strerror (EINVAL);
return SQL_F (conn, errstr) (conn);
}
......