BB2 C port
API reference: Blitz libraries in C and the shared code
Loading...
Searching...
No Matches
arexxlib.c File Reference
#include "blitzlib.h"
#include "blitzexec.h"
#include <exec/execbase.h>
#include <rexx/storage.h>
#include <rexx/rxslib.h>
#include <proto/rexxsyslib.h>
#include <proto/intuition.h>

Macros

#define __NOLIBBASE__
#define ALERT(text)
#define ERR_REXXSYS   0
#define ERR_NOMEM   4
#define ERR_NOPORT   8
#define ARGSLOTS   (MAXRMARG + 1)
#define ARGHEAD(s)

Functions

void _CreateRexxMsg (void)
void _DeleteRexxMsg (void)
void _FillRexxMsg (void)
void _ClearRexxMsg (void)
void _CreateArgString (void)
void _DeleteArgString (void)
void _SendRexxCommand (void)
void _ReplyRexxMsg (void)
void _GetRexxResult (void)
void _GetRexxCommand (void)
void _GetResultString (void)
void _RexxEvent (void)
void _IsRexxMsg (void)
void _RexxError (void)
void SetUpRoutine (void)
void arexxlib_CloseRoutine (void)
void getrexxresultchk (void)
void getrexxcommandchk (void)
static ULONG error_routine (ULONG code)
static int tstrexxmsg (ULONG msg)
static int tstargstring (ULONG arg)
static ULONG createargstring (const UBYTE *s, ULONG len)
static void deleteargstring_rexx (ULONG arg)
static ULONG createargstring_rexx (ULONG str, ULONG len)
static void deleteargstring (ULONG arg)
static void clearrexxmsg (ULONG msg)
static WORD argindex (ULONG n)
static ULONG setup_c (void)
 SetUpRoutine (init): OldOpenLibrary("rexxsyslib.library").
static void close_c (void)
 CloseRoutine (finit): CloseLibrary(RexxSysBase) if it was opened.
static ULONG createrexxmsg_c (ULONG port, ULONG exten, ULONG host, const ULONG *lens)
 CreateRexxMsg(ReplyPort,Exten,Host): a RexxMsg of 128 bytes.
 BLITZ_ALIAS (_CreateRexxMsg, createrexxmsg_c)
static void deleterexxmsg_c (ULONG msg)
 DeleteRexxMsg rexxmsg: delete rm_FileExt, rm_CommAddr and the message (mn_Length bytes, memlib globfree).
 BLITZ_ALIAS (_DeleteRexxMsg, deleterexxmsg_c)
static void clearrexxmsg_c (ULONG msg)
 ClearRexxMsg rexxmsg: delete the ArgStrings of rm_Args[].
 BLITZ_ALIAS (_ClearRexxMsg, clearrexxmsg_c)
static void fillrexxmsg_c (ULONG msg, const UBYTE *fill)
 FillRexxMsg rexxmsg,&FillStruct: fill rm_Args[] from a FillStruct.
 BLITZ_ALIAS (_FillRexxMsg, fillrexxmsg_c)
static ULONG createargstring_c (const UBYTE *s, const ULONG *lens)
 CreateArgString(String): a BB2 ArgString.
 BLITZ_ALIAS (_CreateArgString, createargstring_c)
static void deleteargstring_c (ULONG arg)
 DeleteArgString argstring: free an ArgString.
 BLITZ_ALIAS (_DeleteArgString, deleteargstring_c)
static void sendrexxcommand_c (ULONG msg, ULONG cmd, ULONG action, const ULONG *lens)
 SendRexxCommand rexxmsg,CommandString,ActionCodes: send the message to the public port "REXX".
 BLITZ_ALIAS (_SendRexxCommand, sendrexxcommand_c)
static void replyrexxmsg_c (ULONG msg, ULONG res1, ULONG res2, ULONG str, const ULONG *lens)
 ReplyRexxMsg rexxmsg,Result1,Result2,ResultString: reply to a message from ARexx.
 BLITZ_ALIAS (_ReplyRexxMsg, replyrexxmsg_c)
static ULONG getrexxresult_c (ULONG msg, ULONG n)
 GetRexxResult(rexxmsg,ResultNum): rm_Result1 (1) or rm_Result2 (2).
 BLITZ_ALIAS (_GetRexxResult, getrexxresult_c)
static ULONG copyarg (const UBYTE *s)
static ULONG getrexxcommand_c (ULONG msg, ULONG n)
 GetRexxCommand(rexxmsg,ARGNum): rm_Args[ARGNum-1] as string.
 BLITZ_ALIAS (_GetRexxCommand, getrexxcommand_c)
static ULONG getresultstring_c (ULONG msg)
 GetResultString(rexxmsg): rm_Result2 as string, then the ArgString is deleted.
 BLITZ_ALIAS (_GetResultString, getresultstring_c)
static ULONG rexxevent_c (struct MsgPort *port)
 RexxEvent(PortAddress): the first message of the port, removed.
 BLITZ_ALIAS (_RexxEvent, rexxevent_c)
static ULONG isrexxmsg_c (ULONG msg)
 IsRexxMsg(rexxmsg): rexxsyslib IsRexxMsg.
 BLITZ_ALIAS (_IsRexxMsg, isrexxmsg_c)
static ULONG rexxerror_c (ULONG code)
 RexxError(ErrorCode): the ARexx error message as string.
 BLITZ_ALIAS (_RexxError, rexxerror_c)
static void getrexxresultchk_c (ULONG n)
 The error check of GetRexxResult (debugger only).
static void getrexxcommandchk_c (ULONG n)
 The error check of GetRexxCommand (debugger only).

Variables

static struct RxsLib * RexxSysBase
static struct IntuitionBase * IntuitionBase
static const char RexxSysName [] = "rexxsyslib.library"
static const char IntName [] = "intuition.library"
static char REXXName [] = "REXX"
static const char RENoError [] = "Returned Error not known to Arexx"
static const char OpenRexx [] = ALERT("SORRY CAN NOT OPEN REXXSYSLIB.LIBRARY")
static const char NoMem [] = ALERT("SORRY CAN NOT ALLOCATE THE MEMORY")
static const char NoRexxPort [] = ALERT("SORRY CAN NOT FIND THE REXXPORT")
static const char NoSig [] = ALERT("SORRY CAN NOT ALLOCATE SIGNAL TO PORT")
static const char Unknown [] = ALERT("AN UNKNOWN ERROR HAS OCCURED")
static const char *const Error_Table []
static ULONG frmcstorage

Macro Definition Documentation

◆ __NOLIBBASE__

#define __NOLIBBASE__

◆ ALERT

#define ALERT ( text)
Value:
"\0\226\017" text "\0\001\0\226\031" \
"PRESS ANY MOUSE BUTTON TO CONTINUE\0"
Definition basictest_read.c:318

◆ ARGHEAD

#define ARGHEAD ( s)
Value:
((struct RexxArg *)((UBYTE *)(s) - 8))

◆ ARGSLOTS

#define ARGSLOTS   (MAXRMARG + 1)

◆ ERR_NOMEM

#define ERR_NOMEM   4

◆ ERR_NOPORT

#define ERR_NOPORT   8

◆ ERR_REXXSYS

#define ERR_REXXSYS   0

Function Documentation

◆ _ClearRexxMsg()

void _ClearRexxMsg ( void )

◆ _CreateArgString()

void _CreateArgString ( void )

◆ _CreateRexxMsg()

void _CreateRexxMsg ( void )

◆ _DeleteArgString()

void _DeleteArgString ( void )

◆ _DeleteRexxMsg()

void _DeleteRexxMsg ( void )

◆ _FillRexxMsg()

void _FillRexxMsg ( void )

◆ _GetResultString()

void _GetResultString ( void )

◆ _GetRexxCommand()

void _GetRexxCommand ( void )

◆ _GetRexxResult()

void _GetRexxResult ( void )

◆ _IsRexxMsg()

void _IsRexxMsg ( void )

◆ _ReplyRexxMsg()

void _ReplyRexxMsg ( void )

◆ _RexxError()

void _RexxError ( void )

◆ _RexxEvent()

void _RexxEvent ( void )

◆ _SendRexxCommand()

void _SendRexxCommand ( void )

◆ arexxlib_CloseRoutine()

void arexxlib_CloseRoutine ( void )

◆ argindex()

WORD argindex ( ULONG n)
static

◆ BLITZ_ALIAS() [1/14]

BLITZ_ALIAS ( _ClearRexxMsg ,
clearrexxmsg_c  )

◆ BLITZ_ALIAS() [2/14]

BLITZ_ALIAS ( _CreateArgString ,
createargstring_c  )

◆ BLITZ_ALIAS() [3/14]

BLITZ_ALIAS ( _CreateRexxMsg ,
createrexxmsg_c  )

◆ BLITZ_ALIAS() [4/14]

BLITZ_ALIAS ( _DeleteArgString ,
deleteargstring_c  )

◆ BLITZ_ALIAS() [5/14]

BLITZ_ALIAS ( _DeleteRexxMsg ,
deleterexxmsg_c  )

◆ BLITZ_ALIAS() [6/14]

BLITZ_ALIAS ( _FillRexxMsg ,
fillrexxmsg_c  )

◆ BLITZ_ALIAS() [7/14]

BLITZ_ALIAS ( _GetResultString ,
getresultstring_c  )

◆ BLITZ_ALIAS() [8/14]

BLITZ_ALIAS ( _GetRexxCommand ,
getrexxcommand_c  )

◆ BLITZ_ALIAS() [9/14]

BLITZ_ALIAS ( _GetRexxResult ,
getrexxresult_c  )

◆ BLITZ_ALIAS() [10/14]

BLITZ_ALIAS ( _IsRexxMsg ,
isrexxmsg_c  )

◆ BLITZ_ALIAS() [11/14]

BLITZ_ALIAS ( _ReplyRexxMsg ,
replyrexxmsg_c  )

◆ BLITZ_ALIAS() [12/14]

BLITZ_ALIAS ( _RexxError ,
rexxerror_c  )

◆ BLITZ_ALIAS() [13/14]

BLITZ_ALIAS ( _RexxEvent ,
rexxevent_c  )

◆ BLITZ_ALIAS() [14/14]

BLITZ_ALIAS ( _SendRexxCommand ,
sendrexxcommand_c  )

◆ clearrexxmsg()

void clearrexxmsg ( ULONG msg)
static

◆ clearrexxmsg_c()

void clearrexxmsg_c ( ULONG msg)
static

ClearRexxMsg rexxmsg: delete the ArgStrings of rm_Args[].

All 16 slots, each slot cleared (the guide: "from slot number 1 forward to 16"). Fixed (#49): the original had no limit of 16 and with all slots used went on into rm_PassPort, rm_CommAddr, rm_FileExt ... (deleted and cleared). Fixed (#50): the original stopped at the first 0 slot; FillRexxMsg now stores an integer 0, with more arguments behind it. An integer in a slot is "deleted" if the memory before it looks like an ArgString. Not a RexxMsg (rexxsyslib IsRexxMsg): nothing happens. Without rexxsyslib: its alert, then nothing happens (fixed, #56: the original took the message as valid with address 0).

Parameters
msgd0: the RexxMsg

◆ close_c()

void close_c ( void )
static

CloseRoutine (finit): CloseLibrary(RexxSysBase) if it was opened.

◆ copyarg()

ULONG copyarg ( const UBYTE * s)
static

◆ createargstring()

ULONG createargstring ( const UBYTE * s,
ULONG len )
static

◆ createargstring_c()

ULONG createargstring_c ( const UBYTE * s,
const ULONG * lens )
static

CreateArgString(String): a BB2 ArgString.

A RexxArg in memory of memlib (globalloc, MEMF_PUBLIC|MEMF_CLEAR): ra_Size = length+9 with bit 31 set (allocated by Blitz), ra_Length, ra_Flags $46, ra_Hash = byte sum of the characters, the characters and a 0. At most 65535 characters (ra_Length is a word): a longer string is cut to 65535 (fixed, #57: the original allocated length+9 bytes but copied and stored length & $FFFF). a3 = the string afterwards (not a bug, intended).

Parameters
sd0: the string
lensa2: the compiler's string stack, -4(a2) = its length
Returns
d0: the ArgString (its characters, ra_Buff), 0 if there is no memory

◆ createargstring_rexx()

ULONG createargstring_rexx ( ULONG str,
ULONG len )
static

◆ createrexxmsg_c()

ULONG createrexxmsg_c ( ULONG port,
ULONG exten,
ULONG host,
const ULONG * lens )
static

CreateRexxMsg(ReplyPort,Exten,Host): a RexxMsg of 128 bytes.

memlib globalloc (MEMF_PUBLIC|MEMF_CLEAR); ln_Name "REXX" (so that rexxsyslib IsRexxMsg accepts it), mn_ReplyPort, mn_Length 128, rm_FileExt/rm_CommAddr = BB2 ArgStrings of the extension and host strings. a3 = the extension afterwards (not a bug, intended: "preserve the BB2 string work area"). DIFF: the host length -8(a2) is not copied to -4(a2) on the compiler's stack, a2 is never changed. Errors: no memory - recoverable alert ("SORRY CAN NOT ALLOCATE THE MEMORY"), d0 = the error code 4.

Parameters
portd0: the reply port
extend1: the file extension string
hostd2: the host address string
lensa2: the compiler's string stack, -4(a2)/-8(a2) = the lengths of exten/host
Returns
d0: the RexxMsg, or the error code (4) after the alert

◆ deleteargstring()

void deleteargstring ( ULONG arg)
static

◆ deleteargstring_c()

void deleteargstring_c ( ULONG arg)
static

DeleteArgString argstring: free an ArgString.

BB2 ArgStrings (bit 31 of ra_Size) go to memlib globfree, others to rexxsyslib DeleteArgstring; anything that does not look like an ArgString (the string length up to the 0 is not ra_Length) is left alone.

Parameters
argd0: the ArgString

◆ deleteargstring_rexx()

void deleteargstring_rexx ( ULONG arg)
static

◆ deleterexxmsg_c()

void deleterexxmsg_c ( ULONG msg)
static

DeleteRexxMsg rexxmsg: delete rm_FileExt, rm_CommAddr and the message (mn_Length bytes, memlib globfree).

Not a RexxMsg (rexxsyslib IsRexxMsg): nothing happens. Without rexxsyslib: its alert, then nothing happens (fixed, #56: the original took the message as valid with address 0).

Parameters
msgd0: the RexxMsg

◆ error_routine()

ULONG error_routine ( ULONG code)
static

◆ fillrexxmsg_c()

void fillrexxmsg_c ( ULONG msg,
const UBYTE * fill )
static

FillRexxMsg rexxmsg,&FillStruct: fill rm_Args[] from a FillStruct.

FillStruct = {flags.w, value.l, ..., 0}: flag bit 15-n set = value n is an integer, else a C string that becomes a BB2 ArgString. A string value of 0 ends the list; an integer slot takes its value, 0 too (fixed, #50: the original tested every value for 0 before the flag, an integer 0 ended the list). At most the 16 slots are filled (fixed, #49: the original had no limit, a 17th value went to rm_PassPort, the next ones to rm_CommAddr ...). Errors: no memory - recoverable alert, the rest is not filled. Not a RexxMsg (rexxsyslib IsRexxMsg): nothing happens. Without rexxsyslib: its alert, then nothing happens (fixed, #56: the original took the message as valid with address 0).

Parameters
msgd0: the RexxMsg
filld1: the FillStruct

◆ getresultstring_c()

ULONG getresultstring_c ( ULONG msg)
static

GetResultString(rexxmsg): rm_Result2 as string, then the ArgString is deleted.

Copied to a3 as GetRexxCommand (fixed, #52: a3 ends on the 0). rm_Result2 is cleared then (fixed, #53: the original left it pointing to the deleted ArgString, a second call worked with freed memory).

Parameters
msgd0: the RexxMsg
Returns
d0: the string length; 0 if msg is no RexxMsg or rm_Result2 is no ArgString

◆ getrexxcommand_c()

ULONG getrexxcommand_c ( ULONG msg,
ULONG n )
static

GetRexxCommand(rexxmsg,ARGNum): rm_Args[ARGNum-1] as string.

Copies the ArgString to a3 (the string work area), a3 ends on the 0. Fixed (#52): the original left a3 BEHIND the 0. Errors (debugger only, getrexxcommandchk): "Illegal Argument Number" for an n outside 1 to 16 (fixed, #51: the original had no check; without the debugger the index is a word, n = 0 reads rm_Result2, an invalid argument).

Parameters
msgd0: the RexxMsg
nd1: 1..16
Returns
d0: the string length; 0 if msg is no RexxMsg or the slot is no ArgString

◆ getrexxcommandchk()

void getrexxcommandchk ( void )

◆ getrexxcommandchk_c()

void getrexxcommandchk_c ( ULONG n)
static

The error check of GetRexxCommand (debugger only).

Fixed (#51), not in the original (GetRexxCommand did not check the number): ARGNum must be a slot of rm_Args[], 1 to 16, as the guide says.

Errors: "Illegal Argument Number".

Parameters
nd1: ARGNum

◆ getrexxresult_c()

ULONG getrexxresult_c ( ULONG msg,
ULONG n )
static

GetRexxResult(rexxmsg,ResultNum): rm_Result1 (1) or rm_Result2 (2).

Errors (debugger only, getrexxresultchk): "Illegal Result Number" for an n other than 1 or 2 (fixed, #51: the original had no check; without the debugger the index (n-1)*4 is a word (MULU, d1.w), n = 0 reads rm_Action, an invalid argument). Without rexxsyslib: the alert, then 0 (fixed, #56: the original read the field of a message at address 0).

Parameters
msgd0: the RexxMsg
nd1: 1 or 2
Returns
d0: the result, 0 if msg is no RexxMsg

◆ getrexxresultchk()

void getrexxresultchk ( void )

◆ getrexxresultchk_c()

void getrexxresultchk_c ( ULONG n)
static

The error check of GetRexxResult (debugger only).

Fixed (#51), not in the original (GetRexxResult did not check the number): ResultNum must be 1 (rm_Result1) or 2 (rm_Result2), as the guide says.

Errors: "Illegal Result Number".

Parameters
nd1: ResultNum

◆ isrexxmsg_c()

ULONG isrexxmsg_c ( ULONG msg)
static

IsRexxMsg(rexxmsg): rexxsyslib IsRexxMsg.

The result is 1 or 0, not the Blitz truth values -1/0.

Parameters
msgd0: the message
Returns
d0: 1 if it is a RexxMsg, else 0; without rexxsyslib the error code 0 after the alert

◆ replyrexxmsg_c()

void replyrexxmsg_c ( ULONG msg,
ULONG res1,
ULONG res2,
ULONG str,
const ULONG * lens )
static

ReplyRexxMsg rexxmsg,Result1,Result2,ResultString: reply to a message from ARexx.

Sets rm_Result1/rm_Result2 and ReplyMsg()s the message (not for one that is already a reply). The result ArgString (rexxsyslib, freed by ARexx) is made when Result1 = 0 and the sender asked for a result (RXFF_RESULT in rm_Action). Fixed (#48): the original tested BTST #17,28(a0) - bit 1 of the HIGH byte of rm_Action, i.e. RXFUNC, not RXFF_RESULT. a3 = the result string afterwards (not a bug, intended). DIFF: with something that is not a RexxMsg it returns; the original pulls 15 registers it never pushed (crash). Errors: no memory - recoverable alert, no reply.

Parameters
msgd0: the RexxMsg
res1d1: rm_Result1
res2d2: rm_Result2
strd3: the result string
lensa2: the compiler's string stack, -4(a2) = the result string's length

◆ rexxerror_c()

ULONG rexxerror_c ( ULONG code)
static

RexxError(ErrorCode): the ARexx error message as string.

rexxsyslib ErrorMsg (LVO -96: d0 = code -> d0 = found, a0 = NexxStr), copied to a3. Not a bug (no visible effect): copied up to (not including) its 0, at least one byte, no terminating 0 (the compiler appends it where it passes a string on, blitz2.s:8767 sbtolong); unknown code: "Returned Error not known to Arexx".

Parameters
coded0: the error code
Returns
d0: the string length (word count); without rexxsyslib the error code 0 after the alert

◆ rexxevent_c()

ULONG rexxevent_c ( struct MsgPort * port)
static

RexxEvent(PortAddress): the first message of the port, removed.

Not a bug (by design): removes the message like exec GetMsg (own copy with INTENA and IDNestCnt) and returns replies as well; a reply first gets its arguments deleted (ClearRexxMsg).

Parameters
portd0: the message port
Returns
d0: the message, 0 if there is none (or port is 0)

◆ sendrexxcommand_c()

void sendrexxcommand_c ( ULONG msg,
ULONG cmd,
ULONG action,
const ULONG * lens )
static

SendRexxCommand rexxmsg,CommandString,ActionCodes: send the message to the public port "REXX".

Creates the command ArgString only if rm_Args[0] is 0 (not a bug: keeps an ArgString the user put into slot 0), sets rm_Action and PutMsg()s the message (FindPort under Disable). a3 = the command afterwards (valid RexxMsg only; not a bug, intended). Errors: no memory - recoverable alert; no REXX port - recoverable alert ("SORRY CAN NOT FIND THE REXXPORT"), after the Enable (fixed, #55: the original showed it and returned with interrupts still disabled). Not a RexxMsg (rexxsyslib IsRexxMsg): nothing happens. Without rexxsyslib: its alert, then nothing happens (fixed, #56: the original took the message as valid with address 0).

Parameters
msgd0: the RexxMsg
cmdd1: the command string
actiond2: rm_Action
lensa2: the compiler's string stack, -4(a2) = the command's length

◆ setup_c()

ULONG setup_c ( void )
static

SetUpRoutine (init): OldOpenLibrary("rexxsyslib.library").

On failure a recoverable alert ("SORRY CAN NOT OPEN REXXSYSLIB.LIBRARY", Error_Routine1).

Returns
d0: RexxSysBase, or the error code 0 after the alert

◆ SetUpRoutine()

void SetUpRoutine ( void )

◆ tstargstring()

int tstargstring ( ULONG arg)
static

◆ tstrexxmsg()

int tstrexxmsg ( ULONG msg)
static

Variable Documentation

◆ Error_Table

const char* const Error_Table[]
static
Initial value:
= {
}
static const char OpenRexx[]
Definition arexxlib.c:228
static const char NoSig[]
Definition arexxlib.c:231
static const char NoMem[]
Definition arexxlib.c:229
static const char NoRexxPort[]
Definition arexxlib.c:230
static const char Unknown[]
Definition arexxlib.c:232

◆ frmcstorage

ULONG frmcstorage
static

◆ IntName

const char IntName[] = "intuition.library"
static

◆ IntuitionBase

struct IntuitionBase* IntuitionBase
static

◆ NoMem

const char NoMem[] = ALERT("SORRY CAN NOT ALLOCATE THE MEMORY")
static

◆ NoRexxPort

const char NoRexxPort[] = ALERT("SORRY CAN NOT FIND THE REXXPORT")
static

◆ NoSig

const char NoSig[] = ALERT("SORRY CAN NOT ALLOCATE SIGNAL TO PORT")
static

◆ OpenRexx

const char OpenRexx[] = ALERT("SORRY CAN NOT OPEN REXXSYSLIB.LIBRARY")
static

◆ RENoError

const char RENoError[] = "Returned Error not known to Arexx"
static

◆ REXXName

char REXXName[] = "REXX"
static

◆ RexxSysBase

struct RxsLib* RexxSysBase
static

◆ RexxSysName

const char RexxSysName[] = "rexxsyslib.library"
static

◆ Unknown

const char Unknown[] = ALERT("AN UNKNOWN ERROR HAS OCCURED")
static