67 int main(
int argc,
char **argv)
73 void *pLibHandle = NULL;
76 const char *pszLibraryName =
"librexx.so";
77 char returnBuffer[100];
80 const char *str1 =
"Arg number one";
81 const char *str2 =
"Arg number two";
82 const char *str3 =
"Arg number three";
83 const char *str4 =
"Arg number four";
85 const char *sync_tst =
"call time 'Reset';" \
86 "object1 = .example~new;" \
87 "object2 = .example~new;" \
88 "object3 = .example~new;" \
89 "a.1 = object1~start('REPEAT', 4 , 'Object 1 running');" \
91 "say 'The result method waits until the START message has completed:';" \
92 "a.2 = object2~start('REPEAT', 2, 'Object 2 running');" \
93 "a.3 = object3~start('REPEAT', 2, 'Object 3 running');" \
97 "say 'Elapsed time: ' time('E');" \
99 "::REQUIRES 'example.rex'";
101 if (!(pLibHandle = dlopen(pszLibraryName, RTLD_LAZY )))
103 fprintf(stderr,
" *** Unable to load library %s !\nError message: %s\n",
104 pszLibraryName, dlerror());
108 if(!(FuncAddress = (
PFNREXXSTART) dlsym(pLibHandle,
"RexxStart")))
111 fprintf(stderr,
" *** Unable to load function %s !\nError message: %s\n",
112 "RexxStart", dlerror());
128 printf(
"This is an easy sample of how to invoke the Rexx interpreter. \n");
129 printf(
"The Rexx commandfile which is started is named: startrx1.rex\n");
131 printf(
"Press Enter to continue\n");
148 printf(
"CALLREXX2 - Back from REXXSTART: Return Code: %d\n", rc);
149 printf(
"CALLREXX2 - RESULT-LENGTH: %d\n", (
int)(rexxretval.
strlength));
150 printf(
"CALLREXX2 - RESULT-Value: %s\n", rexxretval.
strptr);
152 if (rexxretval.
strptr != NULL)
157 printf(
"Press Enter to continue\n");
162 printf(
"In this case a previously defined Resultstring is \n");
163 printf(
"delivered to Open Object Rexx, which is large enough to \n");
164 printf(
"hold the Return Value of the Rexx commandfile.\n");
166 printf(
"Press Enter to continue\n");
169 rexxretval.
strptr = returnBuffer;
170 rexxretval.
strlength =
sizeof(returnBuffer);
183 printf(
"CALLREXX2 - Back from REXXSTART: Return Code: %d\n", rc);
184 printf(
"rexxretval.strptr contains %s\n", rexxretval.
strptr);
185 printf(
"CALLREXX2 - RESULT-LENGTH: %d\n", (
int)(rexxretval.
strlength));
186 printf(
"CALLREXX2 - RESULT-Value: %s\n", rexxretval.
strptr);
188 if (rexxretval.
strptr != returnBuffer)
193 printf(
"Press Enter to continue\n");
198 printf(
"In this case a previously defined Resultstring is \n");
199 printf(
"delivered to Open Object Rexx, which is too small to\n");
200 printf(
"hold the Return Value of the Rexx commandfile.\n");
201 printf(
"Rexx reallocates the buffer which needs to be freed.\n");
202 printf(
"in the calling program\n");
204 printf(
"Press Enter to continue\n");
207 rexxretval.
strptr = (
char *)returnBuffer;
210 printf(
"The length of the Resultstring is %d\n", (
int)(rexxretval.
strlength));
223 printf(
"CALLREXX2 - Back from REXXSTART: Return Code: %d\n", rc);
224 printf(
"The ResultString contains %s after call\n", rexxretval.
strptr);
225 printf(
"The length is now %d\n", (
int)(rexxretval.
strlength));
228 if (rexxretval.
strptr != returnBuffer)
233 printf(
"Press Enter to continue\n");
241 printf(
"This is a sample with 4 arguments delivered to \n");
242 printf(
"REXXSTART\n");
243 printf(
"The Rexx commandfile which is started is named: startrx2.rex\n");
245 printf(
"Press Enter to continue\n");
264 printf(
"CALLREXX2 - Back from REXXSTART: Return Code: %d\n", rc);
265 printf(
"CALLREXX2 - RESULT-LENGTH: %d\n", (
int)(rexxretval.
strlength));
266 printf(
"CALLREXX2 - RESULT-Value: %s\n", rexxretval.
strptr);
270 printf(
"Press Enter to continue\n");
275 printf(
"This is a sample with 2 arguments delivered to \n");
276 printf(
"REXXSTART\n");
277 printf(
"The Rexx commandfile which is started is named: startrx2.rex\n");
279 printf(
"Press Enter to continue\n");
296 printf(
"CALLREXX2 - Back from REXXSTART: Return Code: %d\n", rc);
297 printf(
"CALLREXX2 - RESULT-LENGTH: %d\n", (
int)(rexxretval.
strlength));
298 printf(
"CALLREXX2 - RESULT-Value: %s\n", rexxretval.
strptr);
302 printf(
"Press Enter to continue\n");
307 printf(
"This is a sample where the directory listing of the \n");
308 printf(
"actual directory is returned by the Rexx program. The \n");
309 printf(
"returned ResultString is displayed\n");
310 printf(
"The Rexx commandfile which is started is named: startrx3.rex\n");
312 printf(
"Press Enter to continue\n");
329 printf(
"CALLREXX2 - Back from REXXSTART: Return Code: %d\n", rc);
330 printf(
"CALLREXX2 - RESULT-LENGTH: %d\n", (
int)(rexxretval.
strlength));
331 printf(
"CALLREXX2 - RESULT-Value: %s\n", rexxretval.
strptr);
335 printf(
"Press Enter to continue\n");
340 printf(
"This is a sample where the instore parameter [0] is \n");
341 printf(
"tested. Instore parameter [0] is loaded with \n");
342 printf(
"a small Open Object Rexx script showing the concurrency feature.\n");
344 printf(
"Press Enter to continue\n");
347 instore[0].
strptr = (
char *)sync_tst;
348 instore[0].
strlength = strlen(instore[0].strptr);
366 printf(
"CALLREXX2 - Back from REXXSTART: Return Code: %d\n", rc);
367 printf(
"CALLREXX2 - RESULT-LENGTH: %d\n", (
int)(rexxretval.
strlength));
368 printf(
"CALLREXX2 - RESULT-Value: %s\n", rexxretval.
strptr);
372 printf(
"Press Enter to continue\n");
377 printf(
"Now instore[1] is loaded with the content of instore[0]. \n");
378 printf(
"It can be used on subsequent calls. instore[0] is set to NULL \n");
380 printf(
"Press Enter to continue\n");
400 printf(
"CALLREXX2 - Back from REXXSTART: Return Code: %d\n", rc);
401 printf(
"CALLREXX2 - RESULT-LENGTH: %d\n", (
int)(rexxretval.
strlength));
402 printf(
"CALLREXX2 - RESULT-Value: %s\n", rexxretval.
strptr);
406 free(instore[1].strptr);
408 printf(
"Press Enter to continue\n");
413 printf(
"This is a sample to show how to use the Rexx MacroSpace facility. \n");
414 printf(
"First of all load_macro.rex is called to load \n");
415 printf(
"the Rexx script macros.rex into Macrospace. The Macrospace- \n");
416 printf(
"name is upload.rex. \n");
418 printf(
"Press Enter to continue\n");
435 printf(
"CALLREXX2 - Back from REXXSTART: Return Code: %d\n", rc);
436 printf(
"CALLREXX2 - RESULT-LENGTH: %d\n", (
int)(rexxretval.
strlength));
437 printf(
"CALLREXX2 - RESULT-Value: %s\n", rexxretval.
strptr);
441 printf(
"Press Enter to continue\n");
446 printf(
"Now the Open Object Rexx script macros.rex (named upload.rex) has been loaded\n");
447 printf(
"into Macrospace. It is now used in the name option of\n");
448 printf(
"the REXXSTART command. \n");
449 printf(
"It is very important that instore paramenter [0] and [1] are\n");
450 printf(
"initialized to NULL rsp. 0 and used as REXXSTART parameters\n");
452 printf(
"Press Enter to continue\n");
474 printf(
"CALLREXX2 - Back from REXXSTART: Return Code: %d\n", rc);
475 printf(
"CALLREXX2 - RESULT-LENGTH: %d\n", (
int)(rexxretval.
strlength));
476 printf(
"CALLREXX2 - RESULT-Value: %s\n", rexxretval.
strptr);
482 printf(
"Press Enter to continue\n");
487 printf(
"Finally del_macro.rex is called to delete macros.rex (named upload.rex)\n");
488 printf(
"out of the Open Object Rexx Macrospace.\n");
490 printf(
"Press Enter to continue\n");
504 printf(
"CALLREXX2 - Back from REXXSTART: Return Code: %d\n", rc);
505 printf(
"CALLREXX2 - RESULT-LENGTH: %d\n", (
int)(rexxretval.
strlength));
506 printf(
"CALLREXX2 - RESULT-Value: %s\n", rexxretval.
strptr);
510 printf(
"Press Enter to continue\n");
int main(int argc, char **argv)
RexxReturnCode(REXXENTRY * PFNREXXSTART)(size_t, PCONSTRXSTRING, CONSTANT_STRING, PRXSTRING, CONSTANT_STRING, int, PRXSYSEXIT, short *, PRXSTRING)
RexxReturnCode REXXENTRY RexxFreeMemory(void *)
#define MAKERXSTRING(r, p, l)