diff options
author | Gerald Carter <jerry@samba.org> | 2003-09-09 04:07:32 +0000 |
---|---|---|
committer | Gerald Carter <jerry@samba.org> | 2003-09-09 04:07:32 +0000 |
commit | 4093bf7ff8c8861cf7b941945ede53a8ec5bb6c8 (patch) | |
tree | dd0a9f32d9933e1f75d919b5083e007d7453f9c4 /source3/lib/util.c | |
parent | 3d7cb49747a9a7f5cdec0ee05c6270ec3604202f (diff) | |
download | samba-4093bf7ff8c8861cf7b941945ede53a8ec5bb6c8.tar.gz samba-4093bf7ff8c8861cf7b941945ede53a8ec5bb6c8.tar.bz2 samba-4093bf7ff8c8861cf7b941945ede53a8ec5bb6c8.zip |
sync 3.0 into HEAD for the last time
(This used to be commit c17a7dc9a190156a069da3e861c18fd3f81224ad)
Diffstat (limited to 'source3/lib/util.c')
-rw-r--r-- | source3/lib/util.c | 81 |
1 files changed, 5 insertions, 76 deletions
diff --git a/source3/lib/util.c b/source3/lib/util.c index eaa232a549..766c5041b4 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -261,7 +261,7 @@ BOOL init_names(void) } fstrcpy( local_machine, global_myname() ); - trim_string( local_machine, " ", " " ); + trim_char( local_machine, ' ', ' ' ); p = strchr( local_machine, ' ' ); if (p) *p = 0; @@ -311,7 +311,7 @@ BOOL in_group(gid_t group, gid_t current_gid, int ngroups, const gid_t *groups) static const char *Atoic(const char *p, int *n, const char *c) { - if (!isdigit((const int)*p)) { + if (!isdigit((int)*p)) { DEBUG(5, ("Atoic: malformed number\n")); return NULL; } @@ -605,68 +605,6 @@ void unix_clean_name(char *s) 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. ****************************************************************************/ @@ -2205,7 +2143,7 @@ char *lock_path(const char *name) static pstring fname; pstrcpy(fname,lp_lockdir()); - trim_string(fname,"","/"); + trim_char(fname,'\0','/'); if (!directory_exist(fname,NULL)) mkdir(fname,0755); @@ -2225,7 +2163,7 @@ char *pid_path(const char *name) static pstring fname; pstrcpy(fname,lp_piddir()); - trim_string(fname,"","/"); + trim_char(fname,'\0','/'); if (!directory_exist(fname,NULL)) mkdir(fname,0755); @@ -2335,21 +2273,12 @@ BOOL ms_has_wild_w(const smb_ucs2_t *s) BOOL mask_match(const char *string, char *pattern, BOOL is_case_sensitive) { - fstring p2, s2; - if (strcmp(string,"..") == 0) string = "."; if (strcmp(pattern,".") == 0) return False; - if (is_case_sensitive) - return ms_fnmatch(pattern, string, Protocol) == 0; - - fstrcpy(p2, pattern); - fstrcpy(s2, string); - strlower_m(p2); - strlower_m(s2); - return ms_fnmatch(p2, s2, Protocol) == 0; + return ms_fnmatch(pattern, string, Protocol, is_case_sensitive) == 0; } /********************************************************* |