|
BB2 C port
API reference: Blitz libraries in C and the shared code
|
#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." |
| #define __NOLIBBASE__ |
| #define CLIMAX 255 |
| #define DATSIZE 14 |
| #define DOS_BASE_NAME dosbase |
|
static |
|
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.
|
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.
| argptr | a0: the CLI argument string |
| magic | d7: "bLtZ" when started from Blitz |
|
static |
| void wbstartuplib_codefinit | ( | void | ) |
| void wbstartuplib_codeinit | ( | void | ) |
| struct { ... } argData |
|
static |
|
static |
|
static |
| struct arg* first |
| UWORD fromcli |
|
static |
| ULONG numargs |
|
static |
|
static |
|
static |
|
static |
|
static |