Example #1
0
void
strupper(char *s)
{
    while (*s) {
#if UNUSED_CODE
#if !defined(KANJI_WIN95_COMPATIBILITY)
        if (lp_client_code_page() == KANJI_CODEPAGE) {

            if (is_shift_jis(*s)) {
                if (is_sj_lower(s[0], s[1]))
                    s[1] = sj_toupper2(s[1]);
                s += 2;
            } else if (is_kana(*s)) {
                s++;
            } else {
                if (islower((int)(unsigned char)*s))
                    *s = toupper((int)(unsigned char)*s);
                s++;
            }
        } else
#endif /* KANJI_WIN95_COMPATIBILITY */
#endif /* UNUSED_CODE */
        {
            if (islower((int)(unsigned char)*s))
                *s = toupper((int)(unsigned char)*s);
            s++;
        }
    }
}
Example #2
0
/*******************************************************************
  convert a string to upper case
********************************************************************/
void
strupper (char *s)
{
    while (*s)
    {
#if !defined(KANJI_WIN95_COMPATIBILITY)
        /*
         * For completeness we should put in equivalent code for code pages
         * 949 (Korean hangul) and 950 (Big5 Traditional Chinese) here - but
         * doubt anyone wants Samba to behave differently from Win95 and WinNT
         * here. They both treat full width ascii characters as case senstive
         * filenames (ie. they don't do the work we do here).
         * JRA. 
         */

        if (lp_client_code_page () == KANJI_CODEPAGE)
        {
            /* Win95 treats full width ascii characters as case sensitive. */
            if (is_shift_jis (*s))
            {
                if (is_sj_lower (s[0], s[1]))
                    s[1] = sj_toupper2 (s[1]);
                s += 2;
            }
            else if (is_kana (*s))
            {
                s++;
            }
            else
            {
                if (islower (*s))
                    *s = toupper (*s);
                s++;
            }
        }
        else
#endif /* KANJI_WIN95_COMPATIBILITY */
        {
            size_t skip = skip_multibyte_char (*s);
            if (skip != 0)
                s += skip;
            else
            {
                if (islower (*s))
                    *s = toupper (*s);
                s++;
            }
        }
    }
}
Example #3
0
/*******************************************************************
  case insensitive string compararison, length limited
********************************************************************/
int StrnCaseCmp(const char *s, const char *t, size_t n)
{
  /* compare until we run out of string, either t or s, or chars */
  /* We *must* use toupper rather than tolower here due to the
     asynchronous upper to lower mapping.
   */
#if !defined(KANJI_WIN95_COMPATIBILITY)
  /*
   * For completeness we should put in equivalent code for code pages
   * 949 (Korean hangul) and 950 (Big5 Traditional Chinese) here - but
   * doubt anyone wants Samba to behave differently from Win95 and WinNT
   * here. They both treat full width ascii characters as case senstive
   * filenames (ie. they don't do the work we do here).
   * JRA. 
   */

  if(lp_client_code_page() == KANJI_CODEPAGE)
  {
    /* Win95 treats full width ascii characters as case sensitive. */
    int diff;
    for (;n > 0;)
    {
      if (!*s || !*t)
        return toupper (*s) - toupper (*t);
      else if (is_sj_alph (*s) && is_sj_alph (*t))
      {
        diff = sj_toupper2 (*(s+1)) - sj_toupper2 (*(t+1));
        if (diff)
          return diff;
        s += 2;
        t += 2;
        n -= 2;
      }
      else if (is_shift_jis (*s) && is_shift_jis (*t))
      {
        diff = ((int) (unsigned char) *s) - ((int) (unsigned char) *t);
        if (diff)
          return diff;
        diff = ((int) (unsigned char) *(s+1)) - ((int) (unsigned char) *(t+1));
        if (diff)
          return diff;
        s += 2;
        t += 2;
        n -= 2;
      }
      else if (is_shift_jis (*s))
        return 1;
      else if (is_shift_jis (*t))
        return -1;
      else 
      {
        diff = toupper (*s) - toupper (*t);
        if (diff)
          return diff;
        s++;
        t++;
        n--;
      }
    }
    return 0;
  }
  else
#endif /* KANJI_WIN95_COMPATIBILITY */
  {
    while (n && *s && *t && toupper(*s) == toupper(*t))
    {
      s++;
      t++;
      n--;
    }

    /* not run out of chars - strings are different lengths */
    if (n) 
      return(toupper(*s) - toupper(*t));

    /* identical up to where we run out of chars, 
       and strings are same length */
    return(0);
  }
}