/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 2003-2011 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> *
* David Korn <dgk@research.att.com> *
* Phong Vo <kpv@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
static const char usage[] =
"[-?\n@(#)$Id: codex (AT&T Research) 2009-04-15 $\n]"
" standard output according to the \amethod\a operand.]"
"[+?Codex method names consist of a leading identifier and 0 or more options"
" separated by \b-\b or \b+\b. Method names with identical \b-\b options"
" are equivalent. For example, \buu-base64-text\b specifies the"
" \buu\b method with the \bbase64\b and \btext\b options, and"
" \bpzip-crc+partition=test\b specifies the \bpzip\b method with"
" \bcrc\b enabled using the \btest\b partition.]"
"[+?Methods may be composed using the \b<\b and \b>\b operators"
" (with no intervening space.) \b<\b\amethod\a applies the \amethod\a"
" decoder and \b>\b\amethod\a applies the \amethod\a encoder.]"
"[+?Supported methods are listed below. Each method may have one or more"
" of these attributes:]{"
" [+decode?Only decoding is supported -- most likely because the"
" encoder has not been published. If omitted then both"
" encoding and are supported.]"
" [+ident?The decoder self-identifies from the input data and does"
" not require an explicit \amethod\a operand.]"
" [+vcodex?A self-identifying \bvcodex\b(3) method. The encoder and"
" decoder may be applied to either the input or output."
" Otherwise decode is restricted to the input and encode is"
" restricted to the output.]"
"}"
"[+?By default decoders are applied to the standard input from left to"
" right, and encoders are applied to the standard output from right"
" to left. \bvcodex\b methods may be applied to either the input"
" or output depending on the composition context.]"
"[+?All methods accept these options:]{"
" [+PASSPHRASE=\apassphrase\a?The method specific passphrase. If"
" not specified then \b--passphrase\b=\apassphrase\a is used."
" If \b--passphrase\b is not specified then the passphrase"
" for each method requiring one is prompted on and read from"
" exposing passphrases to other processes.]"
" \binitf\b/\bdonef\b calls.]"
" [+SIZE=\asize\a?The decoded size is \asize\a. Some decode methods"
" that lack end of data markers require this because they"
" [+SOURCE=\afile\a?The delta method source \afile\a.]"
" [+TRACE?Enable method trace.]"
" [+VERBOSE?Enable verbose method trace.]"
"}"
"[+?The \bCODEX_OPTIONS\b environment variable may contain space separated"
" options that control all \bcodex\b(3) methods. The environment options"
" are:]{"
" [+trace=\apattern\a?Enable method trace for all methods matching the"
" \bksh\b(1) \apattern\a.]"
" [+verbose=\apattern\a?Enable verbose method trace for all methods"
" matching the \bksh\b(1) \apattern\a. A verbose trace includes"
" \bcodex\b(3) discipline exception calls.]"
"}"
"[+?The supported methods are:]{\fmethods\f}"
"[d:decode?Apply the \amethod\a operand to the standard input only.]"
"[e:encode?Apply the \amethod\a operand to the standard output only.]"
"[f:passfile?Like \b--passphrase\b, except the passphrase is the first"
" line (sans newline) from \afile\a.]:[file]"
"[i:identify?Identify and write the standard input encoding name on the"
" standard output and exit.]"
"[n:null?Write to the \bcodenull\b(3) stream instead of the standard output.]"
"[p:passphrase?The default passphrase for all methods requiring passphrases."
" The method specific \bPASSPHRASE\b=\apassphrase\a overrides the"
" default. If \b--passphrase\b and \bPASSPHRASE\b=\apassphrase\a are"
" not specified then the passphrase for each method requiring one"
" prompt to avoid exposing passphrases to other processes.]:[passphrase]"
"[r:invert|reverse?Invert the method composition.]"
"[t:trace?Enable method trace. Equivalent to"
" \bexport CODEX_OPTIONS='trace=*'\b.]"
"[v:verbose?Enable verbose method trace. A verbose trace includes \bcodex\b(3)"
" discipline exception calls. Equivalent to"
" \bexport CODEX_OPTIONS='verbose=*'\b.]"
"\n"
"\n[ [ <,> ] method [ <,>,| method ... ] ]\n"
"\n"
"[+SEE ALSO?\bcodex\b(3), \bvcodex\b(3)]"
;
#include <ast.h>
#include <codex.h>
#include <option.h>
/*
* optget() info discipline function
*/
static int
{
register const char* p;
register int c;
switch (*s)
{
case 'm':
{
p = " (";
{
p = ",";
}
{
p = ",";
}
{
p = ",";
}
if (*p == ',')
p = meth->description;
while (c = *p++)
{
if (c == ']')
}
{
if (p)
}
}
break;
}
return 0;
}
static void
{
register unsigned char* u;
register unsigned char* e;
{
{
}
else
}
}
#if defined(main)
#if defined(__EXPORT__)
#define extern __EXPORT__
#endif
extern
#endif
int
{
void* buf;
char* s;
char ident[CODEX_IDENT];
flags = 0;
for (;;)
{
{
case 'd':
op = 0;
continue;
case 'e':
ip = 0;
continue;
case 'f':
{
}
continue;
case 'i':
else
return 0;
case 'n':
continue;
case 'p':
continue;
case 'r':
flags |= CODEX_INVERT;
continue;
case 't':
flags |= CODEX_TRACE;
continue;
case 'v':
flags |= CODEX_VERBOSE;
continue;
case ':':
continue;
case '?':
continue;
}
break;
}
return 1;
if (!ip)
if (!op)
#ifdef main
#endif
return error_info.errors != 0;
}