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

Data Structures

struct  arg

Macros

#define __NOLIBBASE__
#define DOS_BASE_NAME   dosbase
#define DATSIZE   14
#define CLIMAX   255

Functions

void wbstartuplib_codeinit (void)
void wbstartuplib_codefinit (void)
static struct arg * addarg (UBYTE *text)
static UBYTE * getcliarg (UBYTE **pp, UWORD *len)
static ULONG codeinit_c (UBYTE *argptr, ULONG magic)
 init - read the program's arguments (CLI or Workbench).
static void codefinit_c (void)
 finit - free the arguments, restore the current directory (a Workbench start, fixed (#307)), close dos.library (fixed, #306), reply the Workbench message.

Variables

struct { 
   UWORD   fromcli 
   ULONG   numargs 
   struct arg *   first 
} argData
static BPTR thisLock
static struct arg * prevArg
static struct Message * wbMsg
static struct Library * wbDos
static BPTR oldDir
static UWORD inQuote
static UBYTE cliString [CLIMAX+2]
static const char err1 [] = "Can't read args!"
static const char errMsg2 [] = "Missing closing quote in argument string."

Macro Definition Documentation

◆ __NOLIBBASE__

#define __NOLIBBASE__

◆ CLIMAX

#define CLIMAX   255

◆ DATSIZE

#define DATSIZE   14

◆ DOS_BASE_NAME

#define DOS_BASE_NAME   dosbase

Function Documentation

◆ addarg()

struct arg * addarg ( UBYTE * text)
static

◆ codefinit_c()

void codefinit_c ( void )
static

finit - free the arguments, restore the current directory (a Workbench start, fixed (#307)), close dos.library (fixed, #306), reply the Workbench message.

The WBStartup message is replied under Forbid (no Permit: the program ends, Workbench cannot unload it before). argData.first is not cleared (not a bug: codeinit clears it at every start). The original changes d0/a1-a3/a6 only when there are arguments / a message, the thunk keeps d0-d1/a0-a1.

◆ codeinit_c()

ULONG codeinit_c ( UBYTE * argptr,
ULONG magic )
static

init - read the program's arguments (CLI or Workbench).

Started from the editor (d7 = "bLtZ") or from a CLI: the CLI string is copied to cliString and split into arguments in place (spaces separate, "..." quotes). From Workbench: waits for the WBStartup message, CurrentDir to the program's lock, the arguments are the WBArgs after the program itself. Keeps d1-d7/a1-a6.

Errors: no memory for an argument node raises "Can't read args!" (see addarg, fixed (#305)).

Fixed (#306): dos.library, opened for CurrentDir, is closed by finit (the original never closed it). Fixed (#307): the old current directory is kept and restored by finit (the original dropped it). Fixed (#308): the CLI string is cut to the 255 characters that fit into cliString (the original copied it without a length check into its 256 bytes); see also #309.

Parameters
argptra0: the CLI argument string
magicd7: "bLtZ" when started from Blitz
Returns
d0: &argData (the init value: from CLI, number of arguments, first argument)

◆ getcliarg()

UBYTE * getcliarg ( UBYTE ** pp,
UWORD * len )
static

◆ wbstartuplib_codefinit()

void wbstartuplib_codefinit ( void )

◆ wbstartuplib_codeinit()

void wbstartuplib_codeinit ( void )

Variable Documentation

◆ [struct]

struct { ... } argData

◆ cliString

UBYTE cliString[CLIMAX+2]
static

◆ err1

const char err1[] = "Can't read args!"
static

◆ errMsg2

const char errMsg2[] = "Missing closing quote in argument string."
static

◆ first

struct arg* first

◆ fromcli

UWORD fromcli

◆ inQuote

UWORD inQuote
static

◆ numargs

ULONG numargs

◆ oldDir

BPTR oldDir
static

◆ prevArg

struct arg* prevArg
static

◆ thisLock

BPTR thisLock
static

◆ wbDos

struct Library* wbDos
static

◆ wbMsg

struct Message* wbMsg
static