|
BB2 C port
API reference: Blitz libraries in C and the shared code
|
#include "blitzlib.h"#include "blitzexec.h"#include <exec/ports.h>#include <exec/memory.h>#include <rexx/storage.h>#include <proto/dos.h>Data Structures | |
| struct | msglists |
Macros | |
| #define | __NOLIBBASE__ |
| #define | DOS_BASE_NAME dosbase |
| #define | AO BLITZ_AMIGAONLY |
| #define | MSGLIST_FULL() |
| #define | NOWORD ((ULONG)-1) |
| #define | REPLYWAIT_TICKS 250 |
Functions | |
| void | _rxcreateport (void) |
| void | _rxdeleteport (void) |
| void | readport (void) |
| void | waitport (void) |
| void | _replymsg (void) |
| void | _replymsg2 (void) |
| void | _rxruncommand2 (void) |
| void | _rxruncommand (void) |
| void | _rxsendersname (void) |
| void | _rxsendcommand2 (void) |
| void | _rxsendcommand (void) |
| void | _rxnumargs (void) |
| void | _rxgetarg (void) |
| void | _rxexecutescript (void) |
| void | _rxrunscript (void) |
| void | _rxdefportname (void) |
| void | _rxnextarg (void) |
| void | _rxreturncode (void) |
| void | _rxtokenise (void) |
| void | _rxmessagelist (void) |
| void | _rxquotechar (void) |
| void | riarexxlib_libinit (void) |
| void | riarexxlib_libfinit (void) |
| void | portchk (void) |
| static void | portchk_c (void) |
| static void * | allocvec (ULONG size, ULONG flags) |
| static void | freevec (void *block) |
| static ULONG | createargstring_lib (const UBYTE *s, ULONG len) |
| static ULONG | createargstring (const UBYTE *s, ULONG len) |
| static void | deleteargstring (ULONG s) |
| static ULONG | allocst (ULONG s, ULONG len) |
| static void | freest (ULONG s) |
| static ULONG | tostring (const UBYTE *s) |
| static ULONG | libinit_c (void) |
| init: open rexxsyslib.library V34; the defaults (quote '"', RXTokenise on, the default port "REXX"). | |
| static void | deleteport (BB_BOOL freename) |
| static void | libfinit_c (void) |
| finit: RXTokenise on again, delete the port if there is one (as RXDeletePort, with its wait of up to 5 s for the replies of the sent list (fixed #1095); the name is left to maxslib, which frees its strings at the end of the program), close rexxsyslib.library. | |
| static void | rxquotechar_c (const UBYTE *s) |
| RXQuoteChar char$: the quote character of the parser (RXTokenise on; default '"'). | |
| static ULONG | rxmessagelist_c (void) |
| RXMessageList: the list of received messages not yet current. | |
| static void | rxtokenise_c (ULONG on) |
| RXTokenise on|off: whether commands are split into words (with RXQuoteChar quotes) or sent as one argument string. | |
| static ULONG | rxreturncode_c (void) |
| RXReturnCode: the Result1 of the last reply to RXSendCommand. | |
| static void | rxdefportname_c (const UBYTE *s) |
| RXDefaultPort portname$: the port of the forms of RXRunCommand and RXSendCommand without a port name. | |
| static const UBYTE * | defport (void) |
| static void | addtolist (ULONG *l, ULONG item) |
| static BB_BOOL | addsent (ULONG item) |
| static ULONG * | findsent (ULONG item) |
| static void | deleteitem (ULONG *item) |
| static void | parseinit (const UBYTE *s) |
| static ULONG | nextparsearg (UBYTE *out) |
| static struct RexxMsg * | makemsg (void) |
| static void | makemsgargs (UBYTE *word) |
| static ULONG | waitport_c (ULONG result) |
| static ULONG | readport_c (void) |
| RXReadPort: take every message from the port; the first of the message list becomes the current message. | |
| static ULONG | sendmsg (void) |
| static ULONG | sendmessage (void) |
| static ULONG | sendto (const UBYTE *port, ULONG cmd, ULONG type, UWORD wait, UWORD whole, UWORD nores) |
| static ULONG | runcommand (const UBYTE *port, ULONG cmd) |
| static ULONG | rxruncommand_c (const UBYTE *port, ULONG cmd) |
| RXRunCommand portname$,command$: send a command to a port, no reply awaited. | |
| static ULONG | rxruncommand2_c (ULONG cmd) |
| RXRunCommand command$: as RXRunCommand to the RXDefaultPort port. | |
| static ULONG | rxexecutescript_c (ULONG name) |
| RXExecuteScript scriptname$: run an ARexx script through the port "REXX" and wait for its end. | |
| static ULONG | rxrunscript_c (ULONG name) |
| RXRunScript scriptname$: run an ARexx script through the port "REXX", no reply awaited. | |
| static ULONG | sendcommand (const UBYTE *port, ULONG cmd) |
| static ULONG | rxsendcommand2_c (ULONG cmd) |
| RXSendCommand(command$): as RXSendCommand to the RXDefaultPort port. | |
| static ULONG | rxsendcommand_c (const UBYTE *port, ULONG cmd, const ULONG *args) |
| RXSendCommand(portname$,command$): send a command and wait for the reply; its result string. | |
| static void | freemsg (ULONG *item) |
| static void | storeresult (struct RexxMsg *m) |
| static void | handlereply (void) |
| static void | takereplies (void) |
| static ULONG | donereadport (ULONG passed) |
| static ULONG | rxwaitport_c (ULONG result) |
| RXWaitPort: wait for a message (if none is in the list), then RXReadPort. | |
| static BB_BOOL | replymsg (ULONG code, const UBYTE *res, const ULONG *args) |
| static void | replymsg_c (ULONG code) |
| RXReplyMsg errcode: reply the current message. | |
| static void | replymsg2_c (ULONG code, const UBYTE *res, const ULONG *args) |
| RXReplyMsg errcode,result$: reply the current message with a result string (CreateArgString). | |
| static ULONG | rxsendersname_c (void) |
| RXSendersName: the name of the current message (ln_Name: the sender's port). | |
| static ULONG | getarg (ULONG n) |
| static ULONG | rxgetarg_c (ULONG n) |
| RXGetArg(argnum): argument argnum (1..16) of the current message. | |
| static ULONG | rxnextarg_c (ULONG argnum) |
| RXNextArg: the next argument of the current message (from 1 on, as RXGetArg). | |
| static ULONG | rxnumargs_c (void) |
| RXNumArgs: the number of arguments of the current message (up to the first 0 of rm_Args). | |
| static void | replywaiting (void) |
| static ULONG | ticksnow (struct Library *dosbase) |
| static BB_BOOL | waitsent (void) |
| static void | rxdeleteport_c (void) |
| RXDeletePort: delete the port. | |
| static ULONG | rxcreateport_c (ULONG name, const ULONG *args) |
| RXCreatePort(name$): make the public port name$ and the message lists. | |
Variables | |
| static struct MsgPort * | msgport |
| static ULONG | msgstring |
| static ULONG | msgtype |
| static UBYTE * | msgportname |
| static UBYTE | quote |
| static UWORD | tokenise |
| static UWORD | oktodelete |
| static UWORD | wholearg |
| static UWORD | noresult |
| static const UBYTE * | curadr |
| static const char | rexxname [] = "rexxsyslib.library" |
| static const char | dosname [] = "dos.library" |
| static const char | realrexxportname [] = "REXX" |
| static const char | emptyname [] = "" |
| static UBYTE * | defportname |
| struct { | |
| struct Library * rexxbase | |
| struct MsgPort * destport | |
| UBYTE * returnstring | |
| ULONG returncode | |
| ULONG * sentlist | |
| ULONG * messagelist | |
| ULONG waitreply | |
| UWORD replyreq | |
| struct RexxMsg * thismsg | |
| struct RexxMsg * currentmessage | |
| UWORD currentarg | |
| } | v |
| #define __NOLIBBASE__ |
| #define AO BLITZ_AMIGAONLY |
| #define DOS_BASE_NAME dosbase |
| #define MSGLIST_FULL | ( | ) |
| #define NOWORD ((ULONG)-1) |
| #define REPLYWAIT_TICKS 250 |
| void _replymsg | ( | void | ) |
| void _replymsg2 | ( | void | ) |
| void _rxcreateport | ( | void | ) |
| void _rxdefportname | ( | void | ) |
| void _rxdeleteport | ( | void | ) |
| void _rxexecutescript | ( | void | ) |
| void _rxgetarg | ( | void | ) |
| void _rxmessagelist | ( | void | ) |
| void _rxnextarg | ( | void | ) |
| void _rxnumargs | ( | void | ) |
| void _rxquotechar | ( | void | ) |
| void _rxreturncode | ( | void | ) |
| void _rxruncommand | ( | void | ) |
| void _rxruncommand2 | ( | void | ) |
| void _rxrunscript | ( | void | ) |
| void _rxsendcommand | ( | void | ) |
| void _rxsendcommand2 | ( | void | ) |
| void _rxsendersname | ( | void | ) |
| void _rxtokenise | ( | void | ) |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
finit: RXTokenise on again, delete the port if there is one (as RXDeletePort, with its wait of up to 5 s for the replies of the sent list (fixed #1095); the name is left to maxslib, which frees its strings at the end of the program), close rexxsyslib.library.
Fixed (#1093): the original never closed rexxsyslib.library.
|
static |
init: open rexxsyslib.library V34; the defaults (quote '"', RXTokenise on, the default port "REXX").
Fixed (#532): the default port is "REXX" again; the original wrote "REXX" and a 0 at +5 over the name, so the byte at +4 of an earlier RXDefaultPort stayed. A copy of an earlier run is maxslib's, freed at that run's end (#529).
|
static |
|
static |
|
static |
|
static |
| void portchk | ( | void | ) |
|
static |
| void readport | ( | void | ) |
|
static |
RXReadPort: take every message from the port; the first of the message list becomes the current message.
Replies to our messages are freed (to RXSendCommand's: its result kept); messages go to the message list; anything else is replied and ends the reading. Fixed (#1100): while the list holds 31 messages the others stay in the port, in their order, and only the replies are taken out of it; the original appended every message without a limit, past the list. Error check portchk: "No message port opened!".
|
static |
|
static |
RXReplyMsg errcode,result$: reply the current message with a result string (CreateArgString).
The string only if the message asked for a result (RXFF_RESULT) and errcode is 0 (fixed #539: the original made it always), and only when the sender's port exists (fixed #540: the original made it first and, with the port gone, tested the Result2 at the a0 FindPort leaves). As the form without.
|
static |
RXReplyMsg errcode: reply the current message.
Nothing without a current message. If the port of the message's ln_Name no longer exists, it is not replied. Afterwards there is no current message (fixed #541: the original kept the replied one).
| code | d0: Result1 |
|
static |
| void riarexxlib_libfinit | ( | void | ) |
| void riarexxlib_libinit | ( | void | ) |
|
static |
|
static |
RXCreatePort(name$): make the public port name$ and the message lists.
The name is copied with AllocSt. Fixed (#528): the lists are allocated before the port is made public, AddPort is not tested, and on failure what was allocated is freed (0, D-018); the original added the port first, tested the d0 AddPort leaves and on failure deleted the port without RemPort, so it stayed in the public list.
|
static |
RXDefaultPort portname$: the port of the forms of RXRunCommand and RXSendCommand without a port name.
Fixed (#529): the name is kept as a copy of its own length (maxslib AllocSt), the copy before freed; the original copied it without a limit into the 65 bytes of rexxportname, over rexxbase and the variables behind it.
| s | d0: portname$ |
|
static |
RXDeletePort: delete the port.
Messages still waiting are replied (RXReplyMsg 5 for the current message, then for each one RXReadPort makes current, then ReplyMsg for the rest of the message list); then it waits up to 5 s for the replies to the messages sent without waiting (RXRunCommand, RXRunScript), replying 5 to messages that arrive meanwhile; then RemPort, the port freed; the block of the lists and the name are freed (fixed #530: the original freed neither). With a reply still outstanding after 5 s the port is only taken off the public list: it and the name stay allocated for the late reply (fixed #1095: the original did not wait, the reply went to the deleted port). Fixed (#1101): the original never replied the message current when it was called. Error check portchk.
|
static |
RXExecuteScript scriptname$: run an ARexx script through the port "REXX" and wait for its end.
RXCOMM|RXFF_RESULT, the name as one argument; while it waits, received messages go to the message list (as RXSendCommand). The script's code is RXReturnCode, a result string is deleted. Fixed (#544, user decision W4 Q1 (b)): the original's _rxruncommand overwrote the type, so it sent RXCOMM|RXFF_STRING (the name as a tokenised string program) and did not wait.
| name | d0: scriptname$ |
|
static |
RXGetArg(argnum): argument argnum (1..16) of the current message.
| n | d0.w: the argument's number |
|
static |
RXMessageList: the list of received messages not yet current.
|
static |
RXNextArg: the next argument of the current message (from 1 on, as RXGetArg).
Fixed (#534): it advances when the argument slot is not 0; the original tested the length, so at an empty argument it stayed.
| argnum | d0: no argument; MOVE.w currentarg,d0 keeps its upper word |
|
static |
RXNumArgs: the number of arguments of the current message (up to the first 0 of rm_Args).
|
static |
RXQuoteChar char$: the quote character of the parser (RXTokenise on; default '"').
| s | d0: the string, its first character |
|
static |
RXReturnCode: the Result1 of the last reply to RXSendCommand.
Fixed (#542): also while no message is current; the original returned 0 then, e.g. right after an RXSendCommand that found the list empty.
|
static |
RXRunCommand command$: as RXRunCommand to the RXDefaultPort port.
| cmd | d0: command$ |
|
static |
RXRunCommand portname$,command$: send a command to a port, no reply awaited.
The message (RXCOMM|RXFF_STRING) goes into the sent list (31 at most: when it is full nothing is sent, 0); its reply is freed with its arguments and its entry (fixed #531).
| port | d0: portname$ |
| cmd | d1: command$ |
|
static |
RXRunScript scriptname$: run an ARexx script through the port "REXX", no reply awaited.
RXCOMM, the name as one argument, into the sent list as RXRunCommand. Fixed (#544): the original's _rxruncommand overwrote the type (it sent RXCOMM|RXFF_STRING, the name as a tokenised string program).
| name | d0: scriptname$ |
|
static |
RXSendCommand(command$): as RXSendCommand to the RXDefaultPort port.
| cmd | d0: command$ |
|
static |
RXSendCommand(portname$,command$): send a command and wait for the reply; its result string.
RXCOMM|RXFF_STRING|RXFF_RESULT. The result goes over the two arguments: a3 back by both lengths (on the a2 stack) + 2. While it waits, received messages go to the message list. The reply's Result1 is RXReturnCode; its Result2 is the result string only with Result1 0 (fixed #545: the original read it as a string also with an error). The result string is copied to a3 and the reply's string deleted (fixed #546: the original copied it with AllocSt, never freed the copy and never deleted the string).
|
static |
RXSendersName: the name of the current message (ln_Name: the sender's port).
|
static |
RXTokenise on|off: whether commands are split into words (with RXQuoteChar quotes) or sent as one argument string.
Fixed (#547): only the word is stored; the original's MOVE.l d0 stored the upper word of the register too, so "off" with a set upper word stayed on.
| on | d0.w: 0 off, else on (the upper word is not part of it) |
|
static |
RXWaitPort: wait for a message (if none is in the list), then RXReadPort.
| result | d0: returned instead of a message while RXSendCommand waits (oktodelete) |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
| void waitport | ( | void | ) |
|
static |
|
static |
|
static |
| UWORD currentarg |
| struct RexxMsg* currentmessage |
|
static |
| struct MsgPort* destport |
|
static |
|
static |
| ULONG* messagelist |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
| UWORD replyreq |
| ULONG returncode |
| UBYTE* returnstring | ( | void | ) |
| struct Library* rexxbase |
|
static |
| ULONG* sentlist |
| struct RexxMsg* thismsg |
|
static |
| struct { ... } v |
| ULONG waitreply |
|
static |