svn commit: samba r15172 - in branches/tmp: . samba4-codepage samba4-codepage/codepages samba4-codepage/lib/util samba4-codepage/ntvfs/posix samba4-codepage/param samba4-codepage/script

jelmer at samba.org jelmer at samba.org
Sun Apr 23 10:16:03 GMT 2006


Author: jelmer
Date: 2006-04-23 10:16:01 +0000 (Sun, 23 Apr 2006)
New Revision: 15172

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=15172

Log:
Add separate branch for my codepage patch. This integrates the valid.dat, upcase.dat and lowcase.dat files 
into a shared library. 

This patch should be integrated whenever --enable-dso becomes the default. Without it, all binaries 
will grow 250k in size.

Added:
   branches/tmp/samba4-codepage/
   branches/tmp/samba4-codepage/codepages/codepages.c
   branches/tmp/samba4-codepage/codepages/config.mk
   branches/tmp/samba4-codepage/codepages/embed-codepage.pl
Removed:
   branches/tmp/samba4-codepage/script/installdat.sh
Modified:
   branches/tmp/samba4-codepage/codepages/
   branches/tmp/samba4-codepage/dynconfig.c
   branches/tmp/samba4-codepage/dynconfig.h
   branches/tmp/samba4-codepage/dynconfig.mk
   branches/tmp/samba4-codepage/lib/util/config.mk
   branches/tmp/samba4-codepage/lib/util/ms_fnmatch.c
   branches/tmp/samba4-codepage/lib/util/util_str.c
   branches/tmp/samba4-codepage/lib/util/util_unistr.c
   branches/tmp/samba4-codepage/main.mk
   branches/tmp/samba4-codepage/ntvfs/posix/pvfs_util.c
   branches/tmp/samba4-codepage/param/util.c


Changeset:
Copied: branches/tmp/samba4-codepage (from rev 15162, branches/SAMBA_4_0/source)


Property changes on: branches/tmp/samba4-codepage/codepages
___________________________________________________________________
Name: svn:ignore
   - 

   + lowcase.c
upcase.c


Added: branches/tmp/samba4-codepage/codepages/codepages.c
===================================================================
--- branches/SAMBA_4_0/source/codepages/codepages.c	2006-04-22 02:33:11 UTC (rev 15162)
+++ branches/tmp/samba4-codepage/codepages/codepages.c	2006-04-23 10:16:01 UTC (rev 15172)
@@ -0,0 +1,71 @@
+/* 
+   Unix SMB/CIFS implementation.
+   Samba utility functions
+   Copyright (C) Andrew Tridgell 1992-2001
+   Copyright (C) Jelmer Vernooij 2006
+   
+   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"
+#include "system/iconv.h"
+
+/**
+ * @file
+ * @brief Unicode string manipulation
+ */
+
+#include "lowcase.c"
+#include "upcase.c"
+
+/**
+ Convert a codepoint_t to upper case.
+**/
+codepoint_t toupper_w(codepoint_t val)
+{
+	if (val < 128) {
+		return toupper(val);
+	}
+	if (val & 0xFFFF0000) {
+		return val;
+	}
+	return SVAL(upcase_table, val*2);
+}
+
+/**
+ Convert a codepoint_t to lower case.
+**/
+codepoint_t tolower_w(codepoint_t val)
+{
+	if (val < 128) {
+		return tolower(val);
+	}
+	if (val & 0xFFFF0000) {
+		return val;
+	}
+	return SVAL(lowcase_table, val*2);
+}
+
+/**
+  compare two codepoints case insensitively
+*/
+int codepoint_cmpi(codepoint_t c1, codepoint_t c2)
+{
+	if (c1 == c2 ||
+	    toupper_w(c1) == toupper_w(c2)) {
+		return 0;
+	}
+	return c1 - c2;
+}


Property changes on: branches/tmp/samba4-codepage/codepages/codepages.c
___________________________________________________________________
Name: svn:eol-style
   + native

Added: branches/tmp/samba4-codepage/codepages/config.mk
===================================================================
--- branches/SAMBA_4_0/source/codepages/config.mk	2006-04-22 02:33:11 UTC (rev 15162)
+++ branches/tmp/samba4-codepage/codepages/config.mk	2006-04-23 10:16:01 UTC (rev 15172)
@@ -0,0 +1,11 @@
+[SUBSYSTEM::codepages]
+OBJ_FILES = codepages.o
+PRIVATE_PROTO_HEADER = codepages.h
+
+codepages/codepages.c: codepages/upcase.c codepages/lowcase.c
+
+codepages/upcase.c: codepages/upcase.dat codepages/embed-codepage.pl
+	./codepages/embed-codepage.pl upcase_table < codepages/upcase.dat > codepages/upcase.c
+
+codepages/lowcase.c: codepages/lowcase.dat codepages/embed-codepage.pl
+	./codepages/embed-codepage.pl lowcase_table < codepages/lowcase.dat > codepages/lowcase.c

Added: branches/tmp/samba4-codepage/codepages/embed-codepage.pl
===================================================================
--- branches/SAMBA_4_0/source/codepages/embed-codepage.pl	2006-04-22 02:33:11 UTC (rev 15162)
+++ branches/tmp/samba4-codepage/codepages/embed-codepage.pl	2006-04-23 10:16:01 UTC (rev 15172)
@@ -0,0 +1,25 @@
+#!/usr/bin/perl
+# Generate a C file holding binary data
+# Copyright (C) 2006 Jelmer Vernooij <jelmer at samba.org>
+# Published under the GNU GPL
+my $i = 0;
+
+my $varname = shift;
+unless ($varname) {
+	$varname = "table";
+}
+
+print "static const uint8_t $varname\[\] = {\n\t";
+
+while(!eof(STDIN)) {
+	$i++;
+	my $c = getc;
+
+	printf "0x%02x", $c;
+
+	print ", " unless eof(STDIN);
+
+	print "\n\t" if ($i % 12 == 0);
+}
+
+print "\n};\n\n";


Property changes on: branches/tmp/samba4-codepage/codepages/embed-codepage.pl
___________________________________________________________________
Name: svn:executable
   + *

Modified: branches/tmp/samba4-codepage/dynconfig.c
===================================================================
--- branches/SAMBA_4_0/source/dynconfig.c	2006-04-22 02:33:11 UTC (rev 15162)
+++ branches/tmp/samba4-codepage/dynconfig.c	2006-04-23 10:16:01 UTC (rev 15172)
@@ -56,9 +56,7 @@
 /** Statically configured LanMan hosts. **/
 _PUBLIC_ const char *dyn_LMHOSTSFILE = LMHOSTSFILE; 
 
-/** Samba data directory. */
-_PUBLIC_ const char *dyn_DATADIR = DATADIR;
-
+/** Modules parent directory. */
 _PUBLIC_ const char *dyn_MODULESDIR = MODULESDIR;
 
 /** Shared library extension */

Modified: branches/tmp/samba4-codepage/dynconfig.h
===================================================================
--- branches/SAMBA_4_0/source/dynconfig.h	2006-04-22 02:33:11 UTC (rev 15162)
+++ branches/tmp/samba4-codepage/dynconfig.h	2006-04-23 10:16:01 UTC (rev 15172)
@@ -30,7 +30,6 @@
 extern const char *dyn_NCALRPCDIR;
 extern const char *dyn_LOGFILEBASE;
 extern const char *dyn_LMHOSTSFILE;
-extern const char *dyn_DATADIR;
 extern const char *dyn_MODULESDIR;
 extern const char *dyn_SHLIBEXT;
 extern const char *dyn_LOCKDIR; 

Modified: branches/tmp/samba4-codepage/dynconfig.mk
===================================================================
--- branches/SAMBA_4_0/source/dynconfig.mk	2006-04-22 02:33:11 UTC (rev 15162)
+++ branches/tmp/samba4-codepage/dynconfig.mk	2006-04-23 10:16:01 UTC (rev 15172)
@@ -5,7 +5,7 @@
 
 PATH_FLAGS = -DCONFIGFILE=\"$(CONFIGFILE)\" \
 	 -DBINDIR=\"$(BINDIR)\" -DLMHOSTSFILE=\"$(LMHOSTSFILE)\" \
-	 -DLOCKDIR=\"$(LOCKDIR)\" -DPIDDIR=\"$(PIDDIR)\" -DDATADIR=\"$(DATADIR)\" \
+	 -DLOCKDIR=\"$(LOCKDIR)\" -DPIDDIR=\"$(PIDDIR)\" \
 	 -DLOGFILEBASE=\"$(LOGFILEBASE)\" -DSHLIBEXT=\"$(SHLIBEXT)\" \
 	 -DCONFIGDIR=\"$(CONFIGDIR)\" -DNCALRPCDIR=\"$(NCALRPCDIR)\" \
 	 -DSWATDIR=\"$(SWATDIR)\" -DPRIVATE_DIR=\"$(PRIVATEDIR)\" \
@@ -21,7 +21,7 @@
 
 DEVEL_PATH_FLAGS = -DCONFIGFILE=\"$(CONFIGFILE)\" -DBINDIR=\"$(builddir)/bin\" \
      -DLMHOSTSFILE=\"$(LMHOSTSFILE)\" -DLOCKDIR=\"$(LOCKDIR)\" \
-	 -DPIDDIR=\"$(PIDDIR)\" -DDATADIR=\"$(srcdir)/codepages\" \
+	 -DPIDDIR=\"$(PIDDIR)\" \
 	 -DLOGFILEBASE=\"$(LOGFILEBASE)\" -DSHLIBEXT=\"$(SHLIBEXT)\" \
 	 -DCONFIGDIR=\"$(CONFIGDIR)\" -DNCALRPCDIR=\"$(NCALRPCDIR)\" \
 	 -DSWATDIR=\"$(srcdir)/../swat\" -DPRIVATE_DIR=\"$(PRIVATEDIR)\" \

Modified: branches/tmp/samba4-codepage/lib/util/config.mk
===================================================================
--- branches/SAMBA_4_0/source/lib/util/config.mk	2006-04-22 02:33:11 UTC (rev 15162)
+++ branches/tmp/samba4-codepage/lib/util/config.mk	2006-04-23 10:16:01 UTC (rev 15172)
@@ -33,7 +33,7 @@
 		module.o
 REQUIRED_SUBSYSTEMS = \
 		CHARSET LIBREPLACE LIBCRYPTO EXT_LIB_DL LIBTALLOC \
-		SOCKET_WRAPPER \
+		SOCKET_WRAPPER codepages \
 # for the base64 functions
 		ldb 
 

Modified: branches/tmp/samba4-codepage/lib/util/ms_fnmatch.c
===================================================================
--- branches/SAMBA_4_0/source/lib/util/ms_fnmatch.c	2006-04-22 02:33:11 UTC (rev 15162)
+++ branches/tmp/samba4-codepage/lib/util/ms_fnmatch.c	2006-04-23 10:16:01 UTC (rev 15172)
@@ -30,6 +30,7 @@
  */
 
 #include "includes.h"
+#include "codepages/codepages.h"
 
 static int null_match(const char *p)
 {

Modified: branches/tmp/samba4-codepage/lib/util/util_str.c
===================================================================
--- branches/SAMBA_4_0/source/lib/util/util_str.c	2006-04-22 02:33:11 UTC (rev 15162)
+++ branches/tmp/samba4-codepage/lib/util/util_str.c	2006-04-23 10:16:01 UTC (rev 15172)
@@ -27,6 +27,7 @@
 #include "smb.h"
 #include "pstring.h"
 #include "lib/ldb/include/ldb.h"
+#include "codepages/codepages.h"
 
 /**
  * @file

Modified: branches/tmp/samba4-codepage/lib/util/util_unistr.c
===================================================================
--- branches/SAMBA_4_0/source/lib/util/util_unistr.c	2006-04-22 02:33:11 UTC (rev 15162)
+++ branches/tmp/samba4-codepage/lib/util/util_unistr.c	2006-04-23 10:16:01 UTC (rev 15172)
@@ -20,90 +20,13 @@
 */
 
 #include "includes.h"
-#include "system/iconv.h"
 
 /**
  * @file
  * @brief Unicode string manipulation
  */
 
-/* these 2 tables define the unicode case handling.  They are loaded
-   at startup either via mmap() or read() from the lib directory */
-static void *upcase_table;
-static void *lowcase_table;
-
-
-/*******************************************************************
-load the case handling tables
-********************************************************************/
-static void load_case_tables(void)
-{
-	TALLOC_CTX *mem_ctx;
-
-	mem_ctx = talloc_init("load_case_tables");
-	if (!mem_ctx) {
-		smb_panic("No memory for case_tables");
-	}
-	upcase_table = map_file(data_path(mem_ctx, "upcase.dat"), 0x20000);
-	lowcase_table = map_file(data_path(mem_ctx, "lowcase.dat"), 0x20000);
-	talloc_free(mem_ctx);
-	if (upcase_table == NULL) {
-		/* try also under codepages for testing purposes */
-		upcase_table = map_file("codepages/upcase.dat", 0x20000);
-		if (upcase_table == NULL) {
-			upcase_table = (void *)-1;
-		}
-	}
-	if (lowcase_table == NULL) {
-		/* try also under codepages for testing purposes */
-		lowcase_table = map_file("codepages/lowcase.dat", 0x20000);
-		if (lowcase_table == NULL) {
-			lowcase_table = (void *)-1;
-		}
-	}
-}
-
 /**
- Convert a codepoint_t to upper case.
-**/
-codepoint_t toupper_w(codepoint_t val)
-{
-	if (val < 128) {
-		return toupper(val);
-	}
-	if (upcase_table == NULL) {
-		load_case_tables();
-	}
-	if (upcase_table == (void *)-1) {
-		return val;
-	}
-	if (val & 0xFFFF0000) {
-		return val;
-	}
-	return SVAL(upcase_table, val*2);
-}
-
-/**
- Convert a codepoint_t to lower case.
-**/
-codepoint_t tolower_w(codepoint_t val)
-{
-	if (val < 128) {
-		return tolower(val);
-	}
-	if (lowcase_table == NULL) {
-		load_case_tables();
-	}
-	if (lowcase_table == (void *)-1) {
-		return val;
-	}
-	if (val & 0xFFFF0000) {
-		return val;
-	}
-	return SVAL(lowcase_table, val*2);
-}
-
-/**
 return the number of bytes occupied by a buffer in CH_UTF16 format
 the result includes the null termination
 **/
@@ -141,15 +64,3 @@
 		return 0;
 	return PTR_DIFF(p, base_ptr) & 1;
 }
-
-/**
-  compare two codepoints case insensitively
-*/
-int codepoint_cmpi(codepoint_t c1, codepoint_t c2)
-{
-	if (c1 == c2 ||
-	    toupper_w(c1) == toupper_w(c2)) {
-		return 0;
-	}
-	return c1 - c2;
-}

Modified: branches/tmp/samba4-codepage/main.mk
===================================================================
--- branches/SAMBA_4_0/source/main.mk	2006-04-22 02:33:11 UTC (rev 15162)
+++ branches/tmp/samba4-codepage/main.mk	2006-04-23 10:16:01 UTC (rev 15172)
@@ -32,6 +32,7 @@
 include scripting/swig/config.mk
 include kdc/config.mk
 include passdb/config.mk
+include codepages/config.mk
 
 DEFAULT_HEADERS = $(srcdir)/include/core.h \
 				  $(srcdir)/include/dlinklist.h \
@@ -61,7 +62,6 @@
 	@echo '  jsdir:       $(JSDIR)'
 	@echo '  swatdir:     $(SWATDIR)'
 	@echo '  mandir:      $(MANDIR)'
-	@echo '  datadir:     $(DATADIR)'
 	@echo '  winbindd_socket_dir:  $(WINBINDD_SOCKET_DIR)'
 
 showflags:
@@ -82,7 +82,7 @@
 PKGCONFIGDIR = $(LIBDIR)/pkgconfig
 LMHOSTSFILE = $(CONFIGDIR)/lmhosts
 
-install: showlayout installbin installdat installswat installmisc installlib \
+install: showlayout installbin installswat installmisc installlib \
 	installheader installpc installplugins
 
 # DESTDIR is used here to prevent packagers wasting their time
@@ -103,7 +103,6 @@
 		$(DESTDIR)$(MANDIR) \
 		$(DESTDIR)$(VARDIR) \
 		$(DESTDIR)$(PRIVATEDIR) \
-		$(DESTDIR)$(DATADIR) \
 		$(DESTDIR)$(PIDDIR) \
 		$(DESTDIR)$(LOCKDIR) \
 		$(DESTDIR)$(LOGFILEBASE) \
@@ -135,9 +134,6 @@
 installheader: headers installdirs
 	@$(PERL) $(srcdir)/script/installheader.pl $(DESTDIR)$(INCLUDEDIR) $(PUBLIC_HEADERS) $(DEFAULT_HEADERS)
 
-installdat: installdirs
-	@$(SHELL) $(srcdir)/script/installdat.sh $(DESTDIR)$(DATADIR) $(srcdir)
-
 installswat: installdirs
 	@$(SHELL) $(srcdir)/script/installswat.sh $(DESTDIR)$(SWATDIR) $(srcdir)
 

Modified: branches/tmp/samba4-codepage/ntvfs/posix/pvfs_util.c
===================================================================
--- branches/SAMBA_4_0/source/ntvfs/posix/pvfs_util.c	2006-04-22 02:33:11 UTC (rev 15162)
+++ branches/tmp/samba4-codepage/ntvfs/posix/pvfs_util.c	2006-04-23 10:16:01 UTC (rev 15172)
@@ -23,6 +23,7 @@
 
 #include "includes.h"
 #include "vfs_posix.h"
+#include "codepages/codepages.h"
 
 /*
   return True if a string contains one of the CIFS wildcard characters

Modified: branches/tmp/samba4-codepage/param/util.c
===================================================================
--- branches/SAMBA_4_0/source/param/util.c	2006-04-22 02:33:11 UTC (rev 15162)
+++ branches/tmp/samba4-codepage/param/util.c	2006-04-23 10:16:01 UTC (rev 15172)
@@ -107,23 +107,7 @@
 	return fname;
 }
 
-
 /**
- * @brief Returns an absolute path to a file in the Samba lib directory.
- *
- * @param name File to find, relative to DATADIR.
- *
- * @retval Pointer to a talloc'ed string containing the full path.
- **/
-
-_PUBLIC_ char *data_path(TALLOC_CTX* mem_ctx, const char *name)
-{
-	char *fname;
-	fname = talloc_asprintf(mem_ctx, "%s/%s", dyn_DATADIR, name);
-	return fname;
-}
-
-/**
  * @brief Returns an absolute path to a file in the Samba private directory.
  *
  * @param name File to find, relative to PRIVATEDIR.

Deleted: branches/tmp/samba4-codepage/script/installdat.sh
===================================================================
--- branches/SAMBA_4_0/source/script/installdat.sh	2006-04-22 02:33:11 UTC (rev 15162)
+++ branches/tmp/samba4-codepage/script/installdat.sh	2006-04-23 10:16:01 UTC (rev 15172)
@@ -1,23 +0,0 @@
-#!/bin/sh
-#fist version March 2002, Herb  Lewis
-
-DATDIR=$1
-SRCDIR=$2/
-
-echo Installing dat files in $DATDIR
-
-for f in $SRCDIR/codepages/*.dat; do
-	FNAME=$DATDIR/`basename $f`
-	echo $FNAME
-	cp $f $FNAME || echo Cannot install $FNAME. Does $USER have privileges?
-	chmod 0644 $FNAME
-done
-
-cat << EOF
-======================================================================
-The dat files have been installed. 
-======================================================================
-EOF
-
-exit 0
-



More information about the samba-cvs mailing list