3 #define INCL_RXSHV /* Shared variable support */
4 #define INCL_RXFUNC /* External functions support */
12 /* This picky compiler claims about unused formal parameters.
13 * This is correct but hides (for human eyes) other errors since they
14 * are many and we can't reduce them all.
15 * Error 4100 is "unused formal parameter".
17 # pragma warning(disable:4100)
20 #define DLLNAME "test2"
23 #define FUNCTION1 Test2Function1
24 #define FUNCTION2 Test2Function2
25 #define LOADFUNCS Test2LoadFuncs
26 #define DROPFUNCS Test2DropFuncs
28 #define NAME_FUNCTION1 "Test2Function1"
29 #define NAME_FUNCTION2 "Test2Function2"
30 #define NAME_LOADFUNCS "Test2LoadFuncs"
31 #define NAME_DROPFUNCS "Test2DropFuncs"
33 RexxFunctionHandler Test2Function1
;
34 RexxFunctionHandler Test2Function2
;
35 RexxFunctionHandler Test2LoadFuncs
;
36 RexxFunctionHandler Test2DropFuncs
;
38 /*-----------------------------------------------------------------------------
39 * Table entry for a REXX/SQL function.
40 *----------------------------------------------------------------------------*/
46 /*-----------------------------------------------------------------------------
47 * Table of REXX/SQL Functions. Used to install/de-install functions.
48 *----------------------------------------------------------------------------*/
49 static const RexxFunction RexxSqlFunctions
[] = {
50 {(PSZ
)NAME_FUNCTION1
, (PFN
)Test2Function1
},
51 {(PSZ
)NAME_FUNCTION2
, (PFN
)Test2Function2
},
52 {(PSZ
)NAME_DROPFUNCS
, (PFN
)Test2DropFuncs
},
56 /*-----------------------------------------------------------------------------
57 * Uppercases the supplied string.
58 *----------------------------------------------------------------------------*/
59 char *make_upper(char *str
)
65 *str
= (char) toupper(*str
);
71 /*-----------------------------------------------------------------------------
72 * Copy a non terminated character array to the nominated buffer (truncate
73 * if necessary) and null terminate.
74 *----------------------------------------------------------------------------*/
75 char *MkAsciz(char *buf
, size_t bufsize
, const char *str
, size_t len
)
77 bufsize
--; /* Make room for terminating byte */
80 memcpy(buf
, str
, len
);
85 static void static_show_parameter(ULONG argc
, RXSTRING argv
[], PSZ func_name
)
90 printf("%s(static): *** No parameters passed ***\n",DLLNAME
);
93 memcpy(buf
,argv
[0].strptr
,argv
[0].strlength
);
94 buf
[argv
[0].strlength
] = '\0';
95 if (strcmp(func_name
,buf
) != 0)
96 printf("%s(static): *** Mismatch of parameters: %s is NOT expected: %s ***\n",
97 DLLNAME
,buf
,func_name
);
101 void global_show_parameter(ULONG argc
, RXSTRING argv
[], PSZ func_name
)
106 printf("%s(global): *** No parameters passed ***\n",DLLNAME
);
109 memcpy(buf
,argv
[0].strptr
,argv
[0].strlength
);
110 buf
[argv
[0].strlength
] = '\0';
111 if (strcmp(func_name
,buf
) != 0)
112 printf("%s(global): *** Mismatch of parameters: %s is NOT expected: %s ***\n",
113 DLLNAME
,buf
,func_name
);
117 APIRET APIENTRY
FUNCTION1(PCSZ name
,ULONG argc
,PRXSTRING argv
,PCSZ stck
,PRXSTRING retstr
)
120 for (i
=0;i
<(int) argc
;i
++)
121 printf(" %s(Test2Function1): Arg: %d <%s>\n",DLLNAME
,i
,argv
[i
].strptr
);
122 static_show_parameter(argc
,argv
,NAME_FUNCTION1
);
123 global_show_parameter(argc
,argv
,NAME_FUNCTION1
);
124 strcpy(retstr
->strptr
,"0");
125 retstr
->strlength
= 1;
129 APIRET APIENTRY
FUNCTION2(PCSZ name
,ULONG argc
,PRXSTRING argv
,PCSZ stck
,PRXSTRING retstr
)
132 for (i
=0;i
<(int) argc
;i
++)
133 printf(" %s(Test2Function2): Arg: %d <%s>\n",DLLNAME
,i
,argv
[i
].strptr
);
134 static_show_parameter(argc
,argv
,NAME_FUNCTION2
);
135 global_show_parameter(argc
,argv
,NAME_FUNCTION2
);
136 strcpy(retstr
->strptr
,"0");
137 retstr
->strlength
= 1;
142 APIRET APIENTRY
DROPFUNCS(PCSZ name
,ULONG argc
,PRXSTRING argv
,PCSZ stck
,PRXSTRING retstr
)
145 const RexxFunction
*func
=NULL
;
147 /* DeRegister all REXX/SQL functions */
148 for (func
= RexxSqlFunctions
; func
->function_name
; func
++)
149 rc
= RexxDeregisterFunction(func
->function_name
);
150 sprintf(retstr
->strptr
,"%d",rc
);
151 retstr
->strlength
= strlen(retstr
->strptr
);
156 /*-----------------------------------------------------------------------------
157 * This function is called to initiate REXX/SQL interface.
158 *----------------------------------------------------------------------------*/
159 static int InitRexxSQL(PSZ progname
)
161 const RexxFunction
*func
=NULL
;
164 /* Register all REXX/SQL functions */
165 for (func
= RexxSqlFunctions
; func
->function_name
; func
++)
166 rc
= RexxRegisterFunctionDll(func
->function_name
,DLLNAME
,func
->function_name
);
171 APIRET APIENTRY
LOADFUNCS(PCSZ name
,ULONG argc
,PRXSTRING argv
,PCSZ stck
,PRXSTRING retstr
)
175 rc
= InitRexxSQL(DLLNAME
);
176 sprintf(retstr
->strptr
,"%d",rc
);
177 retstr
->strlength
= strlen(retstr
->strptr
);