mirror of
https://github.com/VARCem/PDCurses.git
synced 2026-09-24 07:45:21 +00:00
Handle package constants; needs more work.
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
* Mark Hessling M.Hessling@qut.edu.au http://www.lightlink.com/hessling/
|
||||
*/
|
||||
|
||||
static char RCSid[] = "$Id: loader.c,v 1.13 2003/02/17 06:36:38 mark Exp $";
|
||||
static char RCSid[] = "$Id: loader.c,v 1.14 2003/02/19 07:38:21 mark Exp $";
|
||||
|
||||
#include "rxpack.h"
|
||||
|
||||
@@ -44,6 +44,7 @@ extern PackageInitialiser *GETPACKAGEINITIALISER();
|
||||
extern PackageTerminator *GETPACKAGETERMINATOR();
|
||||
extern RexxSubcomHandler *GETPACKAGESUBCOMHANDLER();
|
||||
extern RexxFunction *GETPACKAGEFUNCTIONS();
|
||||
extern RxPackageConstantDef *GETPACKAGECONSTANTS();
|
||||
extern void PACKAGEUSAGE();
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
@@ -221,6 +222,10 @@ int main
|
||||
*/
|
||||
if ( ( rc = RegisterRxSubcom( RxPackageGlobalData, GETPACKAGESUBCOMHANDLER() ) ) != 0 )
|
||||
return( rc );
|
||||
/*
|
||||
* Set the constants for the package
|
||||
*/
|
||||
SetPackageConstants( RxPackageGlobalData, GETPACKAGECONSTANTS(), RXPACKAGENAME );
|
||||
FunctionPrologue( RxPackageGlobalData, GETPACKAGEINITIALISER(), RXPACKAGENAME, 0L, NULL );
|
||||
/*
|
||||
* Set up the system exit for the Say and Trace redirection
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
static char RCSid[] = "$Id: rxpack.c,v 1.23 2003/02/17 10:05:45 mark Exp $";
|
||||
static char RCSid[] = "$Id: rxpack.c,v 1.24 2003/02/19 07:38:22 mark Exp $";
|
||||
|
||||
#include "rxpack.h"
|
||||
|
||||
@@ -204,6 +204,12 @@ int SetRexxVariable
|
||||
ULONG rc=0L;
|
||||
SHVBLOCK shv;
|
||||
|
||||
/*
|
||||
* Uppercase the variable before we do anything. That way all debugging
|
||||
* output reflects the "real" name we are setting.
|
||||
*/
|
||||
( void )make_upper( name );
|
||||
|
||||
InternalTrace( RxPackageGlobalData, "SetRexxVariable", "\"%s\",%d,\"%s\",%d", name, namelen, value, valuelen );
|
||||
|
||||
if ( RxPackageGlobalData->RxRunFlags & MODE_DEBUG)
|
||||
@@ -215,7 +221,6 @@ int SetRexxVariable
|
||||
MkAsciz( buf1, sizeof( buf1 ), name, namelen ),
|
||||
MkAsciz( buf2, sizeof( buf2 ), value, valuelen ) );
|
||||
}
|
||||
( void )make_upper( name );
|
||||
shv.shvnext = ( SHVBLOCK* )NULL;
|
||||
shv.shvcode = RXSHV_SET;
|
||||
MAKERXSTRING( shv.shvname, name, ( ULONG )namelen );
|
||||
@@ -1436,6 +1441,69 @@ int DeregisterRxFunctions
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* This function sets all package constants...
|
||||
*----------------------------------------------------------------------------*/
|
||||
int SetPackageConstants
|
||||
|
||||
#ifdef HAVE_PROTO
|
||||
( RxPackageGlobalDataDef *RxPackageGlobalData, RxPackageConstantDef *RxConstants, char *pname )
|
||||
#else
|
||||
( RxPackageGlobalData, RxConstants, pname )
|
||||
RxPackageGlobalDataDef *RxPackageGlobalData;
|
||||
RxPackageConstantDef *RxConstants;
|
||||
char *pname;
|
||||
#endif
|
||||
|
||||
{
|
||||
int i,varlen,vallen,rc;
|
||||
char varname[250];
|
||||
char *value;
|
||||
char buf[100];
|
||||
RxPackageConstantDef *con=NULL;
|
||||
|
||||
InternalTrace( RxPackageGlobalData, "SetPackageConstants" );
|
||||
|
||||
/*
|
||||
* Before we set the new constants, drop the previous stem.
|
||||
* This may fail because we don't have a stem yet.
|
||||
*/
|
||||
for ( con=RxConstants; con->name; con++ )
|
||||
{
|
||||
varlen = sprintf( varname, "%s%s.%s%s",
|
||||
RxPackageGlobalData->ConstantPrefix,
|
||||
pname,
|
||||
RxPackageGlobalData->ConstantPrefix,
|
||||
con->name );
|
||||
switch( con->type )
|
||||
{
|
||||
case 0:
|
||||
vallen = sprintf( buf, "%ld", con->numeric_value );
|
||||
value = buf;
|
||||
break;
|
||||
case 1:
|
||||
varlen = strlen( con->text_value );
|
||||
value = con->text_value;
|
||||
break;
|
||||
case 2:
|
||||
varlen = sprintf( buf, "%f", con->double_value );
|
||||
value = buf;
|
||||
break;
|
||||
case 3:
|
||||
varlen = sprintf( buf, "%c", con->char_value );
|
||||
value = buf;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
/*
|
||||
* Now set the Rexx variable
|
||||
*/
|
||||
rc = SetRexxVariable( RxPackageGlobalData, varname, varlen, value, vallen );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* This function is called to initialise the package
|
||||
*----------------------------------------------------------------------------*/
|
||||
@@ -1643,11 +1711,12 @@ char *RxGetTraceFile
|
||||
int RxSetConstantPrefix
|
||||
|
||||
#ifdef HAVE_PROTO
|
||||
( RxPackageGlobalDataDef *RxPackageGlobalData, char *name )
|
||||
( RxPackageGlobalDataDef *RxPackageGlobalData, char *name, int setvars )
|
||||
#else
|
||||
( RxPackageGlobalData, name )
|
||||
( RxPackageGlobalData, name, setvars )
|
||||
RxPackageGlobalDataDef *RxPackageGlobalData;
|
||||
char *name;
|
||||
int setvars;
|
||||
#endif
|
||||
|
||||
{
|
||||
@@ -1661,6 +1730,11 @@ int RxSetConstantPrefix
|
||||
return( 1 );
|
||||
}
|
||||
strcpy( RxPackageGlobalData->ConstantPrefix, name );
|
||||
/*
|
||||
* Set the packages constants now, if allowed...
|
||||
*/
|
||||
if ( setvars )
|
||||
SetPackageConstants( RxPackageGlobalData, RxPackageConstantDef *RxConstants, char *pname )
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
|
||||
@@ -206,6 +206,19 @@ typedef struct
|
||||
int terminated; /* indicates if rxpack has called RxTermPackage() for this structure */
|
||||
} RxPackageGlobalDataDef;
|
||||
|
||||
/*
|
||||
* The following structure contains details of a package's constants
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
char *name; /* base name of constant */
|
||||
int type; /* 0 (numeric), 1 (text), 2 (float), 3 (char) */
|
||||
long numeric_value; /* numeric value of constant */
|
||||
char *text_value; /* text value of constant */
|
||||
double double_value; /* double value of constant */
|
||||
char char_value; /* char value of constant */
|
||||
} RxPackageConstantDef;
|
||||
|
||||
typedef int PackageInitialiser( RxPackageGlobalDataDef * );
|
||||
typedef int PackageTerminator( RxPackageGlobalDataDef * );
|
||||
|
||||
@@ -226,6 +239,7 @@ int RegisterRxFunctions Args(( RxPackageGlobalDataDef *, RexxFunction *, char *
|
||||
int RegisterRxSubcom Args(( RxPackageGlobalDataDef *, RexxSubcomHandler ));
|
||||
int QueryRxFunction Args(( RxPackageGlobalDataDef *, char * ));
|
||||
int DeregisterRxFunctions Args(( RxPackageGlobalDataDef *, RexxFunction *, int ));
|
||||
int SetPackageConstants Args(( RxPackageGlobalDataDef *, RxPackageConstantDef *, char * ));
|
||||
char *make_upper Args(( char * ));
|
||||
char *AllocString Args(( char *, int ));
|
||||
char *MkAsciz Args(( char *, int, char *, int ));
|
||||
@@ -237,7 +251,7 @@ int StrToNumber Args(( RXSTRING *, LONG * ));
|
||||
int StrToBool Args(( RXSTRING *, ULONG * ));
|
||||
int RxSetTraceFile Args(( RxPackageGlobalDataDef *, char * ));
|
||||
char *RxGetTraceFile Args(( RxPackageGlobalDataDef * ));
|
||||
int RxSetConstantPrefix Args(( RxPackageGlobalDataDef *, char * ));
|
||||
int RxSetConstantPrefix Args(( RxPackageGlobalDataDef *, char *, int ));
|
||||
char *RxGetConstantPrefix Args(( RxPackageGlobalDataDef * ));
|
||||
void RxSetRunFlags Args(( RxPackageGlobalDataDef *, int ));
|
||||
int RxGetRunFlags Args(( RxPackageGlobalDataDef * ));
|
||||
|
||||
Reference in New Issue
Block a user