Skip to content

Commit 5ccff14

Browse files
committed
Fix Rexx support:
- allow Regina Rexx scripts to run in background - suppress Hercules command output to the console, when capturing to a stem. The documentation states that this is the implemented behavior, but it wasn't. - prevent warnings concerning the rexxutil library when running ooRexx 5
1 parent 94129da commit 5ccff14

File tree

6 files changed

+37
-7
lines changed

6 files changed

+37
-7
lines changed

cgibin.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1279,7 +1279,7 @@ void cgibin_cmd_cmd(WEBBLK *webblk, char *command)
12791279
return; /* command is all blank, ignore */
12801280
}
12811281

1282-
panel_command_capture( command, &response );
1282+
panel_command_capture( command, &response, false );
12831283

12841284
if (response == NULL)
12851285
{

hRexxapi.c

+27-1
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ static HR_EXTFUNC_T AWSCmd
132132
PRXSTRING RetValue // Returned result string
133133
);
134134

135+
static BYTE RegisterRexxHandlersAndFunctions();
136+
135137
/*-------------------------------------------------------------------*/
136138
/* Helper function to 'sprintf' to an RXSTRING */
137139
/*-------------------------------------------------------------------*/
@@ -603,13 +605,18 @@ static HR_ERR_T HerculesCommand
603605
{
604606
HR_ERR_T err; // Hercules Rexx error code
605607
char* resp; // Response from panel_command
608+
bool quiet; // don't show response on console if true
606609

607610
/* Validate arguments and trim Hercules command line */
608611
if (!herccmd || !*TRIM( herccmd ) || !panelrc)
609612
return HRERR_BADARGS;
610613

614+
/* if response is wanted, ask Hercules to be quiet on the console */
615+
if (stemname) quiet = true;
616+
else quiet = false;
617+
611618
/* Issue the Hercules command and capture the response */
612-
*panelrc = panel_command_capture( herccmd, &resp );
619+
*panelrc = panel_command_capture( herccmd, &resp, quiet );
613620

614621
/* Format response string stem values if response is wanted */
615622
if (stemname)
@@ -879,6 +886,10 @@ static HR_REXXRC_T HRexxStart
879886
debug every call made to RexxStart without having to set many
880887
separate breakpoints all over the place.
881888
*/
889+
#if REXX_PKGNUM == REGINA_PKGNUM
890+
/* When running a Regina script in background, handlers need to be re-registered. */
891+
if (!equal_threads( thread_id(), sysblk.impltid )) RegisterRexxHandlersAndFunctions();
892+
#endif
882893
HR_REXXRC_T rc = REXX_DEP( RexxStart )
883894
(
884895
ArgCount, // Number of arguments
@@ -1272,6 +1283,21 @@ BYTE REXX_DEP( LoadExtra )( BYTE verbose )
12721283
{
12731284
libname = REXX_DEP( ExtraLibs )[i];
12741285

1286+
/* ooRexx version 5 and higher doesn't have the rexxutil library anymore */
1287+
#if REXX_PKGNUM == OOREXX_PKGNUM
1288+
if (1
1289+
&& (REXX_DEP( PackageMajorVers ) >= '5')
1290+
#if defined( _MSVC_ )
1291+
&& !strcmp( libname, "rexxutil.dll" )
1292+
#elif defined( __APPLE__ )
1293+
&& !strcmp( libname, "librexxutil.dylib" )
1294+
#else
1295+
&& !strcmp( libname, "librexxutil.so" )
1296+
#endif
1297+
)
1298+
continue;
1299+
#endif
1300+
12751301
if (libname && !(libhandle[i] = dlopen( libname, RTLD_NOW )))
12761302
{
12771303
bSuccess = FALSE;

logmsg.c

+6-2
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ CAPTCTL;
101101

102102
static CAPTCTL captctl_tab [ MAX_CPU_ENGS + 4 ] = {0};
103103
static LOCK captctl_lock;
104+
static bool wrmsg_quiet = false; // suppress panel output if true
104105

105106
#define lock_capture() obtain_lock( &captctl_lock )
106107
#define unlock_capture() release_lock( &captctl_lock );
@@ -199,13 +200,15 @@ static void capture_message( const char* msg, CAPTMSGS* pCAPTMSGS )
199200
/*-------------------------------------------------------------------*/
200201
/* Issue panel command and capture results */
201202
/*-------------------------------------------------------------------*/
202-
DLL_EXPORT int panel_command_capture( char* cmd, char** resp )
203+
DLL_EXPORT int panel_command_capture( char* cmd, char** resp, bool quiet )
203204
{
204205
int rc;
205206
CAPTCTL* pCAPTCTL; // ptr to capturing control entry
206207
CAPTMSGS captmsgs = {0}; // captured messages structure
207208

208209
/* Start capturing */
210+
wrmsg_quiet = quiet; // caller can suppress panel output
211+
// by setting quiet to true
209212
pCAPTCTL = start_capturing( &captmsgs );
210213

211214
/* Execute the Hercules panel command and save the return code */
@@ -216,6 +219,7 @@ DLL_EXPORT int panel_command_capture( char* cmd, char** resp )
216219

217220
/* Stop capturing */
218221
stop_capturing( pCAPTCTL );
222+
wrmsg_quiet = false; // reinstate panel output
219223

220224
/* Return to caller */
221225
return rc;
@@ -351,7 +355,7 @@ static void flog_write( int panel, FILE* f, const char* msg )
351355
}
352356

353357
/* If write to panel wanted, send message through logmsg pipe */
354-
if (panel & WRMSG_PANEL)
358+
if ((panel & WRMSG_PANEL) && !wrmsg_quiet)
355359
_flog_write_pipe( f, msg );
356360

357361
/* Capture this message if capturing is active for this thread */

msgenu.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ HHCnnnnns message-text...
7979
/*-------------------------------------------------------------------*/
8080
LOGM_DLL_IMPORT void fwritemsg( const char* filename, int line, const char* func, BYTE panel, FILE* f, const char* fmt, ... ) ATTR_PRINTF( 6, 7 );
8181
LOGM_DLL_IMPORT void logmsg( const char* fmt, ... ) ATTR_PRINTF( 1, 2 );
82-
LOGM_DLL_IMPORT int panel_command_capture( char* cmd, char** resp );
82+
LOGM_DLL_IMPORT int panel_command_capture( char* cmd, char** resp, bool quiet );
8383

8484
/*-------------------------------------------------------------------*/
8585
/* PRIMARY MESAGE MACROS */

readme/README.REXX.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Support for either package can be enabled or disabled (Linux only) by simply spe
3030
* `--disable-object-rexx` and/or
3131
* `--enable-regina-rexx`
3232

33-
configure option at build time.
33+
configure option at build time. Note that enabling both packages requires them to be installed in different paths, for example ooRexx in /usr local and Regina Rexx in /usr. If both packages are installed in the same path, scripts transfering data from and to Rexx variables or stems may produce incorrect results or hang the whole Hercules system, particularly if they are executed in the background.
3434

3535
On Windows, the only way to purposely disable support is to rename the header file(s) to prevent Hercules from finding them.
3636

vm.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1155,7 +1155,7 @@ int freeresp; /* Flag to free resp */
11551155
/* Issue the command and capture the response */
11561156
if (cmdflags & CMDFLAGS_RESPONSE)
11571157
{
1158-
panel_command_capture( cmd, &resp );
1158+
panel_command_capture( cmd, &resp, false );
11591159

11601160
if (resp)
11611161
freeresp = 1;

0 commit comments

Comments
 (0)