BB2 C port
API reference: Blitz libraries in C and the shared code
Loading...
Searching...
No Matches
xtra.h File Reference
#include <stddef.h>
#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  xtra_base
 The bases of the views: the .xtra as loaded and the kept source header (src[0..x->hdr) of xtra_load, wherever it is now). More...
struct  xtra_text
 A text: a view (in, off, len) or the caller's bytes (XTRA_IN_SET: set, len). More...
struct  xtra_max
 One object maximum. More...
struct  xtra_maxima
 The maxima: the {lib, max} pairs of the .xtra (off: the first pair), the "Max NAME" lines of the header (off: the first one's line, n lines; a NAME given twice is there twice, the last one counts) or the caller's array (xtra_set_maxima). More...
struct  xtra_editor
 The editor part: not in a Blitz 2 .xtra; from a BB22 header or the AmiBlitz3 header. More...
struct  xtra_ab3
 Numbers only AmiBlitz3 has (LabelSearch: XTRA_F_LABEL_SEARCH). More...
struct  xtra
 The settings. More...
struct  xtra_error
 Where an error is: file (XTRA_IN_XTRA or XTRA_IN_HEADER = the source), byte offset (binary formats) or line (1-based, AB3). More...
struct  xtra_iter
 An iterator over the maxima, one by one, in file order. More...

Macros

#define XTRA_NSWITCH   14 /* switch words of the Blitz 2 file */
#define XTRA_NBUFFER   6 /* buffer sizes */
#define XTRA_NRES   8 /* residents (blitz2: mostres) */
#define XTRA_RESNAME   64 /* bytes of a resident's path field */
#define XTRA_PATHLEN   192 /* bytes of the executable's path and name */
#define XTRA_CLILEN   128 /* bytes of the CLI argument (vers 1) */
#define XTRA_LABELLEN   32 /* bytes of AmiBlitz3's LabelSearch */
#define XTRA_FIXED_V0   982 /* fixed part of a vers 0 file */
#define XTRA_FIXED_V1   1110 /* fixed part of a vers 1 file */
#define XTRA_AB3_NSWITCH   15 /* switch words of AmiBlitz3's binary .xtra */
#define XTRA_AB3_FIXED   1112 /* its fixed part (always with CLI block) */
#define XTRA_ON   0x0080 /* GFLG_SELECTED; also the icon byte */
#define XTRA_WARN_ERRORS   0x0180 /* XTRA_SW_WARNINGS: warnings are errors */
#define XTRA_MAX_LIB   0x01
#define XTRA_MAX_NAME   0x02
#define XTRA_ED_CURSOR   0x01
#define XTRA_ED_TOP   0x02

Enumerations

enum  xtra_switch {
  XTRA_SW_RUNTIME_ERRORS , XTRA_SW_DEBUGGER , XTRA_SW_LONG_ARRAYS , XTRA_SW_EXPAND_MACROS ,
  XTRA_SW_QUOTED_MACROS , XTRA_SW_MAKE_SMALLEST , XTRA_SW_DEBUG_INFO , XTRA_SW_AUTO_RUN ,
  XTRA_SW_INTERRUPT_CHECK , XTRA_SW_ASSEMBLER_CHECK , XTRA_SW_OVERFLOW_CHECK , XTRA_SW_WARNINGS ,
  XTRA_SW_DEFAULT_INTERRUPT , XTRA_SW_DEFAULT_OVERFLOW
}
 The switch words in file order (offset 2 + 2 * index); each is the Flags word of the option gadget: XTRA_ON (GFLG_SELECTED) = on. More...
enum  xtra_buffer {
  XTRA_BUF_OBJECT , XTRA_BUF_LIBS , XTRA_BUF_SYSTEM , XTRA_BUF_DATA ,
  XTRA_BUF_MACRO , XTRA_BUF_STRING
}
 The buffer sizes in file order (offset 30 + 4 * index). More...
enum  xtra_type {
  XTRA_T_TED , XTRA_T_BB22 , XTRA_T_AB3 , XTRA_T_TEXT ,
  XTRA_T_COUNT
}
 The type of a source file (xtra_detect, xtra_load). More...
enum  xtra_source { XTRA_SRC_NONE , XTRA_SRC_BLITZ2 , XTRA_SRC_AB3_TEXT }
 Where the settings came from. More...
enum  xtra_in { XTRA_IN_NONE , XTRA_IN_XTRA , XTRA_IN_HEADER , XTRA_IN_SET }
 Where the bytes of a view are; also the file of an error. More...
enum  xtra_field {
  XTRA_F_EXE_PATH , XTRA_F_EXE_NAME , XTRA_F_CLI , XTRA_F_LABEL_SEARCH ,
  XTRA_F_RES0 , XTRA_F_COUNT = XTRA_F_RES0 + XTRA_NRES
}
 The text fields (xtra_get_text, xtra_set_text). More...
enum  xtra_ab3_key {
  XTRA_K_EXEPATH , XTRA_K_EXEFILE , XTRA_K_CREATEICON , XTRA_K_RESIDENTS ,
  XTRA_K_STRINGBUFFER , XTRA_K_MAKESMALLEST , XTRA_K_FUNCOPTIMIZE , XTRA_K_VERSION ,
  XTRA_K_NUMBEROFBUILDS , XTRA_K_CLIARGS , XTRA_K_STACKSIZE , XTRA_K_RUNTIMEDEBUG ,
  XTRA_K_DEBUGINFO , XTRA_K_CREATEDBGFILE , XTRA_K_OVERFLOWCHECK , XTRA_K_ASSEMBLERCHECK ,
  XTRA_K_INTERRUPTCHECK , XTRA_K_AUTORUN , XTRA_K_CURSORLINE , XTRA_K_CURSORCOLUMN ,
  XTRA_K_LABELSEARCH , XTRA_K_LABELREMARK , XTRA_K_LABELALL , XTRA_K_LABELCASE ,
  XTRA_K_LABELPOSITION , XTRA_K_MAX , XTRA_K_COUNT
}
 Keys of the AmiBlitz3 header: bit (1 << key) in xtra_ab3.seen when the header has the key (docs/formats.md 7.2). More...
enum  xtra_err {
  XTRA_OK , XTRA_E_SHORT , XTRA_E_SIZE , XTRA_E_VERS ,
  XTRA_E_UNTERMINATED , XTRA_E_SPACE , XTRA_E_BB22 , XTRA_E_AB3_LINE ,
  XTRA_E_AB3_END , XTRA_E_AB3_NUMBER , XTRA_E_AB3_QUOTE , XTRA_E_LONG ,
  XTRA_E_AB3_RESIDENTS , XTRA_E_AB3_VERSION , XTRA_E_AB3_NAME , XTRA_E_TYPE ,
  XTRA_E_FIELD , XTRA_E_TEXT , XTRA_E_BASE , XTRA_E_COUNT
}
 The error codes of the functions (XTRA_OK = 0: no error). More...
enum  xtra_mode { XTRA_MODE_DETECT , XTRA_MODE_BB2 , XTRA_MODE_AB3 }
 The mode a program is compiled in by blitz2-ab3 (xtra_mode). More...

Functions

const char * xtra_strerror (int code)
 The message of an error code (English, without position).
int xtra_detect (const uint8_t *buf, size_t len, const char *path)
 The type of a source.
int xtra_has_companion (int type)
 Whether the settings of a source of this type are in NAME.xtra.
int xtra_companion_name (const char *path, char *out, size_t cap)
 The name of the companion of the source path: path + ".xtra" (as TED and blitz2 make it).
int xtra_is_ab3_xtra (const uint8_t *xtra, size_t len)
 Whether a companion .xtra has AmiBlitz3's binary format with 15 switch words (since AmiBlitz/AmiBlitz3@bdae3f9e, docs/formats.md 1.3) - not Blitz 2's 14.
int xtra_mode (int force, const uint8_t *src, size_t len, const char *path, const uint8_t *xtra, size_t xlen)
 The mode of a source (xtra_mode.c; docs/ab3/variant.md).
int xtra_load (struct xtra *x, int type, const uint8_t *src, size_t len, const uint8_t *xtra, size_t xlen, struct xtra_error *err)
 Load the settings of a source.
void xtra_init (struct xtra *x)
 Initialise settings with the defaults.
void xtra_apply_vers0 (struct xtra *x)
 What blitz2's loadxtra does after reading a vers 0 file.
const uint8_t * xtra_get_text (const struct xtra *x, const struct xtra_base *b, int field, size_t *len)
 A text field.
size_t xtra_text_cap (int field)
 The bytes of a text field in a Blitz 2 .xtra (with the 0): a text is shorter than this.
int xtra_set_text (struct xtra *x, int field, const void *p, size_t len)
 Set a text field to the caller's bytes.
void xtra_set_maxima (struct xtra *x, const struct xtra_max *m, uint32_t n)
 The maxima from the caller's array instead of those of the .xtra/header.
void xtra_max_begin (struct xtra_iter *it, const struct xtra *x, const struct xtra_base *b)
 Start iterating the maxima of x.
int xtra_next_max (struct xtra_iter *it, struct xtra_max *m)
 The next maximum.
void xtra_take_blitz2 (struct xtra *to, const struct xtra *from)
 Take what a Blitz 2 .xtra holds from from into to.
size_t xtra_blitz2_size (const struct xtra *x)
 The bytes xtra_write_blitz2 writes: the fixed part of x->vers and 4 per maximum with a library number.
int xtra_write_blitz2 (const struct xtra *x, const struct xtra_base *b, uint8_t *out, size_t cap, size_t *len, unsigned *skipped, struct xtra_error *err)
 Write x as Blitz 2 .xtra.
int xtra_write_ab3 (const struct xtra *x, const struct xtra_base *b, char *out, size_t cap, size_t *len, unsigned *skipped)
 Write x as AmiBlitz3 header (not 0-terminated).
size_t xtra_ab3_size (const struct xtra *x, const struct xtra_base *b)
 The bytes xtra_write_ab3 writes.
const char * xtra_ab3_keyname (int key)
 The name of an AmiBlitz3 key ("ExePath", ..., "Max").

Macro Definition Documentation

◆ XTRA_AB3_FIXED

#define XTRA_AB3_FIXED   1112 /* its fixed part (always with CLI block) */

◆ XTRA_AB3_NSWITCH

#define XTRA_AB3_NSWITCH   15 /* switch words of AmiBlitz3's binary .xtra */

◆ XTRA_CLILEN

#define XTRA_CLILEN   128 /* bytes of the CLI argument (vers 1) */

◆ XTRA_ED_CURSOR

#define XTRA_ED_CURSOR   0x01

◆ XTRA_ED_TOP

#define XTRA_ED_TOP   0x02

◆ XTRA_FIXED_V0

#define XTRA_FIXED_V0   982 /* fixed part of a vers 0 file */

◆ XTRA_FIXED_V1

#define XTRA_FIXED_V1   1110 /* fixed part of a vers 1 file */

◆ XTRA_LABELLEN

#define XTRA_LABELLEN   32 /* bytes of AmiBlitz3's LabelSearch */

◆ XTRA_MAX_LIB

#define XTRA_MAX_LIB   0x01

◆ XTRA_MAX_NAME

#define XTRA_MAX_NAME   0x02

◆ XTRA_NBUFFER

#define XTRA_NBUFFER   6 /* buffer sizes */

◆ XTRA_NRES

#define XTRA_NRES   8 /* residents (blitz2: mostres) */

◆ XTRA_NSWITCH

#define XTRA_NSWITCH   14 /* switch words of the Blitz 2 file */

◆ XTRA_ON

#define XTRA_ON   0x0080 /* GFLG_SELECTED; also the icon byte */

◆ XTRA_PATHLEN

#define XTRA_PATHLEN   192 /* bytes of the executable's path and name */

◆ XTRA_RESNAME

#define XTRA_RESNAME   64 /* bytes of a resident's path field */

◆ XTRA_WARN_ERRORS

#define XTRA_WARN_ERRORS   0x0180 /* XTRA_SW_WARNINGS: warnings are errors */

Enumeration Type Documentation

◆ xtra_ab3_key

Keys of the AmiBlitz3 header: bit (1 << key) in xtra_ab3.seen when the header has the key (docs/formats.md 7.2).

Enumerator
XTRA_K_EXEPATH 
XTRA_K_EXEFILE 
XTRA_K_CREATEICON 
XTRA_K_RESIDENTS 
XTRA_K_STRINGBUFFER 
XTRA_K_MAKESMALLEST 
XTRA_K_FUNCOPTIMIZE 
XTRA_K_VERSION 
XTRA_K_NUMBEROFBUILDS 
XTRA_K_CLIARGS 
XTRA_K_STACKSIZE 
XTRA_K_RUNTIMEDEBUG 
XTRA_K_DEBUGINFO 
XTRA_K_CREATEDBGFILE 
XTRA_K_OVERFLOWCHECK 
XTRA_K_ASSEMBLERCHECK 
XTRA_K_INTERRUPTCHECK 
XTRA_K_AUTORUN 
XTRA_K_CURSORLINE 
XTRA_K_CURSORCOLUMN 
XTRA_K_LABELSEARCH 
XTRA_K_LABELREMARK 
XTRA_K_LABELALL 
XTRA_K_LABELCASE 
XTRA_K_LABELPOSITION 
XTRA_K_MAX 
XTRA_K_COUNT 

◆ xtra_buffer

The buffer sizes in file order (offset 30 + 4 * index).

Enumerator
XTRA_BUF_OBJECT 
XTRA_BUF_LIBS 
XTRA_BUF_SYSTEM 
XTRA_BUF_DATA 
XTRA_BUF_MACRO 
XTRA_BUF_STRING 

◆ xtra_err

enum xtra_err

The error codes of the functions (XTRA_OK = 0: no error).

Enumerator
XTRA_OK 
XTRA_E_SHORT 
XTRA_E_SIZE 
XTRA_E_VERS 
XTRA_E_UNTERMINATED 
XTRA_E_SPACE 
XTRA_E_BB22 
XTRA_E_AB3_LINE 
XTRA_E_AB3_END 
XTRA_E_AB3_NUMBER 
XTRA_E_AB3_QUOTE 
XTRA_E_LONG 
XTRA_E_AB3_RESIDENTS 
XTRA_E_AB3_VERSION 
XTRA_E_AB3_NAME 
XTRA_E_TYPE 
XTRA_E_FIELD 
XTRA_E_TEXT 
XTRA_E_BASE 
XTRA_E_COUNT 

◆ xtra_field

enum xtra_field

The text fields (xtra_get_text, xtra_set_text).

Enumerator
XTRA_F_EXE_PATH 
XTRA_F_EXE_NAME 
XTRA_F_CLI 
XTRA_F_LABEL_SEARCH 
XTRA_F_RES0 
XTRA_F_COUNT 

◆ xtra_in

enum xtra_in

Where the bytes of a view are; also the file of an error.

Enumerator
XTRA_IN_NONE 
XTRA_IN_XTRA 
XTRA_IN_HEADER 
XTRA_IN_SET 

◆ xtra_mode

enum xtra_mode

The mode a program is compiled in by blitz2-ab3 (xtra_mode).

Enumerator
XTRA_MODE_DETECT 
XTRA_MODE_BB2 
XTRA_MODE_AB3 

◆ xtra_source

Where the settings came from.

Enumerator
XTRA_SRC_NONE 
XTRA_SRC_BLITZ2 
XTRA_SRC_AB3_TEXT 

◆ xtra_switch

The switch words in file order (offset 2 + 2 * index); each is the Flags word of the option gadget: XTRA_ON (GFLG_SELECTED) = on.

Enumerator
XTRA_SW_RUNTIME_ERRORS 
XTRA_SW_DEBUGGER 
XTRA_SW_LONG_ARRAYS 
XTRA_SW_EXPAND_MACROS 
XTRA_SW_QUOTED_MACROS 
XTRA_SW_MAKE_SMALLEST 
XTRA_SW_DEBUG_INFO 
XTRA_SW_AUTO_RUN 
XTRA_SW_INTERRUPT_CHECK 
XTRA_SW_ASSEMBLER_CHECK 
XTRA_SW_OVERFLOW_CHECK 
XTRA_SW_WARNINGS 
XTRA_SW_DEFAULT_INTERRUPT 
XTRA_SW_DEFAULT_OVERFLOW 

◆ xtra_type

enum xtra_type

The type of a source file (xtra_detect, xtra_load).

Enumerator
XTRA_T_TED 
XTRA_T_BB22 
XTRA_T_AB3 
XTRA_T_TEXT 
XTRA_T_COUNT 

Function Documentation

◆ xtra_ab3_keyname()

const char * xtra_ab3_keyname ( int key)

The name of an AmiBlitz3 key ("ExePath", ..., "Max").

Parameters
keyan enum xtra_ab3_key
Returns
the name; "" for another number

◆ xtra_ab3_size()

size_t xtra_ab3_size ( const struct xtra * x,
const struct xtra_base * b )

The bytes xtra_write_ab3 writes.

Parameters
xthe settings
bthe bases of the views
Returns
the size; 0 on XTRA_E_BASE

◆ xtra_apply_vers0()

void xtra_apply_vers0 ( struct xtra * x)

What blitz2's loadxtra does after reading a vers 0 file.

Auto Run on, Interrupt/Overflow Checking from their defaults, Assembler Checking off (blitz2.s:15371). The loader leaves the file values alone.

Parameters
xthe settings

◆ xtra_blitz2_size()

size_t xtra_blitz2_size ( const struct xtra * x)

The bytes xtra_write_blitz2 writes: the fixed part of x->vers and 4 per maximum with a library number.

Parameters
xthe settings
Returns
the size

◆ xtra_companion_name()

int xtra_companion_name ( const char * path,
char * out,
size_t cap )

The name of the companion of the source path: path + ".xtra" (as TED and blitz2 make it).

Parameters
paththe source's file name
outthe name, 0-terminated
capthe size of out in bytes
Returns
0 or XTRA_E_SPACE

◆ xtra_detect()

int xtra_detect ( const uint8_t * buf,
size_t len,
const char * path )

The type of a source.

"BB22" at the start: XTRA_T_BB22; a $00 byte: XTRA_T_TED; first line "; XTRA": XTRA_T_AB3; other text: XTRA_T_AB3 if path ends in ".ab3" (any case, AmiBlitz3 reads every .ab3 so), else XTRA_T_TEXT. The caller may pass another type to xtra_load.

Parameters
bufthe source
lenits length
pathits file name (may be NULL)
Returns
an enum xtra_type

◆ xtra_get_text()

const uint8_t * xtra_get_text ( const struct xtra * x,
const struct xtra_base * b,
int field,
size_t * len )

A text field.

Parameters
xthe settings
bthe bases of the views (may be NULL)
fieldan enum xtra_field
lenout: the length
Returns
its bytes (not 0-terminated); "" for an empty one; NULL (and *len 0) for a field number out of range or a view whose base b does not give

◆ xtra_has_companion()

int xtra_has_companion ( int type)

Whether the settings of a source of this type are in NAME.xtra.

Parameters
typean enum xtra_type
Returns
1 for XTRA_T_TED, XTRA_T_BB22 and XTRA_T_TEXT, else 0

◆ xtra_init()

void xtra_init ( struct xtra * x)

Initialise settings with the defaults.

Blitz 2's defaults (options.src, the initial gadget flags), no residents, empty texts, no maxima, no editor part, AmiBlitz3's defaults for its own numbers; vers 1, type XTRA_T_TED, XTRA_SRC_NONE.

Parameters
xthe settings

◆ xtra_is_ab3_xtra()

int xtra_is_ab3_xtra ( const uint8_t * xtra,
size_t len )

Whether a companion .xtra has AmiBlitz3's binary format with 15 switch words (since AmiBlitz/AmiBlitz3@bdae3f9e, docs/formats.md 1.3) - not Blitz 2's 14.

The layout as AmiBlitz3's write_xtrafile writes it: vers 1, icon, 15 switch words, 6 buffer sizes at 32, 8 residents at 56, path and name of the executable at 600 and 792, CLI argument (116 bytes) and stack, version, builds at 984 (fixed part XTRA_AB3_FIXED), the {lib, max} pairs, 4 more bytes, maybe PED's XtraExtend. Recognised by: at least the fixed part + 4 bytes, a multiple of 4 (a Blitz 2 .xtra is 982/1110

  • 4n), vers 1, icon and switch words 0 or XTRA_ON, every buffer size below 16 MB (in the 14-word layout's place a buffer's low word would be the next one's high word), the text fields 0-terminated. An older AmiBlitz3 .xtra with 14 switch words is not recognised.
Parameters
xtrathe file, xtra[0..len) (NULL: none)
lenits length
Returns
1 or 0

◆ xtra_load()

int xtra_load ( struct xtra * x,
int type,
const uint8_t * src,
size_t len,
const uint8_t * xtra,
size_t xlen,
struct xtra_error * err )

Load the settings of a source.

x is initialised (xtra_init) and gets:

  • XTRA_T_TED, XTRA_T_TEXT: the .xtra (source XTRA_SRC_BLITZ2) or the defaults (XTRA_SRC_NONE); hdr 0
  • XTRA_T_BB22: the header's editor part, hdr 14/16; the .xtra
  • XTRA_T_AB3: the embedded header (XTRA_SRC_AB3_TEXT, its size in hdr) or AmiBlitz3's defaults (hdr 0)

The views point into the .xtra and into src[0..x->hdr) - the caller keeps both (struct xtra_base). Strict: a .xtra must be 982 + 4n (vers 0) or 1110 + 4n bytes (vers 1) with 0-terminated text fields; the AB3 header must be well-formed (docs/formats.md 7.4).

Parameters
xthe settings
typean enum xtra_type
srcthe source, src[0..len) (may be NULL for XTRA_T_TED/ XTRA_T_TEXT)
lenits length
xtraits companion .xtra, xtra[0..xlen) (NULL: none; ignored for XTRA_T_AB3)
xlenits length
errthe place of an error (may be NULL)
Returns
0 or an enum xtra_err; on an error x holds the defaults

◆ xtra_max_begin()

void xtra_max_begin ( struct xtra_iter * it,
const struct xtra * x,
const struct xtra_base * b )

Start iterating the maxima of x.

Parameters
itthe iterator
xthe settings
bthe bases of the views

◆ xtra_mode()

int xtra_mode ( int force,
const uint8_t * src,
size_t len,
const char * path,
const uint8_t * xtra,
size_t xlen )

The mode of a source (xtra_mode.c; docs/ab3/variant.md).

force XTRA_MODE_BB2 or XTRA_MODE_AB3 (the command line's -mode): that mode. Otherwise by xtra_detect: XTRA_T_AB3 (a text with the embedded header, or a text named *.ab3) is AB3; XTRA_T_TED (tokenised) is AB3 if its companion .xtra has AmiBlitz3's format (xtra_is_ab3_xtra), else BB2; everything else (BB22, text without header) is BB2. The same rule gives the mode of a tokenised include.

Parameters
forcean enum xtra_mode; XTRA_MODE_DETECT (or another value): detect
srcthe source, src[0..len)
lenits length
pathits file name (may be NULL)
xtraits companion .xtra, xtra[0..xlen) (NULL: none)
xlenits length
Returns
XTRA_MODE_BB2 or XTRA_MODE_AB3

◆ xtra_next_max()

int xtra_next_max ( struct xtra_iter * it,
struct xtra_max * m )

The next maximum.

Parameters
itthe iterator (xtra_max_begin)
mout: the maximum
Returns
1 with *m set, 0 at the end

◆ xtra_set_maxima()

void xtra_set_maxima ( struct xtra * x,
const struct xtra_max * m,
uint32_t n )

The maxima from the caller's array instead of those of the .xtra/header.

The AmiBlitz3 writer then replaces all "Max" lines (written in front of "; /XTRA").

Parameters
xthe settings
mthe maxima, m[0..n) (kept by the caller)
ntheir number; 0: none

◆ xtra_set_text()

int xtra_set_text ( struct xtra * x,
int field,
const void * p,
size_t len )

Set a text field to the caller's bytes.

Parameters
xthe settings
fieldan enum xtra_field
pthe text, p[0..len) - kept by the caller as long as x is used (a writer reads it from there)
lenits length
Returns
0, XTRA_E_FIELD, XTRA_E_LONG (len >= xtra_text_cap) or XTRA_E_TEXT (a 0, CR or LF)

◆ xtra_strerror()

const char * xtra_strerror ( int code)

The message of an error code (English, without position).

Parameters
codean enum xtra_err
Returns
the message; "unknown error" for another code

◆ xtra_take_blitz2()

void xtra_take_blitz2 ( struct xtra * to,
const struct xtra * from )

Take what a Blitz 2 .xtra holds from from into to.

vers, icon, switches, buffers, residents (texts, pointers), executable path and name, CLI argument - not the maxima, the editor part, AmiBlitz3's own fields. from's views keep pointing into its .xtra: the base used with to needs from's .xtra (e.g. an .ab3 header updated from a .xtra).

Parameters
tothe settings to change
fromthe settings to take from

◆ xtra_text_cap()

size_t xtra_text_cap ( int field)

The bytes of a text field in a Blitz 2 .xtra (with the 0): a text is shorter than this.

Parameters
fieldan enum xtra_field
Returns
the size; 0 for a field number out of range

◆ xtra_write_ab3()

int xtra_write_ab3 ( const struct xtra * x,
const struct xtra_base * b,
char * out,
size_t cap,
size_t * len,
unsigned * skipped )

Write x as AmiBlitz3 header (not 0-terminated).

  • x from a source with header (x->ab3.header): that header (b->header, x->hdr bytes), line by line: unchanged lines as they are (unknown keys, comments, older layouts, the line ends); the line of a known key whose value in x differs from what the line says gets the new value (the rest of the line kept); keys the header lacks whose value differs from AmiBlitz3's default are added in front of "; /XTRA"; maxima set by xtra_set_maxima replace the "Max" lines. Unchanged x: the same bytes.
  • otherwise a new header, the lines of AmiBlitz3's write_AB3Header (docs/formats.md 7.1), LF line ends.
Parameters
xthe settings
bthe bases of the views
outthe output
capits size in bytes
lenout: the size (also when it does not fit)
skippedout: the maxima without a name, skipped (may be NULL)
Returns
0 or XTRA_E_SPACE, XTRA_E_BASE

◆ xtra_write_blitz2()

int xtra_write_blitz2 ( const struct xtra * x,
const struct xtra_base * b,
uint8_t * out,
size_t cap,
size_t * len,
unsigned * skipped,
struct xtra_error * err )

Write x as Blitz 2 .xtra.

vers as in x (0 without CLI block); a text from the .xtra as its whole field (the bytes after the 0 included: a loaded file gives the same bytes), others 0-terminated and padded with 0; the pairs of the maxima with XTRA_MAX_LIB in their order (the others skipped).

Parameters
xthe settings
bthe bases of the views
outthe output
capits size in bytes
lenout: the size written
skippedout: the maxima skipped (may be NULL)
errthe place of an error (may be NULL)
Returns
0 or XTRA_E_VERS, XTRA_E_SPACE, XTRA_E_LONG, XTRA_E_BASE