00001
00002
00003
00004
00005
00006
00007
00008 #include <stdio.h>
00009
00010 #include "../../basext.h"
00011
00012 besVERSION_NEGOTIATE
00013
00014 printf("The function bootmodu was started and the requested version is %d\n",Version);
00015 printf("The variation is: %s\n",pszVariation);
00016 printf("We are returning accepted version %d\n",(int)INTERFACE_VERSION);
00017 return (int)INTERFACE_VERSION;
00018
00019 besEND
00020
00021 besSUB_START
00022 long *pL;
00023
00024 besMODULEPOINTER = besALLOC(sizeof(long));
00025 if( besMODULEPOINTER == NULL )return 0;
00026 pL = (long *)besMODULEPOINTER;
00027 *pL = 0L;
00028
00029 printf("The function bootmodu was started.\n");
00030
00031 besEND
00032
00033 besSUB_FINISH
00034 printf("The function finimodu was started.\n");
00035 besEND
00036
00037 besFUNCTION(pprint)
00038 int i;
00039 int slen;
00040 char *s;
00041 VARIABLE Argument;
00042
00043 printf("The number of arguments is: %ld\n",besARGNR);
00044
00045 for( i=1 ; i <= besARGNR ; i++ ){
00046 Argument = besARGUMENT(i);
00047 besDEREFERENCE(Argument);
00048 redo:
00049 switch( slen=TYPE(Argument) ){
00050 case VTYPE_LONG:
00051 printf("This is a long: %ld\n",LONGVALUE(Argument));
00052 break;
00053 case VTYPE_DOUBLE:
00054 printf("This is a double: %lf\n",DOUBLEVALUE(Argument));
00055 break;
00056 case VTYPE_STRING:
00057 printf("This is a string ");
00058 s = STRINGVALUE(Argument);
00059 slen = STRLEN(Argument);
00060 while( slen -- )
00061 putc(((int)*s++),stdout);
00062 printf("\n");
00063 break;
00064 case VTYPE_ARRAY:
00065 printf("ARRAY@#%08X\n",LONGVALUE(Argument));
00066 printf("ARRAY LOW INDEX: %ld\n",ARRAYLOW(Argument));
00067 printf("ARRAY HIGH INDEX: %ld\n",ARRAYHIGH(Argument));
00068 printf("The first element of the array is:\n");
00069 Argument = ARRAYVALUE(Argument,ARRAYLOW(Argument));
00070 goto redo;
00071 break;
00072 }
00073 }
00074 besEND
00075
00076 besFUNCTION(set1)
00077 VARIABLE Argument;
00078 LEFTVALUE Lval;
00079 int i;
00080 unsigned long __refcount_;
00081
00082 for( i=1 ; i <= besARGNR ; i++ ){
00083 Argument = besARGUMENT(i);
00084
00085 besLEFTVALUE(Argument,Lval);
00086 if( Lval ){
00087 besRELEASE(*Lval);
00088 *Lval = besNEWLONG;
00089 if( *Lval )
00090 LONGVALUE(*Lval) = 1;
00091 }
00092 }
00093
00094 besEND
00095
00096 besFUNCTION(arbdata)
00097 VARIABLE Argument;
00098 LEFTVALUE Lval;
00099 static char buffer[1024];
00100 char *p;
00101 unsigned long __refcount_;
00102
00103 p = buffer;
00104 sprintf(buffer,"%s","hohohoho\n");
00105 Argument = besARGUMENT(1);
00106
00107 besLEFTVALUE(Argument,Lval);
00108 if( Lval ){
00109 besRELEASE(*Lval);
00110 *Lval = besNEWSTRING(sizeof(char*));
00111 memcpy(STRINGVALUE(*Lval),&p,sizeof(p));
00112 }
00113
00114 besEND
00115
00116 besFUNCTION(pzchar)
00117 int i;
00118 VARIABLE Argument;
00119 char *p;
00120
00121 for( i=1 ; i <= besARGNR ; i++ ){
00122 Argument = besARGUMENT(i);
00123 besDEREFERENCE(Argument);
00124 memcpy(&p,STRINGVALUE(Argument),sizeof(p));
00125 printf("%s\n",p);
00126 }
00127 besEND
00128
00129
00130 besFUNCTION(trial)
00131 long *pL;
00132
00133 printf("Function trial was started...\n");
00134 pL = (long *)besMODULEPOINTER;
00135 (*pL)++;
00136 besRETURNVALUE = besNEWMORTALLONG;
00137 LONGVALUE(besRETURNVALUE) = *pL;
00138
00139 printf("Module directory is %s\n",besCONFIG("module"));
00140 printf("dll extension is %s\n",besCONFIG("dll"));
00141 printf("include directory is %s\n",besCONFIG("include"));
00142
00143 besEND
00144
00145 besFUNCTION(myicall)
00146 VARIABLE Argument;
00147 VARIABLE pArgument;
00148 VARIABLE FunctionResult;
00149 unsigned long ulEntryPoint;
00150 unsigned long i;
00151
00152 Argument = besARGUMENT(1);
00153 besDEREFERENCE(Argument);
00154 ulEntryPoint = LONGVALUE(Argument);
00155
00156 pArgument = besNEWARRAY(0,besARGNR-2);
00157 for( i=2 ; i <= (unsigned)besARGNR ; i++ ){
00158 pArgument->Value.aValue[i-2] = besARGUMENT(i);
00159 }
00160
00161 besHOOK_CALLSCRIBAFUNCTION(ulEntryPoint,
00162 pArgument->Value.aValue,
00163 besARGNR-1,
00164 &FunctionResult);
00165
00166 for( i=2 ; i <= (unsigned)besARGNR ; i++ ){
00167 pArgument->Value.aValue[i-2] = NULL;
00168 }
00169 besRELEASE(pArgument);
00170 besRELEASE(FunctionResult);
00171 besEND
00172
00173 besSUB_AUTO
00174 printf("autoloading %s\n",pszFunction);
00175 *ppFunction = (void *)trial;
00176 besEND
00177
00178 besCOMMAND(iff)
00179 NODE nItem;
00180 VARIABLE Op1;
00181 long ConditionValue;
00182
00183
00184 USE_CALLER_MORTALS;
00185
00186
00187 nItem = besPARAMETERLIST;
00188 if( ! nItem ){
00189 RESULT = NULL;
00190 RETURN;
00191 }
00192 Op1 = besEVALUATEEXPRESSION(CAR(nItem));
00193 ASSERTOKE;
00194
00195 if( Op1 == NULL )ConditionValue = 0;
00196 else{
00197 Op1 = besCONVERT2LONG(Op1);
00198 ConditionValue = LONGVALUE(Op1);
00199 }
00200
00201 if( ! ConditionValue )
00202 nItem = CDR(nItem);
00203
00204 if( ! nItem ){
00205 RESULT = NULL;
00206 RETURN;
00207 }
00208 nItem = CDR(nItem);
00209
00210 RESULT = besEVALUATEEXPRESSION(CAR(nItem));
00211 ASSERTOKE;
00212
00213 RETURN;
00214 besEND_COMMAND