38 #ifndef IO_BASIC_H__LOADED 40 #define IO_BASIC_H__LOADED 1 46 #ifndef INITIAL_H__LOADED 51 #ifndef WARNING_H__LOADED 56 #define MAX_IO_ITEM_LEVEL 20 58 #define HAVE_EVENTIO_USER_FLAG 1 59 #define HAVE_EVENTIO_EXTENDED_LENGTH 1 60 #define HAVE_EVENTIO_HEADER_LENGTH 1 63 #define EVENTIO_USER_FLAG 1 64 #define EVENTIO_EXTENSION_FLAG 2 66 typedef unsigned char BYTE;
124 typedef int (*IO_USER_FUNCTION) (
unsigned char *, long, int);
129 # define IO_BUFFER_INITIAL_LENGTH 8192L 130 # define IO_BUFFER_LENGTH_INCREMENT 8192L 131 # define IO_BUFFER_MAXIMUM_LENGTH 65500L 133 # define IO_BUFFER_INITIAL_LENGTH 32768L 134 # define IO_BUFFER_LENGTH_INCREMENT 65536L 136 # define IO_BUFFER_MAXIMUM_LENGTH 1000000L 138 # define IO_BUFFER_MAXIMUM_LENGTH 3000000L 148 #define COPY_BYTES(_target,_source,_num) memcpy(_target,_source,_num) 151 #define COPY_BYTES_SWAB(_target,_source,_num) swab(_source,_target,_num) 158 #define put_byte(_c,_p) (--(_p)->w_remaining>=0 ? \ 159 (*(_p)->data++ = (BYTE)(_c)) : \ 160 (BYTE)extend_io_buffer(_p,(unsigned)(_c), \ 161 (IO_BUFFER_LENGTH_INCREMENT))) 168 #define get_byte(p) (--(p)->r_remaining>=0? *(p)->data++ : -1) 169 #define get_bytes(p,k) (((p)->r_remaining -= k) >=0 ? (*(p)->data+=k)-k : -1) 184 #define put_vector_of_uint8 put_vector_of_byte 185 #define get_vector_of_uint8 get_vector_of_byte 212 #define put_vector_of_int16 put_vector_of_short 213 #define get_vector_of_int16 get_vector_of_short 239 #ifdef HAVE_64BIT_INT 241 void put_vector_of_int64 (
const int64_t *vec,
int num,
IO_BUFFER *iobuf);
242 void get_vector_of_int64 (int64_t *vec,
int num,
IO_BUFFER *iobuf);
243 void put_vector_of_uint64 (
const uint64_t *vec,
int num,
IO_BUFFER *iobuf);
244 void get_vector_of_uint64 (uint64_t *vec,
int num,
IO_BUFFER *iobuf);
296 int maxlevel,
int verbosity);
323 typedef struct ev_reg_entry *(*EVREGSEARCH)(
unsigned long t);
const char * eventio_registered_description(unsigned long type)
Extract the optional description for a given type number, if available.
Definition: eventio.c:5441
void get_vector_of_int(int *vec, int num, IO_BUFFER *iobuf)
Get a vector of (small) integers from I/O buffer.
Definition: eventio.c:1884
int32_t get_int32(IO_BUFFER *iobuf)
Read a four byte integer from an I/O buffer.
Definition: eventio.c:1976
int get_item_end(IO_BUFFER *iobuf, IO_ITEM_HEADER *item_header)
End reading an item.
Definition: eventio.c:3924
int sync_err_count
Count of synchronization errors.
Definition: io_basic.h:119
int put_var_string(const char *s, IO_BUFFER *iobuf)
Put a string of ASCII characters into an I/O buffer.
Definition: eventio.c:2809
int16_t get_scount16(IO_BUFFER *iobuf)
Shortened version of get_scount for up to 16 bits of data.
Definition: eventio.c:1103
long item_start_offset[MAX_IO_ITEM_LEVEL]
Where the item starts in buffer.
Definition: io_basic.h:104
int item_level
Current level of nesting of items.
Definition: io_basic.h:101
int read_io_block(IO_BUFFER *iobuf, IO_ITEM_HEADER *item_header)
Read the data of an I/O block from the input.
Definition: eventio.c:4893
uint32_t get_uint32(IO_BUFFER *iobuf)
Get a four-byte unsigned integer from an I/O buffer.
Definition: eventio.c:2145
void put_vector_of_float(const float *vec, int num, IO_BUFFER *iobuf)
Put a vector of floats as IEEE 'float' numbers into an I/O buffer.
Definition: eventio.c:2982
int get_string(char *s, int nmax, IO_BUFFER *iobuf)
Get a string of ASCII characters from an I/O buffer.
Definition: eventio.c:2695
void put_count32(uint32_t num, IO_BUFFER *iobuf)
Shortened version of put_count for up to 32 bits of data.
Definition: eventio.c:710
int item_extension[MAX_IO_ITEM_LEVEL]
Where the extension field was used.
Definition: io_basic.h:105
int aux_count
May be used for dedicated buffers.
Definition: io_basic.h:116
char * description
Optional longer description of the data block.
Definition: io_basic.h:317
void get_vector_of_uint32_scount_differential(uint32_t *vec, int num, IO_BUFFER *iobuf)
Get an array of uint32_t as differential scount data from an I/O buffer.
Definition: eventio.c:1461
void get_vector_of_uint16(uint16_t *uval, int num, IO_BUFFER *iobuf)
Get a vector of unsigned shorts from an I/O buffer.
Definition: eventio.c:1718
void get_vector_of_real(double *vec, int num, IO_BUFFER *iobuf)
Get a vector of floating point numbers as 'doubles' from an I/O buffer.
Definition: eventio.c:3092
double get_sfloat(IO_BUFFER *iobuf)
Get a 16-bit float from an I/O buffer and expand it to a double.
Definition: eventio.c:3458
uint16_t get_uint16(IO_BUFFER *iobuf)
Get one unsigned short from an I/O buffer.
Definition: eventio.c:1783
int unget_item(IO_BUFFER *iobuf, IO_ITEM_HEADER *item_header)
Go back to the beginning of an item being read.
Definition: eventio.c:3991
int(* user_function)(unsigned char *, long, int)
For use of special type of I/O.
Definition: io_basic.h:110
int reset_io_block(IO_BUFFER *iobuf)
Reset an I/O block to its empty status.
Definition: eventio.c:4507
void dbl_to_sfloat(double dnum, uint16_t *snum)
Convert a double to the internal representation of a 16 bit floating point number as specified in the...
Definition: eventio.c:3306
int msg_ext
1 if buffer extension should be reported, 0 if not
Definition: io_basic.h:121
void put_vector_of_int32(const int32_t *vec, int num, IO_BUFFER *iobuf)
Put a vector of 32 bit integers into I/O buffer.
Definition: eventio.c:1952
long buflen
Usable length of data space.
Definition: io_basic.h:89
void put_int32(int32_t num, IO_BUFFER *iobuf)
Write a four-byte integer to an I/O buffer.
Definition: eventio.c:1911
void put_vector_of_short(const short *vec, int num, IO_BUFFER *iobuf)
Put a vector of 2-byte integers on an I/O buffer.
Definition: eventio.c:1618
int output_fileno
For use of write() function for output.
Definition: io_basic.h:107
void get_vector_of_long(long *vec, int num, IO_BUFFER *iobuf)
Get a vector of 4-byte integers as long int from I/O buffer.
Definition: eventio.c:2358
IO_BUFFER * allocate_io_buffer(size_t buflen)
Dynamic allocation of an I/O buffer.
Definition: eventio.c:261
void put_vector_of_uint32(const uint32_t *vec, int num, IO_BUFFER *iobuf)
Put a vector of 32 bit integers into I/O buffer.
Definition: eventio.c:2120
void put_long(long num, IO_BUFFER *iobuf)
Put a four-byte integer taken from a 'long' into an I/O buffer.
Definition: eventio.c:2248
long get_long(IO_BUFFER *iobuf)
Get 4-byte integer from I/O buffer and return as a long int.
Definition: eventio.c:2313
void get_vector_of_short(short *vec, int num, IO_BUFFER *iobuf)
Get a vector of short integers from I/O buffer.
Definition: eventio.c:1843
int sync_err_max
Maximum accepted number of synchronisation errors.
Definition: io_basic.h:120
int data_pending
Set to 1 when header is read but not the data.
Definition: io_basic.h:113
int skip_io_block(IO_BUFFER *iobuf, IO_ITEM_HEADER *item_header)
Skip the data of an I/O block from the input.
Definition: eventio.c:5013
long w_remaining
Byte available for reading/writing.
Definition: io_basic.h:90
int next_subitem_type(IO_BUFFER *iobuf)
Reads the header of a sub-item and return the type of it.
Definition: eventio.c:4025
void put_scount(intmax_t num, IO_BUFFER *iobuf)
Put a signed integer of unspecified length to an I/O buffer.
Definition: eventio.c:1024
void get_vector_of_uint32(uint32_t *vec, int num, IO_BUFFER *iobuf)
Get a vector of 32 bit integers from I/O buffer.
Definition: eventio.c:2189
int extended
Set to 1 if you want to use the extension field always.
Definition: io_basic.h:118
FILE * output_file
For use of stream I/O for output.
Definition: io_basic.h:109
int get_short(IO_BUFFER *iobuf)
Get a two-byte integer from an I/O buffer.
Definition: eventio.c:1798
void put_vector_of_int_scount(const int *vec, int num, IO_BUFFER *iobuf)
Put an array of ints as scount32 data into an I/O buffer.
Definition: eventio.c:1271
void get_vector_of_byte(BYTE *vec, int num, IO_BUFFER *iobuf)
Get a vector of bytes from an I/O buffer.
Definition: eventio.c:564
int skip_subitem(IO_BUFFER *iobuf)
When the next sub-item is of no interest, it can be skipped.
Definition: eventio.c:4165
int is_allocated
Indicates if buffer is allocated by eventio.
Definition: io_basic.h:100
Indentification of the system and including some basic include file.
int put_string(const char *s, IO_BUFFER *iobuf)
Put a string of ASCII characters into an I/O buffer.
Definition: eventio.c:2665
uint32_t get_count32(IO_BUFFER *iobuf)
Get an unsigned 32 bit integer of unspecified length from an I/O buffer.
Definition: eventio.c:850
void set_eventio_registry_hook(EVREGSEARCH fptr)
This function should be used to set the find_ev_reg_ptr function pointer.
int input_fileno
For use of read() function for input.
Definition: io_basic.h:106
int regular
1 if a regular file, 0 not known, -1 not regular
Definition: io_basic.h:117
intmax_t get_scount(IO_BUFFER *iobuf)
Get a signed integer of unspecified length from an I/O buffer.
Definition: eventio.c:1086
void get_vector_of_int32(int32_t *vec, int num, IO_BUFFER *iobuf)
Get a vector of 32 bit integers from I/O buffer.
Definition: eventio.c:2020
long max_length
The maximum length for extending the buffer.
Definition: io_basic.h:115
int get_var_string(char *s, int nmax, IO_BUFFER *iobuf)
Get a string of ASCII characters from an I/O buffer.
Definition: eventio.c:2837
long next_subitem_length(IO_BUFFER *iobuf)
Reads the header of a sub-item and return the length of it.
Definition: eventio.c:4080
int get_long_string(char *s, int nmax, IO_BUFFER *iobuf)
Get a long string of ASCII characters from an I/O buffer.
Definition: eventio.c:2768
double get_double(IO_BUFFER *iobuf)
Get a double from the I/O buffer.
Definition: eventio.c:3226
Definition: io_basic.h:313
int32_t get_scount32(IO_BUFFER *iobuf)
Shortened version of get_scount for up to 32 bits of data.
Definition: eventio.c:1175
int copy_item_to_io_block(IO_BUFFER *iobuf2, IO_BUFFER *iobuf, const IO_ITEM_HEADER *item_header)
Copy a sub-item to another I/O buffer as top-level item.
Definition: eventio.c:5235
long next_subitem_ident(IO_BUFFER *iobuf)
Reads the header of a sub-item and return the identifier of it.
Definition: eventio.c:4122
FILE * input_file
For use of stream I/O for input.
Definition: io_basic.h:108
void put_short(int num, IO_BUFFER *iobuf)
Put a two-byte integer on an I/O buffer.
Definition: eventio.c:1583
void get_vector_of_uint16_scount_differential(uint16_t *vec, int num, IO_BUFFER *iobuf)
Get an array of uint16_t as differential scount data from an I/O buffer.
Definition: eventio.c:1342
int remove_item(IO_BUFFER *iobuf, IO_ITEM_HEADER *item_header)
Remove an item from an I/O buffer.
Definition: eventio.c:4294
struct ev_reg_entry * find_ev_reg(unsigned long t)
This optionally available function is implemented externally.
Definition: eventio.c:5419
BYTE * data
Position for next get.../put...
Definition: io_basic.h:91
void get_vector_of_double(double *vec, int num, IO_BUFFER *iobuf)
Get a vector of floating point numbers as 'doubles' from an I/O buffer.
Definition: eventio.c:3270
long min_length
The initial and minimum length of the buffer.
Definition: io_basic.h:114
void put_double(double d, IO_BUFFER *iobuf)
Put a 'double' as such into an I/O buffer.
Definition: eventio.c:3152
int rewind_item(IO_BUFFER *iobuf, IO_ITEM_HEADER *item_header)
Go back to the beginning of an item.
Definition: eventio.c:4261
void put_sfloat(double dnum, IO_BUFFER *iobuf)
Put a 16-bit float to an I/O buffer.
Definition: eventio.c:3410
int find_io_block(IO_BUFFER *iobuf, IO_ITEM_HEADER *item_header)
Find the beginning of the next I/O data block in the input.
Definition: eventio.c:4639
void free_io_buffer(IO_BUFFER *iobuf)
Free an I/O buffer that has been allocated at run-time.
Definition: eventio.c:506
void put_vector_of_uint16_scount_differential(uint16_t *vec, int num, IO_BUFFER *iobuf)
Put an array of uint16_t as differential scount data into an I/O buffer.
Definition: eventio.c:1297
void put_scount32(int32_t num, IO_BUFFER *iobuf)
Shorter version of put_scount for up to 32 bytes of data.
Definition: eventio.c:1044
long sub_item_length[MAX_IO_ITEM_LEVEL]
Length of its sub-items.
Definition: io_basic.h:103
void put_vector_of_real(const double *vec, int num, IO_BUFFER *iobuf)
Put a vector of doubles as IEEE 'float' numbers into an I/O buffer.
Definition: eventio.c:2962
void get_vector_of_float(float *vec, int num, IO_BUFFER *iobuf)
Get a vector of floating point numbers as 'floats' from an I/O buffer.
Definition: eventio.c:3115
double get_real(IO_BUFFER *iobuf)
Get a floating point number (as written by put_real) from the I/O buffer.
Definition: eventio.c:3007
int put_long_string(const char *s, IO_BUFFER *iobuf)
Put a long string of ASCII characters into an I/O buffer.
Definition: eventio.c:2736
void put_vector_of_long(const long *vec, int num, IO_BUFFER *iobuf)
Put a vector of long int as 4-byte integers into an I/O buffer.
Definition: eventio.c:2289
void get_vector_of_int_scount(int *vec, int num, IO_BUFFER *iobuf)
Get an array of ints as scount32 data from an I/O buffer.
Definition: eventio.c:1284
int put_item_begin(IO_BUFFER *iobuf, IO_ITEM_HEADER *item_header)
Begin putting another (sub-) item into the output buffer.
Definition: eventio.c:3480
double dbl_from_sfloat(const uint16_t *snum)
Convert from the internal representation of an OpenGL 16-bit floating point number back to normal flo...
Definition: eventio.c:3423
int search_sub_item(IO_BUFFER *iobuf, IO_ITEM_HEADER *item_header, IO_ITEM_HEADER *sub_item_header)
Search for an item of a specified type.
Definition: eventio.c:4198
void fltp_to_sfloat(const float *fnum, uint16_t *snum)
Convert a float to the internal representation of a 16 bit floating point number as specified in the ...
Definition: eventio.c:3326
uintmax_t get_count(IO_BUFFER *iobuf)
Get an unsigned integer of unspecified length from an I/O buffer.
Definition: eventio.c:801
uint16_t get_count16(IO_BUFFER *iobuf)
Get an unsigned 16 bit integer of unspecified length from an I/O buffer.
Definition: eventio.c:957
long item_length[MAX_IO_ITEM_LEVEL]
Length of each level of items.
Definition: io_basic.h:102
int write_io_block(IO_BUFFER *iobuf)
Write an I/O block to the block's output.
Definition: eventio.c:4551
int put_item_end(IO_BUFFER *iobuf, IO_ITEM_HEADER *item_header)
End of putting an item into the output buffer.
Definition: eventio.c:3606
Pass warning messages to the screen or a usr function as set up.
void put_count16(uint16_t num, IO_BUFFER *iobuf)
Shortened version of put_count for up to 16 bits of data.
Definition: eventio.c:761
void put_vector_of_uint32_scount_differential(uint32_t *vec, int num, IO_BUFFER *iobuf)
Put an array of uint16_t as differential scount data into an I/O buffer.
Definition: eventio.c:1431
void put_vector_of_double(const double *vec, int num, IO_BUFFER *iobuf)
Put a vector of doubles into an I/O buffer.
Definition: eventio.c:3196
void put_uint32(uint32_t num, IO_BUFFER *iobuf)
Put a four-byte integer into an I/O buffer.
Definition: eventio.c:2079
char * name
The data block name (short)
Definition: io_basic.h:316
void put_count(uintmax_t num, IO_BUFFER *iobuf)
Put an unsigned integer of unspecified length to an I/O buffer.
Definition: eventio.c:601
int list_sub_items(IO_BUFFER *iobuf, IO_ITEM_HEADER *item_header, int maxlevel, int verbosity)
Display the contents of sub-items on standard output.
Definition: eventio.c:4395
int put_item_begin_with_flags(IO_BUFFER *iobuf, IO_ITEM_HEADER *item_header, int user_flag, int extended)
Begin putting another (sub-) item into the output buffer.
Definition: eventio.c:3503
void put_scount16(int16_t num, IO_BUFFER *iobuf)
Shorter version of put_scount for up to 16 bytes of data.
Definition: eventio.c:1064
unsigned long type
The data block type number.
Definition: io_basic.h:315
void put_vector_of_int(const int *vec, int num, IO_BUFFER *iobuf)
Put a vector of integers (range -32768 to 32767) into I/O buffer.
Definition: eventio.c:1642
int byte_order
Set if block is not in internal byte order.
Definition: io_basic.h:112
The IO_BUFFER structure contains all data needed the manage the stuff.
Definition: io_basic.h:86
int unput_item(IO_BUFFER *iobuf, IO_ITEM_HEADER *item_header)
Undo writing at the present level.
Definition: eventio.c:3710
void put_vector_of_uint16(const uint16_t *uval, int num, IO_BUFFER *iobuf)
Put a vector of unsigned shorts into an I/O buffer.
Definition: eventio.c:1672
void put_real(double d, IO_BUFFER *iobuf)
Put a 4-byte floating point number into an I/O buffer.
Definition: eventio.c:2885
int list_io_blocks(IO_BUFFER *iobuf, int verbosity)
Show the top-level item of an I/O block on standard output.
Definition: eventio.c:5162
const char * eventio_registered_typename(unsigned long type)
This functions using the stored function pointer are now in the core eventio code.
Definition: eventio.c:5429
int get_item_begin(IO_BUFFER *iobuf, IO_ITEM_HEADER *item_header)
Begin reading an item.
Definition: eventio.c:3755
unsigned char * buffer
Pointer to allocated data space.
Definition: io_basic.h:88
void put_vector_of_byte(const BYTE *vec, int num, IO_BUFFER *iobuf)
Put a vector of bytes into an I/O buffer.
Definition: eventio.c:527
int append_io_block_as_item(IO_BUFFER *iobuf, IO_ITEM_HEADER *item_header, BYTE *_buffer, long length)
Append data from one I/O block into another one.
Definition: eventio.c:5320
int extend_io_buffer(IO_BUFFER *iobuf, unsigned next_byte, long increment)
Extend the dynamically allocated I/O buffer.
Definition: eventio.c:391