iconv.c revision 3f54fd611f536639ec30dd53c48e5ec1897cc7d9
/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1989-2012 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
/*
* Glenn Fowler
* AT&T Research
*/
static const char usage[] =
"[-?\n@(#)$Id: iconv (AT&T Research) 2011-01-11 $\n]"
"[+NAME?iconv - codeset conversion]"
"[+DESCRIPTION?\biconv\b converts the encoding of characters in the \afile\a"
" operands from one codeset to another and writes the results to"
" the standard output. If \afile\a is \b-\b or omitted then the"
" standard input is read.]"
"[+?Character encodings in either codeset may include single-byte values"
" (for example, for the ISO 8859-1:1987 standard characters) or"
" multi-byte values (for example, for certain characters in the"
" ISO 6937:1983 standard). Invalid characters in the input stream"
" (either those that are not valid members of the input codeset or"
" those that have no corresponding value in the output codeset) are"
" output as the underscore character (\b_\b) in the output codeset.]"
"[+?The \bnative\b codeset is determined by the \bLANG\b, \bLC_ALL\b and"
" \bLC_CTYPE\b environment variables. The supported codesets"
" are matched by these left-anchored case-insensitive \bksh\b(1)"
" patterns:]{\fcodesets\f}"
"[+?Conversion between certain codesets may not be supported. Also, since the"
" standard(s) provide no support for listing the known codesets, the"
" above list may be incomplete.]"
"[a:all?List all conversion errors. By default (and \b--omit\b is not "
"specified) \biconv\b stops after the first error.]"
"[c:omit?Omit invalid input characters from the output. Invalid input "
"characters still affect the exit status.]"
"[e:errors?Do not ignore conversion errors.]"
"[f:from?The input codeset is set to \acodeset\a.]:[codeset:=native]"
"[i:ignore?Ignore conversion errors.]"
"[l:list?List all known codesets on the standard output.]"
"[s:silent?Suppress invalid character diagnostics. Invalid input "
"characters still affect the exit status. If \b--all\b is also specified "
"then non-zero invalid character counts are listed.]"
"[t:to?The output codeset is set to \acodeset\a.]:[codeset:=native]"
"\n"
"\n[ pid ... ]\n"
"\n"
"[+SEE ALSO?\bdd\b(1), \biconv\b(3), \bsetlocale\b(3)]"
;
#include <ast.h>
#include <error.h>
#include <iconv.h>
/*
* optget() info discipline function
*/
static int
{
register iconv_list_t* ic;
register const char* p;
register int c;
if (streq(s, "codesets"))
{
if (*p == '(')
p++;
while (c = *p++)
{
if (c == ')' && !*p)
break;
if (c == '?' || c == ']')
}
while (c = *p++)
{
if (c == ']')
}
}
return 0;
}
static int
listall(void)
{
register iconv_list_t* ic;
register const char* p;
{
}
return 0;
}
int
{
char* file;
char* from;
char* to;
int all;
int fail;
int ignore;
int list;
/*
* set up the disciplines
*/
/*
* grab the options
*/
for (;;)
{
{
case 'a':
all = 1;
continue;
case 'c':
continue;
case 'e':
ignore = 0;
continue;
case 'f':
continue;
case 'i':
ignore = 1;
continue;
case 'l':
list = 1;
continue;
case 's':
continue;
case 't':
continue;
case '?':
break;
case ':':
break;
}
break;
}
if (error_info.errors)
if (list)
return listall();
{
}
fail = 0;
argv++;
do
{
{
}
{
continue;
}
{
fail = 1;
{
}
}
}