Date: Sat, 20 Mar 2004 17:31:08 -0800 (PST) From: Peter Wemm <peter@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 49419 for review Message-ID: <200403210131.i2L1V8wQ000867@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=49419 Change 49419 by peter@peter_overcee on 2004/03/20 17:30:37 IFC @49416 Affected files ... .. //depot/projects/hammer/contrib/sort/Makefile#2 delete .. //depot/projects/hammer/contrib/sort/append.c#2 delete .. //depot/projects/hammer/contrib/sort/extern.h#2 delete .. //depot/projects/hammer/contrib/sort/fields.c#2 delete .. //depot/projects/hammer/contrib/sort/files.c#2 delete .. //depot/projects/hammer/contrib/sort/fsort.c#2 delete .. //depot/projects/hammer/contrib/sort/fsort.h#2 delete .. //depot/projects/hammer/contrib/sort/init.c#2 delete .. //depot/projects/hammer/contrib/sort/msort.c#2 delete .. //depot/projects/hammer/contrib/sort/pathnames.h#2 delete .. //depot/projects/hammer/contrib/sort/regress/Makefile#2 delete .. //depot/projects/hammer/contrib/sort/regress/stests#2 delete .. //depot/projects/hammer/contrib/sort/sort.1#2 delete .. //depot/projects/hammer/contrib/sort/sort.c#2 delete .. //depot/projects/hammer/contrib/sort/sort.h#2 delete .. //depot/projects/hammer/contrib/sort/tmp.c#2 delete .. //depot/projects/hammer/etc/ftpusers#3 integrate .. //depot/projects/hammer/etc/mail/aliases#5 integrate .. //depot/projects/hammer/etc/rc.d/devfs#8 integrate .. //depot/projects/hammer/include/stdio.h#7 integrate .. //depot/projects/hammer/lib/libarchive/Makefile#3 integrate .. //depot/projects/hammer/lib/libarchive/archive.h#4 integrate .. //depot/projects/hammer/lib/libarchive/archive_entry.3#2 integrate .. //depot/projects/hammer/lib/libarchive/archive_entry.c#3 integrate .. //depot/projects/hammer/lib/libarchive/archive_entry.h#2 integrate .. //depot/projects/hammer/lib/libarchive/archive_platform.h#2 integrate .. //depot/projects/hammer/lib/libarchive/archive_private.h#3 integrate .. //depot/projects/hammer/lib/libarchive/archive_read.c#3 integrate .. //depot/projects/hammer/lib/libarchive/archive_read_data_into_fd.c#3 integrate .. //depot/projects/hammer/lib/libarchive/archive_read_support_compression_gzip.c#3 integrate .. //depot/projects/hammer/lib/libarchive/archive_read_support_format_cpio.c#4 integrate .. //depot/projects/hammer/lib/libarchive/archive_read_support_format_gnutar.c#3 integrate .. //depot/projects/hammer/lib/libarchive/archive_read_support_format_tar.c#4 integrate .. //depot/projects/hammer/lib/libarchive/archive_string.c#3 integrate .. //depot/projects/hammer/lib/libarchive/archive_string.h#2 integrate .. //depot/projects/hammer/lib/libarchive/archive_util.c#3 integrate .. //depot/projects/hammer/lib/libarchive/archive_write.c#3 integrate .. //depot/projects/hammer/lib/libarchive/archive_write_open_file.c#3 integrate .. //depot/projects/hammer/lib/libarchive/archive_write_set_format_pax.c#4 integrate .. //depot/projects/hammer/lib/libarchive/libarchive.3#2 integrate .. //depot/projects/hammer/lib/libarchive/tar.5#2 integrate .. //depot/projects/hammer/lib/libc/stdio/fseek.3#4 integrate .. //depot/projects/hammer/lib/libc/stdio/funopen.3#3 integrate .. //depot/projects/hammer/libexec/rtld-elf/Makefile#10 integrate .. //depot/projects/hammer/libexec/rtld-elf/debug.h#3 integrate .. //depot/projects/hammer/libexec/rtld-elf/libmap.c#12 integrate .. //depot/projects/hammer/libexec/rtld-elf/libmap.h#4 integrate .. //depot/projects/hammer/libexec/rtld-elf/rtld.c#18 integrate .. //depot/projects/hammer/libexec/rtld-elf/rtld.h#7 integrate .. //depot/projects/hammer/release/doc/en_US.ISO8859-1/relnotes/common/new.sgml#61 integrate .. //depot/projects/hammer/sbin/ldconfig/ldconfig.c#5 integrate .. //depot/projects/hammer/share/examples/pppd/ppp.deny.sample#3 integrate .. //depot/projects/hammer/share/man/man4/man4.i386/acpi_toshiba.4#2 integrate .. //depot/projects/hammer/share/termcap/termcap.src#11 integrate .. //depot/projects/hammer/sys/alpha/alpha/uio_machdep.c#1 branch .. //depot/projects/hammer/sys/alpha/include/_types.h#4 integrate .. //depot/projects/hammer/sys/amd64/amd64/uio_machdep.c#1 branch .. //depot/projects/hammer/sys/amd64/include/_types.h#8 integrate .. //depot/projects/hammer/sys/arm/include/_types.h#3 integrate .. //depot/projects/hammer/sys/compat/ia32/ia32_sysvec.c#12 integrate .. //depot/projects/hammer/sys/compat/ndis/kern_ndis.c#10 integrate .. //depot/projects/hammer/sys/compat/ndis/ndis_var.h#7 integrate .. //depot/projects/hammer/sys/compat/ndis/ntoskrnl_var.h#6 integrate .. //depot/projects/hammer/sys/compat/ndis/subr_ndis.c#9 integrate .. //depot/projects/hammer/sys/compat/ndis/subr_ntoskrnl.c#10 integrate .. //depot/projects/hammer/sys/conf/files#51 integrate .. //depot/projects/hammer/sys/conf/files.alpha#12 integrate .. //depot/projects/hammer/sys/conf/files.amd64#40 integrate .. //depot/projects/hammer/sys/conf/files.ia64#16 integrate .. //depot/projects/hammer/sys/conf/kern.post.mk#20 integrate .. //depot/projects/hammer/sys/dev/aac/aac_pci.c#12 integrate .. //depot/projects/hammer/sys/dev/acpica/acpi_pcib.c#14 integrate .. //depot/projects/hammer/sys/dev/ath/if_ath.c#17 integrate .. //depot/projects/hammer/sys/dev/awi/awi.c#9 integrate .. //depot/projects/hammer/sys/dev/gem/if_gem.c#9 integrate .. //depot/projects/hammer/sys/dev/hme/if_hme.c#7 integrate .. //depot/projects/hammer/sys/dev/if_ndis/if_ndis.c#10 integrate .. //depot/projects/hammer/sys/dev/iir/iir.h#6 integrate .. //depot/projects/hammer/sys/dev/sound/pci/vibes.c#6 integrate .. //depot/projects/hammer/sys/dev/uart/uart_cpu.h#3 integrate .. //depot/projects/hammer/sys/dev/uart/uart_cpu_alpha.c#4 integrate .. //depot/projects/hammer/sys/dev/uart/uart_cpu_amd64.c#4 integrate .. //depot/projects/hammer/sys/dev/uart/uart_cpu_i386.c#4 integrate .. //depot/projects/hammer/sys/dev/uart/uart_cpu_ia64.c#4 integrate .. //depot/projects/hammer/sys/dev/uart/uart_cpu_pc98.c#4 integrate .. //depot/projects/hammer/sys/dev/uart/uart_cpu_sparc64.c#6 integrate .. //depot/projects/hammer/sys/dev/uart/uart_subr.c#1 branch .. //depot/projects/hammer/sys/dev/usb/usb_subr.c#8 integrate .. //depot/projects/hammer/sys/dev/wi/if_wi.c#26 integrate .. //depot/projects/hammer/sys/i386/include/_types.h#6 integrate .. //depot/projects/hammer/sys/ia64/conf/GENERIC.hints#5 integrate .. //depot/projects/hammer/sys/ia64/ia64/uio_machdep.c#1 branch .. //depot/projects/hammer/sys/ia64/include/_types.h#6 integrate .. //depot/projects/hammer/sys/ia64/include/reg.h#5 integrate .. //depot/projects/hammer/sys/modules/uart/Makefile#3 integrate .. //depot/projects/hammer/sys/pci/if_xl.c#34 integrate .. //depot/projects/hammer/sys/powerpc/include/_types.h#4 integrate .. //depot/projects/hammer/sys/sparc64/include/_types.h#5 integrate .. //depot/projects/hammer/sys/sys/types.h#12 integrate .. //depot/projects/hammer/sys/sys/uio.h#7 integrate Differences ... ==== //depot/projects/hammer/etc/ftpusers#3 (text+ko) ==== @@ -1,4 +1,4 @@ -# $FreeBSD: src/etc/ftpusers,v 1.11 2003/04/27 05:49:53 imp Exp $ +# $FreeBSD: src/etc/ftpusers,v 1.12 2004/03/20 19:13:06 maxim Exp $ # # list of users disallowed any ftp access. # read by ftpd(8). @@ -14,6 +14,7 @@ man sshd bind +proxy uucp pop www ==== //depot/projects/hammer/etc/mail/aliases#5 (text+ko) ==== @@ -1,4 +1,4 @@ -# $FreeBSD: src/etc/mail/aliases,v 1.18 2003/04/27 05:49:53 imp Exp $ +# $FreeBSD: src/etc/mail/aliases,v 1.19 2004/03/20 19:13:06 maxim Exp $ # @(#)aliases 5.3 (Berkeley) 5/24/90 # # Aliases in this file will NOT be expanded in the header from @@ -34,6 +34,7 @@ nobody: root operator: root pop: root +proxy: root smmsp: postmaster sshd: root system: root ==== //depot/projects/hammer/etc/rc.d/devfs#8 (text+ko) ==== @@ -1,6 +1,6 @@ #!/bin/sh # -# $FreeBSD: src/etc/rc.d/devfs,v 1.7 2004/03/08 12:25:05 pjd Exp $ +# $FreeBSD: src/etc/rc.d/devfs,v 1.8 2004/03/20 07:10:16 green Exp $ # # PROVIDE: devfs @@ -16,10 +16,23 @@ devfs_start() { - if [ -n "$devfs_system_ruleset" ]; then + if [ -n "$devfs_system_ruleset" -o -n "$devfs_set_rulesets" ]; then devfs_init_rulesets - devfs_set_ruleset $devfs_system_ruleset /dev - devfs_apply_ruleset $devfs_system_ruleset /dev + if [ -n "$devfs_system_ruleset" ]; then + devfs_set_ruleset $devfs_system_ruleset /dev + devfs_apply_ruleset $devfs_system_ruleset /dev + fi + if [ -n "$devfs_set_rulesets" ]; then + local _dir_set + local _dir + local _set + for _dir_set in $devfs_set_rulesets; do + _dir=${_dir_set%=*} + _set=${_dir_set#*=} + devfs_set_ruleset $_set $_dir + devfs_apply_ruleset $_set $_dir + done + fi fi read_devfs_conf } ==== //depot/projects/hammer/include/stdio.h#7 (text+ko) ==== @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)stdio.h 8.5 (Berkeley) 4/29/95 - * $FreeBSD: src/include/stdio.h,v 1.53 2004/03/17 01:43:07 tjr Exp $ + * $FreeBSD: src/include/stdio.h,v 1.54 2004/03/20 11:45:52 tjr Exp $ */ #ifndef _STDIO_H_ @@ -418,16 +418,16 @@ extern int __isthreaded; -#define feof(p) (!__isthreaded ? __sfeof(p) : feof(p)) -#define ferror(p) (!__isthreaded ? __sferror(p) : ferror(p)) -#define clearerr(p) (!__isthreaded ? __sclearerr(p) : clearerr(p)) +#define feof(p) (!__isthreaded ? __sfeof(p) : (feof)(p)) +#define ferror(p) (!__isthreaded ? __sferror(p) : (ferror)(p)) +#define clearerr(p) (!__isthreaded ? __sclearerr(p) : (clearerr)(p)) #if __POSIX_VISIBLE -#define fileno(p) (!__isthreaded ? __sfileno(p) : fileno(p)) +#define fileno(p) (!__isthreaded ? __sfileno(p) : (fileno)(p)) #endif -#define getc(fp) (!__isthreaded ? __sgetc(fp) : getc(fp)) -#define putc(x, fp) (!__isthreaded ? __sputc(x, fp) : putc(x, fp)) +#define getc(fp) (!__isthreaded ? __sgetc(fp) : (getc)(fp)) +#define putc(x, fp) (!__isthreaded ? __sputc(x, fp) : (putc)(x, fp)) #define getchar() getc(stdin) #define putchar(x) putc(x, stdout) ==== //depot/projects/hammer/lib/libarchive/Makefile#3 (text+ko) ==== @@ -1,8 +1,14 @@ # Makefile for libarchive. # -# $FreeBSD: src/lib/libarchive/Makefile,v 1.3 2004/03/09 19:50:41 kientzle Exp $ -# +# $FreeBSD: src/lib/libarchive/Makefile,v 1.4 2004/03/19 22:37:06 kientzle Exp $ + LIB= archive +SHLIB_MAJOR= 1 + +# I'm not yet ready for a shared version of this library, as +# there are still a couple of API changes still in the works. +NOSHLIBS= 1 + SRCS= archive_check_magic.c \ archive_entry.c \ archive_read.c \ @@ -114,8 +120,8 @@ CFLAGS+= -DHAVE_DMALLOC -I/usr/local/include LDFLAGS+= -L/usr/local/lib -ldmalloc .endif +CFLAGS+= -O3 -# Should be WARNS=6, except that zlib.h is borked. <sigh> -WARNS?= 3 +WARNS?= 6 .include <bsd.lib.mk> ==== //depot/projects/hammer/lib/libarchive/archive.h#4 (text+ko) ==== @@ -23,15 +23,14 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD: src/lib/libarchive/archive.h,v 1.4 2004/03/09 19:50:41 kientzle Exp $ + * $FreeBSD: src/lib/libarchive/archive.h,v 1.5 2004/03/19 22:37:06 kientzle Exp $ */ #ifndef ARCHIVE_H_INCLUDED #define ARCHIVE_H_INCLUDED -#include <stdarg.h> -#include <stdint.h> -#include <unistd.h> +#include <inttypes.h> /* For int64_t */ +#include <unistd.h> /* For ssize_t and size_t */ #define ARCHIVE_BYTES_PER_RECORD 512 #define ARCHIVE_DEFAULT_BYTES_PER_BLOCK 10240 ==== //depot/projects/hammer/lib/libarchive/archive_entry.3#2 (text+ko) ==== @@ -22,7 +22,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD: src/lib/libarchive/archive_entry.3,v 1.1 2004/02/09 23:22:53 kientzle Exp $ +.\" $FreeBSD: src/lib/libarchive/archive_entry.3,v 1.2 2004/03/19 22:37:06 kientzle Exp $ .\" .Dd December 15, 2003 .Dt archive_entry 3 @@ -30,13 +30,20 @@ .Sh NAME .Nm archive_entry_clear .Nm archive_entry_clone +.Nm archive_entry_copy_gname_w +.Nm archive_entry_copy_hardlink_w +.Nm archive_entry_copy_pathname_w .Nm archive_entry_copy_stat -.Nm archive_entry_dup +.Nm archive_entry_copy_symlink_w +.Nm archive_entry_copy_uname_w .Nm archive_entry_free .Nm archive_entry_gname +.Nm archive_entry_gname_w .Nm archive_entry_hardlink +.Nm archive_entry_hardlink_w .Nm archive_entry_new .Nm archive_entry_pathname +.Nm archive_entry_pathname_w .Nm archive_entry_set_devmajor .Nm archive_entry_set_devminor .Nm archive_entry_set_gid @@ -51,8 +58,10 @@ .Nm archive_entry_size .Nm archive_entry_stat .Nm archive_entry_symlink +.Nm archive_entry_symlink_w .Nm archive_entry_tartype .Nm archive_entry_uname +.Nm archive_entry_uname_w .Nd functions for manipulating archive entry descriptions .Sh SYNOPSIS .In archive_entry.h @@ -61,19 +70,33 @@ .Ft struct archive_entry * .Fn archive_entry_clone "struct archive_entry *" .Ft void +.Fn archive_entry_copy_gname_w "struct archive_entry *" "const wchar_t *" +.Ft void +.Fn archive_entry_copy_hardlink_w "struct archive_entry *" "const wchar_t *" +.Ft void +.Fn archive_entry_copy_pathname_w "struct archive_entry *" "const wchar_t *" +.Ft void .Fn archive_entry_copy_stat "struct archive_entry *" "struct stat *" -.Ft struct archive_entry * -.Fn archive_entry_dup "struct archive_entry *" +.Ft void +.Fn archive_entry_copy_symlink_w "struct archive_entry *" "const wchar_t *" +.Ft void +.Fn archive_entry_copy_uname_w "struct archive_entry *" "const wchar_t *" .Ft void .Fn archive_entry_free "struct archive_entry *" .Ft const char * .Fn archive_entry_gname "struct archive_entry *" +.Ft const wchar_t * +.Fn archive_entry_gname_w "struct archive_entry *" .Ft const char * .Fn archive_entry_hardlink "struct archive_entry *" +.Ft const wchar_t * +.Fn archive_entry_hardlink_w "struct archive_entry *" .Ft struct archive_entry * .Fn archive_entry_new "void" .Ft const char * .Fn archive_entry_pathname "struct archive_entry *" +.Ft const wchar_t * +.Fn archive_entry_pathname_w "struct archive_entry *" .Ft void .Fn archive_entry_set_devmajor "struct archive_entry *" "dev_t" .Ft void @@ -102,25 +125,65 @@ .Fn archive_entry_stat "struct archive_entry *" .Ft const char * .Fn archive_entry_symlink "struct archive_entry *" +.Ft const wchar_t * +.Fn archive_entry_symlink_w "struct archive_entry *" .Ft int .Fn archive_entry_tartype "struct archive_entry *" .Ft const char * .Fn archive_entry_uname "struct archive_entry *" +.Ft const wchar_t * +.Fn archive_entry_uname_w "struct archive_entry *" .Sh DESCRIPTION These functions create and manipulate data objects that represent entries within an archive. You can think of a .Tn struct archive_entry -as a +as a heavy-duty version of +.Tn struct stat : +it includes everything from .Tn struct stat -on steroids: it includes everything from -.Tn struct stat plus associated pathname, textual group and user names, etc. These objects are used by .Xr libarchive 3 to represent the metadata associated with a particular entry in an archive. +.Pp +Most of the functions here set or read entries +in an object. Such functions have one of the +following forms: .Bl -tag -compact -width indent +.It Fn archive_entry_set_XXXX +Stores the provided data in the object. +In particular, for strings, the pointer is stored, +not the referenced string. +.It Fn archive_entry_copy_XXXX +As above, except that the referenced data is copied +into the object. +.It Fn archive_entry_XXXX +Returns the specified data. +In the case of strings, a const-qualified pointer to +the string is returned. +.El +The string data can be accessed as wide character strings +(which are suffixed with +.Cm _w ) +or normal +.Va char +strings. +Note that these are different representations of the same +data: +For example, if you store a narrow string and read the corresponding +wide string, the object will transparently convert formats +using the current locale. +Similarly, if you store a wide string and then store a +narrow string for the same data, the previously-set wide string will +be discarded in favor of the new data. +.Pp +The remaining functions allocate, destroy, clear, and copy +.Va archive_entry +objects. +These functions are described below: +.Bl -tag -compact -width indent .It Fn archive_entry_clear Erases the object, resetting all internal fields to the same state as a newly-created object. @@ -128,76 +191,20 @@ without thrashing the heap. .It Fn archive_entry_clone A deep copy operation; all text fields are duplicated. -.It Fn archive_entry_copy_stat -Copies the contents of the provided -.Tn struct stat -into the -.Tn struct archive_entry -object. -.It Fn archive_entry_dup -A shallow copy; text fields are not duplicated. .It Fn archive_entry_free Releases the .Tn struct archive_entry object. -.It Fn archive_entry_gname -Returns a pointer to the textual group name. -.It Fn archive_entry_hardlink -If this function returns non-NULL, then this object represents -a hardlink to another filesystem object. -The contents contain the pathname of the object. .It Fn archive_entry_new Allocate and return a blank .Tn struct archive_entry object. -.It Fn archive_entry_pathname -Returns a pointer to the pathname. -.It Fn archive_entry_set_devmajor -Sets the device major number (only valid for objects representing -block and character devices). -.It Fn archive_entry_set_devminor -Sets the device minor number (only valid for objects representing -block and character devices). -.It Fn archive_entry_set_gid -Sets the group ID for the object. -.It Fn archive_entry_set_gname -Sets a pointer to the textual group name. -Note that the name itself is not copied. -.It Fn archive_entry_set_hardlink -Sets the hardlink property; see -.Fn archive_entry_hardlink -above. -.It Fn archive_entry_set_mode -Sets the file mode. -.It Fn archive_entry_set_pathname -Sets a pointer to the pathname. -Note that the pathname text is not copied. -.It Fn archive_entry_set_symlink -Sets a pointer to the contents of a symbolic link. -Note that the pathname text is not copied. .It Fn archive_entry_set_tartype Sets the value to be used in a tar-format header for this entry. Client code should generally not set this; if it is left unset, the library will automatically determine an appropriate value. -.It Fn archive_entry_set_uid -Set the user ID for the object. -.It Fn archive_entry_set_uname -Sets a pointer to the textual user name. -Note that the name itself is not copied. -.It Fn archive_entry_size -Returns the size of the object on disk in bytes. -.It Fn archive_entry_stat -Returns a pointer to a populated -.Tn struct stat . -.It Fn archive_entry_symlink -Returns a pointer to the symlink contents. -.It Fn archive_entry_tartype -Returns the value used in a tar-format header. -Not generally useful to clients. -.It Fn archive_entry_uname -Returns a pointer to the textual user name. .El .\" .Sh EXAMPLE .\" .Sh RETURN VALUES @@ -215,4 +222,4 @@ .Nm libarchive library was written by .An Tim Kientzle Aq kientzle@acm.org . -.Sh BUGS +.\" .Sh BUGS ==== //depot/projects/hammer/lib/libarchive/archive_entry.c#3 (text+ko) ==== @@ -25,19 +25,42 @@ */ #include "archive_platform.h" -__FBSDID("$FreeBSD: src/lib/libarchive/archive_entry.c,v 1.2 2004/03/09 19:50:41 kientzle Exp $"); +__FBSDID("$FreeBSD: src/lib/libarchive/archive_entry.c,v 1.3 2004/03/19 22:37:06 kientzle Exp $"); #include <sys/stat.h> #include <sys/types.h> #ifdef HAVE_DMALLOC #include <dmalloc.h> #endif +#include <stdio.h> #include <stdlib.h> #include <string.h> +#include <wchar.h> #include "archive_entry.h" /* + * Handle wide character (i.e., Unicode) and non-wide character + * strings transparently. + * + */ + +struct aes { + const char *aes_mbs; + char *aes_mbs_alloc; + const wchar_t *aes_wcs; + wchar_t *aes_wcs_alloc; +}; + +void aes_clean(struct aes *); +void aes_copy(struct aes *dest, struct aes *src); +const char * aes_get_mbs(struct aes *); +const wchar_t * aes_get_wcs(struct aes *); +void aes_set_mbs(struct aes *, const char *mbs); +void aes_set_wcs(struct aes *, const wchar_t *wcs); +void aes_copy_wcs(struct aes *, const wchar_t *wcs); + +/* * Description of an archive entry. * * Basically, this is a "struct stat" with a few text fields added in. @@ -70,124 +93,175 @@ int ae_tartype; /* - * Note: If you add any more string fields, update - * archive_entry_clone accordingly. + * Use aes here so that we get transparent mbs<->wcs conversions. */ - const char *ae_acl; /* ACL text */ - const char *ae_acl_default; /* default ACL */ - const char *ae_fflags; /* Text fflags per fflagstostr(3) */ - const char *ae_gname; /* Name of owning group */ - const char *ae_hardlink; /* Name of target for hardlink */ - const char *ae_pathname; /* Name of entry */ - const char *ae_symlink; /* symlink contents */ - const char *ae_uname; /* Name of owner */ - - char buff[1]; /* MUST BE AT END OF STRUCT!!! */ + struct aes ae_acl; /* ACL text */ + struct aes ae_acl_default; /* default ACL */ + struct aes ae_fflags; /* Text fflags per fflagstostr(3) */ + struct aes ae_gname; /* Name of owning group */ + struct aes ae_hardlink; /* Name of target for hardlink */ + struct aes ae_pathname; /* Name of entry */ + struct aes ae_symlink; /* symlink contents */ + struct aes ae_uname; /* Name of owner */ }; -struct archive_entry * -archive_entry_clear(struct archive_entry *entry) +void +aes_clean(struct aes *aes) { - memset(entry, 0, sizeof(*entry)); - entry->ae_tartype = -1; - return entry; + if (aes->aes_mbs_alloc) { + free(aes->aes_mbs_alloc); + aes->aes_mbs_alloc = NULL; + } + if (aes->aes_wcs_alloc) { + free(aes->aes_wcs_alloc); + aes->aes_wcs_alloc = NULL; + } + memset(aes, 0, sizeof(*aes)); } -struct archive_entry * -archive_entry_clone(struct archive_entry *entry) +void +aes_copy(struct aes *dest, struct aes *src) { - int size; - struct archive_entry *entry2; - char *p; + *dest = *src; + if (src->aes_mbs_alloc != NULL) { + dest->aes_mbs_alloc = strdup(src->aes_mbs_alloc); + dest->aes_mbs = dest->aes_mbs_alloc; + } - size = sizeof(*entry2); - if (entry->ae_acl) - size += strlen(entry->ae_acl) + 1; - if (entry->ae_acl_default) - size += strlen(entry->ae_acl_default) + 1; - if (entry->ae_fflags) - size += strlen(entry->ae_fflags) + 1; - if (entry->ae_gname) - size += strlen(entry->ae_gname) + 1; - if (entry->ae_hardlink) - size += strlen(entry->ae_hardlink) + 1; - if (entry->ae_pathname) - size += strlen(entry->ae_pathname) + 1; - if (entry->ae_symlink) - size += strlen(entry->ae_symlink) + 1; - if (entry->ae_uname) - size += strlen(entry->ae_uname) + 1; + if (src->aes_wcs_alloc != NULL) { + dest->aes_wcs_alloc = malloc((wcslen(src->aes_wcs_alloc) + 1) + * sizeof(wchar_t)); + dest->aes_wcs = dest->aes_wcs_alloc; + wcscpy(dest->aes_wcs_alloc, src->aes_wcs); + } +} - entry2 = malloc(size); - *entry2 = *entry; - - /* Copy all of the strings from the original. */ - p = entry2->buff; - - if (entry->ae_acl) { - entry2->ae_acl = p; - strcpy(p, entry->ae_acl); - p += strlen(p) + 1; +const char * +aes_get_mbs(struct aes *aes) +{ + if (aes->aes_mbs == NULL && aes->aes_wcs != NULL) { + /* + * XXX Need to estimate the number of byte in the + * multi-byte form. Assume that, on average, wcs + * chars encode to no more than 3 bytes. There must + * be a better way... XXX + */ + int mbs_length = wcslen(aes->aes_wcs) * 3 + 64; + aes->aes_mbs_alloc = malloc(mbs_length); + aes->aes_mbs = aes->aes_mbs_alloc; + wcstombs(aes->aes_mbs_alloc, aes->aes_wcs, mbs_length - 1); + aes->aes_mbs_alloc[mbs_length - 1] = 0; } + return (aes->aes_mbs); +} - if (entry->ae_acl_default) { - entry2->ae_acl_default = p; - strcpy(p, entry->ae_acl_default); - p += strlen(p) + 1; +const wchar_t * +aes_get_wcs(struct aes *aes) +{ + if (aes->aes_wcs == NULL && aes->aes_mbs != NULL) { + /* + * No single byte will be more than one wide character, + * so this length estimate will always be big enough. + */ + int wcs_length = strlen(aes->aes_mbs); + aes->aes_wcs_alloc + = malloc((wcs_length + 1) * sizeof(wchar_t)); + aes->aes_wcs = aes->aes_wcs_alloc; + mbstowcs(aes->aes_wcs_alloc, aes->aes_mbs, wcs_length); + aes->aes_wcs_alloc[wcs_length] = 0; } + return (aes->aes_wcs); +} - if (entry->ae_fflags) { - entry2->ae_fflags = p; - strcpy(p, entry->ae_fflags); - p += strlen(p) + 1; +void +aes_set_mbs(struct aes *aes, const char *mbs) +{ + if (aes->aes_mbs_alloc) { + free(aes->aes_mbs_alloc); + aes->aes_mbs_alloc = NULL; } - - if (entry->ae_gname) { - entry2->ae_gname = p; - strcpy(p, entry->ae_gname); - p += strlen(p) + 1; + if (aes->aes_wcs_alloc) { + free(aes->aes_wcs_alloc); + aes->aes_wcs_alloc = NULL; } + aes->aes_mbs = mbs; + aes->aes_wcs = NULL; +} - if (entry->ae_hardlink) { - entry2->ae_hardlink = p; - strcpy(p, entry->ae_hardlink); - p += strlen(p) + 1; +void +aes_set_wcs(struct aes *aes, const wchar_t *wcs) +{ + if (aes->aes_mbs_alloc) { + free(aes->aes_mbs_alloc); + aes->aes_mbs_alloc = NULL; } - - if (entry->ae_pathname) { - entry2->ae_pathname = p; - strcpy(p, entry->ae_pathname); - p += strlen(p) + 1; + if (aes->aes_wcs_alloc) { + free(aes->aes_wcs_alloc); + aes->aes_wcs_alloc = NULL; } + aes->aes_mbs = NULL; + aes->aes_wcs = wcs; +} - if (entry->ae_symlink) { - entry2->ae_symlink = p; - strcpy(p, entry->ae_symlink); - p += strlen(p) + 1; +void +aes_copy_wcs(struct aes *aes, const wchar_t *wcs) +{ + if (aes->aes_mbs_alloc) { + free(aes->aes_mbs_alloc); + aes->aes_mbs_alloc = NULL; } - - if (entry->ae_uname) { - entry2->ae_uname = p; - strcpy(p, entry->ae_uname); - p += strlen(p) + 1; + if (aes->aes_wcs_alloc) { + free(aes->aes_wcs_alloc); + aes->aes_wcs_alloc = NULL; } + aes->aes_mbs = NULL; + aes->aes_wcs_alloc = malloc((wcslen(wcs) + 1) * sizeof(wchar_t)); + wcscpy(aes->aes_wcs_alloc, wcs); + aes->aes_wcs = aes->aes_wcs_alloc; +} - return (entry2); +struct archive_entry * +archive_entry_clear(struct archive_entry *entry) +{ + aes_clean(&entry->ae_acl); + aes_clean(&entry->ae_acl_default); + aes_clean(&entry->ae_fflags); + aes_clean(&entry->ae_gname); + aes_clean(&entry->ae_hardlink); + aes_clean(&entry->ae_pathname); + aes_clean(&entry->ae_symlink); + aes_clean(&entry->ae_uname); + memset(entry, 0, sizeof(*entry)); + entry->ae_tartype = -1; + return entry; } struct archive_entry * -archive_entry_dup(struct archive_entry *entry) +archive_entry_clone(struct archive_entry *entry) { struct archive_entry *entry2; + /* Allocate new structure and copy over all of the fields. */ entry2 = malloc(sizeof(*entry2)); - *entry2 = *entry; + entry2->ae_stat = entry->ae_stat; + entry2->ae_tartype = entry->ae_tartype; + + aes_copy(&entry2->ae_acl ,&entry->ae_acl); + aes_copy(&entry2->ae_acl_default ,&entry->ae_acl_default); + aes_copy(&entry2->ae_fflags ,&entry->ae_fflags); + aes_copy(&entry2->ae_gname ,&entry->ae_gname); + aes_copy(&entry2->ae_hardlink ,&entry->ae_hardlink); + aes_copy(&entry2->ae_pathname, &entry->ae_pathname); + aes_copy(&entry2->ae_symlink ,&entry->ae_symlink); + aes_copy(&entry2->ae_uname ,&entry->ae_uname); + return (entry2); } void archive_entry_free(struct archive_entry *entry) { + archive_entry_clear(entry); free(entry); } @@ -199,11 +273,11 @@ entry = malloc(sizeof(*entry)); if(entry == NULL) return (NULL); - archive_entry_clear(entry); + memset(entry, 0, sizeof(*entry)); + entry->ae_tartype = -1; return (entry); } - /* * Functions for reading fields from an archive_entry. */ @@ -211,14 +285,14 @@ const char * archive_entry_acl(struct archive_entry *entry) { - return (entry->ae_acl); + return (aes_get_mbs(&entry->ae_acl)); } const char * archive_entry_acl_default(struct archive_entry *entry) { - return (entry->ae_acl_default); + return (aes_get_mbs(&entry->ae_acl_default)); } dev_t @@ -237,19 +311,19 @@ const char * archive_entry_fflags(struct archive_entry *entry) { - return (entry->ae_fflags); + return (aes_get_mbs(&entry->ae_fflags)); } const char * archive_entry_gname(struct archive_entry *entry) { - return (entry->ae_gname); + return (aes_get_mbs(&entry->ae_gname)); } const char * archive_entry_hardlink(struct archive_entry *entry) { - return (entry->ae_hardlink); + return (aes_get_mbs(&entry->ae_hardlink)); } mode_t @@ -261,7 +335,13 @@ const char * archive_entry_pathname(struct archive_entry *entry) { - return (entry->ae_pathname); + return (aes_get_mbs(&entry->ae_pathname)); +} + +const wchar_t * +archive_entry_pathname_w(struct archive_entry *entry) +{ + return (aes_get_wcs(&entry->ae_pathname)); } int64_t @@ -279,7 +359,7 @@ const char * archive_entry_symlink(struct archive_entry *entry) { - return (entry->ae_symlink); + return (aes_get_mbs(&entry->ae_symlink)); } int @@ -291,7 +371,7 @@ const char * archive_entry_uname(struct archive_entry *entry) { - return (entry->ae_uname); + return (aes_get_mbs(&entry->ae_uname)); } /* @@ -311,14 +391,25 @@ void archive_entry_set_acl(struct archive_entry *entry, const char *acl) { - entry->ae_acl = acl; + aes_set_mbs(&entry->ae_acl, acl); } +void +archive_entry_copy_acl_w(struct archive_entry *entry, const wchar_t *acl) +{ + aes_copy_wcs(&entry->ae_acl, acl); +} void archive_entry_set_acl_default(struct archive_entry *entry, const char *acl) { - entry->ae_acl_default = acl; + aes_set_mbs(&entry->ae_acl_default, acl); +} + +void +archive_entry_copy_acl_default_w(struct archive_entry *entry, const wchar_t *acl) +{ + aes_copy_wcs(&entry->ae_acl_default, acl); } void @@ -342,7 +433,13 @@ void archive_entry_set_fflags(struct archive_entry *entry, const char *flags) { - entry->ae_fflags = flags; + aes_set_mbs(&entry->ae_fflags, flags); +} + +void +archive_entry_copy_fflags_w(struct archive_entry *entry, const wchar_t *flags) +{ + aes_copy_wcs(&entry->ae_fflags, flags); } void @@ -354,13 +451,25 @@ void archive_entry_set_gname(struct archive_entry *entry, const char *name) { - entry->ae_gname = name; + aes_set_mbs(&entry->ae_gname, name); +} + +void +archive_entry_copy_gname_w(struct archive_entry *entry, const wchar_t *name) +{ + aes_copy_wcs(&entry->ae_gname, name); } void archive_entry_set_hardlink(struct archive_entry *entry, const char *target) { - entry->ae_hardlink = target; + aes_set_mbs(&entry->ae_hardlink, target); +} + +void +archive_entry_copy_hardlink_w(struct archive_entry *entry, const wchar_t *target) +{ + aes_copy_wcs(&entry->ae_hardlink, target); } void @@ -372,7 +481,13 @@ void archive_entry_set_pathname(struct archive_entry *entry, const char *name) { - entry->ae_pathname = name; + aes_set_mbs(&entry->ae_pathname, name); +} + +void +archive_entry_copy_pathname_w(struct archive_entry *entry, const wchar_t *name) +{ + aes_copy_wcs(&entry->ae_pathname, name); } void @@ -382,9 +497,15 @@ } void -archive_entry_set_symlink(struct archive_entry *entry, const char *link) +archive_entry_set_symlink(struct archive_entry *entry, const char *linkname) +{ + aes_set_mbs(&entry->ae_symlink, linkname); +} + +void +archive_entry_copy_symlink_w(struct archive_entry *entry, const wchar_t *linkname) { - entry->ae_symlink = link; + aes_copy_wcs(&entry->ae_symlink, linkname); } void @@ -402,6 +523,26 @@ void >>> TRUNCATED FOR MAIL (1000 lines) <<<
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200403210131.i2L1V8wQ000867>