optjoin.c revision 3f54fd611f536639ec30dd53c48e5ec1897cc7d9
/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1985-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
/*
* Glenn Fowler
* AT&T Research
*
* multi-pass commmand line option parse assist
*
* int fun(char** argv, int last)
*
* each fun() argument parses as much of argv as
* possible starting at (opt_info.index,opt_info.offset) using
* optget()
*
* if last!=0 then fun is the last pass to view
* the current arg, otherwise fun sets opt_info.again=1
* and another pass will get a crack at it
*
* 0 fun() return causes immediate optjoin() 0 return
*
* optjoin() returns non-zero if more args remain
* to be parsed at opt_info.index
*/
#include <optlib.h>
typedef int (*Optpass_f)(char**, int);
int
{
int r;
int more;
int user;
int last_index;
int last_offset;
int err_index;
int err_offset;
r = -1;
while (r < 0)
{
{
{
if (!more)
{
r = 0;
break;
}
if (!user)
{
{
r = 1;
break;
}
}
else
err = 0;
}
{
if (opt_info.again > 0 && (!err || err_index < opt_info.index || err_index == opt_info.index && err_offset < opt_info.offset))
{
}
}
{
if (!err)
{
r = 1;
break;
}
}
}
}
return r;
}