ports/63607:

Andrew Wingborn beastie at fromru.com
Mon Mar 1 19:20:13 UTC 2004


>Number:         63607
>Category:       ports
>Synopsis:       
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Mon Mar 01 11:20:12 PST 2004
>Closed-Date:
>Last-Modified:
>Originator:     Andrew Wingborn
>Release:        FreeBSD 5.2-RELEASE i386
>Organization:
myself
>Environment:
System: FreeBSD k6pr300.coolsoft.ru 4.8-RELEASE FreeBSD 4.8-RELEASE #0: Mon Dec 15 23:28:37 MSK 2003 root at k6pr300.coolsoft.ru:/usr/obj/usr/src/sys/K6PR300 i386
>Description:
russian/win2koi
Best fast and easy to use recoder!
For example:
	fetch://anekdot.ru/an/an0402/j040222.html | win2dos | dos2koi | less
And you are feeling on a heaven!
Try this, please!

>How-To-Repeat:
	
>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:
#
#	./
#	./src
#	./src/win2koi.c
#	./src/Makefile
#	./src/win2koi.1
#	./Makefile
#	./pkg-descr
#	./pkg-plist
#
echo c - ./
mkdir -p ./ > /dev/null 2>&1
echo c - ./src
mkdir -p ./src > /dev/null 2>&1
echo x - ./src/win2koi.c
sed 's/^X//' >./src/win2koi.c << 'END-of-./src/win2koi.c'
X/**
X * @(#) Easy recoder  windows-1251 <-> koi8-r <-> cp866
X *
X * @author	Andrew Wingborn		mailto://beastie@fromru.com
X * @version	0.9
X * @date	2004-02-22
X *
X * $FreeBSD$
X *
X * set tabstop=4
X */
X
X#include <stdio.h>
X#include <string.h>
X
X
Xint		chars[256];
X
Xint	win[] = {
X	0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,
X	0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,
X	0xce,0xcf,0xd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	{  "win2koi",	win, koi },
X	{  "win2dos",	win, dos },
X	{  "koi2win",	koi, win },
X	{  "koi2dos",	koi, dos },
X	{  "dos2win",	dos, win },
X	{  "dos2koi",	dos, koi },
X};
X
X#define	SIZE	sizeof(koi)/sizeof(i)
X
XFILE	*input, *output;
X
Xvoid
Xerr_quit(const char *msg)
X{
X	fprintf(stderr, "%s\n", msg);
X	exit(1);
X}
X
XFILE*
XOpen(const char *name, const char *mode)
X{
X	FILE	*fp;
X
X	if( (fp = fopen(name, mode)) == NULL)
X						err_quit("do not open file");
X return(fp);
X}
X
Xvoid
Xrecode(int func)
X{
X	int		i;
X
X	for(i=0; i < 256; i++)
X					chars[i] = i;
X
X	for (i=0; i < SIZE; i++)
X					chars[ code[func].src[i] ] = code[func].dst[i]; 
X
X	while( (i = fgetc(input)) != EOF) 
X					fputc(chars[i], output);
X
X exit(0);
X}
X
Xint
Xmain(int argc,char* argv[])
X{
X	int		i;
X
X	if(argc > 3) 
X		err_quit("man win2koi");
X
X	input  = stdin ;
X	output = stdout;
X
X	if(argc == 3)
X		if(argv[1][0] != '-')
X			input = Open(argv[1], "r");
X
X	if(argc > 1)
X		if(argv[ argc-1 ][0] != '-')
X			output = Open(argv[ argc-1 ], "a");
X
X	for(i=0; i < sizeof(code)/sizeof(struct args); i++)
X		if( strstr(argv[0], code[i].call_name) != NULL)
X													recode(i);
X
X	fprintf(stderr, "%s: ", argv[0]);
X
X	err_quit("unknown function");
X}
X//
X//#EOF
END-of-./src/win2koi.c
echo x - ./src/Makefile
sed 's/^X//' >./src/Makefile << 'END-of-./src/Makefile'
X# $FreeBSD$
X
X.PATH: ${PKGDIR}/src
X
XPROG=		win2koi
X
XCFLAGS+=	-I${PKGDIR}/src
X
XBINDIR=	${PREFIX}/bin
XMANDIR= ${PREFIX}/man/man
X
XLINKS=		${BINDIR}/win2koi ${BINDIR}/win2dos 
XLINKS+=		${BINDIR}/win2koi ${BINDIR}/dos2win 
XLINKS+=		${BINDIR}/win2koi ${BINDIR}/dos2koi 
XLINKS+=		${BINDIR}/win2koi ${BINDIR}/koi2win
XLINKS+=		${BINDIR}/win2koi ${BINDIR}/koi2dos
X
XMLINKS=		win2koi.1 win2dos.1
XMLINKS+=	win2koi.1 dos2win.1
XMLINKS+=	win2koi.1 dos2koi.1
XMLINKS+=	win2koi.1 koi2win.1
XMLINKS+=	win2koi.1 koi2dos.1
X
X.include <bsd.prog.mk>
END-of-./src/Makefile
echo x - ./src/win2koi.1
sed 's/^X//' >./src/win2koi.1 << 'END-of-./src/win2koi.1'
X.\" Copyright (c) 2004	Andrew Wingborn	beastie at fromru.com
X.\"
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.\" 3. All advertising materials mentioning features or use of this software
X.\"    must display the following acknowledgement:
X.\"	This product includes software developed by the University of
X.\"	California, Berkeley and its contributors.
X.\" 4. Neither the name of the University nor the names of its contributors
X.\"    may be used to endorse or promote products derived from this software
X.\"    without specific prior written permission.
X.\"
X.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.Dd Feb 22, 2004
X.Dt WIN2KOI 1
X.\" .Os BSD 4.4
X.Sh NAME
X.Nm win2koi
X.Nd endodings converter to koi8-r, cp866, windows-1251 
X.Sh SYNOPSIS
X.Nm
X.Op Ar filename | -
X.Op Ar ...
X.Sh DESCRIPTION
XThe
X.Nm
Xutility recode text from-to next encodings:
X.Cm koi8 , 
X.Cm cp866 , 
X.Cm cp1251.
X.Pp
XBy default, read from stdin and write to stdout.
X.Pp
XStart program with need you rules to recode:
X.Cm win2koi, 
X.Cm win2dos, 
X.Cm koi2win, 
X.Cm koi2dos, 
X.Cm dos2koi, 
X.Cm dos2win.
X.Pp
XIf you set ones name of file, him will be used how
Xoutput-stream.
X.Sh EXAMPLES
XConvert windows-1251 to koi8-r from stdin to text.koi:
X.Pp
X.Dl "win2koi text.koi < windows1251.html"
X.Pp
XConvert cp866 to windows-1251 from text.dos to text.win:
X.Pp
X.Dl "dos2win text.dos text.win"
X.Pp
XConvert koi8-r to windows-1251 from text.koi to stdout:
X.Pp
X.Dl "koi2win text.koi -"
X.Pp
X.Sh AUTHORS
X.An Andrew A. Wingborn	<beastie at fromru.com>
END-of-./src/win2koi.1
echo x - ./Makefile
sed 's/^X//' >./Makefile << 'END-of-./Makefile'
X# New ports collection makefile for:	win2koi
X# Date created:			22 Feb 2004
X# Whom:					Andrew Wingborn <beastie at fromru.com>
X#
X# $FreeBSD$
X#
X
XPORTNAME=		win2koi
XPORTVERSION=	0.9
XCATEGORIES=		russian
XMASTER_SITES=	# none
XDISTFILES=		# none
X
XMAINTAINER=		beastie at fromru.com
XCOMMENT=		Charset recoder
X
XMAKEFILE=		${PKGDIR}/src/Makefile
XMAKE_ENV=		PKGDIR="${PKGDIR}"
X
XNO_WRKSUBDIR=	yes
X
XMAN1=			win2koi.1
XMANCOMPRESSED=	yes
X
X.include <bsd.port.mk>
END-of-./Makefile
echo x - ./pkg-descr
sed 's/^X//' >./pkg-descr << 'END-of-./pkg-descr'
Xsrc/win2koi.c:
X	Easy converter to windows-1251, koi8-r and cp866 encodings.
XIt is may be easy update to many anywere encodings (looks source :) 
X
X- Andrew Wingborn
Xbeastie at fromru.com
END-of-./pkg-descr
echo x - ./pkg-plist
sed 's/^X//' >./pkg-plist << 'END-of-./pkg-plist'
Xbin/win2koi
Xbin/win2dos
Xbin/koi2win
Xbin/koi2dos
Xbin/dos2koi
Xbin/dos2win
END-of-./pkg-plist
exit

>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the freebsd-ports-bugs mailing list