Added an icon with c:iconx as default tools.
[AROS-Contrib.git] / regina / execiser.c
blobc3301e2710152e6dfdecb1b5ed83fd1ae65fcbbc
1 #include <stdio.h>
2 #include <string.h>
3 #include <stdlib.h>
5 #define INCL_RXSHV
6 #define INCL_RXFUNC
7 #define INCL_RXSYSEXIT
8 #define INCL_RXSUBCOM
9 #define INCL_RXQUEUE
11 #include "rexxsaa.h"
13 #define STARTUPMSG " +++ Interactive trace. \"Trace Off\" to end debug. ENTER to continue."
15 #ifdef _MSC_VER
16 /* This picky compiler claims about unused formal parameters.
17 * This is correct but hides (for human eyes) other errors since they
18 * are many and we can't reduce them all.
19 * Error 4100 is "unused formal parameter".
21 # pragma warning(disable:4100)
22 #endif
24 static void message( char *msg )
26 printf( " %s", msg ) ;
27 fflush(stdout) ;
31 static void mycomplain( char *msg )
33 fprintf( stderr, "Complaint: %s\n", msg ) ;
36 static void iverify( char *msg, int first, int second )
38 if (first != second)
39 printf( "\nInt verify: %s: %d ^= %d\n", msg, first, second ) ;
42 static void sverify( char *msg, PRXSTRING first, char *second )
44 if (!second)
46 if (first->strptr)
47 printf( "\nSecond is null, first: %d<%s>\n", (int) first->strlength,
48 first->strptr ) ;
50 else if (strlen(second) != first->strlength)
52 printf( "\nString length: %s: %d ^=%d\n", msg,
53 (int) first->strlength, (int) strlen(second)) ;
54 printf( " first=%4d<%s>\n", (int) first->strlength, first->strptr ) ;
55 printf( " secnd=%4d<%s>\n", (int) strlen(second), second ) ;
57 else
58 if (memcmp(second, first->strptr, first->strlength))
59 printf( "\nString contents: %s: <%s> ^== <%s>\n", msg,
60 first->strptr, second ) ;
66 LONG APIENTRY instore_exit( LONG ExNum, LONG Subfun, PEXIT PBlock )
68 RXSIOSAY_PARM *psiosay;
69 iverify( "Exitfunction", ExNum, RXSIO ) ;
70 iverify( "Subfunction", Subfun, RXSIOSAY ) ;
71 psiosay = (RXSIOSAY_PARM *)PBlock;
72 sverify( "Exit string", &(psiosay->rxsio_string), "foobar" ) ;
74 return RXEXIT_HANDLED ;
77 static void instore( void )
79 RXSTRING Instore[2] ;
80 RXSYSEXIT Exits[2] ;
81 int rc ;
83 message( "instore" ) ;
85 RexxRegisterExitExe( "Foo", (PFN)instore_exit, NULL ) ;
87 Exits[0].sysexit_name = "Foo" ;
88 Exits[0].sysexit_code = RXSIO ;
89 Exits[1].sysexit_code = RXENDLST ;
91 Instore[0].strptr = "say 'foobar'" ;
92 Instore[0].strlength = strlen( Instore[0].strptr ) ;
93 Instore[1].strptr = NULL ;
94 rc = RexxStart( 0, NULL, "Testing", Instore, "Foo", RXCOMMAND,
95 Exits, NULL, NULL ) ;
97 rc = RexxStart( 0, NULL, "Testing", Instore, "", RXCOMMAND,
98 Exits, NULL, NULL ) ;
100 Instore[0].strptr = NULL ;
101 rc = RexxStart( 0, NULL, "Testing", Instore, "", RXCOMMAND,
102 Exits, NULL, NULL ) ;
104 rc = RexxStart( 0, NULL, "Testing", Instore, "", RXCOMMAND,
105 Exits, NULL, NULL ) ;
107 RexxFreeMemory( Instore[1].strptr ) ;
108 RexxDeregisterExit( "Foo", NULL ) ;
112 LONG APIENTRY trace_exit( LONG ExNum, LONG Subfun, PEXIT PBlock )
114 RXSIOTRC_PARM *psiotrc;
115 iverify( "Exitfunction", ExNum, RXSIO ) ;
116 if (Subfun==RXSIOTRC)
118 psiotrc = (RXSIOTRC_PARM *)PBlock;
119 sverify( "Exit string", &(psiotrc->rxsio_string),
120 " 1 *-* trace off" ) ;
122 else
123 mycomplain( "Unexpected subfunction\n" ) ;
125 return RXEXIT_HANDLED ;
128 static void trace( void )
130 RXSTRING Instore[2] ;
131 RXSYSEXIT Exits[2] ;
132 int rc ;
134 message( "trace" ) ;
136 RexxRegisterExitExe( "Foo", (PFN)trace_exit, NULL ) ;
138 Exits[0].sysexit_name = "Foo" ;
139 Exits[0].sysexit_code = RXSIO ;
140 Exits[1].sysexit_code = RXENDLST ;
142 Instore[0].strptr = "trace all;trace off" ;
143 Instore[0].strlength = strlen( Instore[0].strptr ) ;
144 Instore[1].strptr = NULL ;
146 rc = RexxStart( 0, NULL, "Testing", Instore, "Foo", RXCOMMAND,
147 Exits, NULL, NULL ) ;
149 RexxDeregisterExit( "Foo", NULL ) ;
153 LONG APIENTRY intertrc_exit( LONG ExNum, LONG Subfun, PEXIT PBlock )
155 static int cnt=0 ;
156 static char *data[] = {
158 " 2 *-* say 'hallo'",
159 " >L> \"hallo\"",
160 "hallo",
161 STARTUPMSG,
162 "=",
163 " *-* say 'hallo'",
164 " >L> \"hallo\"",
165 "hallo",
167 " *-* trace off",
170 RXSIOTRC_PARM *psiotrc;
171 RXSIOSAY_PARM *psiosay;
172 RXSIODTR_PARM *psiodtr;
174 iverify( "Exitfunction", ExNum, RXSIO ) ;
175 switch (++cnt)
177 case 1:
178 case 2:
179 case 4:
180 case 6:
181 case 7:
182 case 10:
183 case 11:
184 iverify( "Subfunction", Subfun, RXSIOTRC ) ;
185 psiotrc = (RXSIOTRC_PARM *)PBlock;
186 sverify( "Trace output", &(psiotrc->rxsio_string),data[cnt]);
187 break ;
189 case 3:
190 case 8:
191 iverify( "Subfunction", Subfun, RXSIOSAY ) ;
192 psiosay = (RXSIOSAY_PARM *)PBlock;
193 sverify( "Say output", &(psiosay->rxsio_string), data[cnt]);
194 break ;
196 case 5:
197 case 9:
198 iverify( "Subfunction", Subfun, RXSIODTR ) ;
199 psiodtr = (RXSIODTR_PARM *)PBlock;
200 psiodtr->rxsiodtr_retc.strptr = data[cnt] ;
201 psiodtr->rxsiodtr_retc.strlength = strlen(data[cnt]) ;
202 break ;
204 default:
205 fprintf( stderr, "Out of order msg subfunc=%ld\n", Subfun) ;
206 return RXEXIT_NOT_HANDLED ;
208 return RXEXIT_HANDLED ;
211 static void intertrc( void )
213 RXSTRING Instore[2] ;
214 RXSYSEXIT Exits[2] ;
215 int rc ;
217 message( "intertrc" ) ;
219 RexxRegisterExitExe( "Foo", (PFN)intertrc_exit, NULL ) ;
221 Exits[0].sysexit_name = "Foo" ;
222 Exits[0].sysexit_code = RXSIO ;
223 Exits[1].sysexit_code = RXENDLST ;
225 Instore[0].strptr = "trace ?int\nsay 'hallo'; trace off" ;
226 Instore[0].strlength = strlen( Instore[0].strptr ) ;
227 Instore[1].strptr = NULL ;
229 rc = RexxStart( 0, NULL, "Testing", Instore, "Foo", RXCOMMAND,
230 Exits, NULL, NULL ) ;
232 RexxDeregisterExit( "Foo", NULL ) ;
239 LONG APIENTRY pull_exit( LONG ExNum, LONG Subfun, PEXIT PBlock )
241 static int cnt=0 ;
242 static char *data[] = {
244 "alpha",
245 "ALPHA",
246 "FOO",
247 "beta",
248 "beta",
250 RXSIOSAY_PARM *psiosay;
251 RXSIOTRD_PARM *psiotrd;
253 iverify( "Exitfunction", ExNum, RXSIO ) ;
254 switch (++cnt)
256 case 2:
257 case 3:
258 case 5:
259 iverify( "Subfunction", Subfun, RXSIOSAY ) ;
260 psiosay = (RXSIOSAY_PARM *)PBlock;
261 sverify( "Trace output", &(psiosay->rxsio_string),data[cnt]);
262 break ;
264 case 1:
265 case 4:
266 iverify( "Subfunction", Subfun, RXSIOTRD ) ;
267 psiotrd = (RXSIOTRD_PARM *)PBlock;
268 strcpy(psiotrd->rxsiotrd_retc.strptr,data[cnt]) ;
269 psiotrd->rxsiotrd_retc.strlength = strlen(data[cnt]) ;
270 break ;
272 default:
273 fprintf( stderr, "Out of order msg subfunc=%ld\n", Subfun) ;
274 return RXEXIT_NOT_HANDLED ;
276 return RXEXIT_HANDLED ;
279 static void pull( void )
281 RXSTRING Instore[2] ;
282 RXSYSEXIT Exits[2] ;
283 int rc ;
285 message( "pull" ) ;
287 RexxRegisterExitExe( "Foo", (PFN)pull_exit, NULL ) ;
289 Exits[0].sysexit_name = "Foo" ;
290 Exits[0].sysexit_code = RXSIO ;
291 Exits[1].sysexit_code = RXENDLST ;
293 Instore[0].strptr =
294 "pull bar;say bar;push 'foo';pull bar;say bar;parse pull bar;say bar" ;
295 Instore[0].strlength = strlen( Instore[0].strptr ) ;
296 Instore[1].strptr = NULL ;
298 rc = RexxStart( 0, NULL, "Testing", Instore, "Foo", RXCOMMAND,
299 Exits, NULL, NULL ) ;
301 RexxDeregisterExit( "Foo", NULL ) ;
305 LONG APIENTRY env_exit( LONG ExNum, LONG Subfun, PEXIT PBlock )
307 static int cnt=0 ;
308 static char data[10];
309 RXENVGET_PARM *penvget;
310 RXENVSET_PARM *penvset;
312 iverify( "Exitfunction", ExNum, RXENV ) ;
313 switch (++cnt)
315 case 1:
316 iverify( "Subfunction", Subfun, RXENVGET ) ;
317 penvget = (RXENVGET_PARM *)PBlock;
318 sverify( "Envget name", &(penvget->rxenv_name),"FRED");
319 strcpy(penvget->rxenv_value.strptr,"initial") ;
320 penvget->rxenv_value.strlength = strlen(data) ;
321 break ;
323 case 2:
324 iverify( "Subfunction", Subfun, RXENVSET ) ;
325 penvset = (RXENVSET_PARM *)PBlock;
326 sverify( "Envset name", &(penvset->rxenv_name),"FRED");
327 sverify( "Envset value", &(penvset->rxenv_value),"junk");
328 strcpy( data, "mess" );
329 break ;
331 case 3:
332 iverify( "Subfunction", Subfun, RXENVGET ) ;
333 penvget = (RXENVGET_PARM *)PBlock;
334 sverify( "Envget name", &(penvget->rxenv_name),"FRED");
335 strcpy(penvget->rxenv_value.strptr,data) ;
336 penvget->rxenv_value.strlength = strlen(data) ;
337 break ;
339 default:
340 fprintf( stderr, "Out of order msg subfunc=%ld\n", Subfun) ;
341 return RXEXIT_NOT_HANDLED ;
343 return RXEXIT_HANDLED ;
346 static void env( void )
348 RXSTRING Instore[2] ;
349 RXSYSEXIT Exits[2] ;
350 int rc ;
352 message( "env") ;
354 RexxRegisterExitExe( "Foo", (PFN)env_exit, NULL ) ;
356 Exits[0].sysexit_name = "Foo" ;
357 Exits[0].sysexit_code = RXENV ;
358 Exits[1].sysexit_code = RXENDLST ;
360 Instore[0].strptr =
361 "call value 'FRED', 'junk', 'ENVIRONMENT'; if value('FRED',,'ENVIRONMENT') <> 'mess' then say 'setenv/getenv failed'" ;
362 Instore[0].strlength = strlen( Instore[0].strptr ) ;
363 Instore[1].strptr = NULL ;
365 rc = RexxStart( 0, NULL, "Testing", Instore, "Foo", RXCOMMAND,
366 Exits, NULL, NULL ) ;
368 RexxDeregisterExit( "Foo", NULL ) ;
374 LONG APIENTRY query_init_exit( LONG ExNum, LONG Subfun, PEXIT PBlock )
376 char *name="TEST1" ;
377 int rc ;
378 char result[100];
379 ULONG dup;
380 RXSTRING data;
382 data.strptr = result;
383 rc = RexxCreateQueue( result, sizeof(result), name, &dup ) ;
384 iverify( "Query Init exit", rc, RXQUEUE_OK ) ;
385 data.strlength = strlen(result);
386 sverify( "Query Init exit", &data, name ) ;
387 iverify( "Query Init dup", dup, 0L ) ;
389 data.strptr = "line1";
390 data.strlength = strlen(data.strptr);
391 rc = RexxAddQueue( name, &data, RXQUEUE_FIFO ) ;
392 iverify( "Query Init exit", rc, RXQUEUE_OK ) ;
394 data.strptr = "line2";
395 data.strlength = strlen(data.strptr);
396 rc = RexxAddQueue( name, &data, RXQUEUE_FIFO ) ;
397 iverify( "Query Init exit", rc, RXQUEUE_OK ) ;
399 return RXEXIT_HANDLED ;
402 LONG APIENTRY query_term_exit( LONG ExNum, LONG Subfun, PEXIT PBlock )
404 int rc ;
405 ULONG count;
406 RXSTRING data;
407 DATETIME timestamp;
409 rc = RexxQueryQueue( "FRED", &count ) ;
410 iverify( "Query Term exit", rc, RXQUEUE_OK ) ;
411 iverify( "Query Term count", count, 2L ) ;
413 rc = RexxPullQueue( "FRED", &data, &timestamp, RXQUEUE_NOWAIT );
414 iverify( "Query Term exit", rc, RXQUEUE_OK ) ;
415 sverify( "Query Term data", &data, "2line" ) ;
416 RexxFreeMemory( data.strptr ) ;
418 rc = RexxPullQueue( "FRED", &data, &timestamp, RXQUEUE_NOWAIT );
419 iverify( "Query Term exit", rc, RXQUEUE_OK ) ;
420 sverify( "Query Term data", &data, "1line" ) ;
421 RexxFreeMemory( data.strptr ) ;
423 rc = RexxDeleteQueue( "FRED" );
424 iverify( "Query Init exit", rc, RXQUEUE_OK ) ;
426 rc = RexxDeleteQueue( "TEST1" );
427 iverify( "Query Init exit", rc, RXQUEUE_OK ) ;
429 return RXEXIT_HANDLED ;
432 LONG APIENTRY it_init_exit( LONG ExNum, LONG Subfun, PEXIT PBlock )
434 SHVBLOCK shv ;
435 char *name="FOO" ;
436 int rc ;
437 char *value="foz" ;
439 shv.shvnext = NULL ;
440 shv.shvname.strptr = name ;
441 shv.shvnamelen = shv.shvname.strlength = strlen(name) ;
442 shv.shvvalue.strptr = value ;
443 shv.shvvaluelen = shv.shvvalue.strlength = strlen(value) ;
444 shv.shvcode = RXSHV_SYSET ;
446 rc = RexxVariablePool( &shv ) ;
447 iverify( "Init exit", rc, RXSHV_NEWV ) ;
448 iverify( "Init exit", shv.shvret, RXSHV_NEWV ) ;
449 return RXEXIT_HANDLED ;
453 LONG APIENTRY it_term_exit( LONG ExNum, LONG Subfun, PEXIT PBlock )
455 SHVBLOCK shv ;
456 char *name ;
457 int rc ;
458 char value[64] ;
460 strcpy( value, "" ) ;
461 shv.shvnext = NULL ;
462 name = "MYVAR" ;
463 shv.shvname.strptr = name ;
464 shv.shvnamelen = shv.shvname.strlength = strlen(name) ;
465 shv.shvvalue.strptr = value ;
466 shv.shvvaluelen = 64 ;
467 shv.shvcode = RXSHV_SYFET ;
469 rc = RexxVariablePool( &shv ) ;
470 iverify( "Term exit", rc, RXSHV_NEWV ) ;
471 iverify( "Term exit", shv.shvret, RXSHV_NEWV ) ;
472 sverify( "Term exit:", &(shv.shvvalue), "MYVAR" ) ;
474 shv.shvnext = NULL ;
475 name = "bar" ;
476 shv.shvname.strptr = name ;
477 shv.shvnamelen = shv.shvname.strlength = strlen(name) ;
479 /* The value is the same as above (value) and therefore valid */
480 #if 0
481 shv.shvvalue.strptr = value ;
482 shv.shvvaluelen = 64 ;
483 shv.shvvalue.strlength = strlen(value) ; /* not allowed! not 0-terminated */
484 #endif
485 shv.shvcode = RXSHV_SYFET ;
487 rc = RexxVariablePool( &shv ) ;
488 iverify( "Term exit", rc, RXSHV_OK ) ;
489 iverify( "Term exit", shv.shvret, RXSHV_OK ) ;
490 sverify( "Term exit:", &(shv.shvvalue), "baz" ) ;
492 return RXEXIT_HANDLED ;
496 LONG APIENTRY it_say_exit( LONG ExNum, LONG Subfun, PEXIT PBlock )
498 SHVBLOCK shv ;
499 char *name ;
500 int rc ;
501 char value[64] ;
502 RXSIOSAY_PARM *psiosay;
504 iverify( "Say exit", ExNum, RXSIO ) ;
505 iverify( "Say exit", Subfun, RXSIOSAY ) ;
506 psiosay = (RXSIOSAY_PARM *)PBlock;
507 sverify( "Say exit", &(psiosay->rxsio_string), "foz" ) ;
509 shv.shvnext = NULL ;
510 name = "myvar.1" ;
511 shv.shvname.strptr = name ;
512 shv.shvnamelen = shv.shvname.strlength = strlen(name) ;
513 shv.shvvalue.strptr = value ;
514 shv.shvvaluelen = 64 ;
515 shv.shvcode = RXSHV_SYFET ;
517 rc = RexxVariablePool( &shv ) ;
518 iverify( "Say exit", rc, RXSHV_NEWV ) ;
519 iverify( "Say exit", shv.shvret, RXSHV_NEWV ) ;
520 sverify( "Say exit:", &(shv.shvvalue), "MYVAR.1" ) ;
522 return RXEXIT_HANDLED ;
525 static void init_term(void)
527 RXSTRING Instore[2] ;
528 RXSYSEXIT Exits[4] ;
529 int rc ;
531 message( "init/term" ) ;
533 RexxRegisterExitExe( "init", (PFN)it_init_exit, NULL ) ;
534 RexxRegisterExitExe( "term", (PFN)it_term_exit, NULL ) ;
535 RexxRegisterExitExe( "say", (PFN)it_say_exit, NULL ) ;
537 Exits[0].sysexit_name = "init" ;
538 Exits[0].sysexit_code = RXINI ;
539 Exits[1].sysexit_name = "term" ;
540 Exits[1].sysexit_code = RXTER ;
541 Exits[2].sysexit_name = "say" ;
542 Exits[2].sysexit_code = RXSIO ;
543 Exits[3].sysexit_code = RXENDLST ;
545 Instore[0].strptr =
546 "say foo\n\n\nbar='baz'\nexit" ;
547 Instore[0].strlength = strlen( Instore[0].strptr ) ;
548 Instore[1].strptr = NULL ;
550 rc = RexxStart( 0, NULL, "Testing", Instore, "Foo", RXCOMMAND,
551 Exits, NULL, NULL ) ;
553 RexxDeregisterExit( "init", NULL ) ;
554 RexxDeregisterExit( "term", NULL ) ;
555 RexxDeregisterExit( "say", NULL ) ;
560 LONG APIENTRY vars_exit( LONG ExNum, LONG Subfun, PEXIT PBlock )
562 SHVBLOCK shv[10] ;
563 int rc ;
564 RXSIOSAY_PARM *psiosay;
566 iverify( "Say exit", ExNum, RXSIO ) ;
567 iverify( "Say exit", Subfun, RXSIOSAY ) ;
569 psiosay = (RXSIOSAY_PARM *)PBlock;
570 sverify( "Say exit", &(psiosay->rxsio_string), "Hello" ) ;
572 shv[0].shvnext = &(shv[1]) ;
573 shv[0].shvname.strptr = "BAR" ;
574 shv[0].shvname.strlength = strlen( shv[0].shvname.strptr ) ;
575 shv[0].shvnamelen = shv[0].shvname.strlength ;
576 shv[0].shvvalue.strptr = "B-value-AR" ;
577 shv[0].shvvalue.strlength = strlen( shv[0].shvvalue.strptr ) ;
578 shv[0].shvvaluelen = shv[0].shvvalue.strlength ;
579 shv[0].shvcode = RXSHV_SYSET ;
581 /* Try to get it with lower case letters */
582 shv[1].shvnext = &(shv[2]) ;
583 shv[1].shvname.strptr = "bar " ;
584 shv[1].shvname.strlength = strlen( shv[1].shvname.strptr ) ;
585 shv[1].shvnamelen = shv[1].shvname.strlength ;
586 shv[1].shvvalue.strptr = RexxAllocateMemory( 64 ) ;
587 shv[1].shvvalue.strlength = 64 ;
588 shv[1].shvvaluelen = shv[1].shvvalue.strlength ;
589 shv[1].shvcode = RXSHV_SYFET ;
591 /* then we use capital letters */
592 shv[2].shvnext = &(shv[3]) ;
593 shv[2].shvname.strptr = "BAR" ;
594 shv[2].shvname.strlength = strlen( shv[2].shvname.strptr ) ;
595 shv[2].shvnamelen = shv[2].shvname.strlength ;
596 shv[2].shvvalue.strptr = RexxAllocateMemory( 64 ) ;
597 shv[2].shvvalue.strlength = 64 ;
598 shv[2].shvvaluelen = shv[2].shvvalue.strlength ;
599 shv[2].shvcode = RXSHV_SYFET ;
601 /* Then we set it to something else */
602 shv[3].shvnext = &(shv[4]) ;
603 shv[3].shvname.strptr = "BAR" ;
604 shv[3].shvname.strlength = strlen( shv[3].shvname.strptr ) ;
605 shv[3].shvnamelen = shv[3].shvname.strlength ;
606 shv[3].shvvalue.strptr = "new value" ;
607 shv[3].shvvalue.strlength = strlen( shv[3].shvvalue.strptr ) ;
608 shv[3].shvvaluelen = shv[3].shvvalue.strlength ;
609 shv[3].shvcode = RXSHV_SYSET ;
611 /* And get it */
612 shv[4].shvnext = &(shv[5]) ;
613 shv[4].shvname.strptr = "BAR" ;
614 shv[4].shvname.strlength = strlen( shv[4].shvname.strptr ) ;
615 shv[4].shvnamelen = shv[4].shvname.strlength ;
616 shv[4].shvvalue.strptr = RexxAllocateMemory( 64 ) ;
617 shv[4].shvvalue.strlength = 64 ;
618 shv[4].shvvaluelen = shv[4].shvvalue.strlength ;
619 shv[4].shvcode = RXSHV_SYFET ;
621 /* And drop it */
622 shv[5].shvnext = &(shv[6]) ;
623 shv[5].shvname.strptr = "BAR" ;
624 shv[5].shvname.strlength = strlen( shv[5].shvname.strptr ) ;
625 shv[5].shvnamelen = shv[5].shvname.strlength ;
626 shv[5].shvvalue.strptr = NULL ;
627 shv[5].shvvalue.strlength = 0 ;
628 shv[5].shvvaluelen = shv[5].shvvalue.strlength ;
629 shv[5].shvcode = RXSHV_SYDRO ;
631 /* And then we try to get it again */
632 shv[6].shvnext = &(shv[7]) ;
633 shv[6].shvname.strptr = "BAR" ;
634 shv[6].shvname.strlength = strlen( shv[6].shvname.strptr ) ;
635 shv[6].shvnamelen = shv[6].shvname.strlength ;
636 shv[6].shvvalue.strptr = RexxAllocateMemory( 64 ) ;
637 shv[6].shvvalue.strlength = 64 ;
638 shv[6].shvvaluelen = shv[6].shvvalue.strlength ;
639 shv[6].shvcode = RXSHV_SYFET ;
641 shv[7].shvnext = &(shv[8]) ;
642 shv[7].shvname.strptr = "FOO" ;
643 shv[7].shvname.strlength = strlen( shv[7].shvname.strptr ) ;
644 shv[7].shvnamelen = shv[7].shvname.strlength ;
645 shv[7].shvvalue.strptr = "OOPS" ;
646 shv[7].shvvalue.strlength = strlen( shv[7].shvvalue.strptr ) ;
647 shv[7].shvvaluelen = shv[7].shvvalue.strlength ;
648 shv[7].shvcode = RXSHV_SYSET ;
650 shv[8].shvnext = &(shv[9]) ;
651 shv[8].shvname.strptr = "ABC.FOO" ;
652 shv[8].shvname.strlength = strlen( shv[8].shvname.strptr ) ;
653 shv[8].shvnamelen = shv[8].shvname.strlength ;
654 shv[8].shvvalue.strptr = "hello, there! ... this is a long string" ;
655 shv[8].shvvalue.strlength = strlen( shv[8].shvvalue.strptr ) ;
656 shv[8].shvvaluelen = shv[8].shvvalue.strlength ;
657 shv[8].shvcode = RXSHV_SYSET ;
659 shv[9].shvnext = NULL ;
660 shv[9].shvname.strptr = "ABC.OOPS" ;
661 shv[9].shvname.strlength = strlen( shv[9].shvname.strptr ) ;
662 shv[9].shvnamelen = shv[9].shvname.strlength ;
663 shv[9].shvvalue.strptr = RexxAllocateMemory(16) ;
664 shv[9].shvvalue.strlength = 16 ;
665 shv[9].shvvaluelen = shv[9].shvvalue.strlength ;
666 shv[9].shvcode = RXSHV_SYFET ;
669 rc = RexxVariablePool( shv ) ;
670 iverify( "Term exit", rc, RXSHV_TRUNC | RXSHV_BADN | RXSHV_NEWV ) ;
672 iverify( "Term exit1 ", shv[0].shvret, RXSHV_NEWV ) ;
673 iverify( "Term exit2 ", shv[1].shvret, RXSHV_BADN ) ;
674 iverify( "Term exit3 ", shv[2].shvret, RXSHV_OK ) ;
675 iverify( "Term exit4 ", shv[3].shvret, RXSHV_OK ) ;
676 iverify( "Term exit5 ", shv[4].shvret, RXSHV_OK ) ;
677 iverify( "Term exit6 ", shv[5].shvret, RXSHV_OK ) ;
678 iverify( "Term exit7 ", shv[6].shvret, RXSHV_NEWV ) ;
679 iverify( "Term exit8 ", shv[7].shvret, RXSHV_NEWV ) ;
680 iverify( "Term exit9 ", shv[8].shvret, RXSHV_NEWV ) ;
681 iverify( "Term exit10", shv[9].shvret, RXSHV_TRUNC ) ;
684 sverify( "Term exit1 ", &(shv[2].shvvalue), "B-value-AR" ) ;
685 sverify( "Term exit2 ", &(shv[4].shvvalue), "new value" ) ;
686 sverify( "Term exit3 ", &(shv[6].shvvalue), "BAR" ) ;
687 sverify( "Term exit4 ", &(shv[9].shvvalue), "hello, there! .." ) ;
689 return RXEXIT_HANDLED ;
692 static void vars(void)
694 RXSTRING Instore[2] ;
695 RXSYSEXIT Exits[4] ;
696 int rc ;
698 message( "vars" ) ;
700 RexxRegisterExitExe( "hepp", (PFN)vars_exit, NULL ) ;
702 Exits[0].sysexit_name = "hepp" ;
703 Exits[0].sysexit_code = RXSIO ;
704 Exits[1].sysexit_code = RXENDLST ;
706 Instore[0].strptr =
707 "say 'Hello'" ;
708 Instore[0].strlength = strlen( Instore[0].strptr ) ;
709 Instore[1].strptr = NULL ;
711 rc = RexxStart( 0, NULL, "Testing", Instore, "Foo", RXCOMMAND,
712 Exits, NULL, NULL ) ;
714 RexxDeregisterExit( "hepp", NULL ) ;
720 LONG APIENTRY source_exit( LONG code, LONG subcode, PEXIT ptr )
722 SHVBLOCK Req[6] ;
724 Req[0].shvnext = &(Req[1]) ;
725 Req[0].shvcode = RXSHV_PRIV ;
726 Req[0].shvname.strptr = "SOURCE" ;
727 Req[0].shvname.strlength = strlen( Req[0].shvname.strptr ) ;
728 Req[0].shvnamelen = Req[0].shvname.strlength ;
729 Req[0].shvvalue.strptr = NULL ;
731 Req[1].shvnext = &(Req[2]) ;
732 Req[1].shvcode = RXSHV_PRIV ;
733 Req[1].shvname.strptr = "VERSION" ;
734 Req[1].shvname.strlength = strlen( Req[1].shvname.strptr ) ;
735 Req[1].shvnamelen = Req[1].shvname.strlength ;
736 Req[1].shvvalue.strptr = NULL ;
738 Req[2].shvnext = &(Req[3]) ;
739 Req[2].shvcode = RXSHV_PRIV ;
740 Req[2].shvname.strptr = "PARM" ;
741 Req[2].shvname.strlength = strlen( Req[2].shvname.strptr ) ;
742 Req[2].shvnamelen = Req[2].shvname.strlength ;
743 Req[2].shvvalue.strptr = NULL ;
745 Req[3].shvnext = &(Req[4]) ;
746 Req[3].shvcode = RXSHV_PRIV ;
747 Req[3].shvname.strptr = "PARM.1" ;
748 Req[3].shvname.strlength = strlen( Req[3].shvname.strptr ) ;
749 Req[3].shvnamelen = Req[3].shvname.strlength ;
750 Req[3].shvvalue.strptr = NULL ;
752 Req[4].shvnext = &(Req[5]) ;
753 Req[4].shvcode = RXSHV_PRIV ;
754 Req[4].shvname.strptr = "PARM.2" ;
755 Req[4].shvname.strlength = strlen( Req[4].shvname.strptr ) ;
756 Req[4].shvnamelen = Req[4].shvname.strlength ;
757 Req[4].shvvalue.strptr = NULL ;
759 Req[5].shvnext = NULL ;
760 Req[5].shvcode = RXSHV_PRIV ;
761 Req[5].shvname.strptr = "QUENAME" ;
762 Req[5].shvname.strlength = strlen( Req[5].shvname.strptr ) ;
763 Req[5].shvnamelen = Req[5].shvname.strlength ;
764 Req[5].shvvalue.strptr = NULL ;
766 iverify( "Termin exit", code, RXTER ) ;
767 iverify( "Termin exit", subcode, RXTEREXT ) ;
769 RexxVariablePool( Req ) ;
771 iverify( "Source", Req[0].shvret, RXSHV_OK ) ;
772 iverify( "Version", Req[1].shvret, RXSHV_OK ) ;
773 if (memcmp(Req[1].shvvalue.strptr, "REXX", 4 ))
774 mycomplain( "Invalid Rexx source string\n" ) ;
776 iverify( "Parms", Req[2].shvret, RXSHV_OK ) ;
777 sverify( "Parms", &(Req[2].shvvalue), "1" ) ;
779 iverify( "Parm1a", Req[3].shvret, RXSHV_OK ) ;
780 sverify( "Parm1b", &(Req[3].shvvalue), "one two three" ) ;
782 iverify( "Parm2a", Req[4].shvret, RXSHV_OK ) ;
783 sverify( "Parm2b", &(Req[4].shvvalue), NULL ) ;
785 iverify( "QueName", Req[5].shvret, RXSHV_OK ) ;
786 sverify( "QueName", &(Req[5].shvvalue), "default" ) ;
788 return RXEXIT_HANDLED ;
793 static void source( void )
795 RXSYSEXIT Exits[2] ;
796 RXSTRING Instore[2] ;
797 RXSTRING Params[2] ;
798 int rc ;
800 message("private") ;
802 RexxRegisterExitExe("hei", (PFN)source_exit, NULL ) ;
804 Exits[0].sysexit_name = "hei" ;
805 Exits[0].sysexit_code = RXTER ;
806 Exits[1].sysexit_code = RXENDLST ;
808 Params[0].strptr = "one two three" ;
809 Params[0].strlength = strlen( Params[0].strptr ) ;
811 Instore[0].strptr = "nop" ;
812 Instore[0].strlength = strlen( Instore[0].strptr ) ;
813 Instore[1].strptr = NULL ;
815 rc = RexxStart( 1, Params, "Testing", Instore, "Foo", RXCOMMAND,
816 Exits, NULL, NULL ) ;
818 RexxDeregisterExit( "hei", NULL ) ;
824 LONG APIENTRY parms( LONG code, LONG subcode, PEXIT ptr )
826 RXSYSEXIT Exits[2] ;
827 RXSTRING Instore[2] ;
828 RXSTRING Params[5] ;
829 int rc ;
830 static int done = 0 ;
832 if (code == -1)
834 message("parms") ;
836 RexxRegisterExitExe("hei", (PFN)parms, NULL ) ;
838 Exits[0].sysexit_name = "hei" ;
839 Exits[0].sysexit_code = RXTER ;
840 Exits[1].sysexit_code = RXENDLST ;
842 Params[0].strptr = "one two three" ;
843 Params[0].strlength = strlen( Params[0].strptr ) ;
844 Params[1].strptr = NULL ;
845 Params[1].strlength = 5 ;
846 Params[2].strptr = "" ;
847 Params[2].strlength = strlen( Params[2].strptr ) ;
848 Params[3].strptr = "four five" ;
849 Params[3].strlength = strlen( Params[3].strptr ) ;
850 Params[4].strptr = NULL ;
851 Params[4].strlength = 10 ;
853 Instore[0].strptr = "nop" ;
854 Instore[0].strlength = strlen( Instore[0].strptr ) ;
855 Instore[1].strptr = NULL ;
857 rc = RexxStart( 5, Params, "Testing", Instore, "Foo", RXFUNCTION,
858 Exits, NULL, NULL ) ;
860 if (!done)
861 printf("not done\n") ;
863 RexxDeregisterExit( "hei", NULL ) ;
864 return 0 ;
866 else
868 SHVBLOCK Req[7] ;
870 done = 1 ;
871 Req[0].shvnext = &(Req[1]) ;
872 Req[0].shvcode = RXSHV_PRIV ;
873 Req[0].shvname.strptr = "PARM" ;
874 Req[0].shvname.strlength = strlen( Req[0].shvname.strptr ) ;
875 Req[0].shvnamelen = Req[0].shvname.strlength ;
876 Req[0].shvvalue.strptr = NULL ;
878 Req[1].shvnext = &(Req[2]) ;
879 Req[1].shvcode = RXSHV_PRIV ;
880 Req[1].shvname.strptr = "PARM.1" ;
881 Req[1].shvname.strlength = strlen( Req[1].shvname.strptr ) ;
882 Req[1].shvnamelen = Req[1].shvname.strlength ;
883 Req[1].shvvalue.strptr = NULL ;
885 Req[2].shvnext = &(Req[3]) ;
886 Req[2].shvcode = RXSHV_PRIV ;
887 Req[2].shvname.strptr = "PARM.2" ;
888 Req[2].shvname.strlength = strlen( Req[2].shvname.strptr ) ;
889 Req[2].shvnamelen = Req[2].shvname.strlength ;
890 Req[2].shvvalue.strptr = NULL ;
892 Req[3].shvnext = &(Req[4]) ;
893 Req[3].shvcode = RXSHV_PRIV ;
894 Req[3].shvname.strptr = "PARM.3" ;
895 Req[3].shvname.strlength = strlen( Req[3].shvname.strptr ) ;
896 Req[3].shvnamelen = Req[3].shvname.strlength ;
897 Req[3].shvvalue.strptr = NULL ;
899 Req[4].shvnext = &(Req[5]) ;
900 Req[4].shvcode = RXSHV_PRIV ;
901 Req[4].shvname.strptr = "PARM.4" ;
902 Req[4].shvname.strlength = strlen( Req[4].shvname.strptr ) ;
903 Req[4].shvnamelen = Req[4].shvname.strlength ;
904 Req[4].shvvalue.strptr = NULL ;
906 Req[5].shvnext = &(Req[6]) ;
907 Req[5].shvcode = RXSHV_PRIV ;
908 Req[5].shvname.strptr = "PARM.5" ;
909 Req[5].shvname.strlength = strlen( Req[5].shvname.strptr ) ;
910 Req[5].shvnamelen = Req[5].shvname.strlength ;
911 Req[5].shvvalue.strptr = NULL ;
913 Req[6].shvnext = NULL ;
914 Req[6].shvcode = RXSHV_PRIV ;
915 Req[6].shvname.strptr = "PARM.6" ;
916 Req[6].shvname.strlength = strlen( Req[6].shvname.strptr ) ;
917 Req[6].shvnamelen = Req[6].shvname.strlength ;
918 Req[6].shvvalue.strptr = NULL ;
920 iverify( "Termin exit", code, RXTER ) ;
921 iverify( "Termin exit", subcode, RXTEREXT ) ;
923 RexxVariablePool( Req ) ;
925 iverify( "Parm", Req[0].shvret, RXSHV_OK ) ;
926 sverify( "Parm", &(Req[0].shvvalue), "5" ) ;
928 iverify( "Parm1", Req[1].shvret, RXSHV_OK ) ;
929 sverify( "Parm1", &(Req[1].shvvalue), "one two three" ) ;
931 iverify( "Parm2", Req[2].shvret, RXSHV_OK ) ;
932 sverify( "Parm2", &(Req[2].shvvalue), NULL ) ;
934 iverify( "Parm3", Req[3].shvret, RXSHV_OK ) ;
935 sverify( "Parm3", &(Req[3].shvvalue), "" ) ;
937 iverify( "Parm4", Req[4].shvret, RXSHV_OK ) ;
938 sverify( "Parm4", &(Req[4].shvvalue), "four five" ) ;
940 iverify( "Parm5", Req[5].shvret, RXSHV_OK ) ;
941 sverify( "Parm5", &(Req[5].shvvalue), NULL ) ;
943 iverify( "Parm6", Req[6].shvret, RXSHV_OK ) ;
944 sverify( "Parm6", &(Req[6].shvvalue), NULL ) ;
946 return RXEXIT_HANDLED ;
954 LONG APIENTRY allvars( LONG code, LONG subcode, PEXIT ptr )
956 RXSYSEXIT Exits[2] ;
957 RXSTRING Instore[2] ;
958 RXSTRING Params[5] ;
959 int rc ;
960 static int done = 0 ;
962 if (code == -1)
964 message("allvars") ;
966 RexxRegisterExitExe("hei", (PFN)allvars, NULL ) ;
968 Exits[0].sysexit_name = "hei" ;
969 Exits[0].sysexit_code = RXTER ;
970 Exits[1].sysexit_code = RXENDLST ;
972 Params[0].strptr = "one two three" ;
973 Params[0].strlength = strlen( Params[0].strptr ) ;
974 Params[1].strptr = NULL ;
975 Params[1].strlength = 5 ;
976 Params[2].strptr = "" ;
977 Params[2].strlength = strlen( Params[2].strptr ) ;
978 Params[3].strptr = "four five" ;
979 Params[3].strlength = strlen( Params[3].strptr ) ;
980 Params[4].strptr = NULL ;
981 Params[4].strlength = 10 ;
983 Instore[0].strptr = "foo='one';bar='';foo.='two';foo.bar='three';"
984 "foo.4='four';foo.5='five';drop foo.5 foo.6" ;
986 Instore[0].strlength = strlen( Instore[0].strptr ) ;
987 Instore[1].strptr = NULL ;
989 rc = RexxStart( 5, Params, "Testing", Instore, "Foo", RXFUNCTION,
990 Exits, NULL, NULL ) ;
992 if (!done)
993 printf("not done\n") ;
995 RexxDeregisterExit( "hei", NULL ) ;
996 return 0 ;
998 else
1000 SHVBLOCK Req[10] ;
1001 int i ;
1003 done = 1 ;
1004 for (i=0; i<10; i++)
1006 Req[i].shvnext = (i<10-1) ? (&(Req[i+1])) : NULL ;
1007 Req[i].shvcode = RXSHV_NEXTV ;
1008 Req[i].shvname.strptr = Req[i].shvvalue.strptr = NULL ;
1011 iverify( "Termin exit", code, RXTER ) ;
1012 iverify( "Termin exit", subcode, RXTEREXT ) ;
1014 RexxVariablePool( Req ) ;
1016 iverify( "Parm0", Req[0].shvret, RXSHV_OK ) ;
1017 sverify( "Parm0a", &(Req[0].shvname), "BAR" ) ;
1018 sverify( "Parm0b", &(Req[0].shvvalue), "" ) ;
1020 iverify( "Parm1", Req[1].shvret, RXSHV_OK ) ;
1021 sverify( "Parm1a", &(Req[1].shvname), "FOO." ) ;
1022 sverify( "Parm1b", &(Req[1].shvvalue), "three" ) ;
1024 iverify( "Parm2", Req[2].shvret, RXSHV_OK ) ;
1025 sverify( "Parm2a", &(Req[2].shvname), "FOO.4" ) ;
1026 sverify( "Parm2b", &(Req[2].shvvalue), "four" ) ;
1028 iverify( "Parm3", Req[3].shvret, RXSHV_OK ) ;
1029 sverify( "Parm3a", &(Req[3].shvname), "FOO.5" ) ;
1030 sverify( "Parm3b", &(Req[3].shvvalue), "FOO.5" ) ;
1032 iverify( "Parm4", Req[4].shvret, RXSHV_OK ) ;
1033 sverify( "Parm4a", &(Req[4].shvname), "FOO.6" ) ;
1034 sverify( "Parm4b", &(Req[4].shvvalue), "FOO.6" ) ;
1036 iverify( "Parm5", Req[5].shvret, RXSHV_OK ) ;
1037 sverify( "Parm5a", &(Req[5].shvname), "FOO." ) ;
1038 sverify( "Parm5b", &(Req[5].shvvalue), "two" ) ;
1040 iverify( "Parm6", Req[6].shvret, RXSHV_OK ) ;
1041 sverify( "Parm6a", &(Req[6].shvname), "FOO" ) ;
1042 sverify( "Parm6b", &(Req[6].shvvalue), "one" ) ;
1044 iverify( "Parm", Req[7].shvret, RXSHV_LVAR ) ;
1045 iverify( "Parm", Req[8].shvret, RXSHV_OK ) ;
1046 iverify( "Parm", Req[9].shvret, RXSHV_OK ) ;
1048 return RXEXIT_HANDLED ;
1057 ULONG APIENTRY extfunc( PCSZ name, ULONG params, RXSTRING *parm, PCSZ stck, RXSTRING *ptr )
1059 RXSTRING Instore[2] ;
1060 RXSTRING Result ;
1061 int rc ;
1062 short nret ;
1063 static int done = 0 ;
1065 if (name == NULL)
1067 message("extfunc") ;
1069 RexxRegisterFunctionExe("EXTFUNC", (PFN)extfunc ) ;
1071 Instore[0].strptr = "return extfunc('asdf','qwer',,'zxcv') + 'EXTFUNC'('asdf',,'wer','werrew')" ;
1072 Instore[0].strlength = strlen( Instore[0].strptr ) ;
1073 Instore[1].strptr = NULL ;
1075 Result.strlength = 10 ;
1076 Result.strptr = RexxAllocateMemory( 10 ) ;
1078 rc = RexxStart( 0, NULL, "Testing", Instore, "Foo", RXFUNCTION,
1079 NULL, &nret, &Result ) ;
1081 sverify( "extfunc", &Result, "7" ) ;
1082 iverify( "extfunc", nret, 7 ) ;
1084 if (!done)
1085 printf("not done\n") ;
1087 RexxDeregisterFunction( "EXTFUNC" ) ;
1088 return 0 ;
1090 else
1092 static int once=0 ;
1094 done = 1 ;
1095 if (!once)
1097 ptr->strptr[0] = '3' ;
1098 ptr->strlength = 1 ;
1099 once = 1 ;
1101 else
1103 ptr->strptr[0] = '4' ;
1104 ptr->strlength = 1 ;
1106 return 0 ;
1110 LONG APIENTRY subcom_exit( LONG ExNum, LONG Subfun, PEXIT PBlock )
1112 RXCMDHST_PARM *pcmdhst;
1114 iverify( "Subcom Funcion", ExNum, RXCMD ) ;
1115 iverify( "Subcom Subfunc", Subfun, RXCMDHST ) ;
1116 pcmdhst = (RXCMDHST_PARM *)PBlock;
1117 pcmdhst->rxcmd_retc.strlength = 2;
1118 strcpy(pcmdhst->rxcmd_retc.strptr,"16");
1120 return RXEXIT_HANDLED ;
1123 ULONG APIENTRY run_subcom(PRXSTRING Command, PUSHORT Flags, PRXSTRING Retstr)
1125 RXSYSEXIT Exits[4] ;
1126 RXSTRING Instore[2] ;
1127 RXSTRING Result ;
1128 int rc ;
1129 short nret ;
1131 if (Command == NULL)
1133 message("subcom") ;
1135 RexxRegisterExitExe( "slhepp", (PFN)subcom_exit, NULL ) ;
1137 Exits[0].sysexit_name = "slhepp" ;
1138 Exits[0].sysexit_code = RXCMD ;
1139 Exits[1].sysexit_code = RXENDLST ;
1141 RexxRegisterSubcomExe("SUBCOM", (PFN)run_subcom, NULL ) ;
1143 Instore[0].strptr = "'foobar asdf qwer'" ;
1144 Instore[0].strlength = strlen( Instore[0].strptr ) ;
1145 Instore[1].strptr = NULL ;
1147 Result.strlength = 20 ;
1148 Result.strptr = RexxAllocateMemory( 20 ) ;
1150 rc = RexxStart( 0, NULL, "Testing", Instore, "SUBCOM", RXCOMMAND,
1151 Exits, &nret, &Result ) ;
1153 /* sverify( "subcom result", &Result, "16" ) ; */
1154 /* iverify( "subcom retc", nret, 16 ) ; */
1156 RexxDeregisterSubcom( "SUBCOM" , NULL) ;
1157 RexxDeregisterExit( "slhepp", NULL ) ;
1159 return 0 ;
1161 else
1163 sprintf(Retstr->strptr,"%ld",Command->strlength) ;
1164 Retstr->strlength = strlen(Retstr->strptr);
1165 *Flags = RXSUBCOM_OK;
1166 return 0 ;
1171 static void qtest( void )
1173 RXSTRING Instore[2] ;
1174 RXSYSEXIT Exits[3] ;
1175 int rc ;
1176 char result[100];
1177 ULONG dup;
1179 message( "queue" ) ;
1181 rc = RexxCreateQueue( result, sizeof(result), NULL, &dup ) ;
1182 iverify( "qtest-before", rc, RXQUEUE_OK ) ;
1183 iverify( "qtest-before", dup, 0L ) ;
1185 Exits[0].sysexit_name = "query_init" ;
1186 Exits[0].sysexit_code = RXINI ;
1187 Exits[1].sysexit_name = "query_term" ;
1188 Exits[1].sysexit_code = RXTER ;
1189 Exits[2].sysexit_code = RXENDLST ;
1190 RexxRegisterExitExe( "query_init", (PFN)query_init_exit, NULL ) ;
1191 RexxRegisterExitExe( "query_term", (PFN)query_init_exit, NULL ) ;
1193 Instore[0].strptr = "call rxqueue 'Set', 'test1';"
1194 "if queued() \\= 2 then say 'error:line 2';"
1195 "parse pull line;"
1196 "if line \\= 'line1' then say 'error:line 4';"
1197 "parse pull line;"
1198 "if line \\= 'line2' then say 'error:line 5';"
1199 "if rxqueue('Create','FRED') \\= 'FRED' then say 'error:line 6';"
1200 "push '1line';push '2line';" ;
1201 Instore[0].strlength = strlen( Instore[0].strptr ) ;
1202 Instore[1].strptr = NULL ;
1203 rc = RexxStart( 0, NULL, "Testing", Instore, "Foo", RXCOMMAND,
1204 Exits, NULL, NULL ) ;
1206 RexxFreeMemory( Instore[1].strptr ) ;
1207 RexxDeregisterExit( "query_init", NULL ) ;
1208 RexxDeregisterExit( "query_term", NULL ) ;
1210 rc = RexxDeleteQueue( result );
1211 iverify( "qtest-after", rc, RXQUEUE_OK ) ;
1214 static void (*(routines[]))(void) = {
1215 instore,
1216 trace,
1217 intertrc,
1218 pull,
1219 env,
1220 init_term,
1221 vars,
1222 source,
1223 NULL
1227 static RexxExitHandler *(exits[]) = {
1228 parms,
1229 allvars,
1230 NULL
1234 static RexxFunctionHandler *(efuncs[]) = {
1235 extfunc,
1236 NULL
1239 static RexxSubcomHandler *(scfuncs[]) = {
1240 run_subcom,
1241 NULL
1245 int main( int argc, char *argv[] )
1247 void (**fptr)( void ) ;
1248 RexxExitHandler **eptr ;
1249 RexxFunctionHandler **gptr ;
1250 RexxSubcomHandler **sptr;
1251 RXSTRING version;
1252 ULONG versioncode;
1254 /* We want to see surprisings at once: */
1255 setvbuf(stdout,NULL,_IONBF,0);
1256 setvbuf(stderr,NULL,_IONBF,0);
1257 printf( "Regina Rexx API Tester\n" );
1258 printf( "----------------------\n" );
1260 version.strlength = 0;
1261 version.strptr = NULL;
1262 /* This might not work if we check another Rexx: */
1263 versioncode = ReginaVersion(&version);
1264 printf("Regina's version is %lu.%02lu",
1265 versioncode >> 8,
1266 versioncode & 0xFF);
1267 if (version.strptr)
1269 printf(" (in complete \"%s\")",version.strptr);
1270 RexxFreeMemory(version.strptr);
1272 printf("\n");
1274 for( fptr=routines; *fptr; fptr++ )
1275 (*fptr)() ;
1277 for( eptr=exits; *eptr; eptr++ )
1278 (*eptr)( -1, -1, NULL ) ;
1280 for( gptr=efuncs; *gptr; gptr++ )
1281 (*gptr)( NULL, 0, NULL, NULL, NULL ) ;
1283 for( sptr=scfuncs; *sptr; sptr++ )
1284 (*sptr)( NULL, 0, NULL ) ;
1285 #if !defined(NO_EXTERNAL_QUEUES)
1286 qtest();
1287 #endif
1288 printf( "\n" ) ;
1289 return 0 ;