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

Data Structures

struct  arg
struct  argdata

Macros

#define __NOLIBBASE__
#define DOS_BASE_NAME   dosbase

Functions

void GetNumPars (void)
void GetParString (void)
void FromCLI (void)
void CheckParNum (void)
void CheckParPath (void)
ULONG GetParPath (const struct argdata *wb, ULONG n, UWORD type, struct Library *dosbase)
 ParPath$(Par#,type): the path of a Workbench argument (V36+).
static struct arg * findarg (const struct argdata *wb, ULONG n)
static ULONG movestring (const UBYTE *s)
static UWORD fromcli_c (const struct argdata *wb)
 FromCLI: whether the program was started from the CLI.
 BLITZ_ALIAS (FromCLI, fromcli_c)
static ULONG getnumpars_c (const struct argdata *wb)
 NumPars: the number of arguments passed to the program.
 BLITZ_ALIAS (GetNumPars, getnumpars_c)
static ULONG getparstring_c (const struct argdata *wb, ULONG n)
 Par$(Parameter#): the text of an argument.
 BLITZ_ALIAS (GetParString, getparstring_c)
static void checkparnum_c (const struct argdata *wb, LONG n)
static void checkparpath_c (const struct argdata *wb, LONG n)

Variables

static UBYTE pathBuffer [256]

Macro Definition Documentation

◆ __NOLIBBASE__

#define __NOLIBBASE__

◆ DOS_BASE_NAME

#define DOS_BASE_NAME   dosbase

Function Documentation

◆ BLITZ_ALIAS() [1/3]

BLITZ_ALIAS ( FromCLI ,
fromcli_c  )

◆ BLITZ_ALIAS() [2/3]

BLITZ_ALIAS ( GetNumPars ,
getnumpars_c  )

◆ BLITZ_ALIAS() [3/3]

BLITZ_ALIAS ( GetParString ,
getparstring_c  )

◆ CheckParNum()

void CheckParNum ( void )

◆ checkparnum_c()

void checkparnum_c ( const struct argdata * wb,
LONG n )
static

◆ CheckParPath()

void CheckParPath ( void )

◆ checkparpath_c()

void checkparpath_c ( const struct argdata * wb,
LONG n )
static

◆ findarg()

struct arg * findarg ( const struct argdata * wb,
ULONG n )
static

◆ FromCLI()

void FromCLI ( void )

◆ fromcli_c()

UWORD fromcli_c ( const struct argdata * wb)
static

FromCLI: whether the program was started from the CLI.

MOVE.w (a0),d0: a word function; the upper word of d0 stays in the original and is undefined here (the register rule: the compiler uses only d0.w).

Parameters
wba0: wbstartuplib's argument data (!libs{wbstartuplib,la0})
Returns
d0.w: -1 = CLI (or Blitz), 0 = Workbench

◆ GetNumPars()

void GetNumPars ( void )

◆ getnumpars_c()

ULONG getnumpars_c ( const struct argdata * wb)
static

NumPars: the number of arguments passed to the program.

MOVE.l numArgs(a0),d0.

Parameters
wba0: wbstartuplib's argument data (!libs{wbstartuplib,la0})
Returns
d0: the number of arguments

◆ GetParPath()

ULONG GetParPath ( const struct argdata * wb,
ULONG n,
UWORD type,
struct Library * dosbase )

ParPath$(Par#,type): the path of a Workbench argument (V36+).

NameFromLock(lock, pathBuffer, 255) of the argument's lock, copied to a3; type 0 = the drawer only, otherwise drawer + "/" + name (no "/" after a ":"; the type is tested as a word). An empty path would compare the byte in front of the string (unreachable: NameFromLock succeeds only with a non-empty path). DIFF: the original branches on the CCR that dos.library leaves after NameFromLock (BEQ right after the JSR); here d0 = 0 is tested (the documented failure value). Either way nothing is written and d0 = 0. Errors (debugger only, CheckParPath): "Can only call ParPath$() when run from WB.", then those of Par$. By design (#106): no range check of the argument number (FindArg). By design (#107): without the error checks also called for CLI arguments (lock 0).

Parameters
wba0: wbstartuplib's argument data (!libs{wbstartuplib,la0})
nd0: the argument number (from 1)
typed1.w: 0 = drawer only, otherwise drawer and name
dosbasea6: dos.library
Returns
d0: the length of the string at a3, 0 if NameFromLock fails

◆ GetParString()

void GetParString ( void )

◆ getparstring_c()

ULONG getparstring_c ( const struct argdata * wb,
ULONG n )
static

Par$(Parameter#): the text of an argument.

Copies the argument's text to a3. The original changes a0/a1, keeps d1. Errors (debugger only, CheckParNum): "No parameters passed.", "Non-Existent Parameter." (not 1 <= Parameter# <= NumPars, signed). By design (#106): FindArg walks the list without a check: argument numbers <= 0 or > NumPars run over the end of the list (argument 0: 2^32 steps).

Parameters
wba0: wbstartuplib's argument data (!libs{wbstartuplib,la0})
nd0: the argument number (from 1)
Returns
d0: the length of the string at a3

◆ movestring()

ULONG movestring ( const UBYTE * s)
static

Variable Documentation

◆ pathBuffer

UBYTE pathBuffer[256]
static