00001 /* File: interface.h - the header file for the XSB to Perl interface 00002 ** Author(s): Jin Yu 00003 ** Contact: xsb-contact@cs.sunysb.edu 00004 ** 00005 ** Copyright (C) The Research Foundation of SUNY, 1998 00006 ** 00007 ** XSB is free software; you can redistribute it and/or modify it under the 00008 ** terms of the GNU Library General Public License as published by the Free 00009 ** Software Foundation; either version 2 of the License, or (at your option) 00010 ** any later version. 00011 ** 00012 ** XSB is distributed in the hope that it will be useful, but WITHOUT ANY 00013 ** WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00014 ** FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for 00015 ** more details. 00016 ** 00017 ** You should have received a copy of the GNU Library General Public License 00018 ** along with XSB; if not, write to the Free Software Foundation, 00019 ** Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00020 ** 00021 ** $Id: interface.h,v 1.3 1998/11/18 08:00:16 kifer Exp $ 00022 ** 00023 */ 00024 00025 00026 #include <EXTERN.h> /*perlembed c function's header file*/ 00027 #include <perl.h> 00028 #include "cinterf.h" /*for c and XSB interface functions*/ 00029 00030 /*---------------------------------------------------------------------------- 00031 definitions for the XSB perl interface 00032 ----------------------------------------------------------------------------*/ 00033 00034 #define MATCH -1 00035 #define PREMATCH -2 00036 #define POSTMATCH -3 00037 #define LAST_PAREN_MATCH -4 00038 00039 /*--------------------------------------------------------------------------- 00040 the following can be modified 00041 ---------------------------------------------------------------------------*/ 00042 00043 #define MAX_SUB_MATCH 20 /*how many perl variables $1, $2.. will be loaded */ 00044 #define MAX_TOTAL_MATCH (MAX_SUB_MATCH+4) 00045 /*the total sub match number + pre,post,match... */ 00046 #define FIXEDSUBMATCHSPEC "($&,$`,$',$+" 00047 /* the fixed part of sub match specs*/ 00048 00049 #define SUCCESS 1 /* return code when success */ 00050 #define FAILURE 0 /* return code when failed */ 00051 #define LOADED 1 /* the flag when Perl interpretor is loaded */ 00052 #define UNLOADED 0 /* the flag when Perl interpretor is not loaded */ 00053 00054 #ifndef TRUE 00055 #define TRUE 1 00056 #endif 00057 #ifndef FALSE 00058 #define FALSE 0 00059 #endif 00060 00061 /*---------------------------------------------------------------------------- 00062 *global variables 00063 *--------------------------------------------------------------------------*/ 00064 00065 char* matchResults[MAX_TOTAL_MATCH]; /*$1-$20,$`,$'...*/ 00066 char** bulkMatchList; /*the pointer to the bulk match results*/ 00067 int preBulkMatchNumber;/*the number of the old bulk match results*/ 00068 char* matchPattern; /*match pattern string*/ 00069 int perlObjectStatus; /*if UNLOADED, must load perl interpreter*/ 00070 char* substituteString; /*the substituted string result*/ 00071 char* subMatchSpec; /*the string of submatch arguments ($&,$`...$digit)*/ 00072 00073 /*---------------------------------------------------------------------------- 00074 function declarations 00075 ----------------------------------------------------------------------------*/ 00076 00077 static PerlInterpreter *my_perl; 00078 extern int matchAgain( void ); /*perl interface for next match*/ 00079 extern int loadPerl(void); /*load perl interpreter*/ 00080 extern int unloadPerl( void ); /*unload perl interpreter*/ 00081 extern SV* my_perl_eval_sv(SV *sv, I32 croak_on_error); /*call perl compiler*/ 00082 extern int match(SV *string, char *pattern); /*perl match function*/ 00083 extern int substitute(SV **string, char *pattern);/*perl substitute function*/ 00084 extern int all_matches(SV *string, char *pattern, AV **match_list); 00085 /*perl global match function: all matches*/ 00086 extern void buildSubMatchSpec(void); 00087 /*build the submatch arguments list string*/ 00088 00089