charset.c : Add mapping for code page 932 (KANJI).
authorSamba Release Account <samba-bugs@samba.org>
Mon, 25 Aug 1997 22:18:31 +0000 (22:18 +0000)
committerSamba Release Account <samba-bugs@samba.org>
Mon, 25 Aug 1997 22:18:31 +0000 (22:18 +0000)
client.c : Fix crash bug. Add code to use BUFFER_SIZE for NetServerEnum calls.
namepacket.c: Fixed cast.
nmbsync.c : Add code to use BUFFER_SIZE for NetServerEnum calls.
smb.h : Set default client code page to 932 for KANJI.
system.c : Remove vendor specific code that crept in :-).
util.c : Added #define to allow Samba to behave as Win95 when doing
         KANJI case insensitivity tests.

Jeremy (jallison@whistle.com)

source/client/client.c
source/include/smb.h
source/lib/charset.c
source/lib/system.c
source/lib/util.c
source/namepacket.c
source/nmbsync.c

index f9585c6de5929423f68c5c5689aad7641ba4fa84..329956ce94bdec3bdcf430eaf2e9843b21d16ff9 100644 (file)
@@ -232,7 +232,8 @@ static int readfile(char *b, int size, int n, FILE *f)
          n++;
        }
       
-      b[i++] = c;
+      if(i < n)
+        b[i++] = c;
     }
   
   return(i);
@@ -3878,7 +3879,7 @@ static BOOL list_servers(char *wk_grp)
 
   p = skip_string(p,1);
   SSVAL(p,0,uLevel);
-  SSVAL(p,2,0x2000); /* buf length */
+  SSVAL(p,2,BUFFER_SIZE - SAFETY_MARGIN); /* buf length */
   p += 4;
 
   svtype_p = p;
@@ -3893,7 +3894,7 @@ static BOOL list_servers(char *wk_grp)
   SIVAL(svtype_p,0,SV_TYPE_ALL);
 
   if (call_api(PTR_DIFF(p+4,param),0,
-              8,10000,
+              8,BUFFER_SIZE - SAFETY_MARGIN,
               &rprcnt,&rdrcnt,
               param,NULL,
               &rparam,&rdata))
@@ -3932,7 +3933,7 @@ static BOOL list_servers(char *wk_grp)
   SIVAL(svtype_p,0,SV_TYPE_DOMAIN_ENUM);
 
   if (call_api(PTR_DIFF(p+4,param),0,
-              8,10000,
+              8,BUFFER_SIZE - SAFETY_MARGIN,
               &rprcnt,&rdrcnt,
               param,NULL,
               &rparam,&rdata))
index 1dbe04abc87f29562653b415ca604b380bd7a7bd..540aa0798ddb1db86848b5172e7f119789e09710 100644 (file)
@@ -923,8 +923,13 @@ enum case_handling {CASE_LOWER,CASE_UPPER};
 
 #endif 
 
+#ifdef KANJI
+/* Default client code page - 932 - Japanese */
+#define DEFAULT_CLIENT_CODE_PAGE 932
+#else /* KANJI */
 /* Default client code page - 850 - Western European */
 #define DEFAULT_CLIENT_CODE_PAGE 850
+#endif /* KANJI */
 
 /* Size of buffer to use when moving files across filesystems. */
 #define COPYBUF_SIZE (8*1024)
index 55e2239b55900bf0013cb641450e01074079c5ce..0bbf99e29f59e8c1689a5209bc150b767a1b50db 100644 (file)
@@ -157,6 +157,11 @@ unsigned char cp_437[][4] = {
   {0xEF,0,0,0},
   {0,0,0,0}
 };
+
+/* lower->upper mapping for IBM Code Page 932 - MS-DOS Japanese SJIS */
+unsigned char cp_932[][4] = {
+  {0,0,0,0}
+};
  
 char xx_dos_char_map[256];
 char xx_upper_char_map[256];
@@ -255,11 +260,21 @@ void codepage_initialise(int client_codepage)
     case 437:
       cp = cp_437;
       break;
+    case 932:
+      cp = cp_932;
+      break;
     default:
+#ifdef KANJI
+      /* Use default codepage - currently 932 */
+      DEBUG(6,("codepage_initialise: Using default client codepage %d\n", 
+               932));
+      cp = cp_932;
+#else /* KANJI */
       /* Use default codepage - currently 850 */
       DEBUG(6,("codepage_initialise: Using default client codepage %d\n", 
                850));
       cp = cp_850;
+#endif /* KANJI */
       break;
   }
 
index 39f845b30ebaa28acc7f9003d2a0130df4cc205f..447a4f88aca21778bd2c25dec8e0f5adcf0ae394 100644 (file)
@@ -378,6 +378,7 @@ apparent reason.
 ****************************************************************************/
 struct hostent *sys_gethostbyname(char *name)
 {
+#ifdef REDUCE_ROOT_DNS_LOOKUPS
   char query[256], hostname[256];
   char *domain;
 
@@ -406,5 +407,8 @@ struct hostent *sys_gethostbyname(char *name)
 
   sprintf(query, "%s%s", name, domain);
   return(gethostbyname(query));
+#else /* REDUCE_ROOT_DNS_LOOKUPS */
+  return(gethostbyname(name));
+#endif /* REDUCE_ROOT_DNS_LOOKUPS */
 }
 
index 6f6e03fbd60f0b813ffc16f9d27a3e5f7ba09e9f..d78ecf2728a238961b13fedae928a2a4a2af4b0d 100644 (file)
@@ -808,7 +808,8 @@ int StrCaseCmp(const char *s, const char *t)
   /* We *must* use toupper rather than tolower here due to the
      asynchronous upper to lower mapping.
    */
-#ifdef KANJI
+#if defined(KANJI) && !defined(KANJI_WIN95_COMPATIBILITY)
+  /* Win95 treats full width ascii characters as case sensitive. */
   int diff;
   for (;;)
   {
@@ -865,7 +866,8 @@ int StrnCaseCmp(const char *s, const char *t, int n)
   /* We *must* use toupper rather than tolower here due to the
      asynchronous upper to lower mapping.
    */
-#ifdef KANJI
+#if defined(KANJI) && !defined(KANJI_WIN95_COMPATIBILITY)
+  /* Win95 treats full width ascii characters as case sensitive. */
   int diff;
   for (;n > 0;)
   {
@@ -962,7 +964,8 @@ void strlower(char *s)
 {
   while (*s)
     {
-#ifdef KANJI
+#if defined(KANJI) && !defined(KANJI_WIN95_COMPATIBILITY)
+  /* Win95 treats full width ascii characters as case sensitive. */
        if (is_shift_jis (*s)) {
            if (is_sj_upper (s[0], s[1])) {
                  s[1] = sj_tolower2 (s[1]);
@@ -990,7 +993,8 @@ void strupper(char *s)
 {
   while (*s)
     {
-#ifdef KANJI
+#if defined(KANJI) && !defined(KANJI_WIN95_COMPATIBILITY)
+  /* 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]);
@@ -1041,7 +1045,8 @@ void string_replace(char *s,char oldc,char newc)
 {
   while (*s)
     {
-#ifdef KANJI
+#if defined(KANJI) && !defined(KANJI_WIN95_COMPATIBILITY)
+  /* Win95 treats full width ascii characters as case sensitive. */
        if (is_shift_jis (*s)) {
            s += 2;
        } else if (is_kana (*s)) {
@@ -1136,8 +1141,8 @@ void show_msg(char *buf)
       if (j == 7) DEBUG(10, ("  "));
     }
 
-    DEBUG(10,("\n"));  
-  }
+  DEBUG(10,("\n"));  
+}
 }
 
 /*******************************************************************
@@ -1679,7 +1684,8 @@ BOOL strhasupper(char *s)
 {
   while (*s) 
     {
-#ifdef KANJI
+#if defined(KANJI) && !defined(KANJI_WIN95_COMPATIBILITY)
+  /* Win95 treats full width ascii characters as case sensitive. */
        if (is_shift_jis (*s)) {
            s += 2;
        } else if (is_kana (*s)) {
@@ -1703,7 +1709,8 @@ BOOL strhaslower(char *s)
 {
   while (*s) 
     {
-#ifdef KANJI
+#if defined(KANJI) && !defined(KANJI_WIN95_COMPATIBILITY)
+  /* Win95 treats full width ascii characters as case sensitive. */
        if (is_shift_jis (*s)) {
            if (is_sj_upper (s[0], s[1])) return(True);
            if (is_sj_lower (s[0], s[1])) return (True);
@@ -1728,17 +1735,18 @@ find the number of chars in a string
 int count_chars(char *s,char c)
 {
   int count=0;
-#ifdef KANJI
-  while (*s)
-  {
+#if defined(KANJI) && !defined(KANJI_WIN95_COMPATIBILITY)
+  /* Win95 treats full width ascii characters as case sensitive. */
+  while (*s) 
+    {
     if (is_shift_jis (*s))
          s += 2;
     else 
        {
-         if (*s == c)
-           count++;
-         s++;
-       }
+      if (*s == c)
+       count++;
+      s++;
+    }
   }
 #else /* KANJI */
   while (*s) 
@@ -3294,15 +3302,15 @@ Rewritten by Stefaan A Eeckels <Stefaan.Eeckels@ecc.lu> and
 Paul Rippin <pr3245@nopc.eurostat.cec.be>
 ********************************************************************/
 void standard_sub_basic(char *string)
-{
+  {
   char *s, *p;
-  char pidstr[10];
+    char pidstr[10];
   struct passwd *pass;
 
   for (s = string ; (p = strchr(s,'%')) != NULL ; s = p )
   {
     switch (*(p+1))
-    {
+  {
       case 'G' : if ((pass = Get_Pwnam(sesssetup_user,False))!=NULL)
                    string_sub(p,"%G",gidtoname(pass->pw_gid));
                  else
@@ -3561,10 +3569,10 @@ BOOL is_in_path(char *name, name_compare_entry *namelist)
 
   /* if we have no list it's obviously not in the path */
   if((namelist == NULL ) || ((namelist != NULL) && (namelist[0].name == NULL))) 
-  {
+        {
     DEBUG(5,("is_in_path: no name list.\n"));
     return False;
-  }
+}
 
   /* Get the last component of the unix name. */
   p = strrchr(name, '/');
@@ -3593,7 +3601,7 @@ BOOL is_in_path(char *name, name_compare_entry *namelist)
     }
   }
   DEBUG(5,("is_in_path: match not found\n"));
-
   return False;
 }
 
@@ -3608,7 +3616,7 @@ BOOL is_in_path(char *name, name_compare_entry *namelist)
  * We also check if the entry contains a wildcard to
  * remove a potentially expensive call to mask_match
  * if possible.
- */
  */
 
 void set_namearray(name_compare_entry **ppname_array, char *namelist)
 {
@@ -3626,14 +3634,14 @@ void set_namearray(name_compare_entry **ppname_array, char *namelist)
      first to count the number of elements, the second
      to split it.
    */
-  while (*nameptr 
+  while(*nameptr
     {
       if ( *nameptr == '/' ) 
-      {
+        {
           /* cope with multiple (useless) /s) */
           nameptr++;
           continue;
-      }
+        }
       /* find the next / */
       name_end = strchr(nameptr, '/');
 
@@ -3651,16 +3659,16 @@ void set_namearray(name_compare_entry **ppname_array, char *namelist)
 
   if(( (*ppname_array) = (name_compare_entry *)malloc( 
            (num_entries + 1) * sizeof(name_compare_entry))) == NULL)
-  {
+        {
     DEBUG(0,("set_namearray: malloc fail\n"));
     return;
-  }
+        }
 
   /* Now copy out the names */
   nameptr = namelist;
   i = 0;
   while(*nameptr)
-    {
+             {
       if ( *nameptr == '/' ) 
       {
           /* cope with multiple (useless) /s) */
@@ -3671,10 +3679,10 @@ void set_namearray(name_compare_entry **ppname_array, char *namelist)
       if ((name_end = strchr(nameptr, '/')) != NULL) 
       {
           *name_end = 0;
-      }
+         }
 
       /* oops - the last check for a / didn't find one. */
-      if (name_end == NULL)
+      if(name_end == NULL) 
         break;
 
       (*ppname_array)[i].is_wild = ((strchr( nameptr, '?')!=NULL) ||
@@ -3689,7 +3697,7 @@ void set_namearray(name_compare_entry **ppname_array, char *namelist)
       nameptr = name_end + 1;
       i++;
     }
-
+  
   (*ppname_array)[i].name = NULL;
 
   return;
index 55b525d6c5076c7f4b1f9ce0baf87a541e1a14c3..086e32d9081e7fbc6d96a58476382aeab9ae6d10 100644 (file)
@@ -65,7 +65,7 @@ void debug_browse_data(char *outbuf, int len)
        for (j = 0; j < 16; j++)
          {
            if (i+j >= len) break;
-           DEBUG(4, (" %02x", outbuf[i+j]));
+           DEBUG(4, (" %02x", (unsigned char)outbuf[i+j]));
          }
        
        DEBUG(4, ("\n"));
index a140b7a1bd49086ffba1d7a45a1ad5b9cd92b98d..fd85c82e2cd8ee94c632e62e8fc51be173d72368 100644 (file)
@@ -75,7 +75,7 @@ static BOOL add_info(struct subnet_record *d, struct work_record *work, int serv
   
   p = skip_string(p,1);
   SSVAL(p,0,uLevel);
-  SSVAL(p,2,0x2000); /* buf length */
+  SSVAL(p,2,BUFFER_SIZE - SAFETY_MARGIN); /* buf length */
   p += 4;
   SIVAL(p,0,servertype);
   p += 4;
@@ -83,7 +83,7 @@ static BOOL add_info(struct subnet_record *d, struct work_record *work, int serv
   strcpy(p, work->work_group);
   p = skip_string(p,1);
   
-  if (cli_call_api(PTR_DIFF(p,param),0, 8,10000,
+  if (cli_call_api(PTR_DIFF(p,param),0, 8,BUFFER_SIZE - SAFETY_MARGIN,
                   &rprcnt,&rdrcnt, param,NULL,
                   &rparam,&rdata))
     {