BB2 C port
API reference: Blitz libraries in C and the shared code
Loading...
Searching...
No Matches
ab3args.c File Reference
#include "ab3job.h"

Data Structures

struct  out

Macros

#define MODE_DETECT   0
#define MODE_BB2   1
#define MODE_AB3   2

Typedefs

typedef char ab3args_warnings_complete[sizeof ab3args_warnings/sizeof ab3args_warnings[0]==AB3JOB_W_COUNT+1 ? 1 :-1]

Functions

static int eq (const char *a, const char *b)
static void put (struct out *o, const char *s)
static int fail (struct out *o, int result, const char *a, const char *b, const char *c)
static int eqn (const char *s, const char *e, const char *n)
static int warnlist (struct out *o, const char *opt, const char *v, uint32_t *keep, uint32_t *add)
static int setname (char *dst, const char *src)
int ab3args_parse (int argc, char *const argv[], struct ab3job *job, char *msg, size_t cap)
 Parse the command line of blitz2-ab3.
int ab3args_rc (int result)
 The return code that goes with a result of ab3args_parse.

Variables

const char ab3args_usage []
 The usage (several lines, each ending in LF).
const char *const ab3args_warnings []
 The names of the warnings by number (-w, -werr and the console line), AB3JOB_W_COUNT entries and a NULL.
static const char *const unsupported []

Macro Definition Documentation

◆ MODE_AB3

#define MODE_AB3   2

◆ MODE_BB2

#define MODE_BB2   1

◆ MODE_DETECT

#define MODE_DETECT   0

Typedef Documentation

◆ ab3args_warnings_complete

typedef char ab3args_warnings_complete[ sizeof ab3args_warnings/sizeof ab3args_warnings[0]==AB3JOB_W_COUNT+1 ? 1 :-1]

Function Documentation

◆ ab3args_parse()

int ab3args_parse ( int argc,
char *const argv[],
struct ab3job * job,
char * msg,
size_t cap )

Parse the command line of blitz2-ab3.

argv[1..argc) as libnix (or a shell) splits them. Without an argument that starts with '-' the result is AB3ARGS_EDITOR (blitz2's start with at most a project name). Options, in any case, AmiBlitz3's spelling: -s/-source FILE, -e/-exe FILE, -r/-release, -mode ab3|bb2 and -w/-werr LIST (this repository's), -h/-help. A LIST is comma-separated items all, none, NAME, -NAME (ab3args_warnings), applied left to right; several -w (-werr) are applied in order. The other options of AmiBlitz3's CLI mode (-d/-debug, -run, -dump, -setcom, -setdbg, -strbufsize, -stacksize, -maxerrors, -1/-1pass, -dform, -PED, -save, -v/-verbose) are refused. The first problem decides; -h before it gives AB3ARGS_HELP. Given twice, the last value counts (the lists: both are applied). An unknown warning name or an empty item is AB3ARGS_FAIL.

Parameters
argcthe number of arguments with the program's name
argvthe arguments; argv[0] is the program's name
jobthe job: initialised (magic, defaults) and filled
msgthe message for AB3ARGS_UNSUPPORTED and AB3ARGS_FAIL (one line without LF; "" otherwise)
capthe size of msg in bytes (> 0)
Returns
an enum ab3args_result

◆ ab3args_rc()

int ab3args_rc ( int result)

The return code that goes with a result of ab3args_parse.

Parameters
resultan enum ab3args_result
Returns
AB3JOB_RC_OK for AB3ARGS_HELP, AB3JOB_RC_FAIL for the errors, -1 for AB3ARGS_EDITOR and AB3ARGS_COMPILE (not the end of the run)

◆ eq()

int eq ( const char * a,
const char * b )
static

◆ eqn()

int eqn ( const char * s,
const char * e,
const char * n )
static

◆ fail()

int fail ( struct out * o,
int result,
const char * a,
const char * b,
const char * c )
static

◆ put()

void put ( struct out * o,
const char * s )
static

◆ setname()

int setname ( char * dst,
const char * src )
static

◆ warnlist()

int warnlist ( struct out * o,
const char * opt,
const char * v,
uint32_t * keep,
uint32_t * add )
static

Variable Documentation

◆ ab3args_usage

const char ab3args_usage[]
Initial value:
=
"usage: blitz2-ab3 -s SOURCE -e EXE [-r] [-mode ab3|bb2] [-w LIST] [-werr LIST]\n"
" -s, -source FILE the source to compile (text or tokenised)\n"
" -e, -exe FILE the executable to write\n"
" -r, -release release executable: no runtime error checking,\n"
" no debugger, no debug information\n"
" -mode ab3|bb2 compile in AmiBlitz3 or Blitz Basic 2 mode\n"
" (default: detected from the source)\n"
" -w LIST the warnings shown (default: the source's setting)\n"
" -werr LIST the warnings that are errors\n"
" LIST: all, none, NAME, -NAME, comma-separated,\n"
" left to right; NAME: resclash\n"
" -h, -help this text\n"
"Without options blitz2-ab3 starts the editor like blitz2.\n"

The usage (several lines, each ending in LF).

◆ ab3args_warnings

const char* const ab3args_warnings[]
Initial value:
= {
"resclash",
0
}

The names of the warnings by number (-w, -werr and the console line), AB3JOB_W_COUNT entries and a NULL.

◆ unsupported

const char* const unsupported[]
static
Initial value:
= {
"d", "debug", "run", "dump", "setcom", "setdbg", "strbufsize", "stacksize",
"maxerrors", "1", "1pass", "dform", "ped", "save", "v", "verbose", 0
}