Date: Thu, 22 Jul 2004 23:59:30 GMT From: Peter Wemm <peter@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 57957 for review Message-ID: <200407222359.i6MNxU2U019986@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=57957 Change 57957 by peter@peter_melody on 2004/07/22 23:58:34 IFC @57955 Affected files ... .. //depot/projects/hammer/contrib/ntp/util/ntp-keygen.c#2 integrate .. //depot/projects/hammer/etc/mtree/BSD.root.dist#9 integrate .. //depot/projects/hammer/include/wchar.h#16 integrate .. //depot/projects/hammer/lib/libc/locale/Makefile.inc#21 integrate .. //depot/projects/hammer/lib/libc/locale/mblocal.h#3 integrate .. //depot/projects/hammer/lib/libc/locale/mbsnrtowcs.c#1 branch .. //depot/projects/hammer/lib/libc/locale/mbsrtowcs.3#4 integrate .. //depot/projects/hammer/lib/libc/locale/mbsrtowcs.c#5 integrate .. //depot/projects/hammer/lib/libc/locale/mbstowcs.c#8 integrate .. //depot/projects/hammer/lib/libc/locale/none.c#8 integrate .. //depot/projects/hammer/lib/libc/locale/setrunelocale.c#15 integrate .. //depot/projects/hammer/lib/libc/locale/table.c#9 integrate .. //depot/projects/hammer/lib/libc/locale/wcsnrtombs.c#1 branch .. //depot/projects/hammer/lib/libc/locale/wcsrtombs.3#4 integrate .. //depot/projects/hammer/lib/libc/locale/wcsrtombs.c#5 integrate .. //depot/projects/hammer/lib/libc/locale/wcstombs.c#7 integrate .. //depot/projects/hammer/lib/libc/net/gethostbydns.c#9 integrate .. //depot/projects/hammer/lib/libc/net/name6.c#12 integrate .. //depot/projects/hammer/lib/libc/stdio/fgetws.c#3 integrate .. //depot/projects/hammer/lib/libc/stdio/fputws.c#3 integrate .. //depot/projects/hammer/release/scripts/print-cdrom-packages.sh#20 integrate .. //depot/projects/hammer/sbin/atm/atmconfig/Makefile#4 integrate .. //depot/projects/hammer/sbin/atm/atmconfig/atmconfig.help#3 integrate .. //depot/projects/hammer/sbin/atm/atmconfig/diag.c#5 integrate .. //depot/projects/hammer/sbin/atm/atmconfig/main.c#2 integrate .. //depot/projects/hammer/sbin/atm/atmconfig/private.h#2 integrate .. //depot/projects/hammer/sbin/init/init.8#11 integrate .. //depot/projects/hammer/sbin/ipfw/ipfw.8#25 integrate .. //depot/projects/hammer/share/dict/freebsd#4 integrate .. //depot/projects/hammer/share/man/man4/man4.i386/Makefile#23 integrate .. //depot/projects/hammer/share/man/man4/man4.i386/acpi_panasonic.4#1 branch .. //depot/projects/hammer/share/man/man4/pccbb.4#5 integrate .. //depot/projects/hammer/sys/alpha/alpha/db_trace.c#8 integrate .. //depot/projects/hammer/sys/alpha/alpha/pmap.c#33 integrate .. //depot/projects/hammer/sys/amd64/amd64/db_trace.c#17 integrate .. //depot/projects/hammer/sys/amd64/conf/GENERIC#48 integrate .. //depot/projects/hammer/sys/amd64/conf/GENERIC.hints#11 integrate .. //depot/projects/hammer/sys/arm/arm/busdma_machdep.c#2 integrate .. //depot/projects/hammer/sys/arm/arm/db_trace.c#4 integrate .. //depot/projects/hammer/sys/arm/arm/pmap.c#6 integrate .. //depot/projects/hammer/sys/arm/include/pcb.h#3 integrate .. //depot/projects/hammer/sys/arm/include/pmap.h#3 integrate .. //depot/projects/hammer/sys/conf/files.i386#38 integrate .. //depot/projects/hammer/sys/ddb/db_command.c#10 integrate .. //depot/projects/hammer/sys/ddb/ddb.h#7 integrate .. //depot/projects/hammer/sys/dev/acpica/acpi_timer.c#10 integrate .. //depot/projects/hammer/sys/dev/acpica/acpi_video.c#6 integrate .. //depot/projects/hammer/sys/dev/ed/if_ed_pccard.c#14 integrate .. //depot/projects/hammer/sys/dev/ep/if_ep_eisa.c#7 integrate .. //depot/projects/hammer/sys/dev/ep/if_ep_isa.c#7 integrate .. //depot/projects/hammer/sys/dev/ep/if_ep_mca.c#6 integrate .. //depot/projects/hammer/sys/dev/pccbb/pccbb.c#29 integrate .. //depot/projects/hammer/sys/dev/pccbb/pccbbdevid.h#7 integrate .. //depot/projects/hammer/sys/dev/sio/sio.c#40 integrate .. //depot/projects/hammer/sys/dev/usb/uhub.c#8 integrate .. //depot/projects/hammer/sys/fs/devfs/devfs_vnops.c#13 integrate .. //depot/projects/hammer/sys/i386/acpica/acpi_panasonic.c#1 branch .. //depot/projects/hammer/sys/i386/conf/NOTES#47 integrate .. //depot/projects/hammer/sys/i386/i386/busdma_machdep.c#16 integrate .. //depot/projects/hammer/sys/i386/i386/db_trace.c#10 integrate .. //depot/projects/hammer/sys/i386/i386/pmap.c#47 integrate .. //depot/projects/hammer/sys/ia64/ia64/db_trace.c#10 integrate .. //depot/projects/hammer/sys/ia64/ia64/pmap.c#32 integrate .. //depot/projects/hammer/sys/kern/kern_descrip.c#28 integrate .. //depot/projects/hammer/sys/kern/kern_event.c#19 integrate .. //depot/projects/hammer/sys/kern/kern_prot.c#16 integrate .. //depot/projects/hammer/sys/kern/kern_shutdown.c#20 integrate .. //depot/projects/hammer/sys/kern/kern_switch.c#19 integrate .. //depot/projects/hammer/sys/kern/subr_kdb.c#2 integrate .. //depot/projects/hammer/sys/kern/sys_socket.c#13 integrate .. //depot/projects/hammer/sys/kern/uipc_mbuf.c#20 integrate .. //depot/projects/hammer/sys/kern/uipc_mbuf2.c#11 integrate .. //depot/projects/hammer/sys/kern/vfs_subr.c#47 integrate .. //depot/projects/hammer/sys/kern/vfs_vnops.c#19 integrate .. //depot/projects/hammer/sys/modules/acpi/Makefile#15 integrate .. //depot/projects/hammer/sys/modules/acpi/acpi_panasonic/Makefile#1 branch .. //depot/projects/hammer/sys/net/if_vlan.c#19 integrate .. //depot/projects/hammer/sys/netinet/ip_fw2.c#34 integrate .. //depot/projects/hammer/sys/opencrypto/cryptodev.c#13 integrate .. //depot/projects/hammer/sys/powerpc/include/frame.h#3 integrate .. //depot/projects/hammer/sys/powerpc/powermac/pswitch.c#2 integrate .. //depot/projects/hammer/sys/powerpc/powerpc/db_trace.c#5 integrate .. //depot/projects/hammer/sys/powerpc/powerpc/genassym.c#9 integrate .. //depot/projects/hammer/sys/powerpc/powerpc/swtch.S#4 integrate .. //depot/projects/hammer/sys/powerpc/powerpc/vm_machdep.c#19 integrate .. //depot/projects/hammer/sys/sparc64/sparc64/db_trace.c#7 integrate .. //depot/projects/hammer/sys/sys/cdefs.h#15 integrate .. //depot/projects/hammer/sys/sys/kdb.h#2 integrate .. //depot/projects/hammer/sys/sys/mbuf.h#27 integrate .. //depot/projects/hammer/sys/sys/pipe.h#8 integrate .. //depot/projects/hammer/sys/vm/swap_pager.c#27 integrate .. //depot/projects/hammer/sys/vm/uma_core.c#29 integrate .. //depot/projects/hammer/sys/vm/vm_map.c#41 integrate .. //depot/projects/hammer/sys/vm/vm_object.c#40 integrate .. //depot/projects/hammer/sys/vm/vm_object.h#17 integrate .. //depot/projects/hammer/sys/vm/vm_page.c#32 integrate .. //depot/projects/hammer/tools/regression/lib/libc/locale/Makefile#5 integrate .. //depot/projects/hammer/tools/regression/lib/libc/locale/test-mbsnrtowcs.c#1 branch .. //depot/projects/hammer/tools/regression/lib/libc/locale/test-wcsnrtombs.c#1 branch .. //depot/projects/hammer/tools/regression/pipe/bigpipetest.c#2 integrate .. //depot/projects/hammer/tools/regression/pipe/pipe-reverse.c#1 branch .. //depot/projects/hammer/tools/regression/pipe/pipe-wraparound.c#1 branch .. //depot/projects/hammer/usr.bin/fstat/fstat.c#10 integrate .. //depot/projects/hammer/usr.bin/hexdump/Makefile#4 integrate .. //depot/projects/hammer/usr.bin/hexdump/display.c#4 integrate .. //depot/projects/hammer/usr.bin/hexdump/odsyntax.c#3 integrate .. //depot/projects/hammer/usr.bin/hexdump/parse.c#3 integrate .. //depot/projects/hammer/usr.bin/make/parse.c#13 integrate .. //depot/projects/hammer/usr.bin/tar/bsdtar.1#11 integrate .. //depot/projects/hammer/usr.bin/truncate/truncate.1#2 integrate .. //depot/projects/hammer/usr.bin/truncate/truncate.c#2 integrate .. //depot/projects/hammer/usr.sbin/ntp/Makefile#5 integrate .. //depot/projects/hammer/usr.sbin/ntp/Makefile.inc#4 integrate .. //depot/projects/hammer/usr.sbin/ntp/arlib/Makefile#2 delete .. //depot/projects/hammer/usr.sbin/ntp/config.h#5 integrate .. //depot/projects/hammer/usr.sbin/ntp/ntp-keygen/Makefile#2 integrate .. //depot/projects/hammer/usr.sbin/ntp/ntpd/Makefile#5 integrate .. //depot/projects/hammer/usr.sbin/ntp/ntpdc/Makefile#3 integrate .. //depot/projects/hammer/usr.sbin/ntp/ntpq/Makefile#4 integrate .. //depot/projects/hammer/usr.sbin/pwd_mkdb/pwd_mkdb.8#4 integrate .. //depot/projects/hammer/usr.sbin/pwd_mkdb/pwd_mkdb.c#5 integrate Differences ... ==== //depot/projects/hammer/contrib/ntp/util/ntp-keygen.c#2 (text+ko) ==== @@ -159,7 +159,9 @@ extern char *optarg; /* command line argument */ int debug = 0; /* debug, not de bug */ int rval; /* return status */ +#ifdef OPENSSL u_int modulus = PLEN; /* prime modulus size (bits) */ +#endif int nkeys = 0; /* MV keys */ time_t epoch; /* Unix epoch (seconds) since 1970 */ char *hostname; /* host name (subject name) */ @@ -221,7 +223,9 @@ EVP_PKEY *pkey_iff = NULL; /* IFF parameters */ EVP_PKEY *pkey_gq = NULL; /* GQ parameters */ EVP_PKEY *pkey_mv = NULL; /* MV parameters */ +#endif int md5key = 0; /* generate MD5 keys */ +#ifdef OPENSSL int hostkey = 0; /* generate RSA keys */ int iffkey = 0; /* generate IFF parameters */ int gqpar = 0; /* generate GQ parameters */ @@ -231,7 +235,6 @@ char *sign = NULL; /* sign key */ EVP_PKEY *pkey = NULL; /* temp key */ const EVP_MD *ectx; /* EVP digest */ - char hostbuf[MAXHOSTNAME + 1]; char pathbuf[MAXFILENAME + 1]; const char *scheme = NULL; /* digest/signature scheme */ char *exten = NULL; /* private extension */ @@ -240,6 +243,7 @@ FILE *fstr = NULL; /* file handle */ int iffsw = 0; /* IFF key switch */ #endif /* OPENSSL */ + char hostbuf[MAXHOSTNAME + 1]; u_int temp; #ifdef SYS_WINNT @@ -267,8 +271,10 @@ */ gethostname(hostbuf, MAXHOSTNAME); hostname = hostbuf; +#ifdef OPENSSL trustname = hostbuf; passwd1 = hostbuf; +#endif #ifndef SYS_WINNT gettimeofday(&tv, 0); #else @@ -277,15 +283,22 @@ epoch = tv.tv_sec; rval = 0; while ((temp = getopt(argc, argv, - "c:deGgHIi:Mm:nPp:q:S:s:TV:v:")) != -1) { +#ifdef OPENSSL + "c:deGgHIi:Mm:nPp:q:S:s:TV:v:" +#else + "dM" +#endif + )) != -1) { switch(temp) { +#ifdef OPENSSL /* * -c select public certificate type */ case 'c': scheme = optarg; continue; +#endif /* * -d debug @@ -294,47 +307,59 @@ debug++; continue; +#ifdef OPENSSL /* * -e write identity keys */ case 'e': iffsw++; continue; +#endif +#ifdef OPENSSL /* * -G generate GQ parameters and keys */ case 'G': gqpar++; continue; +#endif +#ifdef OPENSSL /* * -g update GQ keys */ case 'g': gqkey++; continue; +#endif +#ifdef OPENSSL /* * -H generate host key (RSA) */ case 'H': hostkey++; continue; +#endif +#ifdef OPENSSL /* * -I generate IFF parameters */ case 'I': iffkey++; continue; +#endif +#ifdef OPENSSL /* * -i set issuer name */ case 'i': trustname = optarg; continue; +#endif /* * -M generate MD5 keys @@ -343,7 +368,7 @@ md5key++; continue; - +#ifdef OPENSSL /* * -m select modulus (256-2048) */ @@ -352,49 +377,63 @@ fprintf(stderr, "invalid option -m %s\n", optarg); continue; - +#endif + +#ifdef OPENSSL /* * -P generate PC private certificate */ case 'P': exten = EXT_KEY_PRIVATE; continue; +#endif +#ifdef OPENSSL /* * -p output private key password */ case 'p': passwd2 = optarg; continue; +#endif +#ifdef OPENSSL /* * -q input private key password */ case 'q': passwd1 = optarg; continue; +#endif +#ifdef OPENSSL /* * -S generate sign key (RSA or DSA) */ case 'S': sign = optarg; continue; +#endif +#ifdef OPENSSL /* * -s set subject name */ case 's': hostname = optarg; continue; - +#endif + +#ifdef OPENSSL /* * -T trusted certificate (TC scheme) */ case 'T': exten = EXT_KEY_TRUST; continue; +#endif +#ifdef OPENSSL /* * -V <keys> generate MV parameters */ @@ -404,7 +443,9 @@ fprintf(stderr, "invalid option -V %s\n", optarg); continue; +#endif +#ifdef OPENSSL /* * -v <key> update MV keys */ @@ -414,6 +455,7 @@ fprintf(stderr, "invalid option -v %s\n", optarg); continue; +#endif /* * None of the above. @@ -446,6 +488,7 @@ fprintf(stderr, "Random seed file %s %u bytes\n", pathbuf, temp); RAND_add(&epoch, sizeof(epoch), 4.0); +#endif /* * Generate new parameters and keys as requested. These replace @@ -453,6 +496,7 @@ */ if (md5key) gen_md5("MD5"); +#ifdef OPENSSL if (hostkey) pkey_host = genkey("RSA", "host"); if (sign != NULL) @@ -714,7 +758,7 @@ } md5key[j] = (u_char)temp; } - md5key[16] = '\0'; + md5key[15] = '\0'; fprintf(str, "%2d MD5 %16s # MD5 key\n", i, md5key); } @@ -1245,7 +1289,7 @@ char *id /* file name id */ ) { - EVP_PKEY *pkey; /* private key */ + EVP_PKEY *pkey, *pkey1; /* private key */ DSA *dsa; /* DSA parameters */ DSA *sdsa; /* DSA parameters */ BN_CTX *ctx; /* BN working space */ @@ -1284,7 +1328,7 @@ modulus / n); ctx = BN_CTX_new(); u = BN_new(); v = BN_new(); w = BN_new(); b = BN_new(); b1 = BN_new(); - dsa = malloc(sizeof(DSA)); + dsa = DSA_new(); dsa->p = BN_new(); dsa->q = BN_new(); dsa->g = BN_new(); @@ -1589,7 +1633,7 @@ * the designated recipient(s) who pay a suitably outrageous fee * for its use. */ - sdsa = malloc(sizeof(DSA)); + sdsa = DSA_new(); sdsa->p = BN_dup(dsa->p); sdsa->q = BN_dup(BN_value_one()); sdsa->g = BN_dup(BN_value_one()); @@ -1622,15 +1666,16 @@ */ sprintf(ident, "MVkey%d", j); str = fheader(ident, trustname); - pkey = EVP_PKEY_new(); - EVP_PKEY_assign_DSA(pkey, sdsa); - PEM_write_PrivateKey(str, pkey, passwd2 ? + pkey1 = EVP_PKEY_new(); + EVP_PKEY_set1_DSA(pkey1, sdsa); + PEM_write_PrivateKey(str, pkey1, passwd2 ? EVP_des_cbc() : NULL, NULL, 0, NULL, passwd2); fclose(str); fprintf(stderr, "ntpkey_%s_%s.%lu\n", ident, trustname, epoch + JAN_1970); if (debug) DSA_print_fp(stdout, sdsa, 0); + EVP_PKEY_free(pkey1); } /* @@ -1643,7 +1688,7 @@ BN_free(u); BN_free(v); BN_free(w); BN_CTX_free(ctx); BN_free(b); BN_free(b1); BN_free(biga); BN_free(bige); BN_free(ss); BN_free(gbar); BN_free(ghat); - DSA_free(dsa); DSA_free(sdsa); + DSA_free(sdsa); /* * Free the world. @@ -1883,7 +1928,6 @@ break; } } -#endif /* OPENSSL */ /* @@ -1907,6 +1951,7 @@ rval = -1; return (NULL); } +#endif /* OPENSSL */ /* ==== //depot/projects/hammer/etc/mtree/BSD.root.dist#9 (text+ko) ==== @@ -1,4 +1,4 @@ -# $FreeBSD: src/etc/mtree/BSD.root.dist,v 1.66 2004/05/20 10:29:26 pjd Exp $ +# $FreeBSD: src/etc/mtree/BSD.root.dist,v 1.67 2004/07/21 10:14:10 roberto Exp $ # # Please see the file src/etc/mtree/README before making changes to this file. # @@ -38,6 +38,8 @@ # s uname=bind gname=bind mode=0750 # .. .. + ntp uname=root mode=700 + .. pam.d .. periodic ==== //depot/projects/hammer/include/wchar.h#16 (text+ko) ==== @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/include/wchar.h,v 1.42 2004/07/16 06:06:09 tjr Exp $ + * $FreeBSD: src/include/wchar.h,v 1.43 2004/07/21 10:54:57 tjr Exp $ */ /*- @@ -209,6 +209,10 @@ #if __BSD_VISIBLE wchar_t *fgetwln(struct __sFILE * __restrict, size_t * __restrict); +size_t mbsnrtowcs(wchar_t * __restrict, const char ** __restrict, size_t, + size_t, mbstate_t * __restrict); +size_t wcsnrtombs(char * __restrict, const wchar_t ** __restrict, size_t, + size_t, mbstate_t * __restrict); size_t wcslcat(wchar_t *, const wchar_t *, size_t); size_t wcslcpy(wchar_t *, const wchar_t *, size_t); #endif ==== //depot/projects/hammer/lib/libc/locale/Makefile.inc#21 (text+ko) ==== @@ -1,5 +1,5 @@ # from @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 -# $FreeBSD: src/lib/libc/locale/Makefile.inc,v 1.56 2004/07/08 06:43:37 tjr Exp $ +# $FreeBSD: src/lib/libc/locale/Makefile.inc,v 1.57 2004/07/21 10:54:57 tjr Exp $ # locale sources .PATH: ${.CURDIR}/${MACHINE_ARCH}/locale ${.CURDIR}/locale @@ -8,11 +8,13 @@ gb18030.c gb2312.c gbk.c isctype.c iswctype.c \ ldpart.c lmessages.c lmonetary.c lnumeric.c localeconv.c mblen.c \ mbrlen.c \ - mbrtowc.c mbrune.c mbsinit.c mbsrtowcs.c mbtowc.c mbstowcs.c \ + mbrtowc.c mbrune.c mbsinit.c mbsnrtowcs.c \ + mbsrtowcs.c mbtowc.c mbstowcs.c \ mskanji.c nextwctype.c nl_langinfo.c nomacros.c none.c rune.c \ runetype.c setinvalidrune.c setlocale.c setrunelocale.c srune.c \ table.c \ - tolower.c toupper.c utf2.c utf8.c wcrtomb.c wcsrtombs.c wcsftime.c \ + tolower.c toupper.c utf2.c utf8.c wcrtomb.c wcsnrtombs.c \ + wcsrtombs.c wcsftime.c \ wcstof.c wcstod.c \ wcstoimax.c wcstol.c wcstold.c wcstoll.c \ wcstombs.c \ @@ -47,9 +49,11 @@ iswalnum.3 iswupper.3 iswalnum.3 iswxdigit.3 MLINKS+=isxdigit.3 ishexnumber.3 MLINKS+=mbrune.3 mbmb.3 mbrune.3 mbrrune.3 +MLINKS+=mbsrtowcs.3 mbsnrtowcs.3 MLINKS+=rune.3 fgetrune.3 rune.3 fputrune.3 rune.3 fungetrune.3 \ rune.3 setinvalidrune.3 rune.3 setrunelocale.3 rune.3 sgetrune.3 \ rune.3 sputrune.3 +MLINKS+=wcsrtombs.3 wcsnrtombs.3 MLINKS+=wcstod.3 wcstof.3 wcstod.3 wcstold.3 MLINKS+=wcstol.3 wcstoul.3 wcstol.3 wcstoll.3 wcstol.3 wcstoull.3 \ wcstol.3 wcstoimax.3 wcstol.3 wcstoumax.3 ==== //depot/projects/hammer/lib/libc/locale/mblocal.h#3 (text+ko) ==== @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/lib/libc/locale/mblocal.h,v 1.2 2004/05/13 11:20:27 tjr Exp $ + * $FreeBSD: src/lib/libc/locale/mblocal.h,v 1.3 2004/07/21 10:54:57 tjr Exp $ */ #ifndef _MBLOCAL_H_ @@ -37,11 +37,11 @@ extern size_t (*__mbrtowc)(wchar_t * __restrict, const char * __restrict, size_t, mbstate_t * __restrict); extern int (*__mbsinit)(const mbstate_t *); -extern size_t (*__mbsrtowcs)(wchar_t * __restrict, const char ** __restrict, - size_t, mbstate_t * __restrict); +extern size_t (*__mbsnrtowcs)(wchar_t * __restrict, const char ** __restrict, + size_t, size_t, mbstate_t * __restrict); extern size_t (*__wcrtomb)(char * __restrict, wchar_t, mbstate_t * __restrict); -extern size_t (*__wcsrtombs)(char * __restrict, const wchar_t ** __restrict, - size_t, mbstate_t * __restrict); +extern size_t (*__wcsnrtombs)(char * __restrict, const wchar_t ** __restrict, + size_t, size_t, mbstate_t * __restrict); /* * Conversion functions for "NONE"/C/POSIX encoding. @@ -49,17 +49,17 @@ extern size_t _none_mbrtowc(wchar_t * __restrict, const char * __restrict, size_t, mbstate_t * __restrict); extern int _none_mbsinit(const mbstate_t *); -extern size_t _none_mbsrtowcs(wchar_t * __restrict, const char ** __restrict, - size_t, mbstate_t * __restrict); +extern size_t _none_mbsnrtowcs(wchar_t * __restrict, const char ** __restrict, + size_t, size_t, mbstate_t * __restrict); extern size_t _none_wcrtomb(char * __restrict, wchar_t, mbstate_t * __restrict); -extern size_t _none_wcsrtombs(char * __restrict, const wchar_t ** __restrict, - size_t, mbstate_t * __restrict); +extern size_t _none_wcsnrtombs(char * __restrict, const wchar_t ** __restrict, + size_t, size_t, mbstate_t * __restrict); -extern size_t __mbsrtowcs_std(wchar_t * __restrict, const char ** __restrict, - size_t, mbstate_t * __restrict); -extern size_t __wcsrtombs_std(char * __restrict, const wchar_t ** __restrict, - size_t, mbstate_t * __restrict); +extern size_t __mbsnrtowcs_std(wchar_t * __restrict, const char ** __restrict, + size_t, size_t, mbstate_t * __restrict); +extern size_t __wcsnrtombs_std(char * __restrict, const wchar_t ** __restrict, + size_t, size_t, mbstate_t * __restrict); /* * Rune emulation functions. ==== //depot/projects/hammer/lib/libc/locale/mbsrtowcs.3#4 (text+ko) ==== @@ -22,12 +22,13 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD: src/lib/libc/locale/mbsrtowcs.3,v 1.4 2004/04/08 09:59:02 tjr Exp $ -.Dd April 8, 2004 +.\" $FreeBSD: src/lib/libc/locale/mbsrtowcs.3,v 1.5 2004/07/21 10:54:57 tjr Exp $ +.Dd July 21, 2004 .Dt MBSRTOWCS 3 .Os .Sh NAME -.Nm mbsrtowcs +.Nm mbsrtowcs , +.Nm mbsnrtowcs .Nd "convert a character string to a wide-character string (restartable)" .Sh LIBRARY .Lb libc @@ -38,6 +39,11 @@ .Fa "wchar_t * restrict dst" "const char ** restrict src" "size_t len" .Fa "mbstate_t * restrict ps" .Fc +.Ft size_t +.Fo mbsnrtowcs +.Fa "wchar_t * restrict dst" "const char ** restrict src" "size_t nms" +.Fa "size_t len" "mbstate_t * restrict ps" +.Fc .Sh DESCRIPTION The .Fn mbsrtowcs @@ -82,10 +88,21 @@ .Vt mbstate_t object, which is initialized to the initial conversion state at program startup. +.Pp +The +.Fn mbsnrtowcs +function behaves identically to +.Fn mbsrtowcs , +except that conversion stops after reading at most +.Fa nms +bytes from the buffer pointed to by +.Fa src . .Sh RETURN VALUES The .Fn mbsrtowcs -function returns the number of wide characters stored in +and +.Fn mbsnrtowcs +functions return the number of wide characters stored in the array pointed to by .Fa dst if successful, otherwise it returns @@ -93,7 +110,9 @@ .Sh ERRORS The .Fn mbsrtowcs -function will fail if: +and +.Fn mbsnrtowcs +functions will fail if: .Bl -tag -width Er .It Bq Er EILSEQ An invalid multibyte character sequence was encountered. @@ -110,3 +129,7 @@ .Fn mbsrtowcs function conforms to .St -isoC-99 . +.Pp +The +.Fn mbsnrtowcs +function is an extension to the standard. ==== //depot/projects/hammer/lib/libc/locale/mbsrtowcs.c#5 (text+ko) ==== @@ -25,7 +25,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/lib/libc/locale/mbsrtowcs.c,v 1.5 2004/05/13 11:20:27 tjr Exp $"); +__FBSDID("$FreeBSD: src/lib/libc/locale/mbsrtowcs.c,v 1.6 2004/07/21 10:54:57 tjr Exp $"); #include <errno.h> #include <limits.h> @@ -41,46 +41,5 @@ if (ps == NULL) ps = &mbs; - return (__mbsrtowcs(dst, src, len, ps)); -} - -size_t -__mbsrtowcs_std(wchar_t * __restrict dst, const char ** __restrict src, - size_t len, mbstate_t * __restrict ps) -{ - const char *s; - size_t nchr; - wchar_t wc; - int nb; - - s = *src; - nchr = 0; - - if (dst == NULL) { - for (;;) { - if ((nb = (int)__mbrtowc(&wc, s, MB_CUR_MAX, ps)) < 0) - /* Invalid sequence - mbrtowc() sets errno. */ - return ((size_t)-1); - else if (nb == 0) - return (nchr); - s += nb; - nchr++; - } - /*NOTREACHED*/ - } - - while (len-- > 0) { - if ((nb = (int)__mbrtowc(dst, s, MB_CUR_MAX, ps)) < 0) { - *src = s; - return ((size_t)-1); - } else if (nb == 0) { - *src = NULL; - return (nchr); - } - s += nb; - nchr++; - dst++; - } - *src = s; - return (nchr); + return (__mbsnrtowcs(dst, src, SIZE_T_MAX, len, ps)); } ==== //depot/projects/hammer/lib/libc/locale/mbstowcs.c#8 (text+ko) ==== @@ -25,8 +25,9 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/lib/libc/locale/mbstowcs.c,v 1.10 2004/05/13 11:20:27 tjr Exp $"); +__FBSDID("$FreeBSD: src/lib/libc/locale/mbstowcs.c,v 1.11 2004/07/21 10:54:57 tjr Exp $"); +#include <limits.h> #include <stdlib.h> #include <wchar.h> #include "mblocal.h" @@ -38,5 +39,5 @@ mbstate_t mbs; mbs = initial; - return (__mbsrtowcs(pwcs, &s, n, &mbs)); + return (__mbsnrtowcs(pwcs, &s, SIZE_T_MAX, n, &mbs)); } ==== //depot/projects/hammer/lib/libc/locale/none.c#8 (text+ko) ==== @@ -39,7 +39,7 @@ static char sccsid[] = "@(#)none.c 8.1 (Berkeley) 6/4/93"; #endif /* LIBC_SCCS and not lint */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/lib/libc/locale/none.c,v 1.11 2004/05/25 10:45:24 tjr Exp $"); +__FBSDID("$FreeBSD: src/lib/libc/locale/none.c,v 1.12 2004/07/21 10:54:57 tjr Exp $"); #include <errno.h> #include <limits.h> @@ -55,11 +55,12 @@ size_t _none_mbrtowc(wchar_t * __restrict, const char * __restrict, size_t, mbstate_t * __restrict); int _none_mbsinit(const mbstate_t *); -size_t _none_mbsrtowcs(wchar_t * __restrict, const char ** __restrict, - size_t, mbstate_t * __restrict); +size_t _none_mbsnrtowcs(wchar_t * __restrict dst, + const char ** __restrict src, size_t nms, size_t len, + mbstate_t * __restrict ps __unused); size_t _none_wcrtomb(char * __restrict, wchar_t, mbstate_t * __restrict); -size_t _none_wcsrtombs(char * __restrict, const wchar_t ** __restrict, - size_t, mbstate_t * __restrict); +size_t _none_wcsnrtombs(char * __restrict, const wchar_t ** __restrict, + size_t, size_t, mbstate_t * __restrict); int _none_init(_RuneLocale *rl) @@ -67,9 +68,9 @@ __mbrtowc = _none_mbrtowc; __mbsinit = _none_mbsinit; - __mbsrtowcs = _none_mbsrtowcs; + __mbsnrtowcs = _none_mbsnrtowcs; __wcrtomb = _none_wcrtomb; - __wcsrtombs = _none_wcsrtombs; + __wcsnrtombs = _none_wcsnrtombs; _CurrentRuneLocale = rl; __mb_cur_max = 1; return(0); @@ -119,18 +120,20 @@ } size_t -_none_mbsrtowcs(wchar_t * __restrict dst, const char ** __restrict src, - size_t len, mbstate_t * __restrict ps __unused) +_none_mbsnrtowcs(wchar_t * __restrict dst, const char ** __restrict src, + size_t nms, size_t len, mbstate_t * __restrict ps __unused) { const char *s; size_t nchr; - if (dst == NULL) - return (strlen(*src)); + if (dst == NULL) { + s = memchr(*src, '\0', nms); + return (s != NULL ? s - *src : nms); + } s = *src; nchr = 0; - while (len-- > 0) { + while (len-- > 0 && nms-- > 0) { if ((*dst++ = (unsigned char)*s++) == L'\0') { *src = NULL; return (nchr); @@ -142,14 +145,14 @@ } size_t -_none_wcsrtombs(char * __restrict dst, const wchar_t ** __restrict src, - size_t len, mbstate_t * __restrict ps __unused) +_none_wcsnrtombs(char * __restrict dst, const wchar_t ** __restrict src, + size_t nwc, size_t len, mbstate_t * __restrict ps __unused) { const wchar_t *s; size_t nchr; if (dst == NULL) { - for (s = *src; *s != L'\0'; s++) { + for (s = *src; nwc > 0 && *s != L'\0'; s++, nwc--) { if (*s < 0 || *s > UCHAR_MAX) { errno = EILSEQ; return ((size_t)-1); @@ -160,7 +163,7 @@ s = *src; nchr = 0; - while (len-- > 0) { + while (len-- > 0 && nwc-- > 0) { if (*s < 0 || *s > UCHAR_MAX) { errno = EILSEQ; return ((size_t)-1); ==== //depot/projects/hammer/lib/libc/locale/setrunelocale.c#15 (text+ko) ==== @@ -38,7 +38,7 @@ #define OBSOLETE_IN_6 #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/lib/libc/locale/setrunelocale.c,v 1.39 2004/06/23 07:01:43 tjr Exp $"); +__FBSDID("$FreeBSD: src/lib/libc/locale/setrunelocale.c,v 1.40 2004/07/21 10:54:57 tjr Exp $"); #include <rune.h> #include <errno.h> @@ -100,10 +100,11 @@ static size_t (*Cached__wcrtomb)(char * __restrict, wchar_t, mbstate_t * __restrict); static int (*Cached__mbsinit)(const mbstate_t *); - static size_t (*Cached__mbsrtowcs)(wchar_t * __restrict, - const char ** __restrict, size_t, mbstate_t * __restrict); - static size_t (*Cached__wcsrtombs)(char * __restrict, - const wchar_t ** __restrict, size_t, mbstate_t * __restrict); + static size_t (*Cached__mbsnrtowcs)(wchar_t * __restrict, + const char ** __restrict, size_t, size_t, mbstate_t * __restrict); + static size_t (*Cached__wcsnrtombs)(char * __restrict, + const wchar_t ** __restrict, size_t, size_t, + mbstate_t * __restrict); /* * The "C" and "POSIX" locale are always here. @@ -113,9 +114,9 @@ __mb_cur_max = 1; __mbrtowc = _none_mbrtowc; __mbsinit = _none_mbsinit; - __mbsrtowcs = _none_mbsrtowcs; + __mbsnrtowcs = _none_mbsnrtowcs; __wcrtomb = _none_wcrtomb; - __wcsrtombs = _none_wcsrtombs; + __wcsnrtombs = _none_wcsnrtombs; return (0); } @@ -128,9 +129,9 @@ __mb_cur_max = Cached__mb_cur_max; __mbrtowc = Cached__mbrtowc; __mbsinit = Cached__mbsinit; - __mbsrtowcs = Cached__mbsrtowcs; + __mbsnrtowcs = Cached__mbsnrtowcs; __wcrtomb = Cached__wcrtomb; - __wcsrtombs = Cached__wcsrtombs; + __wcsnrtombs = Cached__wcsnrtombs; return (0); } @@ -156,9 +157,9 @@ __mbrtowc = NULL; __mbsinit = NULL; - __mbsrtowcs = __mbsrtowcs_std; + __mbsnrtowcs = __mbsnrtowcs_std; __wcrtomb = NULL; - __wcsrtombs = __wcsrtombs_std; + __wcsnrtombs = __wcsnrtombs_std; rl->__sputrune = __emulated_sputrune; rl->__sgetrune = __emulated_sgetrune; if (strcmp(rl->__encoding, "NONE") == 0) @@ -192,9 +193,9 @@ Cached__mb_cur_max = __mb_cur_max; Cached__mbrtowc = __mbrtowc; Cached__mbsinit = __mbsinit; - Cached__mbsrtowcs = __mbsrtowcs; + Cached__mbsnrtowcs = __mbsnrtowcs; Cached__wcrtomb = __wcrtomb; - Cached__wcsrtombs = __wcsrtombs; + Cached__wcsnrtombs = __wcsnrtombs; (void)strcpy(ctype_encoding, encoding); } else free(rl); ==== //depot/projects/hammer/lib/libc/locale/table.c#9 (text+ko) ==== @@ -38,7 +38,7 @@ static char sccsid[] = "@(#)table.c 8.1 (Berkeley) 6/27/93"; #endif /* LIBC_SCCS and not lint */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/lib/libc/locale/table.c,v 1.23 2004/05/13 11:20:27 tjr Exp $"); +__FBSDID("$FreeBSD: src/lib/libc/locale/table.c,v 1.24 2004/07/21 10:54:57 tjr Exp $"); #include <ctype.h> #include <rune.h> @@ -255,9 +255,9 @@ size_t (*__mbrtowc)(wchar_t * __restrict, const char * __restrict, size_t, mbstate_t * __restrict) = _none_mbrtowc; int (*__mbsinit)(const mbstate_t *) = _none_mbsinit; -size_t (*__mbsrtowcs)(wchar_t * __restrict, const char ** __restrict, - size_t, mbstate_t * __restrict) = _none_mbsrtowcs; +size_t (*__mbsnrtowcs)(wchar_t * __restrict, const char ** __restrict, + size_t, size_t, mbstate_t * __restrict) = _none_mbsnrtowcs; size_t (*__wcrtomb)(char * __restrict, wchar_t, mbstate_t * __restrict) = _none_wcrtomb; -size_t (*__wcsrtombs)(char * __restrict, const wchar_t ** __restrict, - size_t, mbstate_t * __restrict) = _none_wcsrtombs; +size_t (*__wcsnrtombs)(char * __restrict, const wchar_t ** __restrict, + size_t, size_t, mbstate_t * __restrict) = _none_wcsnrtombs; ==== //depot/projects/hammer/lib/libc/locale/wcsrtombs.3#4 (text+ko) ==== @@ -22,13 +22,14 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD: src/lib/libc/locale/wcsrtombs.3,v 1.4 2004/04/08 09:59:02 tjr Exp $ +.\" $FreeBSD: src/lib/libc/locale/wcsrtombs.3,v 1.5 2004/07/21 10:54:57 tjr Exp $ .\" -.Dd April 8, 2004 +.Dd July 21, 2004 .Dt WCSRTOMBS 3 .Os .Sh NAME -.Nm wcsrtombs +.Nm wcsrtombs , +.Nm wcsnrtombs .Nd "convert a wide-character string to a character string (restartable)" .Sh LIBRARY .Lb libc @@ -39,6 +40,11 @@ .Fa "char * restrict dst" "const wchar_t ** restrict src" .Fa "size_t len" "mbstate_t * restrict ps" .Fc +.Ft size_t +.Fo wcsnrtombs +.Fa "char * restrict dst" "const wchar_t ** restrict src" "size_t nwc" +.Fa "size_t len" "mbstate_t * restrict ps" +.Fc .Sh DESCRIPTION The .Fn wcsrtombs @@ -82,10 +88,21 @@ .Vt mbstate_t object, which is initialized to the initial conversion state at program startup. +.Pp +The +.Fn wcsnrtombs +function behaves identically to +.Fn wcsrtombs , +except that conversion stops after reading at most +.Fa nwc +characters from the buffer pointed to by +.Fa src . .Sh RETURN VALUES The .Fn wcsrtombs -function returns the number of bytes stored in +and +.Fn wcsnrtombs +functions return the number of bytes stored in the array pointed to by .Fa dst (not including any terminating null), if successful, otherwise it returns @@ -93,7 +110,9 @@ .Sh ERRORS The .Fn wcsrtombs -function will fail if: +and +.Fn wcsnrtombs >>> TRUNCATED FOR MAIL (1000 lines) <<<
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200407222359.i6MNxU2U019986>