Questions about charset modules

Jelmer Vernooij jelmer at vernstok.nl
Sun Oct 5 00:29:17 GMT 2003


Benjamin,

On Thu, Oct 02, 2003 at 07:45:52PM +0200, Benjamin Riefenstahl wrote about 'Questions about charset modules':
> I have written a charset module for the Mac OS X filesystem encoding,
> using OS services to do the work.  During the design and testing some
> questions came up on which I'd like some advice.

> - I'd like to avoid memory management in these functions as much as
>   possible.  But I need buffers for temporary storage (e.g. to do
>   byte-swapping).  Is there an upper limit to the length of the
>   strings passed to the module, so that I could use fixed-length
>   buffers?
I don't think there's a fixed upper length limit of those buffers...
Perhaps a construction like the one below would be useful to you:

void foo() {
	static char *buffer = NULL; static size_t buffer_size = 0;

	if(needed_buffer_size > buffer_size) { 
		buffer_size = needed_buffer_size;
		buffer = realloc(buffer, buffer_size);
	}
}

This at least eliminates the overhead of allocating and freeing
memory every time the function is called.

> - The charset functions are called with invalid data from some places,
>   I have seen is_legal_name() in smbd/mangle_hash2.c and
>   check_for_pipe() in smbd/open.c.  Both functions cut strings at
>   arbitrary places and so create invalid multi-byte sequences at the
>   end.  How should the charset functions respond?  Currently they just
>   return an error and do nothing.
They should indeed give an error and ignore those bytes. The code
that's calling the function just needs to be fixed....

> - How should the charset module be named?  I currently use
>   modules/charset_macosxfs.c for the source and macosxfs.dylib for the
>   binary.
It should be named bin/charset_macosxfs. at LIBEXT@ while linking and
should be installed to $SAMBALIBDIR/charset/macosxfs. at LIBEXT@.

(Also see the Makefile rule for the 'weird' charset module and the
configure.in macros for the 'weird' charset module)

Jelmer

-- 
Jelmer Vernooij <jelmer at nl.linux.org> - http://jelmer.vernstok.nl/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.samba.org/archive/samba-technical/attachments/20031005/1a165f91/attachment.bin


More information about the samba-technical mailing list