BB2 C port
API reference: Blitz libraries in C and the shared code
Loading...
Searching...
No Matches
ricommoditieslib.c File Reference
#include "blitzlib.h"
#include "blitzexec.h"
#include <libraries/commodities.h>
#include <proto/commodities.h>

Macros

#define __NOLIBBASE__
#define COMMODITIES_BASE_NAME   st_cbase
#define CMD_DISABLE   15
#define CMD_ENABLE   17
#define CMD_APPEAR   19
#define CMD_DISAPPEAR   21
#define CMD_KILL   23
#define CMD_LIST_CHG   27
#define CMD_UNIQUE   25
#define RI_FUNC(code, name, help)
#define SLOT(arr, n)

Functions

void makecommodity (void)
void addhotkey (void)
void hotkeyhit (void)
void waitevent (void)
void event (void)
void exchangemessage (void)
void disabled (void)
void enable (void)
void appear (void)
void disappear (void)
void kill (void)
void list (void)
void unqiue (void)
void cxdisable (void)
 CxDisable, CxEnable, CxAppear, CxDisAppear, CxKill, CxListChange, CxUnique: the CXCMD_ codes.
void cxenable (void)
void cxappear (void)
void cxdisappear (void)
void cxkill (void)
void cxlist (void)
void cxunique (void)
void status (void)
void port (void)
void ricommoditieslib_libinit (void)
void ricommoditieslib_libfinit (void)
void hotkeynumchk (void)
 RI_FUNC (hotkeyhit, "HotKeyHit", "")
 RI_FUNC (event, "CommodityEvent", "")
 RI_FUNC (exchangemessage, "ExchangeMessage", "")
 RI_FUNC (disabled, "ExchangeDisable", "")
 RI_FUNC (enable, "ExchangeEnable", "")
 RI_FUNC (appear, "ExchangeAppear", "")
 RI_FUNC (disappear, "ExchangeDisAppear", "")
 RI_FUNC (kill, "ExchangeKill", "")
 RI_FUNC (list, "ExchangeListChange", "")
 RI_FUNC (unqiue, "ExchangeUnique", "")
 RI_FUNC (cxdisable, "CxDisable", "")
 RI_FUNC (cxenable, "CxEnable", "")
 RI_FUNC (cxappear, "CxAppear", "")
 RI_FUNC (cxdisappear, "CxDisAppear", "")
 RI_FUNC (cxkill, "CxKill", "")
 RI_FUNC (cxlist, "CxListChange", "")
 RI_FUNC (cxunique, "CxUnique", "")
static void libinit_c (void)
 init: OpenLibrary("commodities.library",37).
static void delmsgport (struct MsgPort *p)
static void replymsg (void)
static void libfinit_c (void)
 finit: deletes the broker, replies the messages, deletes the message port and closes commodities.library.
static BB_BOOL waitevent_c (void)
 WaitCommodity: fetches the next message into msg, waiting for one.
static BB_BOOL event_c (void)
 CommodityEvent: fetches the next message (GetMsg) into msg.
static void getmessage (void)
static LONG hotkeyhit_c (void)
 HotKeyHit: the hotkey id of the fetched message.
static LONG exchangemessage_c (void)
 ExchangeMessage: the Exchange command of the fetched message.
static BB_BOOL is_cmd (ULONG cmd)
static BB_BOOL disabled_c (void)
 ExchangeDisable, ExchangeEnable, ExchangeAppear, ExchangeDisAppear, ExchangeKill, ExchangeListChange, ExchangeUnique: whether the last message was that Exchange command.
static BB_BOOL enable_c (void)
static BB_BOOL appear_c (void)
static BB_BOOL disappear_c (void)
static BB_BOOL kill_c (void)
static BB_BOOL list_c (void)
static BB_BOOL unqiue_c (void)
static void delhotkey (LONG n)
static BB_BOOL addhotkey_c (LONG n, STRPTR desc)
 SetHotKey(hotkeynum,hotkey$): a hotkey filter with a sender (id hotkeynum) attached to the broker.
static ULONG port_c (void)
 CommodityMsgPort: the message port address.
static BB_BOOL status_c (LONG on)
 SetCxStatus on|off: -1 activates, 0 deactivates the broker.
static BB_BOOL makecommodity_c (STRPTR name, STRPTR title, STRPTR descr)
 MakeCommodity(name$,title$,description$): the commodity's broker (NBU_UNIQUE|NBU_NOTIFY, COF_SHOW_HIDE), activated.
static void hotkeynumchk_c (ULONG n)
 The error check of SetHotKey (debugger only).

Variables

struct { 
   struct NewBroker   newbroker 
   UBYTE   inputevent [18] 
   struct MsgPort *   msgport 
   CxObj *   cobject 
   ULONG   cxfilter [16] 
   ULONG   cxsends [16] 
   LONG   hotkey 
   ULONG   cxmsgid 
   ULONG   cxmsgtype 
   ULONG   cxmsgevent 
   CxMsg *   msg 
   STRPTR   hotkeystring 
   CxObj *   currentfilter 
} st
static struct Library * st_cbase
static const char cname [] = "commodities.library"

Macro Definition Documentation

◆ __NOLIBBASE__

#define __NOLIBBASE__

◆ CMD_APPEAR

#define CMD_APPEAR   19

◆ CMD_DISABLE

#define CMD_DISABLE   15

◆ CMD_DISAPPEAR

#define CMD_DISAPPEAR   21

◆ CMD_ENABLE

#define CMD_ENABLE   17

◆ CMD_KILL

#define CMD_KILL   23

◆ CMD_LIST_CHG

#define CMD_LIST_CHG   27

◆ CMD_UNIQUE

#define CMD_UNIQUE   25

◆ COMMODITIES_BASE_NAME

#define COMMODITIES_BASE_NAME   st_cbase

◆ RI_FUNC

#define RI_FUNC ( code,
name,
help )
Value:
BLITZ_SUBS(BLITZ_AMIGAONLY(code), 0, 0); BLITZ_NAME(name, help)
char * name
Definition asllib.c:150
#define BLITZ_ARGS0()
Definition blitzlib.h:352
#define BLITZ_LIBS0()
Definition blitzlib.h:363
#define BLITZ_AFUNCTION(t)
Definition blitzlib.h:344
#define BLITZ_NAME(name, help)
Definition blitzlib.h:371
#define BL_LONG
Definition blitzlib.h:92
#define BLITZ_AMIGAONLY(code)
Definition blitzlib.h:510
UBYTE code[4]
Definition ridisasmlib.c:375

◆ SLOT

#define SLOT ( arr,
n )
Value:
((ULONG *)((ULONG)(arr) + ((ULONG)(n) << 2)))
ULONG WORD UWORD UWORD border ULONG ULONG struct bb_bitmap *dst void UWORD n
Definition 2dlib.c:2498

Function Documentation

◆ addhotkey()

void addhotkey ( void )

◆ addhotkey_c()

BB_BOOL addhotkey_c ( LONG n,
STRPTR desc )
static

SetHotKey(hotkeynum,hotkey$): a hotkey filter with a sender (id hotkeynum) attached to the broker.

Amiga mode only; the broker is activated afterwards. A number outside 0..15 hits the variables around cxfilter/cxsends: an invalid argument, refused by hotkeynumchk with runtime error checking (#564). Fixed (#563): a replaced hotkey's filter is deleted with its sender (DeleteCxObjAll, which also detaches it), and when a step fails the new filter (with a sender attached to it) is deleted and the slots are cleared; the original only removed the replaced objects (RemoveCxObj, the sender only if the filter existed) and left what it had made before a failure. Fixed (#565): a description commodities cannot parse (CxObjError of the new filter, COERR_BADFILTER) is refused: the filter is deleted, the result 0; AttachCxObj (void) is not tested. The original never called CxObjError (its 'oops2 tail is unreachable) and tested the d0 AttachCxObj leaves.

Parameters
nd0: the hotkey number
descd1: the hotkey description (CX_FILTER)
Returns
d0: BB_TRUE, BB_FALSE without a broker, for a description commodities cannot parse or if an object cannot be made

◆ appear()

void appear ( void )

◆ appear_c()

BB_BOOL appear_c ( void )
static

◆ cxappear()

void cxappear ( void )

◆ cxdisable()

void cxdisable ( void )

CxDisable, CxEnable, CxAppear, CxDisAppear, CxKill, CxListChange, CxUnique: the CXCMD_ codes.

Inline constants (MOVE.l CXCMD_...,d0, copied by the compiler). Result: d0 = the code (15, 17, 19, 21, 23, 27, 25).

◆ cxdisappear()

void cxdisappear ( void )

◆ cxenable()

void cxenable ( void )

◆ cxkill()

void cxkill ( void )

◆ cxlist()

void cxlist ( void )

◆ cxunique()

void cxunique ( void )

◆ delhotkey()

void delhotkey ( LONG n)
static

◆ delmsgport()

void delmsgport ( struct MsgPort * p)
static

◆ disabled()

void disabled ( void )

◆ disabled_c()

BB_BOOL disabled_c ( void )
static

ExchangeDisable, ExchangeEnable, ExchangeAppear, ExchangeDisAppear, ExchangeKill, ExchangeListChange, ExchangeUnique: whether the last message was that Exchange command.

Amiga mode only. Fixed (#555): only a CXM_COMMAND message counts; the original compared the id whatever the type (a hotkey id 15 counted as ExchangeDisable).

Returns
d0: BB_TRUE if the last message is a CXM_COMMAND with the CXCMD_ code, else BB_FALSE

◆ disappear()

void disappear ( void )

◆ disappear_c()

BB_BOOL disappear_c ( void )
static

◆ enable()

void enable ( void )

◆ enable_c()

BB_BOOL enable_c ( void )
static

◆ event()

void event ( void )

◆ event_c()

BB_BOOL event_c ( void )
static

CommodityEvent: fetches the next message (GetMsg) into msg.

Amiga mode only. Fixed (#561): the message fetched before is replied first (HotKeyHit and the others read the current one until the next fetch); the original never replied a message.

Returns
d0: BB_TRUE if there was one, BB_FALSE if not or without a broker

◆ exchangemessage()

void exchangemessage ( void )

◆ exchangemessage_c()

LONG exchangemessage_c ( void )
static

ExchangeMessage: the Exchange command of the fetched message.

Amiga mode only. Reads id, type and data of msg as HotKeyHit.

Returns
d0: the CXCMD_ code of a CXM_COMMAND message, else 0 (also without a broker or message)

◆ getmessage()

void getmessage ( void )
static

◆ hotkeyhit()

void hotkeyhit ( void )

◆ hotkeyhit_c()

LONG hotkeyhit_c ( void )
static

HotKeyHit: the hotkey id of the fetched message.

Amiga mode only. Reads id, type and data of msg (they stay for the Exchange* functions); the message is replied by the next fetch or by finit (#561).

Returns
d0: the id of a CXM_IEVENT message, else -1 (also without a broker or message)

◆ hotkeynumchk()

void hotkeynumchk ( void )

◆ hotkeynumchk_c()

void hotkeynumchk_c ( ULONG n)
static

The error check of SetHotKey (debugger only).

Fixed (#564), not in the original (ricommoditieslib had no error check area): the number indexes the tables of 16 filters and senders without a check, so a number outside 0..15 made SetHotKey remove and overwrite the variables around them (with -1 the broker). The release code is unchanged (an invalid argument).

Errors: "Hotkey number must be 0 to 15".

Parameters
nd0: the hotkey number

◆ is_cmd()

BB_BOOL is_cmd ( ULONG cmd)
static

◆ kill()

void kill ( void )

◆ kill_c()

BB_BOOL kill_c ( void )
static

◆ libfinit_c()

void libfinit_c ( void )
static

finit: deletes the broker, replies the messages, deletes the message port and closes commodities.library.

Fixed (#561): the message fetched last and those still queued are replied (after the broker is deleted, so no more come) before the port is deleted; the original deleted the port with them. Fixed (#556): commodities.library is closed last; the original closed it first and then called DeleteCxObj through the closed base. Fixed (#557): the broker is deleted with DeleteCxObjAll, its hotkey filters and senders with it, and the slots are cleared; the original's DeleteCxObj left them allocated.

◆ libinit_c()

void libinit_c ( void )
static

init: OpenLibrary("commodities.library",37).

Without the library the base stays 0; MakeCommodity checks it (Fixed (#559)), every other command needs MakeCommodity's broker or port.

◆ list()

void list ( void )

◆ list_c()

BB_BOOL list_c ( void )
static

◆ makecommodity()

void makecommodity ( void )

◆ makecommodity_c()

BB_BOOL makecommodity_c ( STRPTR name,
STRPTR title,
STRPTR descr )
static

MakeCommodity(name$,title$,description$): the commodity's broker (NBU_UNIQUE|NBU_NOTIFY, COF_SHOW_HIDE), activated.

Amiga mode only. The message port is created on the first call. Fixed (#559): without commodities.library (init's OpenLibrary failed) it returns 0 before it makes the port; the original called CxBroker through a base of 0. Fixed (#560): while the library has a broker it returns 0 and the broker stays in use (user decision W4 Q4); the original made a new broker on every call and left the previous one active with the same port.

Parameters
named0: the name
titled1: the title
descrd2: the description
Returns
d0: BB_TRUE, BB_FALSE without the library, with a broker already made or if the port or the broker fails

◆ port()

void port ( void )

◆ port_c()

ULONG port_c ( void )
static

CommodityMsgPort: the message port address.

The only entry callable in Blitz mode too.

Returns
d0: the port, 0 before MakeCommodity

◆ replymsg()

void replymsg ( void )
static

◆ RI_FUNC() [1/17]

RI_FUNC ( appear ,
"ExchangeAppear" ,
""  )

◆ RI_FUNC() [2/17]

RI_FUNC ( cxappear ,
"CxAppear" ,
""  )

◆ RI_FUNC() [3/17]

RI_FUNC ( cxdisable ,
"CxDisable" ,
""  )

◆ RI_FUNC() [4/17]

RI_FUNC ( cxdisappear ,
"CxDisAppear" ,
""  )

◆ RI_FUNC() [5/17]

RI_FUNC ( cxenable ,
"CxEnable" ,
""  )

◆ RI_FUNC() [6/17]

RI_FUNC ( cxkill ,
"CxKill" ,
""  )

◆ RI_FUNC() [7/17]

RI_FUNC ( cxlist ,
"CxListChange" ,
""  )

◆ RI_FUNC() [8/17]

RI_FUNC ( cxunique ,
"CxUnique" ,
""  )

◆ RI_FUNC() [9/17]

RI_FUNC ( disabled ,
"ExchangeDisable" ,
""  )

◆ RI_FUNC() [10/17]

RI_FUNC ( disappear ,
"ExchangeDisAppear" ,
""  )

◆ RI_FUNC() [11/17]

RI_FUNC ( enable ,
"ExchangeEnable" ,
""  )

◆ RI_FUNC() [12/17]

RI_FUNC ( event ,
"CommodityEvent" ,
""  )

◆ RI_FUNC() [13/17]

RI_FUNC ( exchangemessage ,
"ExchangeMessage" ,
""  )

◆ RI_FUNC() [14/17]

RI_FUNC ( hotkeyhit ,
"HotKeyHit" ,
""  )

◆ RI_FUNC() [15/17]

RI_FUNC ( kill ,
"ExchangeKill" ,
""  )

◆ RI_FUNC() [16/17]

RI_FUNC ( list ,
"ExchangeListChange" ,
""  )

◆ RI_FUNC() [17/17]

RI_FUNC ( unqiue ,
"ExchangeUnique" ,
""  )

◆ ricommoditieslib_libfinit()

void ricommoditieslib_libfinit ( void )

◆ ricommoditieslib_libinit()

void ricommoditieslib_libinit ( void )

◆ status()

void status ( void )

◆ status_c()

BB_BOOL status_c ( LONG on)
static

SetCxStatus on|off: -1 activates, 0 deactivates the broker.

Amiga mode only; any other value does nothing. Fixed (#562): tests the broker; the original tested the message port, which a failed MakeCommodity leaves without a broker, and called ActivateCxObj(0).

Parameters
ond0: -1 or 0 (other values are tested, so a LONG)
Returns
d0: BB_TRUE, BB_FALSE without a broker or for another value (a statement: the value is not used)

◆ unqiue()

void unqiue ( void )

◆ unqiue_c()

BB_BOOL unqiue_c ( void )
static

◆ waitevent()

void waitevent ( void )

◆ waitevent_c()

BB_BOOL waitevent_c ( void )
static

WaitCommodity: fetches the next message into msg, waiting for one.

Amiga mode only. Fixed (#566): GetMsg, and on an empty port WaitPort and GetMsg again; the original branched on the condition codes GetMsg leaves, inverted ("ne", what exec leaves: WaitPort, msg = the head, left queued; a message GetMsg had removed was lost). Fixed (#561): the message fetched before is replied first.

Returns
d0: BB_TRUE, BB_FALSE without a broker

Variable Documentation

◆ cname

const char cname[] = "commodities.library"
static

◆ cobject

CxObj* cobject

◆ currentfilter

CxObj* currentfilter

◆ cxfilter

ULONG cxfilter[16]

◆ cxmsgevent

ULONG cxmsgevent

◆ cxmsgid

ULONG cxmsgid

◆ cxmsgtype

ULONG cxmsgtype

◆ cxsends

ULONG cxsends[16]

◆ hotkey

LONG hotkey

◆ hotkeystring

STRPTR hotkeystring

◆ inputevent

UBYTE inputevent[18]

◆ msg

CxMsg* msg

◆ msgport

struct MsgPort* msgport

◆ newbroker

struct NewBroker newbroker

◆ [struct]

struct { ... } st

◆ st_cbase

struct Library* st_cbase
static