Use const pointers in function arguments when possible

master
Pavel Roskin 8 years ago
parent bc868b96b1
commit 6fef1e4eb5

@ -82,7 +82,7 @@ list_add_item(struct list *self, tbus item)
/*****************************************************************************/ /*****************************************************************************/
tbus APP_CC tbus APP_CC
list_get_item(struct list *self, int index) list_get_item(const struct list *self, int index)
{ {
if (index < 0 || index >= self->count) if (index < 0 || index >= self->count)
{ {

@ -40,7 +40,7 @@ list_delete(struct list* self);
void APP_CC void APP_CC
list_add_item(struct list* self, tintptr item); list_add_item(struct list* self, tintptr item);
tintptr APP_CC tintptr APP_CC
list_get_item(struct list* self, int index); list_get_item(const struct list *self, int index);
void APP_CC void APP_CC
list_clear(struct list* self); list_clear(struct list* self);
int APP_CC int APP_CC

@ -222,7 +222,7 @@ internal_log_end(struct log_config *l_cfg)
* @return * @return
*/ */
enum logLevels DEFAULT_CC enum logLevels DEFAULT_CC
internal_log_text2level(char *buf) internal_log_text2level(const char *buf)
{ {
if (0 == g_strcasecmp(buf, "0") || if (0 == g_strcasecmp(buf, "0") ||
0 == g_strcasecmp(buf, "core")) 0 == g_strcasecmp(buf, "core"))

@ -113,7 +113,7 @@ internal_log_lvl2str(const enum logLevels lvl, char *str);
* *
*/ */
enum logLevels DEFAULT_CC enum logLevels DEFAULT_CC
internal_log_text2level(char *s); internal_log_text2level(const char *s);
/** /**
* A function that init our struct that holds all state and * A function that init our struct that holds all state and

@ -264,7 +264,7 @@ g_write(const char *format, ...)
/*****************************************************************************/ /*****************************************************************************/
/* produce a hex dump */ /* produce a hex dump */
void APP_CC void APP_CC
g_hexdump(char *p, int len) g_hexdump(const char *p, int len)
{ {
unsigned char *line; unsigned char *line;
int i; int i;
@ -1342,7 +1342,7 @@ g_set_nonblock(int fd)
/*****************************************************************************/ /*****************************************************************************/
/* returns 0 on error */ /* returns 0 on error */
tintptr APP_CC tintptr APP_CC
g_create_wait_obj(char *name) g_create_wait_obj(const char *name)
{ {
#ifdef _WIN32 #ifdef _WIN32
tintptr obj; tintptr obj;

@ -55,7 +55,7 @@ int DEFAULT_CC g_snprintf(char* dest, int len, const char* format, ...) \
printflike(3, 4); printflike(3, 4);
void DEFAULT_CC g_writeln(const char* format, ...) printflike(1, 2); void DEFAULT_CC g_writeln(const char* format, ...) printflike(1, 2);
void DEFAULT_CC g_write(const char* format, ...) printflike(1, 2); void DEFAULT_CC g_write(const char* format, ...) printflike(1, 2);
void APP_CC g_hexdump(char* p, int len); void APP_CC g_hexdump(const char *p, int len);
void APP_CC g_memset(void* ptr, int val, int size); void APP_CC g_memset(void* ptr, int val, int size);
void APP_CC g_memcpy(void* d_ptr, const void* s_ptr, int size); void APP_CC g_memcpy(void* d_ptr, const void* s_ptr, int size);
int APP_CC g_getchar(void); int APP_CC g_getchar(void);
@ -88,7 +88,7 @@ int APP_CC g_sck_can_recv(int sck, int millis);
int APP_CC g_sck_select(int sck1, int sck2); int APP_CC g_sck_select(int sck1, int sck2);
void APP_CC g_write_ip_address(int rcv_sck, char* ip_address, int bytes); void APP_CC g_write_ip_address(int rcv_sck, char* ip_address, int bytes);
void APP_CC g_sleep(int msecs); void APP_CC g_sleep(int msecs);
tintptr APP_CC g_create_wait_obj(char* name); tintptr APP_CC g_create_wait_obj(const char *name);
tintptr APP_CC g_create_wait_obj_from_socket(tintptr socket, int write); tintptr APP_CC g_create_wait_obj_from_socket(tintptr socket, int write);
void APP_CC g_delete_wait_obj_from_socket(tintptr wait_obj); void APP_CC g_delete_wait_obj_from_socket(tintptr wait_obj);
int APP_CC g_set_wait_obj(tintptr obj); int APP_CC g_set_wait_obj(tintptr obj);

@ -30,7 +30,7 @@ extern struct config_sesman *g_cfg; /* in sesman.c */
/******************************************************************************/ /******************************************************************************/
int DEFAULT_CC int DEFAULT_CC
access_login_allowed(char *user) access_login_allowed(const char *user)
{ {
int gid; int gid;
int ok; int ok;
@ -79,7 +79,7 @@ access_login_allowed(char *user)
/******************************************************************************/ /******************************************************************************/
int DEFAULT_CC int DEFAULT_CC
access_login_mng_allowed(char *user) access_login_mng_allowed(const char *user)
{ {
int gid; int gid;
int ok; int ok;

@ -35,7 +35,7 @@
* *
*/ */
int DEFAULT_CC int DEFAULT_CC
access_login_allowed(char* user); access_login_allowed(const char *user);
/** /**
* *
@ -45,6 +45,6 @@ access_login_allowed(char* user);
* *
*/ */
int DEFAULT_CC int DEFAULT_CC
access_login_mng_allowed(char* user); access_login_mng_allowed(const char *user);
#endif #endif

@ -36,7 +36,7 @@
* *
*/ */
long DEFAULT_CC long DEFAULT_CC
auth_userpass(char* user, char* pass, int *errorcode); auth_userpass(const char *user, const char *pass, int *errorcode);
/** /**
* *
@ -94,7 +94,7 @@ auth_set_env(long in_val);
* *
*/ */
int DEFAULT_CC int DEFAULT_CC
auth_check_pwd_chg(char* user); auth_check_pwd_chg(const char *user);
/** /**
* *
@ -104,6 +104,6 @@ auth_check_pwd_chg(char* user);
* *
*/ */
int DEFAULT_CC int DEFAULT_CC
auth_change_pwd(char* user, char* newpwd); auth_change_pwd(const char *user, const char *newpwd);
#endif #endif

@ -34,7 +34,7 @@ extern struct config_sesman *g_cfg; /* in sesman.c */
/******************************************************************************/ /******************************************************************************/
int DEFAULT_CC int DEFAULT_CC
env_check_password_file(char *filename, char *passwd) env_check_password_file(const char *filename, const char *passwd)
{ {
char encryptedPasswd[16]; char encryptedPasswd[16];
char key[24]; char key[24];
@ -83,8 +83,8 @@ env_check_password_file(char *filename, char *passwd)
/******************************************************************************/ /******************************************************************************/
/* its the responsibility of the caller to free passwd_file */ /* its the responsibility of the caller to free passwd_file */
int DEFAULT_CC int DEFAULT_CC
env_set_user(char *username, char **passwd_file, int display, env_set_user(const char *username, char **passwd_file, int display,
struct list *env_names, struct list* env_values) const struct list *env_names, const struct list *env_values)
{ {
int error; int error;
int pw_uid; int pw_uid;

@ -38,7 +38,7 @@
* *
*/ */
int DEFAULT_CC int DEFAULT_CC
env_check_password_file(char* filename, char* password); env_check_password_file(const char *filename, const char *password);
/** /**
* *
@ -50,7 +50,7 @@ env_check_password_file(char* filename, char* password);
* *
*/ */
int DEFAULT_CC int DEFAULT_CC
env_set_user(char* username, char** passwd_file, int display, env_set_user(const char *username, char **passwd_file, int display,
struct list *env_names, struct list* env_values); const struct list *env_names, const struct list *env_values);
#endif #endif

@ -77,7 +77,8 @@ dumpItemsToString(struct list *self, char *outstr, int len)
/******************************************************************************/ /******************************************************************************/
struct session_item *DEFAULT_CC struct session_item *DEFAULT_CC
session_get_bydata(char *name, int width, int height, int bpp, int type, char *client_ip) session_get_bydata(const char *name, int width, int height, int bpp, int type,
const char *client_ip)
{ {
struct session_chain *tmp; struct session_chain *tmp;
enum SESMAN_CFG_SESS_POLICY policy = g_cfg->sess.policy; enum SESMAN_CFG_SESS_POLICY policy = g_cfg->sess.policy;
@ -1016,7 +1017,7 @@ session_get_bypid(int pid)
/******************************************************************************/ /******************************************************************************/
struct SCP_DISCONNECTED_SESSION * struct SCP_DISCONNECTED_SESSION *
session_get_byuser(char *user, int *cnt, unsigned char flags) session_get_byuser(const char *user, int *cnt, unsigned char flags)
{ {
struct session_chain *tmp; struct session_chain *tmp;
struct SCP_DISCONNECTED_SESSION *sess; struct SCP_DISCONNECTED_SESSION *sess;

@ -91,7 +91,8 @@ struct session_chain
* *
*/ */
struct session_item* DEFAULT_CC struct session_item* DEFAULT_CC
session_get_bydata(char* name, int width, int height, int bpp, int type, char *client_ip); session_get_bydata(const char *name, int width, int height, int bpp, int type,
const char *client_ip);
#ifndef session_find_item #ifndef session_find_item
#define session_find_item(a, b, c, d, e, f) session_get_bydata(a, b, c, d, e, f); #define session_find_item(a, b, c, d, e, f) session_get_bydata(a, b, c, d, e, f);
#endif #endif
@ -147,6 +148,6 @@ session_get_bypid(int pid);
* *
*/ */
struct SCP_DISCONNECTED_SESSION* struct SCP_DISCONNECTED_SESSION*
session_get_byuser(char* user, int* cnt, unsigned char flags); session_get_byuser(const char *user, int *cnt, unsigned char flags);
#endif #endif

@ -48,7 +48,7 @@ auth_account_disabled(struct spwd *stp);
/******************************************************************************/ /******************************************************************************/
/* returns boolean */ /* returns boolean */
long DEFAULT_CC long DEFAULT_CC
auth_userpass(char *user, char *pass, int *errorcode) auth_userpass(const char *user, const char *pass, int *errorcode)
{ {
const char *encr; const char *encr;
const char *epass; const char *epass;
@ -125,7 +125,7 @@ auth_set_env(long in_val)
/******************************************************************************/ /******************************************************************************/
int DEFAULT_CC int DEFAULT_CC
auth_check_pwd_chg(char *user) auth_check_pwd_chg(const char *user)
{ {
struct passwd *spw; struct passwd *spw;
struct spwd *stp; struct spwd *stp;
@ -182,7 +182,7 @@ auth_check_pwd_chg(char *user)
} }
int DEFAULT_CC int DEFAULT_CC
auth_change_pwd(char *user, char *newpwd) auth_change_pwd(const char *user, const char *newpwd)
{ {
struct passwd *spw; struct passwd *spw;
struct spwd *stp; struct spwd *stp;

@ -44,7 +44,7 @@ extern struct config_sesman* g_cfg; /* in sesman.c */
/******************************************************************************/ /******************************************************************************/
/* returns boolean */ /* returns boolean */
long DEFAULT_CC long DEFAULT_CC
auth_userpass(char *user, char *pass, int *errorcode) auth_userpass(const char *user, const char *pass, int *errorcode)
{ {
int ret = auth_userokay(user, NULL, "auth-xrdp", pass); int ret = auth_userokay(user, NULL, "auth-xrdp", pass);
return ret; return ret;
@ -74,13 +74,13 @@ auth_set_env(long in_val)
/******************************************************************************/ /******************************************************************************/
int DEFAULT_CC int DEFAULT_CC
auth_check_pwd_chg(char* user) auth_check_pwd_chg(const char *user)
{ {
return 0; return 0;
} }
int DEFAULT_CC int DEFAULT_CC
auth_change_pwd(char* user, char* newpwd) auth_change_pwd(const char *user, const char *newpwd)
{ {
return 0; return 0;
} }

@ -396,7 +396,7 @@ cleanup:
/******************************************************************************/ /******************************************************************************/
/* returns boolean */ /* returns boolean */
int DEFAULT_CC int DEFAULT_CC
auth_userpass(char *user, char *pass, int *errorcode) auth_userpass(const char *user, const char *pass, int *errorcode)
{ {
struct k_opts opts; struct k_opts opts;
struct k5_data k5; struct k5_data k5;

@ -102,7 +102,7 @@ get_service_name(char *service_name)
Stores the detailed error code in the errorcode variable*/ Stores the detailed error code in the errorcode variable*/
long DEFAULT_CC long DEFAULT_CC
auth_userpass(char *user, char *pass, int *errorcode) auth_userpass(const char *user, const char *pass, int *errorcode)
{ {
int error; int error;
struct t_auth_info *auth_info; struct t_auth_info *auth_info;

@ -34,7 +34,7 @@
/******************************************************************************/ /******************************************************************************/
/* returns boolean */ /* returns boolean */
int DEFAULT_CC int DEFAULT_CC
auth_userpass(char *user, char *pass, int *errorcode) auth_userpass(const char *user, const char *pass, int *errorcode)
{ {
pam_handle_t *pamh; pam_handle_t *pamh;
pam_userpass_t userpass; pam_userpass_t userpass;

Loading…
Cancel
Save