diff options
| author | cvs2svn <cvs2svn@FreeBSD.org> | 1997-02-06 17:52:31 +0000 |
|---|---|---|
| committer | cvs2svn <cvs2svn@FreeBSD.org> | 1997-02-06 17:52:31 +0000 |
| commit | 02dc1b38dc547431532d39eb3cea448f27dee511 (patch) | |
| tree | f76c198feb4046c89b23e55e8e21e59127e5da55 /usr.bin | |
| parent | c374a1f62238c1d5d8c4bcfe91324b1446a831e4 (diff) | |
Notes
Diffstat (limited to 'usr.bin')
| -rw-r--r-- | usr.bin/colldef/data/de_DE.ISO_8859-1.src | 38 | ||||
| -rw-r--r-- | usr.bin/colldef/data/es_ES.ISO_8859-1.src | 38 | ||||
| -rw-r--r-- | usr.bin/colldef/data/is_IS.ISO_8859-1.src | 38 | ||||
| -rw-r--r-- | usr.bin/fetch/fetch.h | 89 | ||||
| -rw-r--r-- | usr.bin/fetch/file.c | 144 | ||||
| -rw-r--r-- | usr.bin/fetch/uri.c | 122 | ||||
| -rw-r--r-- | usr.bin/limits/Makefile | 13 |
7 files changed, 482 insertions, 0 deletions
diff --git a/usr.bin/colldef/data/de_DE.ISO_8859-1.src b/usr.bin/colldef/data/de_DE.ISO_8859-1.src new file mode 100644 index 000000000000..38dcd059a880 --- /dev/null +++ b/usr.bin/colldef/data/de_DE.ISO_8859-1.src @@ -0,0 +1,38 @@ +# German/ISO 8859-1 (backward compatible with ASCII) +# +# $FreeBSD$ +# +charmap map.ISO_8859-1 +order \ +# controls + <NU>;...;<US>;<PA>;...;<AC>;\ +# + <NS>;<SP>;!;<!I>;\";<<<>;</>/>>;<Nb>;\ + <Cu>;<Ct>;<DO>;<Pd>;<Ye>;\ + %;&;<',>;';\(;\);*;+;<+->;<-:>;<*X>;\,;<-->;-;.;/;\ +# digits + (0,<14>,<12>,<34>);(1,<1S>);(2,<2S>);(3,<3S>);4;...;9;\ +# + :;\;;\<;=;>;?;<?I>;<SE>;<PI>;<Co>;<Rg>;<At>;\ +# capital + (A,<A'>,<A!>,<A/>>,<AA>,<A:>,<A?>,<AE>);\ + B;(C,<C,>);D;(E,<E'>,<E!>,<E/>>,<E:>);\ + F;G;H;(I,<I'>,<I!>,<I/>>,<I:>);\ + J;...;M;(N,<N?>);(O,<O'>,<O!>,<O/>>,<O:>,<O?>,<O//>);\ + P;...;T;(U,<U'>,<U!>,<U/>>,<U:>);\ + V;W;X;(Y,<Y'>);Z;\ + <D->;<TH>;\ +# + [;\\;];^;<':>;_;<'m>;<''>;`;\ +# small + (a,<a'>,<a!>,<a/>>,<aa>,<a:>,<a?>,<ae>);\ + b;(c,<c,>);d;(e,<e'>,<e!>,<e/>>,<e:>);\ + f;g;h;(i,<i'>,<i!>,<i/>>,<i:>);\ + j;...;m;(n,<n?>);(o,<o'>,<o!>,<o/>>,<o:>,<o?>,<o//>);\ + p;...;r;(s,<ss>);t;(u,<u'>,<u!>,<u/>>,<u:>);\ + v;w;x;(y,<y'>,<y:>);z;\ + <d->;<th>;\ +# + \{;<NO>;|;<BB>;\};~;<.M>;<DG>;<My>;<DT>;\ +# remains + <-a>;<-o> diff --git a/usr.bin/colldef/data/es_ES.ISO_8859-1.src b/usr.bin/colldef/data/es_ES.ISO_8859-1.src new file mode 100644 index 000000000000..7c2b21fc5955 --- /dev/null +++ b/usr.bin/colldef/data/es_ES.ISO_8859-1.src @@ -0,0 +1,38 @@ +# Espan~ol (backward compatible with ASCII) +# +# $FreeBSD$ +# +charmap map.ISO_8859-1 +order \ +# controls + <NU>;...;<US>;<PA>;...;<AC>;\ +# + <NS>;<SP>;!;<!I>;\";<<<>;</>/>>;<Nb>;\ + <Cu>;<Ct>;<DO>;<Pd>;<Ye>;\ + %;&;<',>;';\(;\);*;+;<+->;<-:>;<*X>;\,;<-->;-;.;/;\ +# digits + (0,<14>,<12>,<34>);(1,<1S>);(2,<2S>);(3,<3S>);4;...;9;\ +# + :;\;;\<;=;>;?;<?I>;<SE>;<PI>;<Co>;<Rg>;<At>;\ +# capital + (A,<A'>,<A!>,<A/>>,<AA>,<A:>,<A?>,<AE>);\ + B;(C,<C,>);{CH,Ch};D;(E,<E'>,<E!>,<E/>>,<E:>);\ + F;G;H;(I,<I'>,<I!>,<I/>>,<I:>);\ + J;...;K;L;{LL,Ll};M;(N,<N?>);(O,<O'>,<O!>,<O/>>,<O:>,<O?>,<O//>);\ + P;Q;R;{RR,Rr};S;T;(U,<U'>,<U!>,<U/>>,<U:>);\ + V;W;X;(Y,<Y'>);Z;\ + <D->;<TH>;\ +# + [;\\;];^;<':>;_;<'m>;<''>;`;\ +# small + (a,<a'>,<a!>,<a/>>,<aa>,<a:>,<a?>,<ae>);\ + b;(c,<c,>);ch;d;(e,<e'>,<e!>,<e/>>,<e:>);\ + f;g;h;(i,<i'>,<i!>,<i/>>,<i:>);\ + j;...;k;l;ll;m;(n,<n?>);(o,<o'>,<o!>,<o/>>,<o:>,<o?>,<o//>);\ + p;q;r;rr;s;t;(u,<u'>,<u!>,<u/>>,<u:>);\ + v;w;x;(y,<y'>,<y:>);z;\ + <d->;<th>;<ss>;\ +# + \{;<NO>;|;<BB>;\};~;<.M>;<DG>;<My>;<DT>;\ +# remains + <-a>;<-o> diff --git a/usr.bin/colldef/data/is_IS.ISO_8859-1.src b/usr.bin/colldef/data/is_IS.ISO_8859-1.src new file mode 100644 index 000000000000..50cd9a95ca8f --- /dev/null +++ b/usr.bin/colldef/data/is_IS.ISO_8859-1.src @@ -0,0 +1,38 @@ +# icelandic (backward compatible with ASCII) +# +# $FreeBSD$ +# +charmap map.ISO_8859-1 +order \ +# controls + <NU>;...;<US>;<PA>;...;<AC>;\ +# + <NS>;<SP>;!;<!I>;\";<<<>;</>/>>;<Nb>;\ + <Cu>;<Ct>;<DO>;<Pd>;<Ye>;\ + %;&;<',>;';\(;\);*;+;<+->;<-:>;<*X>;\,;<-->;-;.;/;\ +# digits + (0,<14>,<12>,<34>);(1,<1S>);(2,<2S>);(3,<3S>);4;...;9;\ +# + :;\;;\<;=;>;?;<?I>;<SE>;<PI>;<Co>;<Rg>;<At>;\ +# capital + (A,<A'>,<A!>,<A/>>,<AA>,<A:>,<A?>);\ + B;(C,<C,>);(D,<D->);(E,<E'>,<E!>,<E/>>,<E:>);\ + F;G;H;(I,<I'>,<I!>,<I/>>,<I:>);\ + J;...;M;(N,<N?>);(O,<O'>,<O!>,<O/>>,<O?>,<O//>);\ + P;...;T;(U,<U'>,<U!>,<U/>>,<U:>);\ + V;W;X;(Y,<Y'>);Z;\ + <TH>;<AE>;<O:>;\ +# + [;\\;];^;<':>;_;<'m>;<''>;`;\ +# small + (a,<a'>,<a!>,<a/>>,<aa>,<a:>,<a?>);\ + b;(c,<c,>);(d,<d->);(e,<e'>,<e!>,<e/>>,<e:>);\ + f;g;h;(i,<i'>,<i!>,<i/>>,<i:>);\ + j;...;m;(n,<n?>);(o,<o'>,<o!>,<o/>>,<o?>,<o//>);\ + p;...;t;(u,<u'>,<u!>,<u/>>,<u:>);\ + v;w;x;(y,<y'>,<y:>);z;\ + <th>;<ae>;<o:>;<ss>;\ +# + \{;<NO>;|;<BB>;\};~;<.M>;<DG>;<My>;<DT>;\ +# remains + <-a>;<-o> diff --git a/usr.bin/fetch/fetch.h b/usr.bin/fetch/fetch.h new file mode 100644 index 000000000000..321af11f671b --- /dev/null +++ b/usr.bin/fetch/fetch.h @@ -0,0 +1,89 @@ +/* + * Copyright 1997 Massachusetts Institute of Technology + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that both the above copyright notice and this + * permission notice appear in all copies, that both the above + * copyright notice and this permission notice appear in all + * supporting documentation, and that the name of M.I.T. not be used + * in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. M.I.T. makes + * no representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied + * warranty. + * + * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS + * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + * SHALL M.I.T. 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. + * + * $Id: fetch.h,v 1.2 1997/01/31 19:55:49 wollman Exp $ + */ + +#ifndef fetch_h +#define fetch_h 1 + + +#define BUFFER_SIZE 1024 +#define FETCH_VERSION "fetch/1.0" +#define PATH_CP "/bin/cp" + +struct fetch_state { + const char *fs_status; + const char *fs_outputfile; + int fs_verbose; /* -q, -v option */ + int fs_newtime; /* -n option */ + int fs_mirror; /* -m option */ + int fs_restart; /* -r option */ + int fs_timeout; /* -T option */ + int fs_passive_mode; /* -p option */ + int fs_linkfile; /* -l option */ + int fs_precious; /* -R option */ + int fs_auto_retry; /* -a option */ + time_t fs_modtime; + void *fs_proto; + int (*fs_retrieve)(struct fetch_state *); + int (*fs_close)(struct fetch_state *); +}; + +struct uri_scheme { + const char *sc_name; /* name of the scheme, <32 characters */ + int (*sc_parse)(struct fetch_state *, const char *); + /* routine to parse a URI and build state */ + int (*sc_proxy_parse)(struct fetch_state *, const char *); + /* same, but for proxy case */ + const char *sc_proxy_envar; /* envar used to determine proxy */ + const char *sc_proxy_by; /* list of protos which can proxy us */ + + /* The rest is filled in dynamically... */ + int sc_can_proxy; + struct uri_scheme *sc_proxyproto; +}; + +extern struct uri_scheme file_scheme, ftp_scheme, http_scheme; + +void adjmodtime(struct fetch_state *fs); +void catchsig(int signo); +void display(struct fetch_state *fs, off_t total, ssize_t thisincr); +void init_schemes(void); +void rm(struct fetch_state *fs); +void setup_sigalrm(void); +void unsetup_sigalrm(void); +void *safe_malloc(size_t len); +char *percent_decode(const char *orig); +char *safe_strdup(const char *orig); +char *safe_strndup(const char *orig, size_t len); +char *to_base64(const unsigned char *buf, size_t len); +int from_base64(const char *orig, unsigned char *buf, size_t *lenp); +int parse_host_port(const char *str, char **hostname, int *port); +int parse_uri(struct fetch_state *fs, const char *uri); +#endif /* ! fetch_h */ diff --git a/usr.bin/fetch/file.c b/usr.bin/fetch/file.c new file mode 100644 index 000000000000..091639c9a18b --- /dev/null +++ b/usr.bin/fetch/file.c @@ -0,0 +1,144 @@ +/*- + * Copyright 1997 Massachusetts Institute of Technology + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that both the above copyright notice and this + * permission notice appear in all copies, that both the above + * copyright notice and this permission notice appear in all + * supporting documentation, and that the name of M.I.T. not be used + * in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. M.I.T. makes + * no representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied + * warranty. + * + * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS + * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + * SHALL M.I.T. 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. + * + * $Id$ + */ + +#include <sys/types.h> + +#include <err.h> +#include <errno.h> +#include <signal.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sysexits.h> +#include <unistd.h> + +#include <sys/wait.h> + +#include "fetch.h" + +static int file_retrieve(struct fetch_state *fs); +static int file_close(struct fetch_state *fs); +static int file_parse(struct fetch_state *fs, const char *uri); + +struct uri_scheme file_scheme = + { "file", file_parse, 0, 0, 0 }; + +/* + * Again, we slightly misinterpret the slash after the hostname as + * being the start of the pathname rather than merely a separator. + */ +static int +file_parse(struct fetch_state *fs, const char *uri) +{ + const char *p; + + p = uri + 5; /* skip past `file:' */ + if (p[0] == '/' && p[1] == '/') { + /* skip past `//localhost', if any */ + p += 2; + while (*p && *p != '/') + p++; + } + + if (p[0] != '/') { + warnx("`%s': expected absolute pathname in `file' URL", uri); + return EX_USAGE; + } + + fs->fs_proto = percent_decode(p); + /* guaranteed to succeed because of above test */ + p = strrchr(fs->fs_proto, '/'); + if (fs->fs_outputfile == 0) /* only set if not overridden by user */ + fs->fs_outputfile = p + 1; + fs->fs_retrieve = file_retrieve; + fs->fs_close = file_close; + return 0; +} + +static int +file_close(struct fetch_state *fs) +{ + free(fs->fs_proto); + fs->fs_proto = 0; + fs->fs_outputfile = 0; + fs->fs_status = "free"; + return 0; +} + +static int +file_retrieve(struct fetch_state *fs) +{ + /* XXX - this seems bogus to me! */ + if (access(fs->fs_outputfile, F_OK) == 0) { + errno = EEXIST; + warn("%s", fs->fs_outputfile); + return EX_USAGE; + } + + if (fs->fs_linkfile) { + fs->fs_status = "symlink"; + if (symlink(fs->fs_proto, fs->fs_outputfile) == -1) { + warn("symlink"); + return EX_OSERR; + } + fs->fs_status = "done"; + } else { + pid_t pid; + int status; + + fflush(stderr); + pid = fork(); + if (pid < 0) { + warn("fork"); + return EX_TEMPFAIL; + } else if (pid == 0) { + execl(PATH_CP, "cp", "-p", fs->fs_proto, + fs->fs_outputfile, (char *)0); + warn("execl: " PATH_CP); + fflush(stderr); + _exit(EX_OSERR); + } else { + fs->fs_status = "copying"; + if (waitpid(pid, &status, 0) < 0) { + warn("waitpid(%ld)", (long)pid); + return EX_OSERR; + } + if (WIFEXITED(status)) + return WEXITSTATUS(status); + if (WIFSIGNALED(status)) + warn(PATH_CP " exited on signal: %s", + sys_signame[WTERMSIG(status)]); + return EX_OSERR; + } + } + return 0; +} + diff --git a/usr.bin/fetch/uri.c b/usr.bin/fetch/uri.c new file mode 100644 index 000000000000..95d4c91898bf --- /dev/null +++ b/usr.bin/fetch/uri.c @@ -0,0 +1,122 @@ +/*- + * Copyright 1997 Massachusetts Institute of Technology + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that both the above copyright notice and this + * permission notice appear in all copies, that both the above + * copyright notice and this permission notice appear in all + * supporting documentation, and that the name of M.I.T. not be used + * in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. M.I.T. makes + * no representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied + * warranty. + * + * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS + * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + * SHALL M.I.T. 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. + * + * $Id$ + */ + +#include <sys/types.h> + +#include <err.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sysexits.h> +#include <unistd.h> + +#include "fetch.h" + +struct uri_scheme *schemes[] = { + &http_scheme, &ftp_scheme, &file_scheme, 0 +}; + +static struct uri_scheme * +find_scheme(const char *name) +{ + int i; + + for (i = 0; schemes[i]; i++) { + if (strcasecmp(schemes[i]->sc_name, name) == 0) + return schemes[i]; + } + return 0; +} + +void +init_schemes(void) +{ + int i; + char schemebuf[32]; + const char *s, *t; + struct uri_scheme *scp; + + for (i = 0; schemes[i]; i++) { + if (getenv(schemes[i]->sc_proxy_envar) != 0) + schemes[i]->sc_can_proxy = 1; + } + + for (i = 0; schemes[i]; i++) { + s = schemes[i]->sc_proxy_by; + while (s && *s) { + t = strchr(s, ','); + if (t) { + schemebuf[0] = '\0'; + strncat(schemebuf, s, t - s); + s = t + 1; + } else { + strcpy(schemebuf, s); + s = 0; + } + scp = find_scheme(schemebuf); + if (scp && scp->sc_can_proxy) { + schemes[i]->sc_proxyproto = scp; + break; + } + } + } +} + +int +parse_uri(struct fetch_state *fs, const char *uri) +{ + const char *colon, *slash; + char *scheme; + struct uri_scheme *scp; + + fs->fs_status = "parsing URI"; + colon = strchr(uri, ':'); + slash = strchr(uri, '/'); + if (!colon || !slash || slash < colon) { + warnx("%s: an absolute URI is required", uri); + return EX_USAGE; + } + + scheme = alloca(colon - uri + 1); + scheme[0] = '\0'; + strncat(scheme, uri, colon - uri); + scp = find_scheme(scheme); + + if (scp == 0) { + warnx("%s: unknown URI scheme", scheme); + return EX_USAGE; + } + if (scp->sc_proxyproto) + return scp->sc_proxyproto->sc_proxy_parse(fs, uri); + else + return scp->sc_parse(fs, uri); +} + diff --git a/usr.bin/limits/Makefile b/usr.bin/limits/Makefile new file mode 100644 index 000000000000..885930fbd7b5 --- /dev/null +++ b/usr.bin/limits/Makefile @@ -0,0 +1,13 @@ +# @(#)Makefile 8.1 (Berkeley) 7/19/93 + +PROG= limits +SRCS= limits.c + +CFLAGS+=-Wall +LDADD+= -lutil +DPADD+= ${LIBUTIL} + +BINOWN= root +BINMODE=0555 + +.include <bsd.prog.mk> |
