/***********************************************************************
* *
* 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 *
* *
* Phong Vo <kpv@research.att.com> *
* *
***********************************************************************/
#include "vchdr.h"
#include <fnmatch.h>
/* Collection of functions to translate command line arguments,
** aliases, etc. to list of transforms and arguments suitable for
** data tranformation by vcsfio().
**
** The syntax is like this:
** Transformation Method1,Method2,...
** Method method.arg1.arg2....
** arg value
** arg name=value
** method alphanumeric string specifying a transform
** name alphanumeric string specifying an argument
** value any string, quotable with [], C-style chars
**
** Written by Kiem-Phong Vo.
*/
#ifndef PATH_MAX
#endif
struct _vcalias_s
};
static char *Dfltalias[] =
{
"tv = ama,table,mtf,rle.0,huffgroup",
"tss7 = ss7,table,mtf,rle.0,huffpart",
"tnls = ama.nls,rtable,mtf,rle.0,huffgroup",
"tnl = ama.nl,table,mtf,rle.0,huffgroup",
"tbdw = bdw,ama,table,mtf,rle.0,huffgroup",
"t = table,mtf,rle.0,huffgroup",
"rte = strip.nl.head=1.tail=1,rdb.pad.plain.whole,table,mtf,rle.0,huffgroup",
"rt = rtable,mtf,rle.0,huffgroup",
"qv = ama,transpose,rle,huffman",
"qnl = ama.nl,transpose,rle,huffman",
"q = transpose,rle,huffman",
"netflow = netflow,mtf,rle.0,huffgroup",
"flatrdb = rdb,bwt,mtf,rle.0,huffgroup",
"fixedrdb = rdb.full,table,mtf,rle.0,huffgroup",
"dna = sieve.reverse.map=ATGCatgc,huffgroup",
"delta = sieve.delta,bwt,mtf,rle.0,huffgroup",
"b = bwt,mtf,rle.0,huffgroup",
0
};
/* create aliases, text lines of the form 'name = value' */
/* create file name extension mappings, text lines of the form 'pattern : value' */
#if __STD_C
static void zipalias(char* s)
#else
char* s; /* spec of new aliases */
#endif
{
ssize_t a, v, w, n;
for(n = s ? strlen(s) : 0; n > 0; )
{ /* skip starting blanks */
while(n > 0 && (isblank(*s) || *s == '\n') )
{ s += 1; n -= 1; }
if(!isalnum(*s) ) /* invalid alias specification */
goto skip_line;
/* get the name */
for(a = 0; a < n; ++a)
if(!isalnum(s[a]))
break;
for(v = a; v < n; ++v)
if(!isblank(s[v]) )
break;
if(s[v] == '=')
else if(s[v] == ':')
else
goto skip_line;
/* get the value */
for(v += 1; v < n; ++v)
if(!isblank(s[v]) )
break;
for(w = v; w < n; ++w)
if(isblank(s[w]) )
break;
if(w == v)
goto skip_line;
break;
for(; n > 0; --n, ++s)
if(*s == '\n')
break;
}
}
/* initialize a list of aliases */
#if __STD_C
#else
void vcaddalias(dflt)
char** dflt; /* list of default aliases */
#endif
{
ssize_t z;
if(!Alias)
{
#if _PACKAGE_ast /* AST alias convention */
}
#endif
/* $HOME/.vcziprc */
sp[z] = '/';
}
}
}
/* other default aliases */
if(dflt)
}
/* map an alias. Arguments are passed onto the first method of the aliased spec */
#if __STD_C
#else
char* spec; /* name.arg1.arg2... */
char* meth; /* buffer for methods */
#endif
{
ssize_t n, a, r;
if(!Alias)
vcaddalias(NIL(char**));
return spec;
/* must be of the form xxx.yyy.zzz... only */
return spec;
/* find the extent of the alias name */
for(n = 0; name[n]; ++n)
break;
name[n] = 0;
/* see if that matches an alias */
break;
if(!alias)
return spec;
/* copy the spec of the first transform to meth[] */
return spec;
return spec;
/* copy additional arguments */
if(r > 0) /* copy the rest of the alias */
}
return meth;
}
/* match a file name */
#if __STD_C
#else
char* name; /* file name to match */
char* meth; /* buffer for methods */
#endif
{
if(!Alias)
vcaddalias(NIL(char**));
{
break;
return meth;
}
return NIL(char*);
}
/* walk an alias list */
#if __STD_C
#else
#endif
{
int rv;
if(!walkf)
return -1;
return rv;
return 0;
}
/* walk the list of aliases */
#if __STD_C
#else
#endif
{
if(!Alias)
vcaddalias(NIL(char**));
}
/* walk the list of fnames */
#if __STD_C
#else
#endif
{
if(!Alias)
vcaddalias(NIL(char**));
}