return(strcmp(s1,s2)==0);
}
+/***************************************************************************
+Do a case-insensitive, whitespace-ignoring string compare.
+***************************************************************************/
+int strwicmp(char *psz1, char *psz2)
+{
+ /* if BOTH strings are NULL, return TRUE, if ONE is NULL return */
+ /* appropriate value. */
+ if (psz1 == psz2)
+ return (0);
+ else if (psz1 == NULL)
+ return (-1);
+ else if (psz2 == NULL)
+ return (1);
+
+ /* sync the strings on first non-whitespace */
+ while (1)
+ {
+ while (isspace(*psz1))
+ psz1++;
+ while (isspace(*psz2))
+ psz2++;
+ if (toupper(*psz1) != toupper(*psz2) || *psz1 == '\0'
+ || *psz2 == '\0')
+ break;
+ psz1++;
+ psz2++;
+ }
+ return (*psz1 - *psz2);
+}
+
/*******************************************************************
convert a string to lower case
else
#endif /* KANJI_WIN95_COMPATIBILITY */
{
- size_t skip = skip_multibyte_char( *s );
+ size_t skip = get_character_len( *s );
if( skip != 0 )
s += skip;
else
else
#endif /* KANJI_WIN95_COMPATIBILITY */
{
- size_t skip = skip_multibyte_char( *s );
+ size_t skip = get_character_len( *s );
if( skip != 0 )
s += skip;
else
void string_replace(char *s,char oldc,char newc)
{
size_t skip;
- while (*s)
- {
- skip = skip_multibyte_char( *s );
- if( skip != 0 )
- s += skip;
- else
- {
+
+ /*
+ * sbcs optimization.
+ */
+ if(!global_is_multibyte_codepage) {
+ while (*s) {
if (oldc == *s)
*s = newc;
s++;
}
+ } else {
+ while (*s)
+ {
+ skip = get_character_len( *s );
+ if( skip != 0 )
+ s += skip;
+ else
+ {
+ if (oldc == *s)
+ *s = newc;
+ s++;
+ }
+ }
}
}
{
size_t len = 0;
- while (*s != '\0') {
- int skip = skip_multibyte_char(*s);
- s += (skip ? skip : 1);
- len++;
+ /*
+ * sbcs optimization.
+ */
+ if(!global_is_multibyte_codepage) {
+ return strlen(s);
+ } else {
+ while (*s != '\0') {
+ int skip = get_character_len(*s);
+ s += (skip ? skip : 1);
+ len++;
+ }
}
return len;
}
if(back_len)
{
- if(!is_multibyte_codepage())
+ if(!global_is_multibyte_codepage)
{
s_len = strlen(s);
while ((s_len >= back_len) &&
size_t charcount = 0;
char *mbp = s;
- while(charcount < (mb_s_len - mb_back_len))
- {
- size_t skip = skip_multibyte_char(*mbp);
- mbp += (skip ? skip : 1);
- charcount++;
+ /*
+ * sbcs optimization.
+ */
+ if(!global_is_multibyte_codepage) {
+ while(charcount < (mb_s_len - mb_back_len)) {
+ mbp += 1;
+ charcount++;
+ }
+ } else {
+ while(charcount < (mb_s_len - mb_back_len)) {
+ size_t skip = skip_multibyte_char(*mbp);
+ mbp += (skip ? skip : 1);
+ charcount++;
+ }
}
/*
else
#endif /* KANJI_WIN95_COMPATIBILITY */
{
- size_t skip = skip_multibyte_char( *s );
+ size_t skip = get_character_len( *s );
if( skip != 0 )
s += skip;
else {
else
#endif /* KANJI_WIN95_COMPATIBILITY */
{
- size_t skip = skip_multibyte_char( *s );
+ size_t skip = get_character_len( *s );
if( skip != 0 )
s += skip;
else {
{
while (*s)
{
- size_t skip = skip_multibyte_char( *s );
+ size_t skip = get_character_len( *s );
if( skip != 0 )
s += skip;
else {
{
while (*s)
{
- size_t skip = skip_multibyte_char( *s );
+ size_t skip = get_character_len( *s );
if( skip != 0 )
s += skip;
else {
/****************************************************************************
set a string value, allocing the space for the string
****************************************************************************/
-BOOL string_init(char **dest,const char *src)
+static BOOL string_init(char **dest,const char *src)
{
size_t l;
if (!src)
}
return s;
}
+
+/* Parse a string of the form DOMAIN/user into a domain and a user */
+
+void parse_domain_user(char *domuser, fstring domain, fstring user)
+{
+ char *p;
+ char *sep = lp_winbind_separator();
+ if (!sep) sep = "\\";
+ p = strchr(domuser,*sep);
+ if (!p) p = strchr(domuser,'\\');
+ if (!p) {
+ fstrcpy(domain,"");
+ fstrcpy(user, domuser);
+ return;
+ }
+
+ fstrcpy(user, p+1);
+ fstrcpy(domain, domuser);
+ domain[PTR_DIFF(p, domuser)] = 0;
+ strupper(domain);
+}