1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 2018 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17 #ifndef SPVBIN_HELPERS_H
18 #define SPVBIN_HELPERS_H 1
31 #define SPVBIN_MAX_ERRORS 16
37 errors[SPVBIN_MAX_ERRORS];
42 void spvbin_input_init (struct spvbin_input *, const void *, size_t);
43 bool spvbin_input_at_end (const struct spvbin_input *);
45 char *spvbin_input_to_error (const struct spvbin_input *, const char *name);
47 bool spvbin_match_bytes (struct spvbin_input *, const void *, size_t);
48 bool spvbin_match_byte (struct spvbin_input *, uint8_t);
50 bool spvbin_parse_bool (struct spvbin_input *, bool *);
51 bool spvbin_parse_byte (struct spvbin_input *, uint8_t *);
52 bool spvbin_parse_int16 (struct spvbin_input *, uint16_t *);
53 bool spvbin_parse_int32 (struct spvbin_input *, uint32_t *);
54 bool spvbin_parse_int64 (struct spvbin_input *, uint64_t *);
55 bool spvbin_parse_be16 (struct spvbin_input *, uint16_t *);
56 bool spvbin_parse_be32 (struct spvbin_input *, uint32_t *);
57 bool spvbin_parse_be64 (struct spvbin_input *, uint64_t *);
58 bool spvbin_parse_double (struct spvbin_input *, double *);
59 bool spvbin_parse_float (struct spvbin_input *, double *);
60 bool spvbin_parse_string (struct spvbin_input *, char **);
61 bool spvbin_parse_bestring (struct spvbin_input *, char **);
63 void spvbin_error (struct spvbin_input *, const char *name, size_t start);
65 void spvbin_print_header (const char *title, size_t start, size_t len,
67 void spvbin_print_presence (const char *title, int indent, bool);
68 void spvbin_print_bool (const char *title, int indent, bool);
69 void spvbin_print_byte (const char *title, int indent, uint8_t);
70 void spvbin_print_int16 (const char *title, int indent, uint16_t);
71 void spvbin_print_int32 (const char *title, int indent, uint32_t);
72 void spvbin_print_int64 (const char *title, int indent, uint64_t);
73 void spvbin_print_double (const char *title, int indent, double);
74 void spvbin_print_string (const char *title, int indent, const char *);
75 void spvbin_print_case (const char *title, int indent, int);
77 struct spvbin_position
82 struct spvbin_position spvbin_position_save (const struct spvbin_input *);
83 void spvbin_position_restore (struct spvbin_position *, struct spvbin_input *);
90 bool spvbin_limit_parse (struct spvbin_limit *, struct spvbin_input *);
91 bool spvbin_limit_parse_be (struct spvbin_limit *, struct spvbin_input *);
92 void spvbin_limit_pop (struct spvbin_limit *, struct spvbin_input *);
94 #endif /* output/spv/spvbin-helpers.h */