callrxnt.c
Go to the documentation of this file.
1
/*----------------------------------------------------------------------------*/
2
/* */
3
/* Copyright (c) 1995, 2004 IBM Corporation. All rights reserved. */
4
/* Copyright (c) 2005-2014 Rexx Language Association. All rights reserved. */
5
/* */
6
/* This program and the accompanying materials are made available under */
7
/* the terms of the Common Public License v1.0 which accompanies this */
8
/* distribution. A copy is also available at the following address: */
9
/* http://www.oorexx.org/license.html */
10
/* */
11
/* Redistribution and use in source and binary forms, with or */
12
/* without modification, are permitted provided that the following */
13
/* conditions are met: */
14
/* */
15
/* Redistributions of source code must retain the above copyright */
16
/* notice, this list of conditions and the following disclaimer. */
17
/* Redistributions in binary form must reproduce the above copyright */
18
/* notice, this list of conditions and the following disclaimer in */
19
/* the documentation and/or other materials provided with the distribution. */
20
/* */
21
/* Neither the name of Rexx Language Association nor the names */
22
/* of its contributors may be used to endorse or promote products */
23
/* derived from this software without specific prior written permission. */
24
/* */
25
/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
26
/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
27
/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
28
/* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */
29
/* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
30
/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */
31
/* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */
32
/* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY */
33
/* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */
34
/* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
35
/* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
36
/* */
37
/*----------------------------------------------------------------------------*/
38
/*********************************************************************/
39
/* */
40
/* File Name: CALLRXNT.C */
41
/* */
42
/* Description: Provides a sample call to the REXX */
43
/* interpreter, passing in an environment name, */
44
/* a file name, and a single argument string. */
45
/* */
46
/* Entry Points: main - main entry point */
47
/* */
48
/* Input: None */
49
/* */
50
/* Output: returns 0 in all cases. */
51
/* */
52
/*********************************************************************/
53
54
#include <
rexx.h
>
/* needed for RexxStart() */
55
#include <stdio.h>
/* needed for printf() */
56
#include <string.h>
/* needed for strlen() */
57
58
int
main
()
59
{
60
CONSTRXSTRING
arg;
/* argument string for REXX */
61
RXSTRING
rexxretval;
/* return value from REXX */
62
63
char
*str =
"These words will be swapped"
;
/* text to swap */
64
65
RexxReturnCode
rc;
/* return code from REXX */
66
short
rexxrc = 0;
/* return code from function */
67
68
printf(
"\nThis program will call the REXX interpreter "
);
69
printf(
"to reverse the order of the\n"
);
70
printf(
"\twords in a string. "
);
71
printf(
"The interpreter is invoked with an initial\n"
);
72
printf(
"\tenvironment name of 'FNC' "
);
73
printf(
"and a file name of 'BACKWARD.FNC'\n\n"
);
74
75
/* By setting the strlength of the output RXSTRING to zero, we */
76
/* force the interpreter to allocate memory and return it to us. */
77
/* We could provide a buffer for the interpreter to use instead. */
78
rexxretval.
strlength
= 0L;
/* initialize return to empty*/
79
80
MAKERXSTRING
(arg, str, strlen(str));
/* create input argument */
81
82
/* Here we call the interpreter. */
83
rc=
RexxStart
(1,
/* number of arguments */
84
&arg,
/* array of arguments */
85
"BACKWARD.FNC"
,
/* name of REXX file */
86
0,
/* No INSTORE used */
87
"FNC"
,
/* Command env. name */
88
RXSUBROUTINE
,
/* Code for how invoked */
89
0,
/* No EXITs on this call */
90
&rexxrc,
/* Rexx program output */
91
&rexxretval );
/* Rexx program output */
92
93
printf(
"Interpreter Return Code: %d\n"
, rc);
94
printf(
"Function Return Code: %d\n"
, (
int
) rexxrc);
95
printf(
"Original String: '%s'\n"
, arg.
strptr
);
96
printf(
"Backwards String: '%s'\n"
, rexxretval.
strptr
);
97
98
RexxFreeMemory
(rexxretval.
strptr
);
/* Release storage */
99
/* given to us by REXX. */
100
system(
"PAUSE"
);
101
return
0;
102
}
RexxStart
int REXXENTRY RexxStart(size_t argcount, PCONSTRXSTRING arglist, const char *programname, PRXSTRING instore, const char *envname, int calltype, PRXSYSEXIT exits, short *retcode, PRXSTRING result)
Definition:
InterpreterAPI.cpp:119
main
int main()
Definition:
callrxnt.c:58
rexx.h
RexxFreeMemory
RexxReturnCode REXXENTRY RexxFreeMemory(void *)
Definition:
RegistrationAPI.cpp:575
MAKERXSTRING
#define MAKERXSTRING(r, p, l)
Definition:
rexx.h:182
RexxReturnCode
int RexxReturnCode
Definition:
rexx.h:73
RXSUBROUTINE
#define RXSUBROUTINE
Definition:
rexxapidefs.h:65
_CONSTRXSTRING
Definition:
rexx.h:161
_CONSTRXSTRING::strptr
const char * strptr
Definition:
rexx.h:163
_RXSTRING
Definition:
rexx.h:156
_RXSTRING::strlength
size_t strlength
Definition:
rexx.h:157
_RXSTRING::strptr
char * strptr
Definition:
rexx.h:158
oorexx
executor
sandbox
jlf
trunk
samples
windows
api
callrxnt
callrxnt.c
Generated by
1.9.2