Move 'weird' character set into new 'developer' module
authorJelmer Vernooij <jelmer@samba.org>
Wed, 13 Nov 2002 19:07:34 +0000 (19:07 +0000)
committerJelmer Vernooij <jelmer@samba.org>
Wed, 13 Nov 2002 19:07:34 +0000 (19:07 +0000)
source/Makefile.in
source/lib/iconv.c
source/modules/developer.c [new file with mode: 0644]

index 8538bd56d6a6479eecf306b436ce5d4ef495d25e..af14c6a9f834bf8ac65bc0766dee0c55275ac2bf 100644 (file)
@@ -116,7 +116,7 @@ SCRIPTS = $(srcdir)/script/smbtar $(srcdir)/script/addtosmbpass $(srcdir)/script
 
 QUOTAOBJS=@QUOTAOBJS@
 
-MODULES = bin/vfs_audit.so bin/vfs_recycle.so bin/vfs_netatalk.so @MODULE_PDB_MYSQL@ @MODULE_PDB_XML@
+MODULES = bin/vfs_audit.so bin/vfs_recycle.so bin/vfs_netatalk.so bin/developer.so @MODULE_PDB_MYSQL@ @MODULE_PDB_XML@
 
 ######################################################################
 # object file lists
@@ -984,7 +984,7 @@ TOPFILES=dynconfig.o dynconfig.po
 
 clean: delheaders python_clean
        -rm -f core */*~ *~ */*.o */*.po */*.po32 */*.@SHLIBEXT@ \
-               $(TOPFILES) $(PROGS) $(SPROGS) .headers.stamp
+               $(TOPFILES) $(PROGS) $(SPROGS) $(MODULES) .headers.stamp
 
 # Making this target will just make sure that the prototype files
 # exist, not necessarily that they are up to date.  Since they're
@@ -1061,7 +1061,7 @@ ctags:
        ctags `find $(srcdir) -name "*.[ch]" | grep -v /CVS/`
 
 realclean: clean delheaders
-       -rm -f config.log $(PROGS) $(SPROGS) bin/.dummy script/findsmb
+       -rm -f config.log $(PROGS) $(MODULES) $(SPROGS) bin/.dummy script/findsmb
 
 distclean: realclean
        -rm -f include/stamp-h
index 3498f976b3edbce4246a3b09ee77443d4ebe2352..e54a74864e1eedb2b533ea1d12c7e6f27353650b 100644 (file)
@@ -25,8 +25,6 @@ static size_t ascii_pull(void *,char **, size_t *, char **, size_t *);
 static size_t ascii_push(void *,char **, size_t *, char **, size_t *);
 static size_t  utf8_pull(void *,char **, size_t *, char **, size_t *);
 static size_t  utf8_push(void *,char **, size_t *, char **, size_t *);
-static size_t weird_pull(void *,char **, size_t *, char **, size_t *);
-static size_t weird_push(void *,char **, size_t *, char **, size_t *);
 static size_t ucs2hex_pull(void *,char **, size_t *, char **, size_t *);
 static size_t ucs2hex_push(void *,char **, size_t *, char **, size_t *);
 static size_t iconv_copy(void *,char **, size_t *, char **, size_t *);
@@ -35,7 +33,6 @@ struct charset_functions builtin_functions[] = {
                {"UCS-2LE",  iconv_copy, iconv_copy},
                {"UTF8",   utf8_pull,  utf8_push},
                {"ASCII", ascii_pull, ascii_push},
-               {"WEIRD", weird_pull, weird_push},
                {"UCS2-HEX", ucs2hex_pull, ucs2hex_push},
                {NULL, NULL, NULL}
 };
@@ -384,111 +381,6 @@ static size_t ucs2hex_push(void *cd, char **inbuf, size_t *inbytesleft,
 }
 
 
-/* the "weird" character set is very useful for testing multi-byte
-   support and finding bugs. Don't use on a production system! 
-*/
-static struct {
-       char from;
-       char *to;
-       int len;
-} weird_table[] = {
-       {'q', "^q^", 3},
-       {'Q', "^Q^", 3},
-       {0, NULL}
-};
-
-static size_t weird_pull(void *cd, char **inbuf, size_t *inbytesleft,
-                        char **outbuf, size_t *outbytesleft)
-{
-       while (*inbytesleft >= 1 && *outbytesleft >= 2) {
-               int i;
-               int done = 0;
-               for (i=0;weird_table[i].from;i++) {
-                       if (strncmp((*inbuf), 
-                                   weird_table[i].to, 
-                                   weird_table[i].len) == 0) {
-                               if (*inbytesleft < weird_table[i].len) {
-                                       DEBUG(0,("ERROR: truncated weird string\n"));
-                                       /* smb_panic("weird_pull"); */
-
-                               } else {
-                                       (*outbuf)[0] = weird_table[i].from;
-                                       (*outbuf)[1] = 0;
-                                       (*inbytesleft)  -= weird_table[i].len;
-                                       (*outbytesleft) -= 2;
-                                       (*inbuf)  += weird_table[i].len;
-                                       (*outbuf) += 2;
-                                       done = 1;
-                                       break;
-                               }
-                       }
-               }
-               if (done) continue;
-               (*outbuf)[0] = (*inbuf)[0];
-               (*outbuf)[1] = 0;
-               (*inbytesleft)  -= 1;
-               (*outbytesleft) -= 2;
-               (*inbuf)  += 1;
-               (*outbuf) += 2;
-       }
-
-       if (*inbytesleft > 0) {
-               errno = E2BIG;
-               return -1;
-       }
-       
-       return 0;
-}
-
-static size_t weird_push(void *cd, char **inbuf, size_t *inbytesleft,
-                        char **outbuf, size_t *outbytesleft)
-{
-       int ir_count=0;
-
-       while (*inbytesleft >= 2 && *outbytesleft >= 1) {
-               int i;
-               int done=0;
-               for (i=0;weird_table[i].from;i++) {
-                       if ((*inbuf)[0] == weird_table[i].from &&
-                           (*inbuf)[1] == 0) {
-                               if (*outbytesleft < weird_table[i].len) {
-                                       DEBUG(0,("No room for weird character\n"));
-                                       /* smb_panic("weird_push"); */
-                               } else {
-                                       memcpy(*outbuf, weird_table[i].to, 
-                                              weird_table[i].len);
-                                       (*inbytesleft)  -= 2;
-                                       (*outbytesleft) -= weird_table[i].len;
-                                       (*inbuf)  += 2;
-                                       (*outbuf) += weird_table[i].len;
-                                       done = 1;
-                                       break;
-                               }
-                       }
-               }
-               if (done) continue;
-
-               (*outbuf)[0] = (*inbuf)[0];
-               if ((*inbuf)[1]) ir_count++;
-               (*inbytesleft)  -= 2;
-               (*outbytesleft) -= 1;
-               (*inbuf)  += 2;
-               (*outbuf) += 1;
-       }
-
-       if (*inbytesleft == 1) {
-               errno = EINVAL;
-               return -1;
-       }
-
-       if (*inbytesleft > 1) {
-               errno = E2BIG;
-               return -1;
-       }
-       
-       return ir_count;
-}
-
 static size_t iconv_copy(void *cd, char **inbuf, size_t *inbytesleft,
                         char **outbuf, size_t *outbytesleft)
 {
diff --git a/source/modules/developer.c b/source/modules/developer.c
new file mode 100644 (file)
index 0000000..c12bbc5
--- /dev/null
@@ -0,0 +1,132 @@
+/* 
+   Unix SMB/CIFS implementation.
+   Samba module with developer tools
+   Copyright (C) Andrew Tridgell 2001
+   Copyright (C) Jelmer Vernooij 2002
+   
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+   
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+   
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+
+static struct {
+       char from;
+       char *to;
+       int len;
+} weird_table[] = {
+       {'q', "^q^", 3},
+       {'Q', "^Q^", 3},
+       {0, NULL}
+};
+
+static size_t weird_pull(void *cd, char **inbuf, size_t *inbytesleft,
+                        char **outbuf, size_t *outbytesleft)
+{
+       while (*inbytesleft >= 1 && *outbytesleft >= 2) {
+               int i;
+               int done = 0;
+               for (i=0;weird_table[i].from;i++) {
+                       if (strncmp((*inbuf), 
+                                   weird_table[i].to, 
+                                   weird_table[i].len) == 0) {
+                               if (*inbytesleft < weird_table[i].len) {
+                                       DEBUG(0,("ERROR: truncated weird string\n"));
+                                       /* smb_panic("weird_pull"); */
+
+                               } else {
+                                       (*outbuf)[0] = weird_table[i].from;
+                                       (*outbuf)[1] = 0;
+                                       (*inbytesleft)  -= weird_table[i].len;
+                                       (*outbytesleft) -= 2;
+                                       (*inbuf)  += weird_table[i].len;
+                                       (*outbuf) += 2;
+                                       done = 1;
+                                       break;
+                               }
+                       }
+               }
+               if (done) continue;
+               (*outbuf)[0] = (*inbuf)[0];
+               (*outbuf)[1] = 0;
+               (*inbytesleft)  -= 1;
+               (*outbytesleft) -= 2;
+               (*inbuf)  += 1;
+               (*outbuf) += 2;
+       }
+
+       if (*inbytesleft > 0) {
+               errno = E2BIG;
+               return -1;
+       }
+       
+       return 0;
+}
+
+static size_t weird_push(void *cd, char **inbuf, size_t *inbytesleft,
+                        char **outbuf, size_t *outbytesleft)
+{
+       int ir_count=0;
+
+       while (*inbytesleft >= 2 && *outbytesleft >= 1) {
+               int i;
+               int done=0;
+               for (i=0;weird_table[i].from;i++) {
+                       if ((*inbuf)[0] == weird_table[i].from &&
+                           (*inbuf)[1] == 0) {
+                               if (*outbytesleft < weird_table[i].len) {
+                                       DEBUG(0,("No room for weird character\n"));
+                                       /* smb_panic("weird_push"); */
+                               } else {
+                                       memcpy(*outbuf, weird_table[i].to, 
+                                              weird_table[i].len);
+                                       (*inbytesleft)  -= 2;
+                                       (*outbytesleft) -= weird_table[i].len;
+                                       (*inbuf)  += 2;
+                                       (*outbuf) += weird_table[i].len;
+                                       done = 1;
+                                       break;
+                               }
+                       }
+               }
+               if (done) continue;
+
+               (*outbuf)[0] = (*inbuf)[0];
+               if ((*inbuf)[1]) ir_count++;
+               (*inbytesleft)  -= 2;
+               (*outbytesleft) -= 1;
+               (*inbuf)  += 2;
+               (*outbuf) += 1;
+       }
+
+       if (*inbytesleft == 1) {
+               errno = EINVAL;
+               return -1;
+       }
+
+       if (*inbytesleft > 1) {
+               errno = E2BIG;
+               return -1;
+       }
+       
+       return ir_count;
+}
+
+struct charset_functions weird_functions = {"WEIRD", weird_pull, weird_push};
+
+int init_module(void)
+{
+       smb_register_charset(&weird_functions);
+       return 0;
+}