LiVES  3.2.0
Data Structures | Macros | Typedefs | Functions
lsd.h File Reference
#include <stdio.h>
#include <inttypes.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>

Go to the source code of this file.

Data Structures

struct  lives_special_field_t
 
struct  lives_struct_def_t
 112 bytes More...
 

Macros

#define debug_print(...)
 
#define memerr_print(size, name, struct)
 
#define baderr_print(...)   fprintf(stderr, __VA_ARGS__)
 
#define ALLOW_UNUSED
 
#define LSD_TEXTLEN   64
 
#define LSD_NAMELEN   16
 
#define LSD_MAX_ALLOC   65535
 
#define LIVES_STRUCT_ID   0x4C7C56332D2D3035
 
#define _MEM_ALIGNMENT_   0
 
#define LIVES_FIELD_FLAG_ALLOC_AND_COPY   (1l << 0)
 AUTONATION FLAGS. More...
 
#define LIVES_FIELD_FLAG_ZERO_ON_COPY   (1l << 1)
 
#define LIVES_FIELD_FLAG_FREE_ON_DELETE   (1l << 16)
 < field wiill be freed in lives_struct_delete free(struct->field) More...
 
#define LIVES_FIELD_FLAG_FREE_ALL_ON_DELETE   (1l << 17)
 for (i = 0; struct->field[i], i++) free(struct->field[i]; More...
 
#define LIVES_FIELD_FLAG_IS_SUBSTRUCT   (1l << 32)
 flags giving extra info about the field (affects copy and delete) More...
 
#define LIVES_FIELD_FLAG_IS_NULLT_ARRAY   (1l << 33)
 
#define LIVES_FIELD_CHARPTR   (LIVES_FIELD_FLAG_ALLOC_AND_COPY | LIVES_FIELD_FLAG_FREE_ON_DELETE)
 
#define LIVES_FIELD_BLOB   LIVES_FIELD_CHARPTR
 
#define LIVES_FIELD_ARRAY   (LIVES_FIELD_FLAG_IS_NULLT_ARRAY | LIVES_FIELD_FLAG_FREE_ON_DELETE)
 
#define LIVES_FIELD_PTR_ARRAY
 
#define LIVES_FIELD_TO_EMPTY_STRING   (LIVES_FIELD_FLAG_ALLOC_AND_COPY | LIVES_FIELD_FLAG_ZERO_ON_COPY)
 
#define SELF_STRUCT_TYPE   "lives_struct_def_t"
 256 bytes More...
 

Typedefs

typedef struct _lives_struct_def lives_struct_def_t
 
typedef void(* lives_struct_new_cb) (void *strct, void *parent, const char *strct_type, void *new_user_data)
 
typedef void(* lives_struct_copied_cb) (void *strct, void *child, const char *strct_type, void *copied_user_data)
 
typedef void(* lives_struct_destroy_cb) (void *strct, const char *strct_type, void *delete_user_data)
 
typedef void(* lives_field_init_cb) (void *strct, const char *struct_type, const char *field_name, void *ptr_to_field)
 
typedef void(* lives_field_copy_cb) (void *dst_struct, void *src_struct, const char *strct_type, const char *field_name, void *ptr_to_dst_field, void *ptr_to_src_field)
 
typedef void(* lives_field_delete_cb) (void *strct, const char *struct_type, const char *field_name, void *ptr_to_field)
 d->*field_name = s->(field_name) + 10; or using anonymous fields: *(int *)dst_field = *(int *)src_field + 10; More...
 

Functions

 error ("LSD_RANDFUNC(ptr, size) must be defined")
 

Macro Definition Documentation

◆ _MEM_ALIGNMENT_

#define _MEM_ALIGNMENT_   0

Definition at line 87 of file lsd.h.

◆ ALLOW_UNUSED

#define ALLOW_UNUSED

Definition at line 45 of file lsd.h.

◆ baderr_print

#define baderr_print (   ...)    fprintf(stderr, __VA_ARGS__)

Definition at line 37 of file lsd.h.

◆ debug_print

#define debug_print (   ...)

Definition at line 23 of file lsd.h.

◆ LIVES_FIELD_ARRAY

Definition at line 174 of file lsd.h.

◆ LIVES_FIELD_BLOB

#define LIVES_FIELD_BLOB   LIVES_FIELD_CHARPTR

Definition at line 172 of file lsd.h.

◆ LIVES_FIELD_CHARPTR

Definition at line 171 of file lsd.h.

◆ LIVES_FIELD_FLAG_ALLOC_AND_COPY

#define LIVES_FIELD_FLAG_ALLOC_AND_COPY   (1l << 0)

AUTONATION FLAGS.

copy flags alloc and copy on copy. If bytesize is set that will be the alocated size, if 0 then we do a strdup. Fixed size is ignored for arrays. if bytesize is 0, field will be set to NULL in lives_struct_copy, if ALLOC_AND_COPY is also set, will be set to empty string if bytesize > 0 and not IS_NULLT_ARRAY then field will will be filled with bytesize zeros dest->field = NULL or memset(dets->field, 0, bytesize) for ARRAYS, the process will be appied to each element in turn however, since a NULL element marks the end of a NULLT_ARRAY, the combination ALLOC_AND_COPY | ZERO_ON_COPY | IS_NULLT_ARRAY may interfere with subsequent copying

Definition at line 118 of file lsd.h.

◆ LIVES_FIELD_FLAG_FREE_ALL_ON_DELETE

#define LIVES_FIELD_FLAG_FREE_ALL_ON_DELETE   (1l << 17)

for (i = 0; struct->field[i], i++) free(struct->field[i];

combined with IS_NULLT_ARRAY, frees all elements, combine with FREE_ON_DELETE to free elemnt after

Definition at line 127 of file lsd.h.

◆ LIVES_FIELD_FLAG_FREE_ON_DELETE

#define LIVES_FIELD_FLAG_FREE_ON_DELETE   (1l << 16)

< field wiill be freed in lives_struct_delete free(struct->field)

Definition at line 124 of file lsd.h.

◆ LIVES_FIELD_FLAG_IS_NULLT_ARRAY

#define LIVES_FIELD_FLAG_IS_NULLT_ARRAY   (1l << 33)

Definition at line 141 of file lsd.h.

◆ LIVES_FIELD_FLAG_IS_SUBSTRUCT

#define LIVES_FIELD_FLAG_IS_SUBSTRUCT   (1l << 32)

flags giving extra info about the field (affects copy and delete)

< field is a substruct with its own lives_struct_def_t; functions should be called recursively it must be possible to locate the lives_struct_def_t field from the first byte sequence matching LIVES_STRUCT_ID in its identifier field lives_struct_copy(struct->field if this is set, all other flag bits are ignored for the field field is an array of elements of size bytelen, last element has all bytes set to zero if bytesize is zero, it is an array of NUL terminated char may be combined with ALLOC_AND_COPY, FREE_ON_DELETE, FREE_ALL_ON_DELETE

Definition at line 140 of file lsd.h.

◆ LIVES_FIELD_FLAG_ZERO_ON_COPY

#define LIVES_FIELD_FLAG_ZERO_ON_COPY   (1l << 1)

Definition at line 119 of file lsd.h.

◆ LIVES_FIELD_PTR_ARRAY

#define LIVES_FIELD_PTR_ARRAY

◆ LIVES_FIELD_TO_EMPTY_STRING

#define LIVES_FIELD_TO_EMPTY_STRING   (LIVES_FIELD_FLAG_ALLOC_AND_COPY | LIVES_FIELD_FLAG_ZERO_ON_COPY)

Definition at line 181 of file lsd.h.

◆ LIVES_STRUCT_ID

#define LIVES_STRUCT_ID   0x4C7C56332D2D3035

Definition at line 51 of file lsd.h.

◆ LSD_MAX_ALLOC

#define LSD_MAX_ALLOC   65535

Definition at line 50 of file lsd.h.

◆ LSD_NAMELEN

#define LSD_NAMELEN   16

Definition at line 49 of file lsd.h.

◆ LSD_TEXTLEN

#define LSD_TEXTLEN   64

Definition at line 48 of file lsd.h.

◆ memerr_print

#define memerr_print (   size,
  name,
  struct 
)
Value:
fprintf(stderr, "WARNING: memory failure allocating " \
"%lu bytes for field %s in struct %s", \
size, name, struct)

Definition at line 28 of file lsd.h.

◆ SELF_STRUCT_TYPE

#define SELF_STRUCT_TYPE   "lives_struct_def_t"

256 bytes

Definition at line 275 of file lsd.h.

Typedef Documentation

◆ lives_field_copy_cb

typedef void(* lives_field_copy_cb) (void *dst_struct, void *src_struct, const char *strct_type, const char *field_name, void *ptr_to_dst_field, void *ptr_to_src_field)

Definition at line 209 of file lsd.h.

◆ lives_field_delete_cb

typedef void(* lives_field_delete_cb) (void *strct, const char *struct_type, const char *field_name, void *ptr_to_field)

d->*field_name = s->(field_name) + 10; or using anonymous fields: *(int *)dst_field = *(int *)src_field + 10;

Definition at line 220 of file lsd.h.

◆ lives_field_init_cb

typedef void(* lives_field_init_cb) (void *strct, const char *struct_type, const char *field_name, void *ptr_to_field)

Definition at line 205 of file lsd.h.

◆ lives_struct_copied_cb

typedef void(* lives_struct_copied_cb) (void *strct, void *child, const char *strct_type, void *copied_user_data)

Definition at line 196 of file lsd.h.

◆ lives_struct_def_t

typedef struct _lives_struct_def lives_struct_def_t

Definition at line 94 of file lsd.h.

◆ lives_struct_destroy_cb

typedef void(* lives_struct_destroy_cb) (void *strct, const char *strct_type, void *delete_user_data)

Definition at line 200 of file lsd.h.

◆ lives_struct_new_cb

typedef void(* lives_struct_new_cb) (void *strct, void *parent, const char *strct_type, void *new_user_data)

Definition at line 192 of file lsd.h.

Function Documentation

◆ error()

error ( "LSD_RANDFUNC(ptr, size) must be defined"  )
LIVES_FIELD_FLAG_ALLOC_AND_COPY
#define LIVES_FIELD_FLAG_ALLOC_AND_COPY
AUTONATION FLAGS.
Definition: lsd.h:108
LIVES_FIELD_FLAG_FREE_ALL_ON_DELETE
#define LIVES_FIELD_FLAG_FREE_ALL_ON_DELETE
for (i = 0; struct->field[i], i++) free(struct->field[i];
Definition: lsd.h:127
LIVES_FIELD_ARRAY
#define LIVES_FIELD_ARRAY
Definition: lsd.h:174