From fdb87e258044b665ec0d9ebdaf5943f2e7d30838 Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Tue, 30 Jul 2013 01:06:41 -0400 Subject: [PATCH] add license --- Duplicate.c | 26 ++++++++++++++++++++++++++ GetEnv.c | 26 ++++++++++++++++++++++++++ Help.c | 2 +- OverlayIIgs.c | 26 ++++++++++++++++++++++++++ SetFile.c | 25 +++++++++++++++++++++++++ 5 files changed, 104 insertions(+), 1 deletion(-) diff --git a/Duplicate.c b/Duplicate.c index aecc113..05d1024 100644 --- a/Duplicate.c +++ b/Duplicate.c @@ -1,3 +1,29 @@ +/* + * Copyright (c) 2013, Kelvin W Sherlock + * All rights reserved. + * + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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. + * + */ + #include #include #include diff --git a/GetEnv.c b/GetEnv.c index ade361a..d6f2bf0 100644 --- a/GetEnv.c +++ b/GetEnv.c @@ -1,3 +1,29 @@ +/* + * Copyright (c) 2013, Kelvin W Sherlock + * All rights reserved. + * + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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. + * + */ + /* * * GetEnv variable diff --git a/Help.c b/Help.c index a346ce5..9f5f30c 100644 --- a/Help.c +++ b/Help.c @@ -1 +1 @@ -/* * MPW Help utility. * * help topic * does a cat of $ShellDirectory:Help:topic */ /* * MPW 3.2 * * C Help.c -o Help.c.o -r {SymOptions} * * Link {SymOptions} -w -c 'MPS ' -t MPST Help.c.o ∂ * -sn STDIO=Main ∂ * -sn INTENV=Main ∂ * -sn %A5Init=Main ∂ * "{Libraries}"Stubs.o ∂ * "{CLibraries}"StdCLib.o ∂ * "{Libraries}"Interface.o ∂ * "{Libraries}"Runtime.o ∂ * "{Libraries}"ToolLibs.o ∂ * -o Help * */ #include #include #include char *base(char *str) { char *rv = str; char *tmp = str; if (!str) return str; for (tmp = str; *tmp; ++tmp) { char c = *tmp; if (c == ':' || c == '/') rv = tmp + 1; } return rv; } void help(char *root, char *topic) { int l; char *path; FILE *fp; // todo -- check if they're being stupid or malicious and // handle / or : chars. topic = base(topic); if (!topic || !*topic) { return; } l = strlen(root) + strlen("Help:") + strlen(topic) + 1; path = malloc(1); if (!path) { fprintf(stderr, "### Help - Memory allocation failure.\n"); return; } sprintf(path, "%sHelp:%s", root, topic); fp = fopen(path, "r"); free(path); if (!fp) { fprintf(stderr, "### Help - \"%s\" was not found.\n", topic); return; } for(;;) { char buffer[512]; int count; count = fread(buffer, 1, sizeof(buffer), fp); if (count == 0) break; fwrite(buffer, 1, count, stdout); } fwrite("\r", 1, 1, stdout); fclose(fp); } int main(int argc, char **argv) { char *root; root = getenv("ShellDirectory"); if (!root || !*root) { fprintf(stderr, "### Help - $ShellDirectory is not defined.\n"); return 1; } if (argc == 1) { help(root, "MPW"); } else { int i; for (i = 1; i < argc; ++i) { help(root, argv[i]); } } return 0; } \ No newline at end of file +/* * Copyright (c) 2013, Kelvin W Sherlock * All rights reserved. * * 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. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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. * */ /* * MPW Help utility. * * help topic * does a cat of $ShellDirectory:Help:topic */ /* * MPW 3.2 * * C Help.c -o Help.c.o -r {SymOptions} * * Link {SymOptions} -w -c 'MPS ' -t MPST Help.c.o ∂ * -sn STDIO=Main ∂ * -sn INTENV=Main ∂ * -sn %A5Init=Main ∂ * "{Libraries}"Stubs.o ∂ * "{CLibraries}"StdCLib.o ∂ * "{Libraries}"Interface.o ∂ * "{Libraries}"Runtime.o ∂ * "{Libraries}"ToolLibs.o ∂ * -o Help * */ #include #include #include char *base(char *str) { char *rv = str; char *tmp = str; if (!str) return str; for (tmp = str; *tmp; ++tmp) { char c = *tmp; if (c == ':' || c == '/') rv = tmp + 1; } return rv; } void help(char *root, char *topic) { int l; char *path; FILE *fp; // todo -- check if they're being stupid or malicious and // handle / or : chars. topic = base(topic); if (!topic || !*topic) { return; } l = strlen(root) + strlen("Help:") + strlen(topic) + 1; path = malloc(1); if (!path) { fprintf(stderr, "### Help - Memory allocation failure.\n"); return; } sprintf(path, "%sHelp:%s", root, topic); fp = fopen(path, "r"); free(path); if (!fp) { fprintf(stderr, "### Help - \"%s\" was not found.\n", topic); return; } for(;;) { char buffer[512]; int count; count = fread(buffer, 1, sizeof(buffer), fp); if (count == 0) break; fwrite(buffer, 1, count, stdout); } fwrite("\r", 1, 1, stdout); fclose(fp); } int main(int argc, char **argv) { char *root; root = getenv("ShellDirectory"); if (!root || !*root) { fprintf(stderr, "### Help - $ShellDirectory is not defined.\n"); return 1; } if (argc == 1) { help(root, "MPW"); } else { int i; for (i = 1; i < argc; ++i) { help(root, argv[i]); } } return 0; } \ No newline at end of file diff --git a/OverlayIIgs.c b/OverlayIIgs.c index 5c9c791..b6ae387 100644 --- a/OverlayIIgs.c +++ b/OverlayIIgs.c @@ -1,3 +1,29 @@ +/* + * Copyright (c) 2013, Kelvin W Sherlock + * All rights reserved. + * + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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. + * + */ + #include #include #include diff --git a/SetFile.c b/SetFile.c index 8fcb01a..3d27c6d 100644 --- a/SetFile.c +++ b/SetFile.c @@ -1,3 +1,28 @@ +/* + * Copyright (c) 2013, Kelvin W Sherlock + * All rights reserved. + * + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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. + * + */ #include #include