share/binary: add macros to obtain the number of bytes handled by each function
[neverball] / share / binary.h
1 #ifndef BINARY_H
2 #define BINARY_H
3
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <string.h>
7
8 /*---------------------------------------------------------------------------*/
9
10 #define FLOAT_BYTES     4
11 #define INDEX_BYTES     4
12 #define SHORT_BYTES     2
13 #define ARRAY_BYTES(n)  (FLOAT_BYTES * (n))
14 #define STRING_BYTES(s) (strlen(s) + 1)
15
16 void put_float(FILE *, const float *);
17 void put_index(FILE *, const int   *);
18 void put_short(FILE *, const short *);
19 void put_array(FILE *, const float *, size_t);
20
21 void get_float(FILE *, float *);
22 void get_index(FILE *, int   *);
23 void get_short(FILE *, short *);
24 void get_array(FILE *, float *, size_t);
25
26 void put_string(FILE *fout, const char *);
27 void get_string(FILE *fin, char *, int );
28
29 /*---------------------------------------------------------------------------*/
30
31 #endif