/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1985-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> *
* David Korn <dgk@research.att.com> *
* Phong Vo <kpv@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
/*
* Glenn Fowler
* AT&T Research
*
*/
#include <ast.h>
#include <cmdlib.h>
#include <proc.h>
static int
{
}
{
if (!(flags & CMD_SILENT))
{
}
}
#include <ast_api.h>
#include <ctype.h>
#include <proc.h>
#ifndef ARG_MAX
#endif
#ifndef EXIT_QUIT
#endif
{
}
/*
* open a cmdarg stream
* initialize the command for execution
* argv[-1] is reserved for procrun(PROC_ARGMOD)
*/
{
register int n;
register char** p;
register char* s;
char* sh;
char* exe;
int c;
int m;
int argc;
long x;
char** post = 0;
n = sizeof(char**);
if (*argv)
{
for (p = argv + 1; *p; p++)
{
{
*p = 0;
post = p + 1;
argpat = 0;
}
else
n += strlen(*p) + 1;
}
}
else
argc = 0;
for (p = environ; *p; p++)
n += sizeof(char**) + strlen(*p) + 1;
x = ARG_MAX;
size = x;
m = roundof(m, sizeof(char**));
if (size < m)
{
return 0;
}
if ((m = x / 10) > 2048)
m = 2048;
if (size > (x - m))
size = x - m;
n = size - n;
{
return 0;
}
c = n / sizeof(char**);
argmax = c;
{
}
{
}
{
{
n = EXIT_NOTFOUND;
(*error_info.exit)(n);
return 0;
}
exe = s;
}
s += strlen(s) + 1;
if (m)
{
s += m;
}
p = (char**)s;
*p++ = exe;
while (*p = *++argv)
p++;
if (m)
{
argmax = 1;
*p++ = 0;
while (s = *argv)
{
s++;
*p++ = s ? *argv : (char*)0;
argv++;
}
*p++ = 0;
}
return cmd;
}
/*
* flush outstanding command file args
*/
int
{
register char* s;
register char** p;
register int n;
return 0;
{
return -1;
}
else
{
char* a;
char* b;
char* e;
char* t;
char* u;
int c;
int m;
c = *s;
{
for (;;)
{
if (!(u = strchr(t, c)))
{
b += sfsprintf(b, e - b, "%s", t);
break;
}
if (!strncmp(s, u, m))
{
b += sfsprintf(b, e - b, "%-.*s%s", u - t, t, a);
t = u + m;
}
else if (b >= e)
break;
else
{
*b++ = *u++;
t = u;
}
}
if (b < e)
*b++ = 0;
}
if (b >= e)
{
return -1;
}
}
{
while (s = *++p)
{
return 0;
}
}
{
n = 0;
}
{
n = EXIT_NOTFOUND - 1;
(*error_info.exit)(n);
}
else if (n >= EXIT_NOTFOUND - 1)
{
(*error_info.exit)(n);
}
{
if (n)
error_info.errors++;
}
return n;
}
/*
* add file to the command arg list
*/
int
{
int i;
int r;
r = 0;
if (len > 0)
{
{
{
return -1;
}
{
if (r < i)
r = i;
return r;
}
}
r = i;
}
else
return r;
}
/*
* close a cmdarg stream
*/
int
{
int n;
{
n = -1;
}
else
{
}
return n;
}