Select Git revision
Process.pmod
-
Fredrik Hübinette (Hubbe) authored
Rev: lib/modules/Process.pmod:1.18
Fredrik Hübinette (Hubbe) authoredRev: lib/modules/Process.pmod:1.18
module_support.c 14.88 KiB
/*
|| This file is part of Pike. For copyright information see COPYRIGHT.
|| Pike is distributed under GPL, LGPL and MPL. See the file COPYING
|| for more information.
|| $Id: module_support.c,v 1.66 2005/12/04 18:57:55 nilsson Exp $
*/
#include "global.h"
#include "module_support.h"
#include "interpret.h"
#include "svalue.h"
#include "stralloc.h"
#include "pike_types.h"
#include "pike_error.h"
#include "mapping.h"
#include "object.h"
#include "operators.h"
#include "bignum.h"
#define sp Pike_sp
/* Checks that args_to_check arguments are OK.
* Returns 1 if everything worked ok, zero otherwise.
* If something went wrong, 'exepect_result' tells you what went wrong.
* Make sure to finish the argument list with a zero.
*/
static int va_check_args(struct svalue *s,
int args_to_check,
struct expect_result *res,
va_list arglist)
{
res->error_type = ERR_NONE;
res->expected = 0;
for (res->argno=0; res->argno < args_to_check; res->argno++)
{
if(!(res->expected & BIT_MANY))
{
res->expected = va_arg(arglist, unsigned int);
if(!res->expected)
{
res->error_type = ERR_TOO_MANY;
return 0;
}
}
if (!((1UL << s[res->argno].type) & res->expected) &&
!(res->expected & BIT_ZERO &&
s[res->argno].type == T_INT && s[res->argno].u.integer == 0))
{
res->got = DO_NOT_WARN((unsigned char)s[res->argno].type);
res->error_type = ERR_BAD_ARG;
return 0;
}
}
if(!(res->expected & BIT_MANY))
res->expected = va_arg(arglist, unsigned int);
if(!res->expected ||
(res->expected & BIT_VOID)) return 1;
res->error_type = ERR_TOO_FEW;
return 0;
}
/* Returns the number of the first bad argument,
* -X if there were too few arguments
* or 0 if all arguments were OK.
*/
PMOD_EXPORT int check_args(int args, ...)