Skip to content

Commit

Permalink
One simple task pulled on the thread of constification, which rippled…
Browse files Browse the repository at this point in the history
… throughout

the codebase.  I'm sure there'll be more cleanup of warnings in the contrib
modules; this is just the first pass.
  • Loading branch information
Castaglia committed Apr 15, 2016
1 parent 74cf2a6 commit 067c38c
Show file tree
Hide file tree
Showing 40 changed files with 460 additions and 383 deletions.
10 changes: 4 additions & 6 deletions include/auth.h
@@ -1,6 +1,6 @@
/*
* ProFTPD - FTP server daemon
* Copyright (c) 2004-2014 The ProFTPD Project team
* Copyright (c) 2004-2016 The ProFTPD Project team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -22,9 +22,7 @@
* the source distribution.
*/

/* ProFTPD Auth API
* $Id: auth.h,v 1.14 2011-05-23 20:35:35 castaglia Exp $
*/
/* ProFTPD Auth API */

#ifndef PR_AUTH_H
#define PR_AUTH_H
Expand Down Expand Up @@ -104,7 +102,7 @@ int pr_auth_requires_pass(pool *, const char *);
* configuration for that user. If the user name is not be handled as
* an anonymous login, NULL is returned.
*/
config_rec *pr_auth_get_anon_config(pool *p, char **, char **, char **);
config_rec *pr_auth_get_anon_config(pool *p, const char **, char **, char **);

/* Wrapper function around the chroot(2) system call, handles setting of
* appropriate environment variables if necessary.
Expand Down Expand Up @@ -164,7 +162,7 @@ int pr_auth_cache_set(int enable, unsigned int flags);
/* Wrapper function for retrieving the user's home directory. This handles
* any possible RewriteHome configuration.
*/
char *pr_auth_get_home(pool *, char *pw_dir);
const char *pr_auth_get_home(pool *, const char *pw_dir);

/* For internal use only. */
int init_auth(void);
Expand Down
2 changes: 1 addition & 1 deletion include/cmd.h
Expand Up @@ -27,7 +27,7 @@

cmd_rec *pr_cmd_alloc(pool *p, int, ...);
int pr_cmd_clear_cache(cmd_rec *cmd);
char *pr_cmd_get_displayable_str(cmd_rec *cmd, size_t *len);
const char *pr_cmd_get_displayable_str(cmd_rec *cmd, size_t *len);
int pr_cmd_get_errno(cmd_rec *cmd);

int pr_cmd_cmp(cmd_rec *cmd, int cmd_id);
Expand Down
6 changes: 3 additions & 3 deletions include/dirtree.h
Expand Up @@ -2,7 +2,7 @@
* ProFTPD - FTP server daemon
* Copyright (c) 1997, 1998 Public Flood Software
* Copyright (c) 1999, 2000 MacGyver aka Habeeb J. Dihu <macgyver@tos.net>
* Copyright (c) 2001-2015 The ProFTPD Project team
* Copyright (c) 2001-2016 The ProFTPD Project team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -226,14 +226,14 @@ int dir_check(pool *, cmd_rec *, const char *, const char *, int *);
int dir_check_canon(pool *, cmd_rec *, const char *, const char *, int *);
int is_dotdir(const char *);
int login_check_limits(xaset_t *, int, int, int *);
char *path_subst_uservar(pool *, char **);
const char *path_subst_uservar(pool *, const char **);
void resolve_anonymous_dirs(xaset_t *);
void resolve_deferred_dirs(server_rec *);
void fixup_dirs(server_rec *, int);
unsigned char check_context(cmd_rec *, int);
char *get_context_name(cmd_rec *);
int get_boolean(cmd_rec *, int);
char *get_full_cmd(cmd_rec *);
const char *get_full_cmd(cmd_rec *);

/* Internal use only. */
void init_dirtree(void);
Expand Down
36 changes: 18 additions & 18 deletions include/modules.h
Expand Up @@ -2,7 +2,7 @@
* ProFTPD - FTP server daemon
* Copyright (c) 1997, 1998 Public Flood Software
* Copyright (c) 1999, 2000 MacGyver aka Habeeb J. Dihu <macgyver@tos.net>
* Copyright (c) 2001-2015 The ProFTPD Project team
* Copyright (c) 2001-2016 The ProFTPD Project team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -34,10 +34,10 @@ typedef struct modret_struc modret_t;

struct modret_struc {
module *mr_handler_module; /* which module handled this? */
int mr_error; /* !0 if error */
char *mr_numeric; /* numeric error code */
char *mr_message; /* text message */
void *data; /* add'l data -- undefined */
int mr_error; /* !0 if error */
const char *mr_numeric; /* numeric error code */
const char *mr_message; /* text message */
void *data; /* add'l data -- undefined */
};

/* The following macros are for creating basic modret_t, and can
Expand Down Expand Up @@ -66,7 +66,7 @@ struct modret_struc {

typedef struct conftab_rec {
char *directive;
modret_t *(*handler)(cmd_rec*);
modret_t *(*handler)(cmd_rec *);

module *m; /* Reference to owning module
* set when module is initialized
Expand Down Expand Up @@ -107,11 +107,11 @@ typedef struct cmdtab_rec {

/* See above for cmd types. */
unsigned char cmd_type;
char *command;
const char *command;

/* Command group. */
char *group;
modret_t *(*handler)(cmd_rec*);
const char *group;
modret_t *(*handler)(cmd_rec *);

/* Does this command require authentication? */
unsigned char requires_auth;
Expand All @@ -126,19 +126,19 @@ typedef struct cmdtab_rec {

typedef struct authtab_rec {
int auth_flags; /* future use */
char *name;
modret_t *(*handler)(cmd_rec*);
const char *name;
modret_t *(*handler)(cmd_rec *);

module *m;
} authtable;

#define PR_AUTH_FL_REQUIRED 0x00001

struct module_struc {
module *next,*prev;
module *next, *prev;

int api_version; /* API version _not_ module version */
char *name; /* Module name */
const char *name; /* Module name */

struct conftab_rec *conftable; /* Configuration directive table */
struct cmdtab_rec *cmdtable; /* Command table */
Expand All @@ -147,7 +147,7 @@ struct module_struc {
int (*init)(void); /* Module initialization */
int (*sess_init)(void); /* Session initialization */

char *module_version; /* Module version */
const char *module_version; /* Module version */
void *handle; /* Module handle */

/* Internal use; high number == higher priority. */
Expand All @@ -158,7 +158,7 @@ struct module_struc {

/* Prototypes */

unsigned char command_exists(char *);
unsigned char command_exists(const char *);
int modules_init(void);
void modules_list(int flags);
void modules_list2(int (*listf)(const char *, ...), int flags);
Expand Down Expand Up @@ -186,12 +186,12 @@ void set_auth_check(int (*ck)(cmd_rec *));
extern int (*cmd_auth_chk)(cmd_rec *);

/* For use from inside module handler functions */
modret_t *mod_create_ret(cmd_rec *, unsigned char, char *, char *);
modret_t *mod_create_ret(cmd_rec *, unsigned char, const char *, const char *);
modret_t *mod_create_error(cmd_rec *, int);
modret_t *mod_create_data(cmd_rec *, void *);

/* Implemented in mod_core.c */
int core_chgrp(cmd_rec *, char *, uid_t, gid_t);
int core_chmod(cmd_rec *, char *, mode_t);
int core_chgrp(cmd_rec *, const char *, uid_t, gid_t);
int core_chmod(cmd_rec *, const char *, mode_t);

#endif /* PR_MODULES_H */
20 changes: 10 additions & 10 deletions include/proftpd.h
Expand Up @@ -109,7 +109,7 @@ typedef struct {
uid_t fsuid; /* Saved file UID */
gid_t fsgid; /* Saved file GID */

char *user, *group; /* Username/groupname after login */
const char *user, *group; /* Username/groupname after login */
uid_t login_uid; /* UID after login, but before
* session.uid is changed
*/
Expand All @@ -120,7 +120,7 @@ typedef struct {
pr_table_t *notes; /* Session notes table */

pr_class_t *conn_class; /* Session class */
char *proc_prefix; /* The "prefix" of our process name */
const char *proc_prefix; /* The "prefix" of our process name */

int wtmp_log; /* Are we logging to wtmp? */
int multiline_rfc2228; /* Are we using RFC2228-style multiline responses ? */
Expand All @@ -130,12 +130,12 @@ typedef struct {

int hide_password; /* Hide password in logs/ps listing */

char *chroot_path; /* Chroot directory */
const char *chroot_path; /* Chroot directory */

struct config_struc *anon_config; /* Anonymous FTP configuration */
char *anon_user; /* E-mail address sent to us */
const char *anon_user; /* Email address sent to us */

char *curr_cmd; /* Current FTP command */
const char *curr_cmd; /* Current FTP command */
int curr_cmd_id; /* Current FTP command ID */
struct cmd_struc *curr_cmd_rec; /* Current command */

Expand All @@ -152,17 +152,17 @@ typedef struct {

int xfer_type; /* xfer session attributes, default/append/hidden */
int direction;
char *filename; /* As shown to user */
char *path; /* As used in transfer */
char *path_hidden; /* As used in hidden stor */
const char *filename; /* As shown to user */
const char *path; /* As used in transfer */
const char *path_hidden; /* As used in hidden stor */

unsigned int bufsize,buflen;
unsigned int bufsize, buflen;

struct timeval start_time; /* Time current transfer started */
off_t file_size; /* Total size of file (if known) */
off_t total_bytes; /* Total bytes transfered */

char *bufstart,*buf;
char *bufstart, *buf;
} xfer;

/* Total number of bytes uploaded in this session. */
Expand Down
7 changes: 3 additions & 4 deletions include/session.h
@@ -1,6 +1,6 @@
/*
* ProFTPD - FTP server daemon
* Copyright (c) 2009-2014 The ProFTPD Project team
* Copyright (c) 2009-2016 The ProFTPD Project team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -25,8 +25,7 @@
#ifndef PR_SESSION_H
#define PR_SESSION_H

/* List of disconnect/end-of-session reason codes.
*/
/* List of disconnect/end-of-session reason codes. */

/* Unknown/unspecified reason for disconnection */
#define PR_SESS_DISCONNECT_UNSPECIFIED 0
Expand Down Expand Up @@ -77,7 +76,7 @@
* the session ended. If a pointer to a char * was provided, any extra
* disconnect details will be provided.
*/
const char *pr_session_get_disconnect_reason(char **details);
const char *pr_session_get_disconnect_reason(const char **details);

/* Returns the current protocol name in use.
*
Expand Down
7 changes: 5 additions & 2 deletions include/str.h
Expand Up @@ -38,7 +38,7 @@
const char *quote_dir(pool *p, char *dir);

char *sstrcat(char *, const char *, size_t);
char *sreplace(pool *, char *, ...);
const char *sreplace(pool *, const char *, ...);

char *pdircat(pool *, ...);
char *pstrcat(pool *, ...);
Expand All @@ -57,8 +57,11 @@ char *pstrndup(pool *, const char *, size_t);
int pr_strnrstr(const char *s, size_t slen, const char *suffix,
size_t suffixlen, int flags);

/* Returns a quoted version of the given string. */
const char *pr_str_quote(pool *p, const char *str);

/* Newer version of sreplace(), with more control and better error reporting. */
char *pr_str_replace(pool *, unsigned int, char *, ...);
const char *pr_str_replace(pool *, unsigned int, const char *, ...);
char *pr_str_strip(pool *, char *);
char *pr_str_strip_end(char *, char *);
int pr_str_get_nbytes(const char *, const char *, off_t *);
Expand Down

0 comments on commit 067c38c

Please sign in to comment.