1
1

* samba/*: Added many const qualifiers to properly fix the

warnings emitted by gcc with -Wwrite-strings.
	* smbfs.c: Likewise.
Этот коммит содержится в:
Roland Illig 2005-09-07 07:33:39 +00:00
родитель 689ee9f8ae
Коммит 5ddb6be28e
18 изменённых файлов: 119 добавлений и 117 удалений

Просмотреть файл

@ -1,3 +1,9 @@
2005-09-07 Roland Illig <roland.illig@gmx.de>
* samba/*: Added many const qualifiers to properly fix the
warnings emitted by gcc with -Wwrite-strings.
* smbfs.c: Likewise.
2005-09-05 Roland Illig <roland.illig@gmx.de> 2005-09-05 Roland Illig <roland.illig@gmx.de>
* direntry.c: Added const qualifiers to work around gcc * direntry.c: Added const qualifiers to work around gcc

Просмотреть файл

@ -6,13 +6,13 @@
char *unix2dos_format(char *str,BOOL overwrite); char *unix2dos_format(char *str,BOOL overwrite);
char *dos2unix_format(char *str, BOOL overwrite); char *dos2unix_format(char *str, BOOL overwrite);
void interpret_character_set(char *str); void interpret_character_set(const char *str);
/* The following definitions come from lib/charset.c */ /* The following definitions come from lib/charset.c */
void charset_initialise(void); void charset_initialise(void);
void codepage_initialise(int client_codepage); void codepage_initialise(int client_codepage);
void add_char_string(char *s); void add_char_string(const char *s);
/* The following definitions come from lib/debug.c */ /* The following definitions come from lib/debug.c */
@ -36,7 +36,7 @@ struct in_addr *iface_ip(struct in_addr ip);
/* The following definitions come from lib/kanji.c */ /* The following definitions come from lib/kanji.c */
void interpret_coding_system(char *str); void interpret_coding_system(const char *str);
BOOL is_multibyte_codepage(void); BOOL is_multibyte_codepage(void);
void initialize_multibyte_vectors( int client_codepage); void initialize_multibyte_vectors( int client_codepage);
@ -91,14 +91,14 @@ time_t get_create_time(SMB_STRUCT_STAT *st,BOOL fake_dirs);
/* The following definitions come from lib/username.c */ /* The following definitions come from lib/username.c */
char *get_home_dir(char *user); const char *get_home_dir(char *user);
BOOL map_username(char *user); BOOL map_username(const char *user);
struct passwd *Get_Pwnam(char *user,BOOL allow_change); struct passwd *Get_Pwnam(const char *user);
BOOL user_in_list(char *user,char *list); BOOL user_in_list(const char *user,char *list);
/* The following definitions come from lib/util.c */ /* The following definitions come from lib/util.c */
char *tmpdir(void); const char *tmpdir(void);
BOOL in_group(gid_t group, gid_t current_gid, int ngroups, gid_t *groups); BOOL in_group(gid_t group, gid_t current_gid, int ngroups, gid_t *groups);
char *Atoic(char *p, int *n, char *c); char *Atoic(char *p, int *n, char *c);
char *get_numlist(char *p, uint32 **num, int *count); char *get_numlist(char *p, uint32 **num, int *count);
@ -139,8 +139,8 @@ void *Realloc(void *p,size_t size);
BOOL get_myname(char *my_name,struct in_addr *ip); BOOL get_myname(char *my_name,struct in_addr *ip);
BOOL ip_equal(struct in_addr ip1,struct in_addr ip2); BOOL ip_equal(struct in_addr ip1,struct in_addr ip2);
int interpret_protocol(char *str,int def); int interpret_protocol(char *str,int def);
uint32 interpret_addr(char *str); uint32 interpret_addr(const char *str);
struct in_addr *interpret_addr2(char *str); struct in_addr *interpret_addr2(const char *str);
BOOL zero_ip(struct in_addr ip); BOOL zero_ip(struct in_addr ip);
BOOL matchname(char *remotehost,struct in_addr addr); BOOL matchname(char *remotehost,struct in_addr addr);
void standard_sub_basic(char *str); void standard_sub_basic(char *str);
@ -150,7 +150,7 @@ struct hostent *Get_Hostbyname(const char *name);
char *uidtoname(uid_t uid); char *uidtoname(uid_t uid);
char *gidtoname(gid_t gid); char *gidtoname(gid_t gid);
uid_t nametouid(const char *name); uid_t nametouid(const char *name);
void smb_panic(char *why); void smb_panic(const char *why);
char *readdirname(DIR *p); char *readdirname(DIR *p);
BOOL is_in_path(char *name, name_compare_entry *namelist); BOOL is_in_path(char *name, name_compare_entry *namelist);
void set_namearray(name_compare_entry **ppname_array, char *namelist); void set_namearray(name_compare_entry **ppname_array, char *namelist);
@ -207,7 +207,7 @@ char *client_addr(int fd);
/* The following definitions come from lib/util_str.c */ /* The following definitions come from lib/util_str.c */
void set_first_token(char *ptr); void set_first_token(char *ptr);
BOOL next_token(char **ptr,char *buff,char *sep, size_t bufsize); BOOL next_token(char **ptr,char *buff, const char *sep, size_t bufsize);
char **toktocliplist(int *ctok, char *sep); char **toktocliplist(int *ctok, char *sep);
int StrCaseCmp(const char *s, const char *t); int StrCaseCmp(const char *s, const char *t);
int StrnCaseCmp(const char *s, const char *t, size_t n); int StrnCaseCmp(const char *s, const char *t, size_t n);
@ -265,7 +265,7 @@ BOOL cli_session_setup(struct cli_state *cli,
char *workgroup); char *workgroup);
BOOL cli_ulogoff(struct cli_state *cli); BOOL cli_ulogoff(struct cli_state *cli);
BOOL cli_send_tconX(struct cli_state *cli, BOOL cli_send_tconX(struct cli_state *cli,
char *share, char *dev, char *pass, int passlen); const char *share, const char *dev, const char *pass, int passlen);
BOOL cli_tdis(struct cli_state *cli); BOOL cli_tdis(struct cli_state *cli);
BOOL cli_rename(struct cli_state *cli, char *fname_src, char *fname_dst); BOOL cli_rename(struct cli_state *cli, char *fname_src, char *fname_dst);
BOOL cli_unlink(struct cli_state *cli, char *fname); BOOL cli_unlink(struct cli_state *cli, char *fname);
@ -279,9 +279,9 @@ BOOL cli_unlock(struct cli_state *cli, int fnum, uint32 offset, uint32 len, int
size_t cli_read(struct cli_state *cli, int fnum, char *buf, off_t offset, size_t size); size_t cli_read(struct cli_state *cli, int fnum, char *buf, off_t offset, size_t size);
ssize_t cli_write(struct cli_state *cli, ssize_t cli_write(struct cli_state *cli,
int fnum, uint16 write_mode, int fnum, uint16 write_mode,
char *buf, off_t offset, size_t size); const char *buf, off_t offset, size_t size);
ssize_t cli_smbwrite(struct cli_state *cli, ssize_t cli_smbwrite(struct cli_state *cli,
int fnum, char *buf, off_t offset, size_t size); int fnum, const char *buf, off_t offset, size_t size);
BOOL cli_getattrE(struct cli_state *cli, int fd, BOOL cli_getattrE(struct cli_state *cli, int fd,
uint16 *attr, size_t *size, uint16 *attr, size_t *size,
time_t *c_time, time_t *a_time, time_t *m_time); time_t *c_time, time_t *a_time, time_t *m_time);
@ -327,7 +327,7 @@ BOOL cli_dskattr(struct cli_state *cli, int *bsize, int *total, int *avail);
struct in_addr *name_query(int fd,const char *name,int name_type, BOOL bcast,BOOL recurse, struct in_addr *name_query(int fd,const char *name,int name_type, BOOL bcast,BOOL recurse,
struct in_addr to_ip, int *count, void (*fn)(struct packet_struct *)); struct in_addr to_ip, int *count, void (*fn)(struct packet_struct *));
FILE *startlmhosts(char *fname); FILE *startlmhosts(const char *fname);
BOOL getlmhostsent( FILE *fp, pstring name, int *name_type, struct in_addr *ipaddr); BOOL getlmhostsent( FILE *fp, pstring name, int *name_type, struct in_addr *ipaddr);
void endlmhosts(FILE *fp); void endlmhosts(FILE *fp);
BOOL resolve_name(const char *name, struct in_addr *return_ip, int name_type); BOOL resolve_name(const char *name, struct in_addr *return_ip, int name_type);
@ -588,12 +588,12 @@ int lp_minprintspace(int );
int lp_printing(int ); int lp_printing(int );
int lp_oplock_contention_limit(int ); int lp_oplock_contention_limit(int );
char lp_magicchar(int ); char lp_magicchar(int );
BOOL lp_add_home(char *pszHomename, int iDefaultService, char *pszHomedir); BOOL lp_add_home(const char *pszHomename, int iDefaultService, const char *pszHomedir);
int lp_add_service(char *pszService, int iDefaultService); int lp_add_service(char *pszService, int iDefaultService);
BOOL lp_add_printer(char *pszPrintername, int iDefaultService); BOOL lp_add_printer(char *pszPrintername, int iDefaultService);
BOOL lp_file_list_changed(void); BOOL lp_file_list_changed(void);
void *lp_local_ptr(int snum, void *ptr); void *lp_local_ptr(int snum, void *ptr);
BOOL lp_do_parameter(int snum, char *pszParmName, char *pszParmValue); BOOL lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue);
BOOL lp_is_default(int snum, struct parm_struct *parm); BOOL lp_is_default(int snum, struct parm_struct *parm);
struct parm_struct *lp_next_parameter(int snum, int *i, int allparameters); struct parm_struct *lp_next_parameter(int snum, int *i, int allparameters);
BOOL lp_snum_ok(int iService); BOOL lp_snum_ok(int iService);
@ -603,7 +603,7 @@ void lp_killunused(BOOL (*snumused)(int ));
BOOL lp_load(const char *pszFname,BOOL global_only, BOOL save_defaults, BOOL add_ipc); BOOL lp_load(const char *pszFname,BOOL global_only, BOOL save_defaults, BOOL add_ipc);
void lp_resetnumservices(void); void lp_resetnumservices(void);
int lp_numservices(void); int lp_numservices(void);
int lp_servicenumber(char *pszServiceName); int lp_servicenumber(const char *pszServiceName);
char *volume_label(int snum); char *volume_label(int snum);
int lp_default_server_announce(void); int lp_default_server_announce(void);
int lp_major_announce_version(void); int lp_major_announce_version(void);
@ -614,7 +614,7 @@ BOOL lp_kernel_oplocks(void);
/* The following definitions come from param/params.c */ /* The following definitions come from param/params.c */
BOOL pm_process( char *FileName, BOOL pm_process( const char *FileName,
BOOL (*sfunc)(char *), BOOL (*sfunc)(const char *),
BOOL (*pfunc)(char *, char *) ); BOOL (*pfunc)(const char *, const char *) );
#endif /* _PROTO_H_ */ #endif /* _PROTO_H_ */

Просмотреть файл

@ -69,7 +69,7 @@ typedef int BOOL;
arguemnts to DEBUG() right. We have got them wrong too often in the arguemnts to DEBUG() right. We have got them wrong too often in the
past */ past */
#ifdef HAVE_STDARG_H #ifdef HAVE_STDARG_H
int Debug1( char *, ... ) int Debug1( const char *, ... )
#ifdef __GNUC__ #ifdef __GNUC__
__attribute__ ((format (printf, 1, 2))) __attribute__ ((format (printf, 1, 2)))
#endif #endif
@ -874,7 +874,7 @@ struct parm_struct
parm_type type; parm_type type;
parm_class class; parm_class class;
void *ptr; void *ptr;
BOOL (*special)(char *, char **); BOOL (*special)(const char *, char **);
const struct enum_list *enum_list; const struct enum_list *enum_list;
unsigned flags; unsigned flags;
union { union {

Просмотреть файл

@ -216,7 +216,7 @@ char *dos2unix_format(char *str, BOOL overwrite)
/* /*
* Interpret character set. * Interpret character set.
*/ */
void interpret_character_set(char *str) void interpret_character_set(const char *str)
{ {
if (strequal (str, "iso8859-1")) { if (strequal (str, "iso8859-1")) {
init_iso8859_1(); init_iso8859_1();

Просмотреть файл

@ -374,7 +374,7 @@ for code page %d failed. Using default client codepage 850\n",
/******************************************************************* /*******************************************************************
add characters depending on a string passed by the user add characters depending on a string passed by the user
********************************************************************/ ********************************************************************/
void add_char_string(char *s) void add_char_string(const char *s)
{ {
char *extra_chars = (char *)strdup(s); char *extra_chars = (char *)strdup(s);
char *t; char *t;

Просмотреть файл

@ -131,13 +131,13 @@ void setup_logging( const char *pname, BOOL interactive )
* ************************************************************************** ** * ************************************************************************** **
*/ */
#ifdef HAVE_STDARG_H #ifdef HAVE_STDARG_H
int Debug1( char *format_str, ... ) int Debug1( const char *format_str, ... )
{ {
#else #else
int Debug1(va_alist) int Debug1(va_alist)
va_dcl va_dcl
{ {
char *format_str; const char *format_str;
#endif #endif
va_list ap; va_list ap;
int old_errno = errno; int old_errno = errno;
@ -148,7 +148,7 @@ va_dcl
va_start( ap, format_str ); va_start( ap, format_str );
#else #else
va_start( ap ); va_start( ap );
format_str = va_arg( ap, char * ); format_str = va_arg( ap, const char * );
#endif #endif
(void)vfprintf( dbf, format_str, ap ); (void)vfprintf( dbf, format_str, ap );
va_end( ap ); va_end( ap );
@ -182,7 +182,7 @@ va_dcl
va_start( ap, format_str ); va_start( ap, format_str );
#else #else
va_start( ap ); va_start( ap );
format_str = va_arg( ap, char * ); format_str = va_arg( ap, const char * );
#endif #endif
(void)vfprintf( dbf, format_str, ap ); (void)vfprintf( dbf, format_str, ap );
va_end( ap ); va_end( ap );

Просмотреть файл

@ -124,7 +124,7 @@ static void get_broadcast(struct in_addr *if_ipaddr,
load a list of network interfaces load a list of network interfaces
****************************************************************************/ ****************************************************************************/
static void interpret_interfaces(char *s, struct interface **interfaces, static void interpret_interfaces(char *s, struct interface **interfaces,
char *description) const char *description)
{ {
char *ptr; char *ptr;
fstring token; fstring token;

Просмотреть файл

@ -1046,7 +1046,7 @@ static void setup_string_function(int codes)
Interpret coding system. Interpret coding system.
************************************************************************/ ************************************************************************/
void interpret_coding_system(char *str) void interpret_coding_system(const char *str)
{ {
int codes = UNKNOWN_CODE; int codes = UNKNOWN_CODE;

Просмотреть файл

@ -23,17 +23,17 @@
extern int DEBUGLEVEL; extern int DEBUGLEVEL;
/* internal functions */ /* internal functions */
static struct passwd *uname_string_combinations(char *s, struct passwd * (*fn) (char *), int N); static struct passwd *uname_string_combinations(char *s, struct passwd * (*fn) (const char *), int N);
static struct passwd *uname_string_combinations2(char *s, int offset, struct passwd * (*fn) (char *), int N); static struct passwd *uname_string_combinations2(char *s, int offset, struct passwd * (*fn) (const char *), int N);
/**************************************************************************** /****************************************************************************
get a users home directory. get a users home directory.
****************************************************************************/ ****************************************************************************/
char *get_home_dir(char *user) const char *get_home_dir(char *user)
{ {
struct passwd *pass; struct passwd *pass;
pass = Get_Pwnam(user, False); pass = Get_Pwnam(user);
if (!pass) return(NULL); if (!pass) return(NULL);
return(pass->pw_dir); return(pass->pw_dir);
@ -51,7 +51,7 @@ function. Previously, the map_username was being called
every time Get_Pwnam was called. every time Get_Pwnam was called.
Returns True if username was changed, false otherwise. Returns True if username was changed, false otherwise.
********************************************************************/ ********************************************************************/
BOOL map_username(char *user) BOOL map_username(const char *user)
{ {
static BOOL initialised=False; static BOOL initialised=False;
static fstring last_from,last_to; static fstring last_from,last_to;
@ -148,7 +148,7 @@ BOOL map_username(char *user)
/**************************************************************************** /****************************************************************************
Get_Pwnam wrapper Get_Pwnam wrapper
****************************************************************************/ ****************************************************************************/
static struct passwd *_Get_Pwnam(char *s) static struct passwd *_Get_Pwnam(const char *s)
{ {
struct passwd *ret; struct passwd *ret;
@ -174,24 +174,19 @@ static struct passwd *_Get_Pwnam(char *s)
/**************************************************************************** /****************************************************************************
a wrapper for getpwnam() that tries with all lower and all upper case a wrapper for getpwnam() that tries with all lower and all upper case
if the initial name fails. Also tried with first letter capitalised if the initial name fails. Also tried with first letter capitalised
Note that this can change user!
****************************************************************************/ ****************************************************************************/
struct passwd *Get_Pwnam(char *user,BOOL allow_change) struct passwd *Get_Pwnam(const char *a_user)
{ {
fstring user2; fstring user;
int last_char; int last_char;
int usernamelevel = lp_usernamelevel(); int usernamelevel = lp_usernamelevel();
struct passwd *ret; struct passwd *ret;
if (!user || !(*user)) if (!a_user || !(*a_user))
return(NULL); return(NULL);
StrnCpy(user2,user,sizeof(user2)-1); StrnCpy(user,a_user,sizeof(user)-1);
if (!allow_change) {
user = &user2[0];
}
ret = _Get_Pwnam(user); ret = _Get_Pwnam(user);
if (ret) return(ret); if (ret) return(ret);
@ -222,9 +217,6 @@ struct passwd *Get_Pwnam(char *user,BOOL allow_change)
ret = uname_string_combinations(user, _Get_Pwnam, usernamelevel); ret = uname_string_combinations(user, _Get_Pwnam, usernamelevel);
if (ret) return(ret); if (ret) return(ret);
if (allow_change)
fstrcpy(user,user2);
return(NULL); return(NULL);
} }
@ -379,7 +371,7 @@ try all combinations with N uppercase letters.
offset is the first char to try and change (start with 0) offset is the first char to try and change (start with 0)
it assumes the string starts lowercased it assumes the string starts lowercased
****************************************************************************/ ****************************************************************************/
static struct passwd *uname_string_combinations2(char *s,int offset,struct passwd *(*fn)(char *),int N) static struct passwd *uname_string_combinations2(char *s,int offset,struct passwd *(*fn)(const char *),int N)
{ {
int len = strlen(s); int len = strlen(s);
int i; int i;
@ -413,7 +405,7 @@ try all combinations with up to N uppercase letters.
offset is the first char to try and change (start with 0) offset is the first char to try and change (start with 0)
it assumes the string starts lowercased it assumes the string starts lowercased
****************************************************************************/ ****************************************************************************/
static struct passwd * uname_string_combinations(char *s,struct passwd * (*fn)(char *),int N) static struct passwd * uname_string_combinations(char *s,struct passwd * (*fn)(const char *),int N)
{ {
int n; int n;
struct passwd *ret; struct passwd *ret;

Просмотреть файл

@ -101,7 +101,7 @@ pstring myhostname="";
pstring user_socket_options=""; pstring user_socket_options="";
pstring sesssetup_user=""; pstring sesssetup_user="";
static char * const samlogon_user = ""; static const char * const samlogon_user = "";
const BOOL sam_logon_in_ssb = False; const BOOL sam_logon_in_ssb = False;
@ -115,7 +115,7 @@ char **my_netbios_names;
find a suitable temporary directory. The result should be copied immediately find a suitable temporary directory. The result should be copied immediately
as it may be overwritten by a subsequent call as it may be overwritten by a subsequent call
****************************************************************************/ ****************************************************************************/
char *tmpdir(void) const char *tmpdir(void)
{ {
char *p; char *p;
if ((p = getenv("MC_TMPDIR")) || (p = getenv("TMPDIR"))) { if ((p = getenv("MC_TMPDIR")) || (p = getenv("TMPDIR"))) {
@ -1748,7 +1748,7 @@ int interpret_protocol(char *str,int def)
/**************************************************************************** /****************************************************************************
interpret an internet address or name into an IP address in 4 byte form interpret an internet address or name into an IP address in 4 byte form
****************************************************************************/ ****************************************************************************/
uint32 interpret_addr(char *str) uint32 interpret_addr(const char *str)
{ {
struct hostent *hp; struct hostent *hp;
uint32 res; uint32 res;
@ -1787,7 +1787,7 @@ uint32 interpret_addr(char *str)
/******************************************************************* /*******************************************************************
a convenient addition to interpret_addr() a convenient addition to interpret_addr()
******************************************************************/ ******************************************************************/
struct in_addr *interpret_addr2(char *str) struct in_addr *interpret_addr2(const char *str)
{ {
static struct in_addr ret; static struct in_addr ret;
uint32 a = interpret_addr(str); uint32 a = interpret_addr(str);
@ -1991,7 +1991,7 @@ static char *automount_lookup(char *user_name)
This is Luke's original function with the NIS lookup code This is Luke's original function with the NIS lookup code
moved out to a separate function. moved out to a separate function.
*******************************************************************/ *******************************************************************/
static char *automount_server(char *user_name) static char *automount_server(const char *user_name)
{ {
static pstring server_name; static pstring server_name;
@ -2066,7 +2066,7 @@ void standard_sub_basic(char *str)
char *s, *p; char *s, *p;
char pidstr[10]; char pidstr[10];
struct passwd *pass; struct passwd *pass;
char *username = sam_logon_in_ssb ? samlogon_user : sesssetup_user; const char *username = sam_logon_in_ssb ? samlogon_user : sesssetup_user;
for (s = str ; s && *s && (p = strchr(s,'%')); s = p ) for (s = str ; s && *s && (p = strchr(s,'%')); s = p )
{ {
@ -2074,7 +2074,7 @@ void standard_sub_basic(char *str)
{ {
case 'G' : case 'G' :
{ {
if ((pass = Get_Pwnam(username,False))!=NULL) if ((pass = Get_Pwnam(username))!=NULL)
{ {
string_sub(p,"%G",gidtoname(pass->pw_gid)); string_sub(p,"%G",gidtoname(pass->pw_gid));
} }
@ -2154,7 +2154,8 @@ do some standard substitutions in a string
****************************************************************************/ ****************************************************************************/
void standard_sub(connection_struct *conn,char *str) void standard_sub(connection_struct *conn,char *str)
{ {
char *p, *s, *home; char *p, *s;
const char *home;
for (s=str; (p=strchr(s, '%'));s=p) { for (s=str; (p=strchr(s, '%'));s=p) {
switch (*(p+1)) { switch (*(p+1)) {
@ -2324,9 +2325,9 @@ uid_t nametouid(const char *name)
/******************************************************************* /*******************************************************************
something really nasty happened - panic! something really nasty happened - panic!
********************************************************************/ ********************************************************************/
void smb_panic(char *why) void smb_panic(const char *why)
{ {
char *cmd = lp_panic_action(); const char *cmd = lp_panic_action();
if (cmd && *cmd) { if (cmd && *cmd) {
system(cmd); system(cmd);
} }

Просмотреть файл

@ -61,7 +61,7 @@ enum SOCK_OPT_TYPES {OPT_BOOL,OPT_INT,OPT_ON};
static const struct static const struct
{ {
char *name; const char *name;
int level; int level;
int option; int option;
int value; int value;

Просмотреть файл

@ -36,7 +36,7 @@ void set_first_token(char *ptr)
Based on a routine by GJC@VILLAGE.COM. Based on a routine by GJC@VILLAGE.COM.
Extensively modified by Andrew.Tridgell@anu.edu.au Extensively modified by Andrew.Tridgell@anu.edu.au
****************************************************************************/ ****************************************************************************/
BOOL next_token(char **ptr,char *buff,char *sep, size_t bufsize) BOOL next_token(char **ptr,char *buff, const char *sep, size_t bufsize)
{ {
char *s; char *s;
BOOL quoted; BOOL quoted;

Просмотреть файл

@ -87,7 +87,7 @@ static BOOL cli_send_smb(struct cli_state *cli)
struct struct
{ {
int err; int err;
char *message; const char *message;
} const rap_errmap[] = } const rap_errmap[] =
{ {
{5, "User has insufficient privilege" }, {5, "User has insufficient privilege" },
@ -218,7 +218,7 @@ static char *fix_char_ptr(unsigned int datap, unsigned int converter,
send a SMB trans or trans2 request send a SMB trans or trans2 request
****************************************************************************/ ****************************************************************************/
static BOOL cli_send_trans(struct cli_state *cli, int trans, static BOOL cli_send_trans(struct cli_state *cli, int trans,
char *name, int pipe_name_len, const char *name, int pipe_name_len,
int fid, int flags, int fid, int flags,
uint16 *setup, int lsetup, int msetup, uint16 *setup, int lsetup, int msetup,
char *param, int lparam, int mparam, char *param, int lparam, int mparam,
@ -581,7 +581,7 @@ int cli_RNetShareEnum(struct cli_state *cli, void (*fn)(const char *, uint32, co
char *sname = p; char *sname = p;
int type = SVAL(p,14); int type = SVAL(p,14);
int comment_offset = IVAL(p,16) & 0xFFFF; int comment_offset = IVAL(p,16) & 0xFFFF;
char *cmnt = comment_offset?(rdata+comment_offset-converter):""; const char *cmnt = comment_offset?(rdata+comment_offset-converter):"";
fn(sname, type, cmnt, state); fn(sname, type, cmnt, state);
} }
} else { } else {
@ -654,7 +654,7 @@ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype,
for (i = 0;i < count;i++, p += 26) { for (i = 0;i < count;i++, p += 26) {
char *sname = p; char *sname = p;
int comment_offset = (IVAL(p,22) & 0xFFFF)-converter; int comment_offset = (IVAL(p,22) & 0xFFFF)-converter;
char *cmnt = comment_offset?(rdata+comment_offset):""; const char *cmnt = comment_offset?(rdata+comment_offset):"";
if (comment_offset < 0 || comment_offset > rdrcnt) continue; if (comment_offset < 0 || comment_offset > rdrcnt) continue;
stype = IVAL(p,18) & ~SV_TYPE_LOCAL_LIST_ONLY; stype = IVAL(p,18) & ~SV_TYPE_LOCAL_LIST_ONLY;
@ -677,7 +677,7 @@ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype,
static struct { static struct {
int prot; int prot;
char *name; const char *name;
} }
const prots[] = const prots[] =
{ {
@ -847,7 +847,7 @@ BOOL cli_ulogoff(struct cli_state *cli)
send a tconX send a tconX
****************************************************************************/ ****************************************************************************/
BOOL cli_send_tconX(struct cli_state *cli, BOOL cli_send_tconX(struct cli_state *cli,
char *share, char *dev, char *pass, int passlen) const char *share, const char *dev, const char *pass, int passlen)
{ {
fstring fullshare, pword; fstring fullshare, pword;
char *p; char *p;
@ -1408,7 +1408,7 @@ size_t cli_read(struct cli_state *cli, int fnum, char *buf, off_t offset, size_t
/**************************************************************************** /****************************************************************************
issue a single SMBwrite and don't wait for a reply issue a single SMBwrite and don't wait for a reply
****************************************************************************/ ****************************************************************************/
static void cli_issue_write(struct cli_state *cli, int fnum, off_t offset, uint16 mode, char *buf, static void cli_issue_write(struct cli_state *cli, int fnum, off_t offset, uint16 mode, const char *buf,
size_t size, int i) size_t size, int i)
{ {
char *p; char *p;
@ -1452,7 +1452,7 @@ static void cli_issue_write(struct cli_state *cli, int fnum, off_t offset, uint1
****************************************************************************/ ****************************************************************************/
ssize_t cli_write(struct cli_state *cli, ssize_t cli_write(struct cli_state *cli,
int fnum, uint16 write_mode, int fnum, uint16 write_mode,
char *buf, off_t offset, size_t size) const char *buf, off_t offset, size_t size)
{ {
int bwritten = 0; int bwritten = 0;
int issued = 0; int issued = 0;
@ -1503,7 +1503,7 @@ ssize_t cli_write(struct cli_state *cli,
write to a file using a SMBwrite and not bypassing 0 byte writes write to a file using a SMBwrite and not bypassing 0 byte writes
****************************************************************************/ ****************************************************************************/
ssize_t cli_smbwrite(struct cli_state *cli, ssize_t cli_smbwrite(struct cli_state *cli,
int fnum, char *buf, off_t offset, size_t size) int fnum, const char *buf, off_t offset, size_t size)
{ {
char *p; char *p;

Просмотреть файл

@ -223,7 +223,7 @@ struct in_addr *name_query(int fd,const char *name,int name_type, BOOL bcast,BOO
Start parsing the lmhosts file. Start parsing the lmhosts file.
*********************************************************/ *********************************************************/
FILE *startlmhosts(char *fname) FILE *startlmhosts(const char *fname)
{ {
FILE *fp = sys_fopen(fname,"r"); FILE *fp = sys_fopen(fname,"r");
if (!fp) { if (!fp) {
@ -347,7 +347,8 @@ static BOOL resolve_bcast(const char *name, struct in_addr *return_ip, int name_
struct in_addr *iplist = NULL; struct in_addr *iplist = NULL;
int count; int count;
int num_interfaces = iface_count(); int num_interfaces = iface_count();
set_socket_options(sock,"SO_BROADCAST"); static char so_broadcast[] = "SO_BROADCAST";
set_socket_options(sock, so_broadcast);
/* /*
* Lookup the name on all the interfaces, return on * Lookup the name on all the interfaces, return on
* the first successful match. * the first successful match.
@ -508,8 +509,9 @@ BOOL resolve_name(const char *name, struct in_addr *return_ip, int name_type)
} }
pstrcpy(name_resolve_list, lp_name_resolve_order()); pstrcpy(name_resolve_list, lp_name_resolve_order());
if (!name_resolve_list || !*name_resolve_list)
pstrcpy(name_resolve_list, "host");
ptr = name_resolve_list; ptr = name_resolve_list;
if (!ptr || !*ptr) ptr = "host";
while (next_token(&ptr, tok, LIST_SEP, sizeof(tok))) { while (next_token(&ptr, tok, LIST_SEP, sizeof(tok))) {
if((strequal(tok, "host") || strequal(tok, "hosts"))) { if((strequal(tok, "host") || strequal(tok, "hosts"))) {

Просмотреть файл

@ -28,7 +28,7 @@ int num_good_sends = 0;
int num_good_receives = 0; int num_good_receives = 0;
static struct opcode_names { static struct opcode_names {
char *nmb_opcode_name; const char *nmb_opcode_name;
int opcode; int opcode;
} const nmb_header_opcode_names[] = { } const nmb_header_opcode_names[] = {
{"Query", 0 }, {"Query", 0 },
@ -44,7 +44,7 @@ static struct opcode_names {
/**************************************************************************** /****************************************************************************
* Lookup a nmb opcode name. * Lookup a nmb opcode name.
****************************************************************************/ ****************************************************************************/
static char *lookup_opcode_name( int opcode ) static const char *lookup_opcode_name( int opcode )
{ {
const struct opcode_names *op_namep = nmb_header_opcode_names; const struct opcode_names *op_namep = nmb_header_opcode_names;
@ -59,7 +59,7 @@ static char *lookup_opcode_name( int opcode )
/**************************************************************************** /****************************************************************************
print out a res_rec structure print out a res_rec structure
****************************************************************************/ ****************************************************************************/
static void debug_nmb_res_rec(struct res_rec *res, char *hdr) static void debug_nmb_res_rec(struct res_rec *res, const char *hdr)
{ {
int i, j; int i, j;

Просмотреть файл

@ -450,11 +450,11 @@ static int default_server_announce;
#define NUMPARAMETERS (sizeof(parm_table) / sizeof(struct parm_struct)) #define NUMPARAMETERS (sizeof(parm_table) / sizeof(struct parm_struct))
/* prototypes for the special type handlers */ /* prototypes for the special type handlers */
static BOOL handle_valid_chars(char *pszParmValue, char **ptr); static BOOL handle_valid_chars(const char *pszParmValue, char **ptr);
static BOOL handle_include(char *pszParmValue, char **ptr); static BOOL handle_include(const char *pszParmValue, char **ptr);
static BOOL handle_copy(char *pszParmValue, char **ptr); static BOOL handle_copy(const char *pszParmValue, char **ptr);
static BOOL handle_character_set(char *pszParmValue,char **ptr); static BOOL handle_character_set(const char *pszParmValue,char **ptr);
static BOOL handle_coding_system(char *pszParmValue,char **ptr); static BOOL handle_coding_system(const char *pszParmValue,char **ptr);
#if 0 #if 0
static void set_default_server_announce_type(void); static void set_default_server_announce_type(void);
#endif /* 0 */ #endif /* 0 */
@ -1291,15 +1291,15 @@ FN_LOCAL_CHAR(lp_magicchar,magic_char)
/* local prototypes */ /* local prototypes */
static int strwicmp( const char *psz1, const char *psz2 ); static int strwicmp( const char *psz1, const char *psz2 );
static int map_parameter( char *pszParmName); static int map_parameter( const char *pszParmName);
static BOOL set_boolean( BOOL *pb, char *pszParmValue ); static BOOL set_boolean( BOOL *pb, const char *pszParmValue );
static int getservicebyname(char *pszServiceName, service *pserviceDest); static int getservicebyname(const char *pszServiceName, service *pserviceDest);
static void copy_service( service *pserviceDest, static void copy_service( service *pserviceDest,
service *pserviceSource, service *pserviceSource,
BOOL *pcopymapDest ); BOOL *pcopymapDest );
static BOOL service_ok(int iService); static BOOL service_ok(int iService);
static BOOL do_parameter(char *pszParmName, char *pszParmValue); static BOOL do_parameter(const char *pszParmName, const char *pszParmValue);
static BOOL do_section(char *pszSectionName); static BOOL do_section(const char *pszSectionName);
static void init_copymap(service *pservice); static void init_copymap(service *pservice);
@ -1343,7 +1343,7 @@ static void free_service(service *pservice)
add a new service to the services array initialising it with the given add a new service to the services array initialising it with the given
service service
***************************************************************************/ ***************************************************************************/
static int add_a_service(service *pservice, char *name) static int add_a_service(service *pservice, const char *name)
{ {
int i; int i;
service tservice; service tservice;
@ -1393,7 +1393,7 @@ static int add_a_service(service *pservice, char *name)
add a new home service, with the specified home directory, defaults coming add a new home service, with the specified home directory, defaults coming
from service ifrom from service ifrom
***************************************************************************/ ***************************************************************************/
BOOL lp_add_home(char *pszHomename, int iDefaultService, char *pszHomedir) BOOL lp_add_home(const char *pszHomename, int iDefaultService, const char *pszHomedir)
{ {
int i = add_a_service(pSERVICE(iDefaultService),pszHomename); int i = add_a_service(pSERVICE(iDefaultService),pszHomename);
@ -1494,7 +1494,7 @@ static int strwicmp(const char *psz1, const char *psz2)
Map a parameter's string representation to something we can use. Map a parameter's string representation to something we can use.
Returns False if the parameter string is not recognised, else TRUE. Returns False if the parameter string is not recognised, else TRUE.
***************************************************************************/ ***************************************************************************/
static int map_parameter(char *pszParmName) static int map_parameter(const char *pszParmName)
{ {
int iIndex; int iIndex;
@ -1515,7 +1515,7 @@ Set a boolean variable from the text value stored in the passed string.
Returns True in success, False if the passed string does not correctly Returns True in success, False if the passed string does not correctly
represent a boolean. represent a boolean.
***************************************************************************/ ***************************************************************************/
static BOOL set_boolean(BOOL *pb, char *pszParmValue) static BOOL set_boolean(BOOL *pb, const char *pszParmValue)
{ {
BOOL bRetval; BOOL bRetval;
@ -1541,7 +1541,7 @@ static BOOL set_boolean(BOOL *pb, char *pszParmValue)
/*************************************************************************** /***************************************************************************
Find a service by name. Otherwise works like get_service. Find a service by name. Otherwise works like get_service.
***************************************************************************/ ***************************************************************************/
static int getservicebyname(char *pszServiceName, service *pserviceDest) static int getservicebyname(const char *pszServiceName, service *pserviceDest)
{ {
int iService; int iService;
@ -1740,7 +1740,7 @@ BOOL lp_file_list_changed(void)
/*************************************************************************** /***************************************************************************
handle the interpretation of the coding system parameter handle the interpretation of the coding system parameter
*************************************************************************/ *************************************************************************/
static BOOL handle_coding_system(char *pszParmValue,char **ptr) static BOOL handle_coding_system(const char *pszParmValue,char **ptr)
{ {
string_set(ptr,pszParmValue); string_set(ptr,pszParmValue);
interpret_coding_system(pszParmValue); interpret_coding_system(pszParmValue);
@ -1750,7 +1750,7 @@ static BOOL handle_coding_system(char *pszParmValue,char **ptr)
/*************************************************************************** /***************************************************************************
handle the interpretation of the character set system parameter handle the interpretation of the character set system parameter
***************************************************************************/ ***************************************************************************/
static BOOL handle_character_set(char *pszParmValue,char **ptr) static BOOL handle_character_set(const char *pszParmValue,char **ptr)
{ {
string_set(ptr,pszParmValue); string_set(ptr,pszParmValue);
interpret_character_set(pszParmValue); interpret_character_set(pszParmValue);
@ -1761,7 +1761,7 @@ static BOOL handle_character_set(char *pszParmValue,char **ptr)
/*************************************************************************** /***************************************************************************
handle the valid chars lines handle the valid chars lines
***************************************************************************/ ***************************************************************************/
static BOOL handle_valid_chars(char *pszParmValue,char **ptr) static BOOL handle_valid_chars(const char *pszParmValue,char **ptr)
{ {
string_set(ptr,pszParmValue); string_set(ptr,pszParmValue);
@ -1779,7 +1779,7 @@ static BOOL handle_valid_chars(char *pszParmValue,char **ptr)
/*************************************************************************** /***************************************************************************
handle the include operation handle the include operation
***************************************************************************/ ***************************************************************************/
static BOOL handle_include(char *pszParmValue,char **ptr) static BOOL handle_include(const char *pszParmValue,char **ptr)
{ {
pstring fname; pstring fname;
pstrcpy(fname,pszParmValue); pstrcpy(fname,pszParmValue);
@ -1802,7 +1802,7 @@ static BOOL handle_include(char *pszParmValue,char **ptr)
/*************************************************************************** /***************************************************************************
handle the interpretation of the copy parameter handle the interpretation of the copy parameter
***************************************************************************/ ***************************************************************************/
static BOOL handle_copy(char *pszParmValue,char **ptr) static BOOL handle_copy(const char *pszParmValue,char **ptr)
{ {
BOOL bRetval; BOOL bRetval;
int iTemp; int iTemp;
@ -1872,7 +1872,7 @@ void *lp_local_ptr(int snum, void *ptr)
Process a parameter for a particular service number. If snum < 0 Process a parameter for a particular service number. If snum < 0
then assume we are in the globals then assume we are in the globals
***************************************************************************/ ***************************************************************************/
BOOL lp_do_parameter(int snum, char *pszParmName, char *pszParmValue) BOOL lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue)
{ {
int parmnum, i; int parmnum, i;
void *parm_ptr=NULL; /* where we are going to store the result */ void *parm_ptr=NULL; /* where we are going to store the result */
@ -1981,7 +1981,7 @@ BOOL lp_do_parameter(int snum, char *pszParmName, char *pszParmValue)
/*************************************************************************** /***************************************************************************
Process a parameter. Process a parameter.
***************************************************************************/ ***************************************************************************/
static BOOL do_parameter( char *pszParmName, char *pszParmValue ) static BOOL do_parameter( const char *pszParmName, const char *pszParmValue )
{ {
if( !bInGlobalSection && bGlobalOnly ) if( !bInGlobalSection && bGlobalOnly )
return(True); return(True);
@ -2041,7 +2041,7 @@ Process a new section (service). At this stage all sections are services.
Later we'll have special sections that permit server parameters to be set. Later we'll have special sections that permit server parameters to be set.
Returns True on success, False on failure. Returns True on success, False on failure.
***************************************************************************/ ***************************************************************************/
static BOOL do_section(char *pszSectionName) static BOOL do_section(const char *pszSectionName)
{ {
BOOL bRetval; BOOL bRetval;
BOOL isglobal = ((strwicmp(pszSectionName, GLOBAL_NAME) == 0) || BOOL isglobal = ((strwicmp(pszSectionName, GLOBAL_NAME) == 0) ||
@ -2177,7 +2177,7 @@ static void lp_add_auto_services(char *str)
homes = lp_servicenumber(HOMES_NAME); homes = lp_servicenumber(HOMES_NAME);
for (p=strtok(s,LIST_SEP);p;p=strtok(NULL,LIST_SEP)) { for (p=strtok(s,LIST_SEP);p;p=strtok(NULL,LIST_SEP)) {
char *home = get_home_dir(p); const char *home = get_home_dir(p);
if (lp_servicenumber(p) >= 0) continue; if (lp_servicenumber(p) >= 0) continue;
@ -2340,7 +2340,7 @@ exist. Note that this is a DIFFERENT ANIMAL from the internal function
getservicebyname()! This works ONLY if all services have been loaded, and getservicebyname()! This works ONLY if all services have been loaded, and
does not copy the found service. does not copy the found service.
***************************************************************************/ ***************************************************************************/
int lp_servicenumber(char *pszServiceName) int lp_servicenumber(const char *pszServiceName)
{ {
int iService; int iService;

Просмотреть файл

@ -181,7 +181,7 @@ static int Continuation( char *line, int pos )
} /* Continuation */ } /* Continuation */
static BOOL Section( FILE *InFile, BOOL (*sfunc)(char *) ) static BOOL Section( FILE *InFile, BOOL (*sfunc)(const char *) )
/* ------------------------------------------------------------------------ ** /* ------------------------------------------------------------------------ **
* Scan a section name, and pass the name to function sfunc(). * Scan a section name, and pass the name to function sfunc().
* *
@ -199,7 +199,7 @@ static BOOL Section( FILE *InFile, BOOL (*sfunc)(char *) )
int c; int c;
int i; int i;
int end; int end;
char *func = "params.c:Section() -"; const char *func = "params.c:Section() -";
i = 0; /* <i> is the offset of the next free byte in bufr[] and */ i = 0; /* <i> is the offset of the next free byte in bufr[] and */
end = 0; /* <end> is the current "end of string" offset. In most */ end = 0; /* <end> is the current "end of string" offset. In most */
@ -274,7 +274,7 @@ static BOOL Section( FILE *InFile, BOOL (*sfunc)(char *) )
return( False ); return( False );
} /* Section */ } /* Section */
static BOOL Parameter( FILE *InFile, BOOL (*pfunc)(char *, char *), int c ) static BOOL Parameter( FILE *InFile, BOOL (*pfunc)(const char *, const char *), int c )
/* ------------------------------------------------------------------------ ** /* ------------------------------------------------------------------------ **
* Scan a parameter name and value, and pass these two fields to pfunc(). * Scan a parameter name and value, and pass these two fields to pfunc().
* *
@ -302,7 +302,7 @@ static BOOL Parameter( FILE *InFile, BOOL (*pfunc)(char *, char *), int c )
int i = 0; /* Position within bufr. */ int i = 0; /* Position within bufr. */
int end = 0; /* bufr[end] is current end-of-string. */ int end = 0; /* bufr[end] is current end-of-string. */
int vstart = 0; /* Starting position of the parameter value. */ int vstart = 0; /* Starting position of the parameter value. */
char *func = "params.c:Parameter() -"; const char *func = "params.c:Parameter() -";
/* Read the parameter name. */ /* Read the parameter name. */
while( 0 == vstart ) /* Loop until we've found the start of the value. */ while( 0 == vstart ) /* Loop until we've found the start of the value. */
@ -416,8 +416,8 @@ static BOOL Parameter( FILE *InFile, BOOL (*pfunc)(char *, char *), int c )
} /* Parameter */ } /* Parameter */
static BOOL Parse( FILE *InFile, static BOOL Parse( FILE *InFile,
BOOL (*sfunc)(char *), BOOL (*sfunc)(const char *),
BOOL (*pfunc)(char *, char *) ) BOOL (*pfunc)(const char *, const char *) )
/* ------------------------------------------------------------------------ ** /* ------------------------------------------------------------------------ **
* Scan & parse the input. * Scan & parse the input.
* *
@ -476,7 +476,7 @@ static BOOL Parse( FILE *InFile,
return( True ); return( True );
} /* Parse */ } /* Parse */
static FILE *OpenConfFile( char *FileName ) static FILE *OpenConfFile( const char *FileName )
/* ------------------------------------------------------------------------ ** /* ------------------------------------------------------------------------ **
* Open a configuration file. * Open a configuration file.
* *
@ -489,7 +489,7 @@ static FILE *OpenConfFile( char *FileName )
*/ */
{ {
FILE *OpenedFile; FILE *OpenedFile;
char *func = "params.c:OpenConfFile() -"; const char *func = "params.c:OpenConfFile() -";
extern BOOL in_client; extern BOOL in_client;
int lvl = in_client?1:0; int lvl = in_client?1:0;
@ -510,9 +510,9 @@ static FILE *OpenConfFile( char *FileName )
return( OpenedFile ); return( OpenedFile );
} /* OpenConfFile */ } /* OpenConfFile */
BOOL pm_process( char *FileName, BOOL pm_process( const char *FileName,
BOOL (*sfunc)(char *), BOOL (*sfunc)(const char *),
BOOL (*pfunc)(char *, char *) ) BOOL (*pfunc)(const char *, const char *) )
/* ------------------------------------------------------------------------ ** /* ------------------------------------------------------------------------ **
* Process the named parameter file. * Process the named parameter file.
* *
@ -529,7 +529,7 @@ BOOL pm_process( char *FileName,
{ {
int result; int result;
FILE *InFile; FILE *InFile;
char *func = "params.c:pm_process() -"; const char *func = "params.c:pm_process() -";
InFile = OpenConfFile( FileName ); /* Open the config file. */ InFile = OpenConfFile( FileName ); /* Open the config file. */
if( NULL == InFile ) if( NULL == InFile )

Просмотреть файл

@ -1010,6 +1010,7 @@ smbfs_do_connect (const char *server, char *share)
static int static int
smbfs_get_master_browser(char **host) smbfs_get_master_browser(char **host)
{ {
static char so_broadcast[] = "SO_BROADCAST";
int count; int count;
struct in_addr *ip_list, bcast_addr; struct in_addr *ip_list, bcast_addr;
extern struct in_addr ipzero; extern struct in_addr ipzero;
@ -1019,7 +1020,7 @@ smbfs_get_master_browser(char **host)
interpret_addr(lp_socket_address()), True ); interpret_addr(lp_socket_address()), True );
if (fd == -1) if (fd == -1)
return 0; return 0;
set_socket_options(fd, "SO_BROADCAST"); set_socket_options(fd, so_broadcast);
ip_list = iface_bcast(ipzero); ip_list = iface_bcast(ipzero);
bcast_addr = *ip_list; bcast_addr = *ip_list;
if ((ip_list = name_query(fd, "\01\02__MSBROWSE__\02", 1, True, if ((ip_list = name_query(fd, "\01\02__MSBROWSE__\02", 1, True,