merge.c revision 3f54fd611f536639ec30dd53c48e5ec1897cc7d9
/***********************************************************************
* *
* 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> *
* *
***********************************************************************/
#pragma prototyped
static const char merge_usage[] =
"[+PLUGIN?\findex\f]"
"[+DESCRIPTION?The \bmerge\b query merges the input files based on"
" the ordering specified by \b--key\b and \b--reverse\b options."
" The files must already be ordered; there is no verification."
" Multiple \b--key\b and \b--reverse\b options may be specified.]"
"[k:key?\afield\a is a sort key in normal order.]:[field]"
"[r:reverse?\afield\a is a sort key in reverse order.]:[field]"
"\n"
"\n[ file ... ]\n"
"\n"
;
#include <dsslib.h>
struct File_s
{
};
struct Key_s
{
int sense;
};
struct State_s
{
};
extern Dsslib_t dss_lib_merge;
static int
{
int k;
int r;
{
}
return -1;
return 1;
return 0;
}
static void
{
register int k;
{
{
return;
}
}
}
static int
{
int i;
int k;
int n;
int r;
char* path;
char* u;
char** v;
{
return -1;
}
r = -1;
k = 0;
keys = 0;
for (;;)
{
{
case 'k':
case 'r':
goto bad;
{
goto bad;
}
if (keys)
else
k++;
continue;
case '?':
else
return -1;
continue;
case ':':
else
return -1;
continue;
}
break;
}
goto bad;
for (v = argv; *v; v++);
n = v - argv;
if (files)
{
for (v = files; *v; v++);
n += v - files;
}
if (!n)
n = 1;
if (!(state = vmnewof(vm, 0, State_t, 1, (n - 1) * sizeof(File_t))) || !(operands = vmnewof(vm, 0, Cxoperand_t, n * k, 0)))
{
goto bad;
}
{
goto bad;
}
{
operands += k;
}
{
goto bad;
}
n = 0;
argv++;
else if (files)
{
files = 0;
argv++;
}
for (;;)
{
goto drop;
n++;
{
if (!files)
break;
files = 0;
break;
}
}
goto drop;
{
goto drop;
}
r = 0;
drop:
bad:
return r;
}
{
{
"merge",
"merge input files",
CXH,
0,
0,
0,
0,
0,
1
},
{0}
};
{
"merge",
"merge query"
"[-1lms5P?\n@(#)$Id: dss merge query (AT&T Research) 2003-02-14 $\n]"
CXH,
0,
0,
0,
0,
0,
0,
&queries[0]
};