mirror of
https://github.com/samba-team/samba.git
synced 2025-08-03 04:22:09 +03:00
More tuning from cachegrind. Change most trim_string() calls to trim_char(0,
as that's what they do. Fix string_replace() to fast-path ascii.
Jeremy.
(This used to be commit f35e9a8b90
)
This commit is contained in:
@ -373,10 +373,10 @@ BOOL load_auth_module(struct auth_context *auth_context,
|
|||||||
if (p) {
|
if (p) {
|
||||||
*p = 0;
|
*p = 0;
|
||||||
module_params = p+1;
|
module_params = p+1;
|
||||||
trim_string(module_params, " ", " ");
|
trim_char(module_params, ' ', ' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
trim_string(module_name, " ", " ");
|
trim_char(module_name, ' ', ' ');
|
||||||
|
|
||||||
entry = auth_find_backend_entry(module_name);
|
entry = auth_find_backend_entry(module_name);
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ static BOOL check_user_equiv(const char *user, const char *remote, const char *e
|
|||||||
if (! lines) return False;
|
if (! lines) return False;
|
||||||
for (i=0; lines[i]; i++) {
|
for (i=0; lines[i]; i++) {
|
||||||
char *buf = lines[i];
|
char *buf = lines[i];
|
||||||
trim_string(buf," "," ");
|
trim_char(buf,' ',' ');
|
||||||
|
|
||||||
if (buf[0] != '#' && buf[0] != '\n')
|
if (buf[0] != '#' && buf[0] != '\n')
|
||||||
{
|
{
|
||||||
|
@ -230,7 +230,7 @@ static struct chat_struct *make_pw_chat(char *p)
|
|||||||
special_char_sub(prompt);
|
special_char_sub(prompt);
|
||||||
fstrcpy(t->prompt, prompt);
|
fstrcpy(t->prompt, prompt);
|
||||||
strlower_m(t->prompt);
|
strlower_m(t->prompt);
|
||||||
trim_string(t->prompt, " ", " ");
|
trim_char(t->prompt, ' ', ' ');
|
||||||
|
|
||||||
if (!next_token(&p, reply, NULL, sizeof(fstring)))
|
if (!next_token(&p, reply, NULL, sizeof(fstring)))
|
||||||
break;
|
break;
|
||||||
@ -241,7 +241,7 @@ static struct chat_struct *make_pw_chat(char *p)
|
|||||||
special_char_sub(reply);
|
special_char_sub(reply);
|
||||||
fstrcpy(t->reply, reply);
|
fstrcpy(t->reply, reply);
|
||||||
strlower_m(t->reply);
|
strlower_m(t->reply);
|
||||||
trim_string(t->reply, " ", " ");
|
trim_char(t->reply, ' ', ' ');
|
||||||
|
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
@ -304,7 +304,7 @@ static int smb_pam_passchange_conv(int num_msg,
|
|||||||
case PAM_PROMPT_ECHO_ON:
|
case PAM_PROMPT_ECHO_ON:
|
||||||
DEBUG(10,("smb_pam_passchange_conv: PAM_PROMPT_ECHO_ON: PAM said: %s\n", msg[replies]->msg));
|
DEBUG(10,("smb_pam_passchange_conv: PAM_PROMPT_ECHO_ON: PAM said: %s\n", msg[replies]->msg));
|
||||||
fstrcpy(current_prompt, msg[replies]->msg);
|
fstrcpy(current_prompt, msg[replies]->msg);
|
||||||
trim_string(current_prompt, " ", " ");
|
trim_char(current_prompt, ' ', ' ');
|
||||||
for (t=pw_chat; t; t=t->next) {
|
for (t=pw_chat; t; t=t->next) {
|
||||||
|
|
||||||
DEBUG(10,("smb_pam_passchange_conv: PAM_PROMPT_ECHO_ON: trying to match |%s| to |%s|\n",
|
DEBUG(10,("smb_pam_passchange_conv: PAM_PROMPT_ECHO_ON: trying to match |%s| to |%s|\n",
|
||||||
@ -335,7 +335,7 @@ static int smb_pam_passchange_conv(int num_msg,
|
|||||||
case PAM_PROMPT_ECHO_OFF:
|
case PAM_PROMPT_ECHO_OFF:
|
||||||
DEBUG(10,("smb_pam_passchange_conv: PAM_PROMPT_ECHO_OFF: PAM said: %s\n", msg[replies]->msg));
|
DEBUG(10,("smb_pam_passchange_conv: PAM_PROMPT_ECHO_OFF: PAM said: %s\n", msg[replies]->msg));
|
||||||
fstrcpy(current_prompt, msg[replies]->msg);
|
fstrcpy(current_prompt, msg[replies]->msg);
|
||||||
trim_string(current_prompt, " ", " ");
|
trim_char(current_prompt, ' ', ' ');
|
||||||
for (t=pw_chat; t; t=t->next) {
|
for (t=pw_chat; t; t=t->next) {
|
||||||
|
|
||||||
DEBUG(10,("smb_pam_passchange_conv: PAM_PROMPT_ECHO_OFF: trying to match |%s| to |%s|\n",
|
DEBUG(10,("smb_pam_passchange_conv: PAM_PROMPT_ECHO_OFF: trying to match |%s| to |%s|\n",
|
||||||
|
@ -1006,7 +1006,7 @@ static int cmd_mkdir(void)
|
|||||||
*ddir2 = 0;
|
*ddir2 = 0;
|
||||||
|
|
||||||
pstrcpy(ddir,mask);
|
pstrcpy(ddir,mask);
|
||||||
trim_string(ddir,".",NULL);
|
trim_char(ddir,'.','\0');
|
||||||
p = strtok(ddir,"/\\");
|
p = strtok(ddir,"/\\");
|
||||||
while (p) {
|
while (p) {
|
||||||
pstrcat(ddir2,p);
|
pstrcat(ddir2,p);
|
||||||
|
@ -53,8 +53,8 @@ static BOOL load_msg(const char *msg_file)
|
|||||||
}
|
}
|
||||||
if (msgid && strncmp(lines[i], "msgstr \"", 8) == 0) {
|
if (msgid && strncmp(lines[i], "msgstr \"", 8) == 0) {
|
||||||
msgstr = lines[i] + 8;
|
msgstr = lines[i] + 8;
|
||||||
trim_string(msgid, NULL, "\"");
|
trim_char(msgid, '\0', '\"');
|
||||||
trim_string(msgstr, NULL, "\"");
|
trim_char(msgstr, '\0', '\"');
|
||||||
if (*msgstr == 0) {
|
if (*msgstr == 0) {
|
||||||
msgstr = msgid;
|
msgstr = msgid;
|
||||||
}
|
}
|
||||||
|
@ -879,9 +879,8 @@ size_t pull_ucs2(const void *base_ptr, char *dest, const void *src, size_t dest_
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (flags & STR_TERMINATE) {
|
if (flags & STR_TERMINATE) {
|
||||||
if (src_len == (size_t)-1) {
|
/* src_len -1 is the default for null terminated strings. */
|
||||||
src_len = strlen_w(src)*2 + 2;
|
if (src_len != (size_t)-1) {
|
||||||
} else {
|
|
||||||
size_t len = strnlen_w(src, src_len/2);
|
size_t len = strnlen_w(src, src_len/2);
|
||||||
if (len < src_len/2)
|
if (len < src_len/2)
|
||||||
len++;
|
len++;
|
||||||
@ -1051,4 +1050,3 @@ size_t align_string(const void *base_ptr, const char *p, int flags)
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ void set_local_machine_name(const char* local_name, BOOL perm)
|
|||||||
already_perm = perm;
|
already_perm = perm;
|
||||||
|
|
||||||
fstrcpy(tmp_local_machine,local_name);
|
fstrcpy(tmp_local_machine,local_name);
|
||||||
trim_string(tmp_local_machine," "," ");
|
trim_char(tmp_local_machine,' ',' ');
|
||||||
alpha_strcpy(local_machine,tmp_local_machine,SAFE_NETBIOS_CHARS,sizeof(local_machine)-1);
|
alpha_strcpy(local_machine,tmp_local_machine,SAFE_NETBIOS_CHARS,sizeof(local_machine)-1);
|
||||||
strlower_m(local_machine);
|
strlower_m(local_machine);
|
||||||
}
|
}
|
||||||
@ -79,7 +79,7 @@ void set_remote_machine_name(const char* remote_name, BOOL perm)
|
|||||||
already_perm = perm;
|
already_perm = perm;
|
||||||
|
|
||||||
fstrcpy(tmp_remote_machine,remote_name);
|
fstrcpy(tmp_remote_machine,remote_name);
|
||||||
trim_string(tmp_remote_machine," "," ");
|
trim_char(tmp_remote_machine,' ',' ');
|
||||||
alpha_strcpy(remote_machine,tmp_remote_machine,SAFE_NETBIOS_CHARS,sizeof(remote_machine)-1);
|
alpha_strcpy(remote_machine,tmp_remote_machine,SAFE_NETBIOS_CHARS,sizeof(remote_machine)-1);
|
||||||
strlower_m(remote_machine);
|
strlower_m(remote_machine);
|
||||||
}
|
}
|
||||||
@ -111,7 +111,7 @@ void sub_set_smb_name(const char *name)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
fstrcpy(tmp,name);
|
fstrcpy(tmp,name);
|
||||||
trim_string(tmp," "," ");
|
trim_char(tmp,' ',' ');
|
||||||
strlower_m(tmp);
|
strlower_m(tmp);
|
||||||
alpha_strcpy(smb_user_name,tmp,SAFE_NETBIOS_CHARS,sizeof(smb_user_name)-1);
|
alpha_strcpy(smb_user_name,tmp,SAFE_NETBIOS_CHARS,sizeof(smb_user_name)-1);
|
||||||
}
|
}
|
||||||
|
@ -261,7 +261,7 @@ BOOL init_names(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
fstrcpy( local_machine, global_myname() );
|
fstrcpy( local_machine, global_myname() );
|
||||||
trim_string( local_machine, " ", " " );
|
trim_char( local_machine, ' ', ' ' );
|
||||||
p = strchr( local_machine, ' ' );
|
p = strchr( local_machine, ' ' );
|
||||||
if (p)
|
if (p)
|
||||||
*p = 0;
|
*p = 0;
|
||||||
@ -605,68 +605,6 @@ void unix_clean_name(char *s)
|
|||||||
trim_string(s,NULL,"/..");
|
trim_string(s,NULL,"/..");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************
|
|
||||||
Convert '\' to '/'.
|
|
||||||
Reduce a file name, removing or reducing /../ , /./ , // elements.
|
|
||||||
Remove also any trailing . and /
|
|
||||||
Return a new allocated string.
|
|
||||||
********************************************************************/
|
|
||||||
|
|
||||||
smb_ucs2_t *unix_clean_path(const smb_ucs2_t *s)
|
|
||||||
{
|
|
||||||
smb_ucs2_t *ns;
|
|
||||||
smb_ucs2_t *p, *r, *t;
|
|
||||||
|
|
||||||
DEBUG(3, ("unix_clean_path\n")); /* [%unicode]\n")); */
|
|
||||||
if(!s)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
/* convert '\' to '/' */
|
|
||||||
ns = strdup_w(s);
|
|
||||||
if (!ns)
|
|
||||||
return NULL;
|
|
||||||
unix_format_w(ns);
|
|
||||||
|
|
||||||
/* remove all double slashes */
|
|
||||||
p = ns;
|
|
||||||
ns = all_string_sub_wa(p, "//", "/");
|
|
||||||
SAFE_FREE(p);
|
|
||||||
if (!ns)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
/* remove any /./ */
|
|
||||||
p = ns;
|
|
||||||
ns = all_string_sub_wa(p, "/./", "/");
|
|
||||||
SAFE_FREE(p);
|
|
||||||
if (!ns)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
/* reduce any /../ */
|
|
||||||
t = ns;
|
|
||||||
while (*t && (r = strstr_wa(t, "/.."))) {
|
|
||||||
t = &(r[3]);
|
|
||||||
if (*t == UCS2_CHAR('/') || *t == 0) {
|
|
||||||
*r = 0;
|
|
||||||
p = strrchr_w(ns, UCS2_CHAR('/'));
|
|
||||||
if (!p)
|
|
||||||
p = ns;
|
|
||||||
if (*t == 0)
|
|
||||||
*p = 0;
|
|
||||||
else
|
|
||||||
memmove(p, t, (strlen_w(t) + 1) * sizeof(smb_ucs2_t));
|
|
||||||
t = p;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* remove any leading ./ trailing /. */
|
|
||||||
trim_string_wa(ns, "./", "/.");
|
|
||||||
|
|
||||||
/* remove any leading and trailing / */
|
|
||||||
trim_string_wa(ns, "/", "/");
|
|
||||||
|
|
||||||
return ns;
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
Make a dir struct.
|
Make a dir struct.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -2205,7 +2143,7 @@ char *lock_path(const char *name)
|
|||||||
static pstring fname;
|
static pstring fname;
|
||||||
|
|
||||||
pstrcpy(fname,lp_lockdir());
|
pstrcpy(fname,lp_lockdir());
|
||||||
trim_string(fname,"","/");
|
trim_char(fname,'\0','/');
|
||||||
|
|
||||||
if (!directory_exist(fname,NULL))
|
if (!directory_exist(fname,NULL))
|
||||||
mkdir(fname,0755);
|
mkdir(fname,0755);
|
||||||
@ -2225,7 +2163,7 @@ char *pid_path(const char *name)
|
|||||||
static pstring fname;
|
static pstring fname;
|
||||||
|
|
||||||
pstrcpy(fname,lp_piddir());
|
pstrcpy(fname,lp_piddir());
|
||||||
trim_string(fname,"","/");
|
trim_char(fname,'\0','/');
|
||||||
|
|
||||||
if (!directory_exist(fname,NULL))
|
if (!directory_exist(fname,NULL))
|
||||||
mkdir(fname,0755);
|
mkdir(fname,0755);
|
||||||
|
@ -364,9 +364,27 @@ BOOL strisnormal(const char *s)
|
|||||||
|
|
||||||
void string_replace(pstring s,char oldc,char newc)
|
void string_replace(pstring s,char oldc,char newc)
|
||||||
{
|
{
|
||||||
push_ucs2(NULL, tmpbuf,s, sizeof(tmpbuf), STR_TERMINATE);
|
unsigned char *p;
|
||||||
|
|
||||||
|
/* this is quite a common operation, so we want it to be
|
||||||
|
fast. We optimise for the ascii case, knowing that all our
|
||||||
|
supported multi-byte character sets are ascii-compatible
|
||||||
|
(ie. they match for the first 128 chars) */
|
||||||
|
|
||||||
|
for (p = (unsigned char *)s; *p; p++) {
|
||||||
|
if (*p & 0x80) /* mb string - slow path. */
|
||||||
|
break;
|
||||||
|
if (*p == oldc)
|
||||||
|
*p = newc;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!*p)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* Slow (mb) path. */
|
||||||
|
push_ucs2(NULL, tmpbuf, p, sizeof(tmpbuf), STR_TERMINATE);
|
||||||
string_replace_w(tmpbuf, UCS2_CHAR(oldc), UCS2_CHAR(newc));
|
string_replace_w(tmpbuf, UCS2_CHAR(oldc), UCS2_CHAR(newc));
|
||||||
pull_ucs2(NULL, s, tmpbuf, -1, sizeof(tmpbuf), STR_TERMINATE);
|
pull_ucs2(NULL, p, tmpbuf, -1, sizeof(tmpbuf), STR_TERMINATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -406,6 +424,59 @@ size_t str_ascii_charnum(const char *s)
|
|||||||
return strlen(tmpbuf2);
|
return strlen(tmpbuf2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOL trim_char(char *s,char cfront,char cback)
|
||||||
|
{
|
||||||
|
BOOL ret = False;
|
||||||
|
char *ep;
|
||||||
|
char *fp = s;
|
||||||
|
|
||||||
|
/* Ignore null or empty strings. */
|
||||||
|
if (!s || (s[0] == '\0'))
|
||||||
|
return False;
|
||||||
|
|
||||||
|
if (cfront) {
|
||||||
|
while (*fp && *fp == cfront)
|
||||||
|
fp++;
|
||||||
|
if (!*fp) {
|
||||||
|
/* We ate the string. */
|
||||||
|
s[0] = '\0';
|
||||||
|
return True;
|
||||||
|
}
|
||||||
|
if (fp != s)
|
||||||
|
ret = True;
|
||||||
|
}
|
||||||
|
|
||||||
|
ep = fp + strlen(fp) - 1;
|
||||||
|
if (cback) {
|
||||||
|
/* Attempt ascii only. Bail for mb strings. */
|
||||||
|
while ((ep >= fp) && (*ep == cback)) {
|
||||||
|
ret = True;
|
||||||
|
if ((ep > fp) && (((unsigned char)ep[-1]) & 0x80)) {
|
||||||
|
/* Could be mb... bail back to tim_string. */
|
||||||
|
char fs[2], bs[2];
|
||||||
|
if (cfront) {
|
||||||
|
fs[0] = cfront;
|
||||||
|
fs[1] = '\0';
|
||||||
|
}
|
||||||
|
bs[0] = cback;
|
||||||
|
bs[1] = '\0';
|
||||||
|
return trim_string(s, cfront ? fs : NULL, bs);
|
||||||
|
} else {
|
||||||
|
ep--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ep < fp) {
|
||||||
|
/* We ate the string. */
|
||||||
|
s[0] = '\0';
|
||||||
|
return True;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ep[1] = '\0';
|
||||||
|
memmove(s, fp, ep-fp+2);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Trim the specified elements off the front and back of a string.
|
Trim the specified elements off the front and back of a string.
|
||||||
**/
|
**/
|
||||||
|
@ -951,8 +951,9 @@ BOOL cli_chkpath(struct cli_state *cli, const char *path)
|
|||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
pstrcpy(path2,path);
|
pstrcpy(path2,path);
|
||||||
trim_string(path2,NULL,"\\");
|
trim_char(path2,'\0','\\');
|
||||||
if (!*path2) *path2 = '\\';
|
if (!*path2)
|
||||||
|
*path2 = '\\';
|
||||||
|
|
||||||
memset(cli->outbuf,'\0',smb_size);
|
memset(cli->outbuf,'\0',smb_size);
|
||||||
set_message(cli->outbuf,0,0,True);
|
set_message(cli->outbuf,0,0,True);
|
||||||
|
@ -61,7 +61,7 @@ static struct node_status *parse_node_status(char *p, int *num_names)
|
|||||||
p++;
|
p++;
|
||||||
for (i=0;i< *num_names;i++) {
|
for (i=0;i< *num_names;i++) {
|
||||||
StrnCpy(ret[i].name,p,15);
|
StrnCpy(ret[i].name,p,15);
|
||||||
trim_string(ret[i].name,NULL," ");
|
trim_char(ret[i].name,'\0',' ');
|
||||||
ret[i].type = CVAL(p,15);
|
ret[i].type = CVAL(p,15);
|
||||||
ret[i].flags = p[16];
|
ret[i].flags = p[16];
|
||||||
p += 18;
|
p += 18;
|
||||||
|
@ -336,7 +336,7 @@ static int recycle_unlink(vfs_handle_struct *handle, connection_struct *conn, co
|
|||||||
repository = alloc_sub_conn(conn, recycle_repository(handle));
|
repository = alloc_sub_conn(conn, recycle_repository(handle));
|
||||||
ALLOC_CHECK(repository, done);
|
ALLOC_CHECK(repository, done);
|
||||||
/* shouldn't we allow absolute path names here? --metze */
|
/* shouldn't we allow absolute path names here? --metze */
|
||||||
trim_string(repository, "/", "/");
|
trim_char(repository, '/', '/');
|
||||||
|
|
||||||
if(!repository || *(repository) == '\0') {
|
if(!repository || *(repository) == '\0') {
|
||||||
DEBUG(3, ("recycle: repository path not set, purging %s...\n", file_name));
|
DEBUG(3, ("recycle: repository path not set, purging %s...\n", file_name));
|
||||||
|
@ -40,7 +40,7 @@ static BOOL parse_dfs_path(char* pathname, struct dfs_path* pdp)
|
|||||||
|
|
||||||
ZERO_STRUCTP(pdp);
|
ZERO_STRUCTP(pdp);
|
||||||
|
|
||||||
trim_string(temp,"\\","\\");
|
trim_char(temp,'\\','\\');
|
||||||
DEBUG(10,("temp in parse_dfs_path: .%s. after trimming \\'s\n",temp));
|
DEBUG(10,("temp in parse_dfs_path: .%s. after trimming \\'s\n",temp));
|
||||||
|
|
||||||
/* now tokenize */
|
/* now tokenize */
|
||||||
@ -275,7 +275,7 @@ static BOOL resolve_dfs_path(char* dfspath, struct dfs_path* dp,
|
|||||||
char *q;
|
char *q;
|
||||||
pstring buf;
|
pstring buf;
|
||||||
pstrcpy(buf, dfspath);
|
pstrcpy(buf, dfspath);
|
||||||
trim_string(buf, NULL, "\\");
|
trim_char(buf, '\0', '\\');
|
||||||
for (; consumed_level; consumed_level--) {
|
for (; consumed_level; consumed_level--) {
|
||||||
q = strrchr(buf, '\\');
|
q = strrchr(buf, '\\');
|
||||||
if (q) *q = 0;
|
if (q) *q = 0;
|
||||||
@ -780,7 +780,7 @@ BOOL create_msdfs_link(struct junction_map* jn, BOOL exists)
|
|||||||
for(i=0; i<jn->referral_count; i++) {
|
for(i=0; i<jn->referral_count; i++) {
|
||||||
char* refpath = jn->referral_list[i].alternate_path;
|
char* refpath = jn->referral_list[i].alternate_path;
|
||||||
|
|
||||||
trim_string(refpath, "\\", "\\");
|
trim_char(refpath, '\\', '\\');
|
||||||
if(*refpath == '\0') {
|
if(*refpath == '\0') {
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
insert_comma = False;
|
insert_comma = False;
|
||||||
|
@ -204,7 +204,7 @@ static void domain_master_node_status_success(struct subnet_record *subrec,
|
|||||||
pull_ascii_nstring(qname, p);
|
pull_ascii_nstring(qname, p);
|
||||||
name_type = CVAL(p,15);
|
name_type = CVAL(p,15);
|
||||||
nb_flags = get_nb_flags(&p[16]);
|
nb_flags = get_nb_flags(&p[16]);
|
||||||
trim_string(qname,NULL," ");
|
trim_char(qname,'\0',' ');
|
||||||
|
|
||||||
p += 18;
|
p += 18;
|
||||||
|
|
||||||
@ -427,7 +427,7 @@ static void get_domain_master_name_node_status_success(struct subnet_record *sub
|
|||||||
pull_ascii_nstring(qname, p);
|
pull_ascii_nstring(qname, p);
|
||||||
name_type = CVAL(p,15);
|
name_type = CVAL(p,15);
|
||||||
nb_flags = get_nb_flags(&p[16]);
|
nb_flags = get_nb_flags(&p[16]);
|
||||||
trim_string(qname,NULL," ");
|
trim_char(qname,'\0',' ');
|
||||||
|
|
||||||
p += 18;
|
p += 18;
|
||||||
|
|
||||||
|
@ -328,7 +328,7 @@ void write_browse_list(time_t t, BOOL force_write)
|
|||||||
updatecount++;
|
updatecount++;
|
||||||
|
|
||||||
pstrcpy(fname,lp_lockdir());
|
pstrcpy(fname,lp_lockdir());
|
||||||
trim_string(fname,NULL,"/");
|
trim_char(fname,'\0' ,'/');
|
||||||
pstrcat(fname,"/");
|
pstrcat(fname,"/");
|
||||||
pstrcat(fname,SERVER_LIST);
|
pstrcat(fname,SERVER_LIST);
|
||||||
pstrcpy(fnamenew,fname);
|
pstrcpy(fnamenew,fname);
|
||||||
|
@ -1558,8 +1558,8 @@ static char *lp_string(const char *s)
|
|||||||
lp_talloc = talloc_init("lp_talloc");
|
lp_talloc = talloc_init("lp_talloc");
|
||||||
|
|
||||||
tmpstr = alloc_sub_basic(current_user_info.smb_name, s);
|
tmpstr = alloc_sub_basic(current_user_info.smb_name, s);
|
||||||
if (trim_string(tmpstr, "\"", "\"")) {
|
if (trim_char(tmpstr, '\"', '\"')) {
|
||||||
if (strchr(tmpstr,'"') != NULL) {
|
if (strchr(tmpstr,'\"') != NULL) {
|
||||||
SAFE_FREE(tmpstr);
|
SAFE_FREE(tmpstr);
|
||||||
tmpstr = alloc_sub_basic(current_user_info.smb_name,s);
|
tmpstr = alloc_sub_basic(current_user_info.smb_name,s);
|
||||||
}
|
}
|
||||||
@ -3112,7 +3112,7 @@ BOOL lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue
|
|||||||
pstr_sprintf(param_key, "%s:", pszParmName);
|
pstr_sprintf(param_key, "%s:", pszParmName);
|
||||||
slen = strlen(param_key);
|
slen = strlen(param_key);
|
||||||
pstrcat(param_key, sep+1);
|
pstrcat(param_key, sep+1);
|
||||||
trim_string(param_key+slen, " ", " ");
|
trim_char(param_key+slen, ' ', ' ');
|
||||||
not_added = True;
|
not_added = True;
|
||||||
data = (snum < 0) ? Globals.param_opt :
|
data = (snum < 0) ? Globals.param_opt :
|
||||||
ServicePtrs[snum]->param_opt;
|
ServicePtrs[snum]->param_opt;
|
||||||
|
@ -422,10 +422,10 @@ static NTSTATUS make_pdb_methods_name(struct pdb_methods **methods, struct pdb_c
|
|||||||
if (p) {
|
if (p) {
|
||||||
*p = 0;
|
*p = 0;
|
||||||
module_location = p+1;
|
module_location = p+1;
|
||||||
trim_string(module_location, " ", " ");
|
trim_char(module_location, ' ', ' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
trim_string(module_name, " ", " ");
|
trim_char(module_name, ' ', ' ');
|
||||||
|
|
||||||
|
|
||||||
DEBUG(5,("Attempting to find an passdb backend to match %s (%s)\n", selected, module_name));
|
DEBUG(5,("Attempting to find an passdb backend to match %s (%s)\n", selected, module_name));
|
||||||
|
@ -41,9 +41,11 @@ NTSTATUS pdb_init_plugin(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_method, con
|
|||||||
if (p) {
|
if (p) {
|
||||||
*p = 0;
|
*p = 0;
|
||||||
plugin_location = p+1;
|
plugin_location = p+1;
|
||||||
trim_string(plugin_location, " ", " ");
|
trim_char(plugin_location, ' ', ' ');
|
||||||
} else plugin_location = NULL;
|
} else {
|
||||||
trim_string(plugin_name, " ", " ");
|
plugin_location = NULL;
|
||||||
|
}
|
||||||
|
trim_char(plugin_name, ' ', ' ');
|
||||||
|
|
||||||
DEBUG(5, ("Trying to load sam plugin %s\n", plugin_name));
|
DEBUG(5, ("Trying to load sam plugin %s\n", plugin_name));
|
||||||
dl_handle = sys_dlopen(plugin_name, RTLD_NOW );
|
dl_handle = sys_dlopen(plugin_name, RTLD_NOW );
|
||||||
|
@ -766,14 +766,14 @@ static BOOL parse_lpq_nt(char *line,print_queue_struct *buf,BOOL first)
|
|||||||
|
|
||||||
/* Make sure the status is valid */
|
/* Make sure the status is valid */
|
||||||
parse_line.space2 = '\0';
|
parse_line.space2 = '\0';
|
||||||
trim_string(parse_line.status, NULL, " ");
|
trim_char(parse_line.status, '\0', ' ');
|
||||||
if (!strequal(parse_line.status, LPRNT_PRINTING) &&
|
if (!strequal(parse_line.status, LPRNT_PRINTING) &&
|
||||||
!strequal(parse_line.status, LPRNT_PAUSED) &&
|
!strequal(parse_line.status, LPRNT_PAUSED) &&
|
||||||
!strequal(parse_line.status, LPRNT_WAITING))
|
!strequal(parse_line.status, LPRNT_WAITING))
|
||||||
return(False);
|
return(False);
|
||||||
|
|
||||||
parse_line.space3 = '\0';
|
parse_line.space3 = '\0';
|
||||||
trim_string(parse_line.jobname, NULL, " ");
|
trim_char(parse_line.jobname, '\0', ' ');
|
||||||
|
|
||||||
buf->job = atoi(parse_line.jobid);
|
buf->job = atoi(parse_line.jobid);
|
||||||
buf->priority = 0;
|
buf->priority = 0;
|
||||||
@ -837,7 +837,7 @@ static BOOL parse_lpq_os2(char *line,print_queue_struct *buf,BOOL first)
|
|||||||
|
|
||||||
/* Get the job name */
|
/* Get the job name */
|
||||||
parse_line.space2[0] = '\0';
|
parse_line.space2[0] = '\0';
|
||||||
trim_string(parse_line.jobname, NULL, " ");
|
trim_char(parse_line.jobname, '\0', ' ');
|
||||||
fstrcpy(buf->fs_file, parse_line.jobname);
|
fstrcpy(buf->fs_file, parse_line.jobname);
|
||||||
|
|
||||||
buf->priority = 0;
|
buf->priority = 0;
|
||||||
@ -850,7 +850,7 @@ static BOOL parse_lpq_os2(char *line,print_queue_struct *buf,BOOL first)
|
|||||||
|
|
||||||
/* Make sure we have a valid status */
|
/* Make sure we have a valid status */
|
||||||
parse_line.space4[0] = '\0';
|
parse_line.space4[0] = '\0';
|
||||||
trim_string(parse_line.status, NULL, " ");
|
trim_char(parse_line.status, '\0', ' ');
|
||||||
if (!strequal(parse_line.status, LPROS2_PRINTING) &&
|
if (!strequal(parse_line.status, LPROS2_PRINTING) &&
|
||||||
!strequal(parse_line.status, LPROS2_PAUSED) &&
|
!strequal(parse_line.status, LPROS2_PAUSED) &&
|
||||||
!strequal(parse_line.status, LPROS2_WAITING))
|
!strequal(parse_line.status, LPROS2_WAITING))
|
||||||
|
@ -2026,7 +2026,7 @@ static WERROR update_a_printer_2(NT_PRINTER_INFO_LEVEL_2 *info)
|
|||||||
|
|
||||||
if (info->servername[0]!='\0') {
|
if (info->servername[0]!='\0') {
|
||||||
trim_string(info->printername, info->servername, NULL);
|
trim_string(info->printername, info->servername, NULL);
|
||||||
trim_string(info->printername, "\\", NULL);
|
trim_char(info->printername, '\\', '\0');
|
||||||
info->servername[0]='\0';
|
info->servername[0]='\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,7 +159,7 @@ WERROR _dfs_remove(pipes_struct *p, DFS_Q_DFS_REMOVE *q_u,
|
|||||||
{
|
{
|
||||||
pstring refpath;
|
pstring refpath;
|
||||||
pstrcpy(refpath,jn.referral_list[i].alternate_path);
|
pstrcpy(refpath,jn.referral_list[i].alternate_path);
|
||||||
trim_string(refpath, "\\", "\\");
|
trim_char(refpath, '\\', '\\');
|
||||||
DEBUG(10,("_dfs_remove: refpath: .%s.\n", refpath));
|
DEBUG(10,("_dfs_remove: refpath: .%s.\n", refpath));
|
||||||
if(strequal(refpath, altpath))
|
if(strequal(refpath, altpath))
|
||||||
{
|
{
|
||||||
@ -257,7 +257,7 @@ static BOOL init_reply_dfs_info_3(TALLOC_CTX *ctx, struct junction_map* j, DFS_I
|
|||||||
struct referral* ref = &(j[i].referral_list[ii]);
|
struct referral* ref = &(j[i].referral_list[ii]);
|
||||||
|
|
||||||
pstrcpy(path, ref->alternate_path);
|
pstrcpy(path, ref->alternate_path);
|
||||||
trim_string(path,"\\","");
|
trim_char(path,'\\','\0');
|
||||||
p = strrchr_m(path,'\\');
|
p = strrchr_m(path,'\\');
|
||||||
if(p==NULL)
|
if(p==NULL)
|
||||||
{
|
{
|
||||||
|
@ -259,7 +259,7 @@ static int expect(int master, char *issue, char *expected)
|
|||||||
/* Eat leading/trailing whitespace before match. */
|
/* Eat leading/trailing whitespace before match. */
|
||||||
pstring str;
|
pstring str;
|
||||||
pstrcpy( str, buffer);
|
pstrcpy( str, buffer);
|
||||||
trim_string( str, " ", " ");
|
trim_char( str, ' ', ' ');
|
||||||
|
|
||||||
if ((match = (unix_wild_match(expected, str) == 0)))
|
if ((match = (unix_wild_match(expected, str) == 0)))
|
||||||
timeout = 200;
|
timeout = 200;
|
||||||
|
@ -125,7 +125,7 @@ BOOL unix_convert(pstring name,connection_struct *conn,char *saved_last_componen
|
|||||||
* also trim trailing /'s.
|
* also trim trailing /'s.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
trim_string(name,"/","/");
|
trim_char(name,'/','/');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If we trimmed down to a single '\0' character
|
* If we trimmed down to a single '\0' character
|
||||||
@ -164,7 +164,7 @@ BOOL unix_convert(pstring name,connection_struct *conn,char *saved_last_componen
|
|||||||
return(True);
|
return(True);
|
||||||
|
|
||||||
start = name;
|
start = name;
|
||||||
while (strncmp(start,"./",2) == 0)
|
while (start[0] == '.' && start[1] == '/')
|
||||||
start += 2;
|
start += 2;
|
||||||
|
|
||||||
pstrcpy(orig_path, name);
|
pstrcpy(orig_path, name);
|
||||||
|
@ -66,11 +66,12 @@ void stat_cache_add( const char *full_orig_name, const char *orig_translated_pat
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Don't cache trivial valid directory entries.
|
* Don't cache trivial valid directory entries such as . and ..
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if((*full_orig_name == '\0') || (strcmp(full_orig_name, ".") == 0) ||
|
if((*full_orig_name == '\0') || (full_orig_name[0] == '.' &&
|
||||||
(strcmp(full_orig_name, "..") == 0))
|
((full_orig_name[1] == '\0') ||
|
||||||
|
(full_orig_name[1] == '.' && full_orig_name[1] == '\0'))))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -217,13 +217,13 @@ static void uw_pathname(pstring fname, const char *uw_name, const char *uw_defau
|
|||||||
/* For w-files, first look for explicit "wtmp dir" */
|
/* For w-files, first look for explicit "wtmp dir" */
|
||||||
if (uw_name[0] == 'w') {
|
if (uw_name[0] == 'w') {
|
||||||
pstrcpy(dirname,lp_wtmpdir());
|
pstrcpy(dirname,lp_wtmpdir());
|
||||||
trim_string(dirname,"","/");
|
trim_char(dirname,'\0','/');
|
||||||
}
|
}
|
||||||
|
|
||||||
/* For u-files and non-explicit w-dir, look for "utmp dir" */
|
/* For u-files and non-explicit w-dir, look for "utmp dir" */
|
||||||
if (dirname == 0 || strlen(dirname) == 0) {
|
if (dirname == 0 || strlen(dirname) == 0) {
|
||||||
pstrcpy(dirname,lp_utmpdir());
|
pstrcpy(dirname,lp_utmpdir());
|
||||||
trim_string(dirname,"","/");
|
trim_char(dirname,'\0','/');
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If explicit directory above, use it */
|
/* If explicit directory above, use it */
|
||||||
|
@ -233,10 +233,10 @@ BOOL vfs_init_custom(connection_struct *conn, const char *vfs_object)
|
|||||||
if (p) {
|
if (p) {
|
||||||
*p = 0;
|
*p = 0;
|
||||||
module_param = p+1;
|
module_param = p+1;
|
||||||
trim_string(module_param, " ", " ");
|
trim_char(module_param, ' ', ' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
trim_string(module_name, " ", " ");
|
trim_char(module_name, ' ', ' ');
|
||||||
|
|
||||||
/* First, try to load the module with the new module system */
|
/* First, try to load the module with the new module system */
|
||||||
if((entry = vfs_find_backend_entry(module_name)) ||
|
if((entry = vfs_find_backend_entry(module_name)) ||
|
||||||
|
Reference in New Issue
Block a user