Date: Wed, 21 Apr 1999 16:29:24 -0500 (CDT) From: Chris Costello <chris@holly.dyndns.org> To: FreeBSD-gnats-submit@freebsd.org Subject: ports/11267: [New port] textproc/fconv (the return) Message-ID: <199904212129.QAA00897@holly.dyndns.org>
next in thread | raw e-mail | index | archive | help
>Number: 11267 >Category: ports >Synopsis: [New port] textproc/fconv (the return) >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Wed Apr 21 14:30:01 PDT 1999 >Closed-Date: >Last-Modified: >Originator: Chris Costello >Release: FreeBSD 4.0-CURRENT i386 >Organization: None, whatsoever. >Environment: (null) >Description: pkg/DESCR: As well as being a work-alike for the BSDI utility mentioned in the doscmd man page, dos2bsd (and bsd2dos), fconv supports conversion to and from Macintosh type files (which use only '\r'). >How-To-Repeat: Not applicable. NOTE: I don't have an "appropriate" (as in "pipe big enough") server to host this on, so I'd like to be contacted for a distfile should my port be accepted. >Fix: # This is a shell archive. Save it in a file, remove anything before # this line, and then unpack it by entering "sh file". Note, it may # create directories; files and directories will be owned by you and # have default permissions. # # This archive contains: # # fconv-0.1 # fconv-0.1/Makefile # fconv-0.1/fconv.c # echo c - fconv-0.1 mkdir -p fconv-0.1 > /dev/null 2>&1 echo x - fconv-0.1/Makefile sed 's/^X//' >fconv-0.1/Makefile << 'END-of-fconv-0.1/Makefile' X# X# Copyright (c) 1999 Chris Costello <chris@calldei.com> X# All rights reserved. X# X# Redistribution and use in source and binary forms, with or without X# modification, are permitted provided that the following conditions X# are met: X# 1. Redistributions of source code must retain the above copyright X# notice, this list of conditions and the following disclaimer. X# 2. Redistributions in binary form must reproduce the above copyright X# notice, this list of conditions and the following disclaimer in the X# documentation and/or other materials provided with the distribution. X# X# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND X# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE X# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE X# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE X# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL X# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS X# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) X# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT X# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY X# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF X# SUCH DAMAGE. X XLINKS = dos2bsd XLINKS += bsd2dos XLINKS += mac2bsd XLINKS += bsd2mac X Xall: fconv links X Xfconv: fconv.c X Xlinks: dos2bsd bsd2dos mac2bsd bsd2mac X X.for LINK in $(LINKS) X$(LINK): X ln fconv $(LINK) X.endfor X Xinstall: all fconv links X.for PRG in $(LINKS) X ${INSTALL} -c -o root -g wheel -m 0755 $(PRG) /usr/local/bin X.endfor X Xclean: X rm -f $(LINKS) fconv END-of-fconv-0.1/Makefile echo x - fconv-0.1/fconv.c sed 's/^X//' >fconv-0.1/fconv.c << 'END-of-fconv-0.1/fconv.c' X/*- X * Copyright (c) 1999 Chris Costello <chris@calldei.com> X * All rights reserved. X * X * Redistribution and use in source and binary forms, with or without X * modification, are permitted provided that the following conditions X * are met: X * 1. Redistributions of source code must retain the above copyright X * notice, this list of conditions and the following disclaimer. X * 2. Redistributions in binary form must reproduce the above copyright X * notice, this list of conditions and the following disclaimer in the X * documentation and/or other materials provided with the distribution. X * X * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE X * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF X * SUCH DAMAGE. X */ X X#include <err.h> X#include <stdio.h> X#include <string.h> X#include <stdlib.h> X#include <unistd.h> X X#define TEST(s1, s2, s3, s4) \ X{ \ X if (!strcmp(prg, #s1)) \ X mode = s1; \ X else if (!strcmp(prg, #s2)) \ X mode = s2; \ X else if (!strcmp(prg, #s3)) \ X mode = s3; \ X else if (!strcmp(prg, #s4)) \ X mode = s4; \ X else \ X mode = -1; \ X} X Xvoid usage(void); Xvoid noprg(void); X Xchar *prg; X Xint Xmain(argc, argv) X int argc; X char **argv; X{ X char ch, *src, *dst, *tprg; X int mode = -1; X int dos2bsd = 1, bsd2dos = 2, mac2bsd = 3, bsd2mac = 4; X X /* X * Default the input and output filenames to stdin and stdout X * respectively, this is what BSDI's dos2bsd/bsd2dos does. X */ X src = "/dev/stdin"; X dst = "/dev/stdout"; X X /* prg is a pointer to the original argv[0] */ X prg = argv[0]; X X /* X * $ dos2bsd -a -b -c X * dos2bsd: illegal option -- a X * usage: dos2bsd [input [output]] X * -------------------------------- X * It looks like it uses getopt, but doesn't allow any opts (the X * manual page also doesn't mention any options). X */ X X while ((ch = getopt(argc, argv, "?")) != -1) X switch(ch) { X case '?': X default: X usage(); X /* NOTREACHED */ X } X X argc -= optind; X argv += optind; X X /* X * Now we see how many args we have, and set the source/destination X * as necessary. X */ X X switch (argc) { X case 2: X if (freopen(dst = argv[1], "w", stdout) == NULL) X err(1, "%s", argv[1]); X /* FALLTHROUGH */ X case 1: X if (freopen(dst = argv[0], "r", stdin) == NULL) X err(1, "%s", argv[0]); X /* FALLTHROUGH */ X case 0: X break; X default: X usage(); X /* NOTREACHED */ X } X X /* Now determine the program to use */ X tprg = strchr(prg, '/'); X X if (tprg != NULL) { X if ((tprg += 1) != NULL) { X prg = tprg; X TEST(dos2bsd, bsd2dos, mac2bsd, bsd2mac); X if (mode == -1) X usage(); X } X } X X switch (mode) { X case 1: X while ((ch = getchar()) != EOF) { X if (ch != '\r') X putchar(ch); X } X break; X case 2: X while ((ch = getchar()) != EOF) { X if (ch == '\n') X putchar('\r'); X putchar(ch); X } X break; X case 3: X while ((ch = getchar()) != EOF) { X if (ch == '\r') X putchar('\n'); X else X putchar(ch); X } X break; X case 4: X while ((ch = getchar()) != EOF) { X if (ch == '\n') X putchar('\r'); X else X putchar(ch); X } X break; X default: X noprg(); X /* NOTREACHED */ X } X X if (ferror(stdin)) X err(1, "%s", src); X if (ferror(stdout)) X err(1, "%s", dst); X X fclose(stdin); X fclose(stdout); X X exit(0); X} X Xvoid Xnoprg() X{ X errx(1, "This can only be run as dos2bsd, bsd2dos, mac2bsd, or bsd2mac"); X /* NOTREACHED */ X} X Xvoid Xusage() X{ X fprintf(stderr, "usage: %s [input [output]]\n", prg); X exit(1); X} X END-of-fconv-0.1/fconv.c exit >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-ports" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199904212129.QAA00897>