charcnv.c client.c clitar.c kanji.c kanji.h loadparm.c
authorJeremy Allison <jra@samba.org>
Thu, 11 Sep 1997 20:17:32 +0000 (20:17 +0000)
committerJeremy Allison <jra@samba.org>
Thu, 11 Sep 1997 20:17:32 +0000 (20:17 +0000)
mangle.c smb.h util.c:

  Big merge to allow KANJI support to be in the main
binary without explicitly compiling with it.

locking.c: Fix for smbstatus not being able to read files.
namepacket.c: Removed unneccesary debug statement.
trans2.c: Added Luke's proposed fix (ifdefed out until further testing).
nmblookup.c: Fixed bug where query fails and status is done on bogus IP.

Jeremy (jallison@whistle.com)

13 files changed:
source/client/client.c
source/client/clitar.c
source/include/kanji.h
source/include/smb.h
source/lib/charcnv.c
source/lib/kanji.c
source/lib/util.c
source/locking/locking.c
source/namepacket.c
source/param/loadparm.c
source/smbd/mangle.c
source/smbd/trans2.c
source/utils/nmblookup.c

index 4718db84ac02587f72371db6252844374551167c..e9042555e209bd9d3c7a08aa2690af806690466d 100644 (file)
@@ -143,12 +143,8 @@ extern int Client;
 
 #define USENMB
 
-#ifdef KANJI
 extern int coding_system;
-#define CNV_LANG(s) (coding_system == DOSV_CODE?s:dos_to_unix(s, False))
-#define CNV_INPUT(s) (coding_system == DOSV_CODE?s:unix_to_dos(s, True))
-static BOOL
-setup_term_code (char *code)
+static BOOL setup_term_code (char *code)
 {
     int new;
     new = interpret_coding_system (code, UNKNOWN_CODE);
@@ -158,10 +154,8 @@ setup_term_code (char *code)
     }
     return False;
 }
-#else
 #define CNV_LANG(s) dos2unix_format(s,False)
 #define CNV_INPUT(s) unix2dos_format(s,True)
-#endif
 
 /****************************************************************************
 setup basics in a outgoing packet
@@ -4392,10 +4386,6 @@ static void usage(char *pname)
   DEBUG(0,("Usage: %s service <password> [-p port] [-d debuglevel] [-l log] ",
           pname));
 
-#ifdef KANJI
-  DEBUG(0,("[-t termcode] "));
-#endif /* KANJI */
-
   DEBUG(0,("\nVersion %s\n",VERSION));
   DEBUG(0,("\t-p port               listen on the specified port\n"));
   DEBUG(0,("\t-d debuglevel         set the debuglevel\n"));
@@ -4411,9 +4401,7 @@ static void usage(char *pname)
   DEBUG(0,("\t-U username           set the network username\n"));
   DEBUG(0,("\t-W workgroup          set the workgroup name\n"));
   DEBUG(0,("\t-c command string     execute semicolon separated commands\n"));
-#ifdef KANJI
   DEBUG(0,("\t-t terminal code      terminal i/o code {sjis|euc|jis7|jis8|junet|hex}\n"));
-#endif /* KANJI */
   DEBUG(0,("\t-T<c|x>IXgbNa          command line tar\n"));
   DEBUG(0,("\t-D directory          start from directory\n"));
   DEBUG(0,("\n"));
@@ -4435,6 +4423,13 @@ static void usage(char *pname)
   BOOL message = False;
   extern char tar_type;
   static pstring servicesf = CONFIGFILE;
+  pstring term_code;
+
+#ifdef KANJI
+  strcpy(term_code, KANJI);
+#else /* KANJI */
+  *term_code = 0;
+#endif /* KANJI */
 
   *query_host = 0;
   *base_directory = 0;
@@ -4506,9 +4501,6 @@ static void usage(char *pname)
        }
     }
 
-#ifdef KANJI
-  setup_term_code (KANJI);
-#endif
   while ((opt = 
          getopt(argc, argv,"s:B:O:M:i:Nn:d:Pp:l:hI:EB:U:L:t:m:W:T:D:c:")) != EOF)
     switch (opt)
@@ -4604,13 +4596,7 @@ static void usage(char *pname)
        strcpy(servicesf, optarg);
        break;
       case 't':
-#ifdef KANJI
-       if (!setup_term_code (optarg)) {
-           DEBUG(0, ("%s: unknown terminal code name\n", optarg));
-           usage (pname);
-           exit (1);
-       }
-#endif
+        strcpy(term_code, optarg);
        break;
       default:
        usage(pname);
@@ -4635,6 +4621,18 @@ static void usage(char *pname)
     fprintf(stderr, "Can't load %s - run testparm to debug it\n", servicesf);
   }
 
+  codepage_initialise(lp_client_code_page());
+
+  if(lp_client_code_page() == KANJI_CODEPAGE)
+  {
+        if (!setup_term_code (term_code))
+    {
+            DEBUG(0, ("%s: unknown terminal code name\n", optarg));
+            usage (pname);
+            exit (1);
+        }
+  }
+
   if (*workgroup == 0)
     strcpy(workgroup,lp_workgroup());
 
index d5bca8c5bbb6e13687e5a73c109c72df2d28ee03..a30f6c2960f98bf7fd4ba92c59dc9c8718afbcb9 100644 (file)
@@ -306,27 +306,35 @@ static void fixtarname(char *tptr, char *fp, int l)
    * to lovely unix /'s :-} */
 
   *tptr++='.';
-#ifdef KANJI
-  while (l > 0) {
-    if (is_shift_jis (*fp)) {
-      *tptr++ = *fp++;
-      *tptr++ = *fp++;
-      l -= 2;
-    } else if (is_kana (*fp)) {
-      *tptr++ = *fp++;
-      l--;
-    } else if (*fp == '\\') {
-      *tptr++ = '/';
+  if(lp_client_code_page() == KANJI_CODEPAGE)
+  {
+    while (l > 0) {
+      if (is_shift_jis (*fp)) {
+        *tptr++ = *fp++;
+        *tptr++ = *fp++;
+        l -= 2;
+      } else if (is_kana (*fp)) {
+        *tptr++ = *fp++;
+        l--;
+      } else if (*fp == '\\') {
+        *tptr++ = '/';
+        fp++;
+        l--;
+      } else {
+        *tptr++ = *fp++;
+        l--;
+      }
+    }
+  }
+  else
+  {
+    while (l--)
+    {
+      *tptr=(*fp == '\\') ? '/' : *fp;
+      tptr++;
       fp++;
-      l--;
-    } else {
-      *tptr++ = *fp++;
-      l--;
     }
   }
-#else
-  while (l--) { *tptr=(*fp == '\\') ? '/' : *fp; tptr++; fp++; }
-#endif
 }
 
 /****************************************************************************
@@ -1203,27 +1211,35 @@ static void unfixtarname(char *tptr, char *fp, int l)
   if (*fp == '.') fp++;
   if (*fp == '\\' || *fp == '/') fp++;
 
-#ifdef KANJI
-  while (l > 0) {
-    if (is_shift_jis (*fp)) {
-      *tptr++ = *fp++;
-      *tptr++ = *fp++;
-      l -= 2;
-    } else if (is_kana (*fp)) {
-      *tptr++ = *fp++;
-      l--;
-    } else if (*fp == '/') {
-      *tptr++ = '\\';
+  if(lp_client_code_page() == KANJI_CODEPAGE)
+  {
+    while (l > 0) {
+      if (is_shift_jis (*fp)) {
+        *tptr++ = *fp++;
+        *tptr++ = *fp++;
+        l -= 2;
+      } else if (is_kana (*fp)) {
+        *tptr++ = *fp++;
+        l--;
+      } else if (*fp == '/') {
+        *tptr++ = '\\';
+        fp++;
+        l--;
+      } else {
+        *tptr++ = *fp++;
+        l--;
+      }
+    }
+  }
+  else
+  {
+    while (l--)
+    {
+      *tptr=(*fp == '/') ? '\\' : *fp;
+      tptr++;
       fp++;
-      l--;
-    } else {
-      *tptr++ = *fp++;
-      l--;
     }
   }
-#else
-  while (l--) { *tptr=(*fp == '/') ? '\\' : *fp; tptr++; fp++; }
-#endif
 }
 
 static void do_tarput()
index 865ac3b2c90f2358d9846dd8661b4f27cff03e1b..1d2359baa9496f9ba033e88cc81ac7bb727aa41b 100644 (file)
@@ -27,8 +27,6 @@
 #ifndef _KANJI_H_
 #define _KANJI_H_
 
-#ifdef KANJI
-
 /* FOR SHIFT JIS CODE */
 #define is_shift_jis(c) \
     ((0x81 <= ((unsigned char) (c)) && ((unsigned char) (c)) <= 0x9f) \
 extern char* (*_dos_to_unix) (const char *str, BOOL overwrite);
 extern char* (*_unix_to_dos) (const char *str, BOOL overwrite);
 
-#define unix_to_dos (*_unix_to_dos)
-#define dos_to_unix (*_dos_to_unix)
-
 extern char *sj_strtok (char *s1, const char *s2);
 extern char *sj_strchr (const char *s, int c);
 extern char *sj_strrchr (const char *s, int c);
@@ -137,11 +132,7 @@ extern char *sj_strstr (const char *s1, const char *s2);
 
 int interpret_coding_system (char *str, int def);
 
-#else 
-
 #define unix_to_dos(x,y) unix2dos_format(x,y)
 #define dos_to_unix(x,y) dos2unix_format(x,y)
 
-#endif /* not KANJI */
-
 #endif /* _KANJI_H_ */
index b55c180f36170bedb45cd2bce2d374207c0e6991..47fbf32f834eec57087ee43889c2092e7b258450 100644 (file)
@@ -926,14 +926,16 @@ enum case_handling {CASE_LOWER,CASE_UPPER};
 
 #endif 
 
+/* Defines needed for multi-codepage support. */
+#define KANJI_CODEPAGE 932
+
 #ifdef KANJI
-/* Default client code page - 932 - Japanese */
-#define DEFAULT_CLIENT_CODE_PAGE 932
+/* Default client code page - Japanese */
+#define DEFAULT_CLIENT_CODE_PAGE KANJI_CODEPAGE
 #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 6be455c47b27c0ce545f268937ab79aebf7f12d4..a7dff4224be390dd0f76ba6eb23bbb753c5900ed 100644 (file)
@@ -107,13 +107,18 @@ char *unix2dos_format(char *str,BOOL overwrite)
     char *dp;
 
     if (!mapsinited) initmaps();
-    if (overwrite) {
-        for (p = str; *p; p++) *p = unix2dos[(unsigned char)*p];
-        return str;
-    } else {
-        for (p = str, dp = cvtbuf; *p; p++,dp++) *dp = unix2dos[(unsigned char)*p];
-        *dp = 0;
-        return cvtbuf;
+
+    if(lp_client_code_page() == KANJI_CODEPAGE)
+      return (*_unix_to_dos)(str, overwrite);
+    else {
+      if (overwrite) {
+          for (p = str; *p; p++) *p = unix2dos[(unsigned char)*p];
+          return str;
+      } else {
+          for (p = str, dp = cvtbuf; *p; p++,dp++) *dp = unix2dos[(unsigned char)*p];
+          *dp = 0;
+          return cvtbuf;
+      }
     }
 }
 
@@ -126,13 +131,18 @@ char *dos2unix_format(char *str, BOOL overwrite)
     char *dp;
 
     if (!mapsinited) initmaps();
-    if (overwrite) {
-        for (p = str; *p; p++) *p = dos2unix[(unsigned char)*p];
-        return str;
-    } else {
-        for (p = str, dp = cvtbuf; *p; p++,dp++) *dp = dos2unix[(unsigned char)*p];
-        *dp = 0;
-        return cvtbuf;
+
+    if(lp_client_code_page() == KANJI_CODEPAGE)
+      return (*_dos_to_unix)(str, overwrite);
+    else {
+      if (overwrite) {
+          for (p = str; *p; p++) *p = dos2unix[(unsigned char)*p];
+          return str;
+      } else {
+          for (p = str, dp = cvtbuf; *p; p++,dp++) *dp = dos2unix[(unsigned char)*p];
+          *dp = 0;
+          return cvtbuf;
+      }
     }
 }
 
index 479763fd406461a2041ff0581f1475febbae8e80..f5888e48773554276c7cd83d3fe1fc922bef0aa5 100644 (file)
@@ -23,7 +23,6 @@
      and add all jis codes sequence type at 1995.8.16
      Notes: Hexadecimal code by <ohki@gssm.otuka.tsukuba.ac.jp>
 */
-#ifdef KANJI
 
 #define _KANJI_C_
 #include "includes.h"
@@ -888,7 +887,3 @@ int interpret_coding_system(char *str, int def)
     }  
     return setup_string_function (codes);
 }
-#else 
- int kanji_dummy_procedure(void)
-{return 0;}
-#endif /* KANJI */
index 7f922def7e37a8a2d02f060862ef4f93a913aacc..ce0b8bc7682696a8f1aedefeb6bb3f10c4ce6270 100644 (file)
@@ -813,53 +813,59 @@ int StrCaseCmp(const char *s, const char *t)
   /* We *must* use toupper rather than tolower here due to the
      asynchronous upper to lower mapping.
    */
-#if defined(KANJI) && !defined(KANJI_WIN95_COMPATIBILITY)
-  /* Win95 treats full width ascii characters as case sensitive. */
-  int diff;
-  for (;;)
+#if !defined(KANJI_WIN95_COMPATIBILITY)
+  if(lp_client_code_page() == KANJI_CODEPAGE)
   {
-    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;
-       }
-    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;
-       }
-    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++;
-       }
+    /* Win95 treats full width ascii characters as case sensitive. */
+    int diff;
+    for (;;)
+    {
+      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;
+      }
+      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;
+      }
+      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++;
+      }
+    }
   }
-#else /* KANJI */
-  while (*s && *t && toupper(*s) == toupper(*t))
+  else
+#endif /* KANJI_WIN95_COMPATIBILITY */
   {
-    s++; t++;
-  }
+    while (*s && *t && toupper(*s) == toupper(*t))
+    {
+      s++;
+      t++;
+    }
 
-  return(toupper(*s) - toupper(*t));
-#endif /* KANJI */
+    return(toupper(*s) - toupper(*t));
+  }
 }
 
 /*******************************************************************
@@ -871,61 +877,69 @@ 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.
    */
-#if defined(KANJI) && !defined(KANJI_WIN95_COMPATIBILITY)
-  /* Win95 treats full width ascii characters as case sensitive. */
-  int diff;
-  for (;n > 0;)
+#if !defined(KANJI_WIN95_COMPATIBILITY)
+  if(lp_client_code_page() == KANJI_CODEPAGE)
   {
-    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--;
-       }
+    /* 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;
   }
-  return 0;
-#else /* KANJI */
-  while (n-- && *s && *t && toupper(*s) == toupper(*t))
+  else
+#endif /* KANJI_WIN95_COMPATIBILITY */
   {
-    s++; t++;
-  }
+    while (n-- && *s && *t && toupper(*s) == toupper(*t))
+    {
+      s++;
+      t++;
+    }
 
-  /* not run out of chars - strings are different lengths */
-  if (n) return(toupper(*s) - toupper(*t));
+    /* 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);
-#endif /* KANJI */
+    /* identical up to where we run out of chars, 
+       and strings are same length */
+    return(0);
+  }
 }
 
 /*******************************************************************
@@ -968,27 +982,36 @@ BOOL strcsequal(char *s1,char *s2)
 void strlower(char *s)
 {
   while (*s)
+  {
+#if !defined(KANJI_WIN95_COMPATIBILITY)
+    if(lp_client_code_page() == KANJI_CODEPAGE)
+    {
+      /* 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]);
+        s += 2;
+      }
+      else if (is_kana (*s))
+      {
+        s++;
+      }
+      else
+      {
+        if (isupper(*s))
+          *s = tolower(*s);
+        s++;
+      }
+    }
+    else
+#endif /* KANJI_WIN95_COMPATIBILITY */
     {
-#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]);
-           }
-           s += 2;
-       } else if (is_kana (*s)) {
-           s++;
-       } else {
-           if (isupper(*s))
-               *s = tolower(*s);
-           s++;
-       }
-#else /* KANJI */
       if (isupper(*s))
-         *s = tolower(*s);
+        *s = tolower(*s);
       s++;
-#endif /* KANJI */
     }
+  }
 }
 
 /*******************************************************************
@@ -997,27 +1020,36 @@ void strlower(char *s)
 void strupper(char *s)
 {
   while (*s)
+  {
+#if !defined(KANJI_WIN95_COMPATIBILITY)
+    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 */
     {
-#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]);
-           }
-           s += 2;
-       } else if (is_kana (*s)) {
-           s++;
-       } else {
-           if (islower(*s))
-               *s = toupper(*s);
-           s++;
-       }
-#else /* KANJI */
       if (islower(*s))
-       *s = toupper(*s);
+        *s = toupper(*s);
       s++;
-#endif /* KANJI */
     }
+  }
 }
 
 /*******************************************************************
@@ -1049,24 +1081,30 @@ BOOL strisnormal(char *s)
 void string_replace(char *s,char oldc,char newc)
 {
   while (*s)
+  {
+#if !defined(KANJI_WIN95_COMPATIBILITY)
+    if(lp_client_code_page() == KANJI_CODEPAGE)
+    {
+      /* Win95 treats full width ascii characters as case sensitive. */
+      if (is_shift_jis (*s))
+        s += 2;
+      else if (is_kana (*s))
+        s++;
+      else
+      {
+        if (oldc == *s)
+          *s = newc;
+        s++;
+      }
+    }
+    else
+#endif /* KANJI_WIN95_COMPATIBILITY */
     {
-#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)) {
-           s++;
-       } else {
-           if (oldc == *s)
-               *s = newc;
-           s++;
-       }
-#else /* KANJI */
       if (oldc == *s)
-       *s = newc;
+        *s = newc;
       s++;
-#endif /* KANJI */
     }
+  }
 }
 
 /****************************************************************************
@@ -1688,22 +1726,30 @@ does a string have any uppercase chars in it?
 BOOL strhasupper(char *s)
 {
   while (*s) 
+  {
+#if !defined(KANJI_WIN95_COMPATIBILITY)
+    if(lp_client_code_page() == KANJI_CODEPAGE)
+    {
+      /* Win95 treats full width ascii characters as case sensitive. */
+      if (is_shift_jis (*s))
+        s += 2;
+      else if (is_kana (*s))
+        s++;
+      else
+      {
+        if (isupper(*s))
+          return(True);
+        s++;
+      }
+    }
+    else
+#endif /* KANJI_WIN95_COMPATIBILITY */
     {
-#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)) {
-           s++;
-       } else {
-           if (isupper(*s)) return(True);
-           s++;
-       }
-#else /* KANJI */
-      if (isupper(*s)) return(True);
+      if (isupper(*s))
+        return(True);
       s++;
-#endif /* KANJI */
     }
+  }
   return(False);
 }
 
@@ -1713,24 +1759,38 @@ does a string have any lowercase chars in it?
 BOOL strhaslower(char *s)
 {
   while (*s) 
+  {
+#if !defined(KANJI_WIN95_COMPATIBILITY)
+    if(lp_client_code_page() == KANJI_CODEPAGE)
     {
-#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);
-           s += 2;
-       } else if (is_kana (*s)) {
-           s++;
-       } else {
-           if (islower(*s)) return(True);
-           s++;
-       }
-#else /* KANJI */
-      if (islower(*s)) return(True);
+      /* 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);
+        s += 2;
+      }
+      else if (is_kana (*s))
+      {
+        s++;
+      }
+      else
+      {
+        if (islower(*s))
+          return(True);
+        s++;
+      }
+    }
+    else
+#endif /* KANJI_WIN95_COMPATIBILITY */
+    {
+      if (islower(*s))
+        return(True);
       s++;
-#endif /* KANJI */
     }
+  }
   return(False);
 }
 
@@ -1740,27 +1800,33 @@ find the number of chars in a string
 int count_chars(char *s,char c)
 {
   int count=0;
-#if defined(KANJI) && !defined(KANJI_WIN95_COMPATIBILITY)
-  /* Win95 treats full width ascii characters as case sensitive. */
-  while (*s) 
+
+#if !defined(KANJI_WIN95_COMPATIBILITY)
+  if(lp_client_code_page() == KANJI_CODEPAGE)
+  {
+    /* 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 (is_shift_jis (*s))
+        s += 2;
+      else 
+      {
+        if (*s == c)
+          count++;
+        s++;
+      }
     }
   }
-#else /* KANJI */
-  while (*s) 
+  else
+#endif /* KANJI_WIN95_COMPATIBILITY */
+  {
+    while (*s) 
     {
       if (*s == c)
-       count++;
+        count++;
       s++;
     }
-#endif /* KANJI */
+  }
   return(count);
 }
 
index f579a75a0bc17b3c1767e2ff6975c2819f887d64..760d21a05d8ee3c3e8f983d7a0aeb5081afef0ae 100644 (file)
@@ -616,7 +616,7 @@ BOOL lock_share_entry(int cnum, uint32 dev, uint32 inode, share_lock_token *ptok
 #ifdef SECURE_SHARE_MODES
     fd = (share_lock_token)open(fname,O_RDWR|O_CREAT,0600);
 #else /* SECURE_SHARE_MODES */
-    fd = (share_lock_token)open(fname,O_RDWR|O_CREAT,0644);
+    fd = (share_lock_token)open(fname,O_RDWR|O_CREAT,0666);
 #endif /* SECURE_SHARE_MODES */
     umask(old_umask);
     if(!become_user(cnum,Connections[cnum].vuid))
index d60ef9f6ae2150added60341e95c37ac2fe3e0b9..44e449b8c2afa55ecabb50703b5811365e48670c 100644 (file)
@@ -199,11 +199,6 @@ void reply_netbios_packet(struct packet_struct *p1,int trn_id,
   
   p = *p1;
 
-  if (recursion_available && lp_wins_server())
-  {
-    DEBUG(0,("reply_netbios_packet: r_a not to be used when not a WINS server\n"));
-  }
-
   switch (rcv_code)
   {
     case NMB_STATUS:
index c3a75812557a19c379d2e000f3e0351b1afdabe2..047334e143a529b974de4d1788c2e48131ccd511 100644 (file)
 
 #include "includes.h"
 
+/* Set default coding system for KANJI if none specified in Makefile. */
+#ifndef KANJI
+#define KANJI "sjis"
+#endif /* KANJI */
+
 BOOL bLoaded = False;
 
 extern int DEBUGLEVEL;
@@ -97,9 +102,7 @@ int keepalive=0;
 extern BOOL use_getwd_cache;
 
 extern int extra_time_offset;
-#ifdef KANJI
 extern int coding_system;
-#endif
 
 /* 
  * This structure describes global (ie., server-wide) parameters.
@@ -367,9 +370,7 @@ static BOOL handle_case(char *pszParmValue,int *val);
 static BOOL handle_printing(char *pszParmValue,int *val);
 static BOOL handle_character_set(char *pszParmValue,int *val);
 static BOOL handle_announce_as(char *pszParmValue, int *val);
-#ifdef KANJI
 static BOOL handle_coding_system(char *pszParmValue,int *val);
-#endif /* KANJI */
 
 static void set_default_server_announce_type(void);
 
@@ -452,9 +453,7 @@ struct parm_struct
   {"read size",        P_INTEGER, P_GLOBAL, &Globals.ReadSize,          NULL},
   {"shared mem size",  P_INTEGER, P_GLOBAL, &Globals.shmem_size,        NULL},
   {"shared file entries",  P_INTEGER, P_GLOBAL, &Globals.shmem_hash_size, NULL},
-#ifdef KANJI
   {"coding system",    P_INTEGER, P_GLOBAL, &coding_system, handle_coding_system},
-#endif /* KANJI */
   {"client code page", P_INTEGER, P_GLOBAL, &Globals.client_code_page, NULL},
   {"os level",         P_INTEGER, P_GLOBAL, &Globals.os_level,          NULL},
   {"max ttl",          P_INTEGER, P_GLOBAL, &Globals.max_ttl,           NULL},
@@ -646,9 +645,7 @@ static void init_globals(void)
   Globals.bNISHomeMap = False;
   string_set(&Globals.szNISHomeMapName, "auto.home");
 #endif
-#ifdef KANJI
   coding_system = interpret_coding_system (KANJI, SJIS_CODE);
-#endif /* KANJI */
   Globals.client_code_page = DEFAULT_CLIENT_CODE_PAGE;
   Globals.bTimeServer = False;
 
@@ -1418,7 +1415,6 @@ BOOL lp_file_list_changed(void)
   return(False);
 }
 
-#ifdef KANJI
 /***************************************************************************
   handle the interpretation of the coding system parameter
   *************************************************************************/
@@ -1427,7 +1423,6 @@ static BOOL handle_coding_system(char *pszParmValue,int *val)
   *val = interpret_coding_system(pszParmValue,*val);
   return(True);
 }
-#endif /* KANJI */
 
 /***************************************************************************
 handle the interpretation of the character set system parameter
index a08402a85ea43e00a72858fc20c815f4eb6ee127..3f753cf855670893aba1d5fc14d371767422de95 100644 (file)
@@ -123,30 +123,34 @@ BOOL is_8_3(char *fname, BOOL check_case)
 
   {
     char *p = fname;
-#ifdef KANJI
-    dot_pos = 0;
-    while (*p)
+    if(lp_client_code_page() == KANJI_CODEPAGE)
+    {
+      dot_pos = 0;
+      while (*p)
       {
-         if (is_shift_jis (*p)) {
-             p += 2;
-         } else if (is_kana (*p)) {
-             p ++;
-         } else {
-             if (*p == '.' && !dot_pos)
-                 dot_pos = (char *) p;
-             if (!isdoschar(*p))
-                 return(False);
-             p++;
-         }
-      }      
-#else
-    while (*p)
+        if (is_shift_jis (*p)) 
+          p += 2;
+        else if (is_kana (*p)) 
+          p ++;
+        else 
+        {
+          if (*p == '.' && !dot_pos)
+            dot_pos = (char *) p;
+          if (!isdoschar(*p))
+            return(False);
+          p++;
+        }
+      }
+    }      
+    else
+    {
+      while (*p)
       {
-       if (!isdoschar(*p))
-         return(False);
-       p++;
+        if (!isdoschar(*p))
+          return(False);
+        p++;
       }      
-#endif /* KANJI */
+    }
   }
 
   /* no dot and less than 9 means OK */
@@ -498,84 +502,90 @@ void mangle_name_83(char *s)
   DEBUG(5,("Mangling name %s to ",s));
 
   if (p)
-    {
-      if (p == s)
-       strcpy(extension,"___");
-      else
+  {
+    if (p == s)
+      strcpy(extension,"___");
+    else
        {
          *p++ = 0;
          while (*p && extlen < 3)
-           {
-#ifdef KANJI
-             if (is_shift_jis (*p))
-               {
-                 if (extlen < 2)
-                   {
-                     extension[extlen++] = p[0];
-                     extension[extlen++] = p[1];
-                   }
-                 else 
-                   {
-                     extension[extlen++] = base36 (((unsigned char) *p) % 36);
-                   }
-                 p += 2;
-               }
-             else if (is_kana (*p))
-               {
-                 extension[extlen++] = p[0];
-                 p++;
-               }
-             else 
-               {
-                 if (isdoschar (*p) && *p != '.')
-                   extension[extlen++] = p[0];
-                 p++;
-               }
-#else
-             if (isdoschar(*p) && *p != '.')
-               extension[extlen++] = *p;
-             p++;
-#endif /* KANJI */
-           }
+         {
+        if(lp_client_code_page() == KANJI_CODEPAGE)
+        {
+          if (is_shift_jis (*p))
+          {
+            if (extlen < 2)
+            {
+              extension[extlen++] = p[0];
+              extension[extlen++] = p[1];
+            }
+            else 
+            {
+              extension[extlen++] = base36 (((unsigned char) *p) % 36);
+            }
+            p += 2;
+          }
+          else if (is_kana (*p))
+          {
+            extension[extlen++] = p[0];
+            p++;
+          }
+          else 
+          {
+            if (isdoschar (*p) && *p != '.')
+              extension[extlen++] = p[0];
+            p++;
+          }
+        }
+        else
+        {
+          if (isdoschar(*p) && *p != '.')
+            extension[extlen++] = *p;
+          p++;
+        }
+      }
          extension[extlen] = 0;
-       }
     }
+  }
 
   p = s;
 
   while (*p && baselen < 5)
+  {
+    if(lp_client_code_page() == KANJI_CODEPAGE)
     {
-#ifdef KANJI
       if (is_shift_jis (*p))
-       {
-         if (baselen < 4)
-           {
-             base[baselen++] = p[0];
-             base[baselen++] = p[1];
-           }
-         else 
-           {
+      {
+        if (baselen < 4)
+        {
+          base[baselen++] = p[0];
+          base[baselen++] = p[1];
+        }
+        else 
+        {
              base[baselen++] = base36 (((unsigned char) *p) % 36);
-           }
-         p += 2;
-       }
+        }
+        p += 2;
+      }
       else if (is_kana (*p))
-       {
-         base[baselen++] = p[0];
-         p++;
-       }
+      {
+        base[baselen++] = p[0];
+        p++;
+      }
       else 
-       {
-         if (isdoschar (*p) && *p != '.')
-           base[baselen++] = p[0];
-         p++;
-       }
-#else
+      {
+        if (isdoschar (*p) && *p != '.')
+          base[baselen++] = p[0];
+        p++;
+      }
+    }
+    else
+    {
       if (isdoschar(*p) && *p != '.')
-       base[baselen++] = *p;
+        base[baselen++] = *p;
       p++;
-#endif /* KANJI */
     }
+  }
   base[baselen] = 0;
 
   csum = csum % (36*36);
@@ -601,7 +611,8 @@ static BOOL illegal_name(char *name)
   static BOOL initialised=False;
   unsigned char *s;
 
-  if (!initialised) {
+  if (!initialised) 
+  {
     char *ill = "*\\/?<>|\":{}";
     initialised = True;
   
@@ -610,21 +621,23 @@ static BOOL illegal_name(char *name)
       illegal[*s] = True;
   }
 
-#ifdef KANJI
-  for (s = (unsigned char *)name; *s;) {
-    if (is_shift_jis (*s)) {
-      s += 2;
-    } else if (illegal[*s]) {
-      return(True);
-    } else {
-      s++;
+  if(lp_client_code_page() == KANJI_CODEPAGE)
+  {
+    for (s = (unsigned char *)name; *s;) {
+      if (is_shift_jis (*s)) {
+        s += 2;
+      } else if (illegal[*s]) {
+        return(True);
+      } else {
+        s++;
+      }
     }
   }
-#else
-  for (s = (unsigned char *)name;*s;s++)
-    if (illegal[*s]) return(True);
-#endif
-
+  else
+  {
+    for (s = (unsigned char *)name;*s;s++)
+      if (illegal[*s]) return(True);
+  }
 
   return(False);
 }
index 19c1158658ca939545db1f3002defa17c5ded093..c8e726d36e866f71ad0648eb6f06c64d157b84c1 100644 (file)
@@ -1347,6 +1347,14 @@ static int call_trans2setfilepathinfo(char *inbuf, char *outbuf, int length,
       tvs.modtime=MAX(interpret_long_date(pdata+16),
                       interpret_long_date(pdata+24));
 
+#if 0 /* Needs more testing... */
+      /* Test from Luke to prevent Win95 from
+         setting incorrect values here.
+       */
+      if (tvs.actime < tvs.modtime)
+        return(ERROR(ERRDOS,ERRnoaccess));
+#endif /* Needs more testing... */
+
       /* attributes */
       mode = IVAL(pdata,32);
       break;
index 582f4eb6db387a599c4384d1689943e14905fbd6..25c94dcd6a05df4c82650010dff1091639c29e8c 100644 (file)
@@ -192,17 +192,25 @@ int main(int argc,char *argv[])
        retries = 1;
       }
 
-    if (name_query(ServerFD,lookup,lookup_type,bcast,True,
+      if (name_query(ServerFD,lookup,lookup_type,bcast,True,
                   bcast_addr,&ip,NULL)) 
-       {
-         printf("%s %s\n",inet_ntoa(ip),lookup);
-    }
+      {
+        printf("%s %s\n",inet_ntoa(ip),lookup);
+
+        /* We can only do find_status if the ip address returned
+           was valid - ie. name_query returned true.
+         */
        if (find_status) 
        {
              printf("Looking up status of %s\n",inet_ntoa(ip));
              name_status(ServerFD,lookup,lookup_type,True,ip,NULL,NULL,NULL);
              printf("\n");
        }
+      }
+      else
+      {
+        printf("name_query failed to find name %s\n", lookup);
+      }
   }
 
   return(0);