allow access to argc and argv in the c-interface.

This commit is contained in:
Vitor Santos Costa 2011-10-13 16:46:39 +01:00
parent 98cc029b66
commit 72afe868ec
3 changed files with 18 additions and 2 deletions

View File

@ -543,6 +543,7 @@ X_API void *STD_PROTO(YAP_ExternalDataInStackFromTerm,(Term));
X_API int STD_PROTO(YAP_NewOpaqueType,(void *));
X_API Term STD_PROTO(YAP_NewOpaqueObject,(int, size_t));
X_API void *STD_PROTO(YAP_OpaqueObjectFromTerm,(Term));
X_API int STD_PROTO(YAP_Argv,(char *** argvp));
static int
dogc( USES_REGS1 )
@ -1942,6 +1943,7 @@ YAP_ReadBuffer(char *s, Term *tp)
Term t;
BACKUP_H();
LOCAL_ErrorMessage=NULL;
while ((t = Yap_StringToTerm(s,tp)) == 0L) {
if (LOCAL_ErrorMessage) {
if (!strcmp(LOCAL_ErrorMessage,"Stack Overflow")) {
@ -3715,7 +3717,8 @@ int YAP_MaxOpPriority(Atom at, Term module)
return ret;
}
int YAP_OpInfo(Atom at, Term module, int opkind, int *yap_type, int *prio)
int
YAP_OpInfo(Atom at, Term module, int opkind, int *yap_type, int *prio)
{
AtomEntry *ae = RepAtom(at);
OpEntry *info;
@ -3779,4 +3782,11 @@ int YAP_OpInfo(Atom at, Term module, int opkind, int *yap_type, int *prio)
}
int
YAP_Argv(char ***argvp)
{
if (argvp) {
*argvp = GLOBAL_argv;
}
return GLOBAL_argc;
}

View File

@ -16836,6 +16836,10 @@ function is called with two arguments: the exit code of the process
the closure argument @var{closure}.
@c See also @code{at_halt/1}.
@item @code{int} YAP_Argv(@code{char ***argvp})
@findex YAP_Argv (C-Interface function)
Return the number of arguments to YAP and instantiate argvp to point to the list of such arguments.
@end table

View File

@ -566,6 +566,8 @@ extern X_API YAP_Term PROTO(YAP_NewOpaqueObject,(YAP_opaque_tag_t, size_t));
extern X_API void *PROTO(YAP_OpaqueObjectFromTerm,(YAP_Term));
extern X_API int *PROTO(YAP_Argv,(char ***));
#define YAP_InitCPred(N,A,F) YAP_UserCPredicate(N,F,A)
__END_DECLS