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

Data Structures

struct  span
struct  out

Functions

static int lower (int c)
static int blank (int c)
static void trim (struct span *s)
static int same (struct span s, const char *w)
static int dec (uint32_t *v, unsigned d)
static int number (struct span s, uint32_t *out)
static int text (struct span *s)
static int view (struct xtra *x, int f, const uint8_t *h, struct span s)
static void setsw (struct xtra *x, int sw, uint32_t v)
const char * xtra_ab3_keyname (int k)
 The name of an AmiBlitz3 key ("ExePath", ..., "Max").
static int keyof (struct span key, struct span *name)
static int version (struct span s, uint8_t v[3])
static int residents (struct xtra *x, const uint8_t *h, struct span s)
static int maximum (struct xtra *x, struct span name, struct span value, size_t lstart)
static int keyvalue (struct xtra *x, const uint8_t *h, struct span key, struct span value, uint32_t line, size_t lstart)
static void nextline (const uint8_t *buf, size_t size, size_t *pos, struct span *s)
static int marker (struct span s, const char *word)
static int split (struct span t, struct span *key, struct span *value)
int xtra_ab3_has_header (const uint8_t *buf, size_t size)
void xtra_ab3_defaults (struct xtra *x)
int xtra_ab3_read (struct xtra *x, const uint8_t *buf, size_t size, struct xtra_error *err)
int xtra_ab3_next_max (const uint8_t *h, uint32_t *pos, uint32_t end, struct xtra_max *m)
static void ch (struct out *o, char c)
static void str (struct out *o, const char *s)
static void bytes (struct out *o, const void *p, size_t n)
static void num (struct out *o, uint32_t v)
static void snum (struct out *o, uint32_t v)
static uint32_t word (uint16_t v)
static void key (struct out *o, int k)
static int on (uint16_t v)
static uint32_t cursor (const struct xtra *x, int column)
static int value (struct out *o, int k, const struct xtra *x, const struct xtra_base *b)
static int keyline (struct out *o, int k, const struct xtra *x, const struct xtra_base *b)
static int same_text (const struct xtra *x, const struct xtra *y, const struct xtra_base *b, int f)
static int same_value (int k, const struct xtra *x, const struct xtra *y, const struct xtra_base *b)
static void maxlines (struct out *o, const struct xtra *x, const struct xtra_base *b, unsigned *skip)
static void section (struct out *o, const char *title)
static int fresh (struct out *o, const struct xtra *x, const struct xtra_base *b, unsigned *skip)
static int linekey (struct span s, struct span *key, struct span *value)
static int later (const uint8_t *h, size_t pos, size_t end, int k)
static int update (struct out *o, const struct xtra *x, const struct xtra_base *b, unsigned *skip)
int xtra_write_ab3 (const struct xtra *x, const struct xtra_base *b, char *outbuf, 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.

Function Documentation

◆ blank()

int blank ( int c)
static

◆ bytes()

void bytes ( struct out * o,
const void * p,
size_t n )
static

◆ ch()

void ch ( struct out * o,
char c )
static

◆ cursor()

uint32_t cursor ( const struct xtra * x,
int column )
static

◆ dec()

int dec ( uint32_t * v,
unsigned d )
static

◆ fresh()

int fresh ( struct out * o,
const struct xtra * x,
const struct xtra_base * b,
unsigned * skip )
static

◆ key()

void key ( struct out * o,
int k )
static

◆ keyline()

int keyline ( struct out * o,
int k,
const struct xtra * x,
const struct xtra_base * b )
static

◆ keyof()

int keyof ( struct span key,
struct span * name )
static

◆ keyvalue()

int keyvalue ( struct xtra * x,
const uint8_t * h,
struct span key,
struct span value,
uint32_t line,
size_t lstart )
static

◆ later()

int later ( const uint8_t * h,
size_t pos,
size_t end,
int k )
static

◆ linekey()

int linekey ( struct span s,
struct span * key,
struct span * value )
static

◆ lower()

int lower ( int c)
static

◆ marker()

int marker ( struct span s,
const char * word )
static

◆ maximum()

int maximum ( struct xtra * x,
struct span name,
struct span value,
size_t lstart )
static

◆ maxlines()

void maxlines ( struct out * o,
const struct xtra * x,
const struct xtra_base * b,
unsigned * skip )
static

◆ nextline()

void nextline ( const uint8_t * buf,
size_t size,
size_t * pos,
struct span * s )
static

◆ num()

void num ( struct out * o,
uint32_t v )
static

◆ number()

int number ( struct span s,
uint32_t * out )
static

◆ on()

int on ( uint16_t v)
static

◆ residents()

int residents ( struct xtra * x,
const uint8_t * h,
struct span s )
static

◆ same()

int same ( struct span s,
const char * w )
static

◆ same_text()

int same_text ( const struct xtra * x,
const struct xtra * y,
const struct xtra_base * b,
int f )
static

◆ same_value()

int same_value ( int k,
const struct xtra * x,
const struct xtra * y,
const struct xtra_base * b )
static

◆ section()

void section ( struct out * o,
const char * title )
static

◆ setsw()

void setsw ( struct xtra * x,
int sw,
uint32_t v )
static

◆ snum()

void snum ( struct out * o,
uint32_t v )
static

◆ split()

int split ( struct span t,
struct span * key,
struct span * value )
static

◆ str()

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

◆ text()

int text ( struct span * s)
static

◆ trim()

void trim ( struct span * s)
static

◆ update()

int update ( struct out * o,
const struct xtra * x,
const struct xtra_base * b,
unsigned * skip )
static

◆ value()

int value ( struct out * o,
int k,
const struct xtra * x,
const struct xtra_base * b )
static

◆ version()

int version ( struct span s,
uint8_t v[3] )
static

◆ view()

int view ( struct xtra * x,
int f,
const uint8_t * h,
struct span s )
static

◆ word()

uint32_t word ( uint16_t v)
static

◆ xtra_ab3_defaults()

void xtra_ab3_defaults ( struct xtra * x)

◆ xtra_ab3_has_header()

int xtra_ab3_has_header ( const uint8_t * buf,
size_t size )

◆ 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_next_max()

int xtra_ab3_next_max ( const uint8_t * h,
uint32_t * pos,
uint32_t end,
struct xtra_max * m )

◆ xtra_ab3_read()

int xtra_ab3_read ( struct xtra * x,
const uint8_t * buf,
size_t size,
struct xtra_error * err )

◆ 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_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