From: Erez Zadok Date: Sun, 7 Aug 2005 03:43:19 +0000 (+0000) Subject: * libamu/util.c, amd/autil.c (strsplit): moved strsplit() function X-Git-Tag: before-clocktime-fixes~43 X-Git-Url: https://git.fsl.cs.sunysb.edu/?a=commitdiff_plain;h=ec14412f1b9bb4cc72f596694957f7892ed241c9;p=am-utils-6.1.git * libamu/util.c, amd/autil.c (strsplit): moved strsplit() function from Amd code to to libamu, so sun2amd could use it. * amd/Makefile.am (sbin_PROGRAMS): build sun2amd binary and man page. (EXTRA_sun2amd_OBJECTS): sun2amd needs to link with all info_*.c files * amd/sun2amd.8: placeholder for man page. * amd/sun2amd.c: placeholder for C version of translator from Sun syntax maps to Amd maps. * */*.[0-9]: include file name in nroff source comment. --- diff --git a/ChangeLog b/ChangeLog index dc1fdbc..4f83dea 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,19 @@ 2005-08-06 Erez Zadok + * libamu/util.c, amd/autil.c (strsplit): moved strsplit() function + from Amd code to to libamu, so sun2amd could use it. + + * amd/Makefile.am (sbin_PROGRAMS): build sun2amd binary and man + page. + (EXTRA_sun2amd_OBJECTS): sun2amd needs to link with all info_*.c files + + * amd/sun2amd.8: placeholder for man page. + + * amd/sun2amd.c: placeholder for C version of translator from Sun + syntax maps to Amd maps. + + * */*.[0-9]: include file name in nroff source comment. + * ALL: use '0' properly when assigning or passing it to functions. If in the context pointer, use NULL. If in the context of a single char (say within a string), the use '\0'. This is just to @@ -45,7 +59,6 @@ in the distro (IMHO), and should be cleaned upon "make clean". (amd_SOURCES): include new sun_map_parse.y and sun_map_tok.l files. - * ylwrap: new file needed because we have two parsers now. * amd/sun_map_{parse.y,tok.l}: cleanup and formatting. diff --git a/amd/Makefile.am b/amd/Makefile.am index 4780f95..a8b0fb8 100644 --- a/amd/Makefile.am +++ b/amd/Makefile.am @@ -4,10 +4,10 @@ # Level: Makefile for amd/ directory # Author: Erez Zadok -sbin_PROGRAMS = amd +sbin_PROGRAMS = amd sun2amd # man pages -man_MANS = amd.8 +man_MANS = amd.8 sun2amd.8 # test scripts TESTS = test1.sh @@ -100,12 +100,34 @@ EXTRA_amd_SOURCES = \ \ get_args.c +sun2amd_SOURCES = \ + sun_map_parse.y \ + sun_map_tok.l \ + \ + sun2amd.c \ + sun_map.c + +EXTRA_sun2amd_SOURCES = \ + info_file.c \ + info_exec.c \ + info_hesiod.c \ + info_ldap.c \ + info_ndbm.c \ + info_nis.c \ + info_nisplus.c \ + info_passwd.c \ + info_sun.c \ + info_union.c + # AMD_FS_OBJS: a list of ops_*.o objects added, depending on which # filesystem types this system supports. # AMD_INFO_OBJS: a list of info_*.o objects added, depending on which map # types this system supports. EXTRA_amd_OBJECTS = @AMD_FS_OBJS@ @AMD_INFO_OBJS@ -LDADD = $(EXTRA_amd_OBJECTS) get_args.o ../libamu/libamu.la +amd_LDADD = $(EXTRA_amd_OBJECTS) get_args.o ../libamu/libamu.la + +EXTRA_sun2amd_OBJECTS = @AMD_INFO_OBJS@ +sun2amd_LDADD = $(EXTRA_sun2amd_OBJECTS) ../libamu/libamu.la # must manually add f/lex library to LIBS, and not to LDADD. LIBS = @LIBS@ @LEXLIB@ @WRAPLIB@ diff --git a/amd/amd.8 b/amd/amd.8 index cf943e1..765a8bb 100644 --- a/amd/amd.8 +++ b/amd/amd.8 @@ -36,9 +36,8 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" %W% (Berkeley) %G% .\" -.\" $Id: amd.8,v 1.14 2005/01/03 20:56:45 ezk Exp $ +.\" File: am-utils/amd/amd.8 .\" .TH AMD 8 "3 November 1989" .SH NAME diff --git a/amd/autil.c b/amd/autil.c index e439c27..fc67117 100644 --- a/amd/autil.c +++ b/amd/autil.c @@ -94,76 +94,6 @@ strealloc(char *p, char *s) } -/* - * Split s using ch as delimiter and qc as quote character - */ -char ** -strsplit(char *s, int ch, int qc) -{ - char **ivec; - int ic = 0; - int done = 0; - - ivec = (char **) xmalloc((ic + 1) * sizeof(char *)); - - while (!done) { - char *v; - - /* - * skip to split char - */ - while (*s && (ch == ' ' ? (isascii(*s) && isspace((int)*s)) : *s == ch)) - *s++ = '\0'; - - /* - * End of string? - */ - if (!*s) - break; - - /* - * remember start of string - */ - v = s; - - /* - * skip to split char - */ - while (*s && !(ch == ' ' ? (isascii(*s) && isspace((int)*s)) : *s == ch)) { - if (*s++ == qc) { - /* - * Skip past string. - */ - s++; - while (*s && *s != qc) - s++; - if (*s == qc) - s++; - } - } - - if (!*s) - done = 1; - *s++ = '\0'; - - /* - * save string in new ivec slot - */ - ivec[ic++] = v; - ivec = (char **) xrealloc((voidp) ivec, (ic + 1) * sizeof(char *)); - if (amuDebug(D_STR)) - plog(XLOG_DEBUG, "strsplit saved \"%s\"", v); - } - - if (amuDebug(D_STR)) - plog(XLOG_DEBUG, "strsplit saved a total of %d strings", ic); - - ivec[ic] = NULL; - - return ivec; -} - - /* * Strip off the trailing part of a domain * to produce a short-form domain relative diff --git a/amd/sun2amd.8 b/amd/sun2amd.8 new file mode 100644 index 0000000..6352589 --- /dev/null +++ b/amd/sun2amd.8 @@ -0,0 +1,44 @@ +.\" +.\" Copyright (c) 1997-2005 Erez Zadok +.\" Copyright (c) 1990 Jan-Simon Pendry +.\" Copyright (c) 1990 Imperial College of Science, Technology & Medicine +.\" Copyright (c) 1990 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Jan-Simon Pendry at Imperial College, London. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgment: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" +.\" File: am-utils/amd/sun2amd.8 +.\" +.TH SUN2AMD 8L "8 August 2005" +.SH NAME +sun2amd \- converts Sun automount maps to Amd maps diff --git a/amd/sun2amd.c b/amd/sun2amd.c new file mode 100644 index 0000000..647fa9b --- /dev/null +++ b/amd/sun2amd.c @@ -0,0 +1,65 @@ +/* + * Copyright (c) 1997-2005 Erez Zadok + * Copyright (c) 1989 Jan-Simon Pendry + * Copyright (c) 1989 Imperial College of Science, Technology & Medicine + * Copyright (c) 1989 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Jan-Simon Pendry at Imperial College, London. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgment: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * + * File: am-utils/amd/sun2amd.c + * + */ + +/* + * Translate Sun-syntax maps to Amd maps + */ + +#ifdef HAVE_CONFIG_H +# include +#endif /* HAVE_CONFIG_H */ +#include +#include + +/* XXX: empty placeholder. Fill in */ + + +/* dummies to make the program compile and link */ +struct amu_global_options gopt; /* may not be needed for sun2amd */ + + +int +main() +{ + exit(1); +} diff --git a/amq/amq.8 b/amq/amq.8 index ee62df8..e296e0f 100644 --- a/amq/amq.8 +++ b/amq/amq.8 @@ -36,9 +36,8 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" %W% (Berkeley) %G% .\" -.\" $Id: amq.8,v 1.15 2005/01/03 20:56:45 ezk Exp $ +.\" File: am-utils/amq/amq.8 .\" .TH AMQ 8 "25 April 1989" .SH NAME diff --git a/amq/pawd.1 b/amq/pawd.1 index ac98d2e..e4d4745 100644 --- a/amq/pawd.1 +++ b/amq/pawd.1 @@ -36,9 +36,8 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" %W% (Berkeley) %G% .\" -.\" $Id: pawd.1,v 1.9 2005/01/03 20:56:45 ezk Exp $ +.\" File: am-utils/amq/pawd.1 .\" .TH PAWD 1 "6 Jan 1998" .SH NAME diff --git a/fixmount/fixmount.8 b/fixmount/fixmount.8 index 9dfdfe8..663741d 100644 --- a/fixmount/fixmount.8 +++ b/fixmount/fixmount.8 @@ -36,9 +36,8 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" %W% (Berkeley) %G% .\" -.\" $Id: fixmount.8,v 1.12 2005/01/03 20:56:46 ezk Exp $ +.\" File: am-utils/fixmount/fixmount.8 .\" .TH FIXMOUNT 8 "26 Feb 1993" .SH NAME diff --git a/fsinfo/fsinfo.8 b/fsinfo/fsinfo.8 index 0f0f79e..04fe3f0 100644 --- a/fsinfo/fsinfo.8 +++ b/fsinfo/fsinfo.8 @@ -32,8 +32,8 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" from: @(#)fsinfo.8 8.1 (Berkeley) 6/28/93 -.\" $Id: fsinfo.8,v 1.13 2005/01/03 20:56:46 ezk Exp $ +.\" +.\" File: am-utils/fsinfo/fsinfo.8 .\" .TH FSINFO 8 "June 28, 1993" .SH NAME diff --git a/hlfsd/hlfsd.8 b/hlfsd/hlfsd.8 index 56e5652..7531111 100644 --- a/hlfsd/hlfsd.8 +++ b/hlfsd/hlfsd.8 @@ -36,7 +36,8 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $Id: hlfsd.8,v 1.11 2005/01/03 20:56:46 ezk Exp $ +.\" +.\" File: am-utils/hlfsd/hlfsd.8 .\" .\" HLFSD was written at Columbia University Computer Science Department, by .\" Erez Zadok and Alexander Dupuy diff --git a/libamu/strutil.c b/libamu/strutil.c index d11d318..556fb07 100644 --- a/libamu/strutil.c +++ b/libamu/strutil.c @@ -121,6 +121,76 @@ xstrlcat(char *dst, const char *src, size_t len) } +/* + * Split s using ch as delimiter and qc as quote character + */ +char ** +strsplit(char *s, int ch, int qc) +{ + char **ivec; + int ic = 0; + int done = 0; + + ivec = (char **) xmalloc((ic + 1) * sizeof(char *)); + + while (!done) { + char *v; + + /* + * skip to split char + */ + while (*s && (ch == ' ' ? (isascii(*s) && isspace((int)*s)) : *s == ch)) + *s++ = '\0'; + + /* + * End of string? + */ + if (!*s) + break; + + /* + * remember start of string + */ + v = s; + + /* + * skip to split char + */ + while (*s && !(ch == ' ' ? (isascii(*s) && isspace((int)*s)) : *s == ch)) { + if (*s++ == qc) { + /* + * Skip past string. + */ + s++; + while (*s && *s != qc) + s++; + if (*s == qc) + s++; + } + } + + if (!*s) + done = 1; + *s++ = '\0'; + + /* + * save string in new ivec slot + */ + ivec[ic++] = v; + ivec = (char **) xrealloc((voidp) ivec, (ic + 1) * sizeof(char *)); + if (amuDebug(D_STR)) + plog(XLOG_DEBUG, "strsplit saved \"%s\"", v); + } + + if (amuDebug(D_STR)) + plog(XLOG_DEBUG, "strsplit saved a total of %d strings", ic); + + ivec[ic] = NULL; + + return ivec; +} + + /* * Make all the directories in the path. */ diff --git a/mk-amd-map/mk-amd-map.8 b/mk-amd-map/mk-amd-map.8 index 9c9ccf7..c3f5713 100644 --- a/mk-amd-map/mk-amd-map.8 +++ b/mk-amd-map/mk-amd-map.8 @@ -32,8 +32,8 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" from: @(#)mk-amd-map.8 8.1 (Berkeley) 6/28/93 -.\" $Id: mk-amd-map.8,v 1.9 2005/01/03 20:56:46 ezk Exp $ +.\" +.\" File: am-utils/mk-amd-map/mk-amd-map.8 .\" .TH MK-AMD-MAP 8 "June 28, 1993" .SH NAME diff --git a/scripts/amd.conf.5 b/scripts/amd.conf.5 index d904121..feca1ee 100644 --- a/scripts/amd.conf.5 +++ b/scripts/amd.conf.5 @@ -36,9 +36,8 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" %W% (Berkeley) %G% .\" -.\" $Id: amd.conf.5,v 1.40 2005/08/06 18:58:45 ezk Exp $ +.\" File: am-utils/scripts/amd.conf.5 .\" .TH AMD.CONF 5 "7 August 1997" .SH NAME diff --git a/scripts/automount2amd.8 b/scripts/automount2amd.8 index ad2d477..776213f 100644 --- a/scripts/automount2amd.8 +++ b/scripts/automount2amd.8 @@ -36,9 +36,8 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" %W% (Berkeley) %G% .\" -.\" $Id: automount2amd.8,v 1.8 2005/01/03 20:56:46 ezk Exp $ +.\" File: am-utils/scripts/automount2amd.8 .\" .TH AUTOMOUNT2AMD 8L "24 May 1993" .SH NAME diff --git a/wire-test/wire-test.8 b/wire-test/wire-test.8 index 07503cd..4765c35 100644 --- a/wire-test/wire-test.8 +++ b/wire-test/wire-test.8 @@ -36,9 +36,8 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" %W% (Berkeley) %G% .\" -.\" $Id: wire-test.8,v 1.10 2005/01/03 20:56:46 ezk Exp $ +.\" File: am-utils/wire-test/wire-test.8 .\" .TH WIRE-TEST 8 "26 Feb 1993" .SH NAME