satyr 0.42
Loading...
Searching...
No Matches
utils.h
Go to the documentation of this file.
1/*
2 utils.h
3
4 Copyright (C) 2010 Red Hat, Inc.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License along
17 with this program; if not, write to the Free Software Foundation, Inc.,
18 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19*/
20#ifndef SATYR_UTILS_H
21#define SATYR_UTILS_H
22
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34#include <stdlib.h>
35#include <stdarg.h>
36#include <stdbool.h>
37#include <stdint.h>
38#include <assert.h>
39#include <glib.h>
40
41#define SR_lower "abcdefghijklmnopqrstuvwxyz"
42#define SR_upper "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
43#define SR_alpha SR_lower SR_upper
44#define SR_space " \t\r\n\v\f"
45#define SR_digit "0123456789"
46#define SR_alnum SR_alpha SR_digit
47
48#define __sr_printf(x, y) __attribute__((format(printf, (x), (y))))
49
54extern bool
56
57void
58sr_struniq(char **strings, size_t *size);
59
64int
65sr_ptrstrcmp(const void *s1, const void *s2);
66
77char *
78sr_strchr_location(const char *s, int c, int *line, int *column);
79
90char *
91sr_strstr_location(const char *haystack,
92 const char *needle,
93 int *line,
94 int *column);
95
104size_t
105sr_strspn_location(const char *s,
106 const char *accept,
107 int *line,
108 int *column);
109
115char *
116sr_file_to_string(const char *filename,
117 char **error_message);
118
119bool
120sr_string_to_file(const char *filename,
121 char *contents,
122 char **error_message);
123
129bool
130sr_skip_char(const char **input, char c);
131
137bool
138sr_skip_char_limited(const char **input, const char *allowed);
139
146bool
147sr_parse_char_limited(const char **input,
148 const char *allowed,
149 char *result);
150
156int
157sr_skip_char_sequence(const char **input, char c);
158
166int
167sr_skip_char_span(const char **input, const char *chars);
168
180int
181sr_skip_char_span_location(const char **input,
182 const char *chars,
183 int *line,
184 int *column);
185
195int
196sr_parse_char_span(const char **input,
197 const char *accept,
198 char **result);
199
207int
208sr_skip_char_cspan(const char **input, const char *reject);
209
219bool
220sr_parse_char_cspan(const char **input,
221 const char *reject,
222 char **result);
223
231int
232sr_skip_string(const char **input, const char *string);
233
242bool
243sr_parse_string(const char **input, const char *string, char **result);
244
250char
251sr_parse_digit(const char **input);
252
260int
261sr_skip_uint(const char **input);
262
269int
270sr_parse_uint32(const char **input, uint32_t *result);
271
272int
273sr_parse_uint64(const char **input, uint64_t *result);
274
282int
283sr_skip_hexadecimal_uint(const char **input);
284
292int
293sr_skip_hexadecimal_0xuint(const char **input);
294
302int
303sr_parse_hexadecimal_uint64(const char **input, uint64_t *result);
304
312int
313sr_parse_hexadecimal_0xuint64(const char **input, uint64_t *result);
314
315char *
316sr_skip_whitespace(const char *s);
317
318char *
319sr_skip_non_whitespace(const char *s);
320
321bool
322sr_skip_to_next_line_location(const char **s, int *line, int *column);
323
327char *
328sr_bin2hex(char *dst, const char *str, int count);
329
330char *
331sr_indent(const char *input, int spaces);
332
333char *
334sr_indent_except_first_line(const char *input, int spaces);
335
336char *
337sr_build_path(const char *first_element, ...);
338
344void
345sr_parse_os_release(const char *input,
346 void (*callback)(char*, char*, void*),
347 void *data);
348
349char*
350anonymize_path(char *file_name);
351
357char *
358sr_demangle_symbol(const char *sym);
359
360#ifdef __cplusplus
361}
362#endif
363
364#endif
int sr_skip_uint(const char **input)
int sr_skip_char_span(const char **input, const char *chars)
bool sr_parse_string(const char **input, const char *string, char **result)
int sr_parse_uint32(const char **input, uint32_t *result)
int sr_skip_hexadecimal_uint(const char **input)
int sr_skip_char_cspan(const char **input, const char *reject)
bool sr_debug_parser
void sr_parse_os_release(const char *input, void(*callback)(char *, char *, void *), void *data)
char * sr_strchr_location(const char *s, int c, int *line, int *column)
bool sr_skip_char_limited(const char **input, const char *allowed)
int sr_ptrstrcmp(const void *s1, const void *s2)
char * sr_file_to_string(const char *filename, char **error_message)
int sr_skip_char_sequence(const char **input, char c)
int sr_parse_hexadecimal_uint64(const char **input, uint64_t *result)
int sr_skip_string(const char **input, const char *string)
int sr_skip_hexadecimal_0xuint(const char **input)
char * sr_demangle_symbol(const char *sym)
int sr_parse_hexadecimal_0xuint64(const char **input, uint64_t *result)
int sr_skip_char_span_location(const char **input, const char *chars, int *line, int *column)
char * sr_bin2hex(char *dst, const char *str, int count)
char sr_parse_digit(const char **input)
bool sr_parse_char_cspan(const char **input, const char *reject, char **result)
int sr_parse_char_span(const char **input, const char *accept, char **result)
char * sr_strstr_location(const char *haystack, const char *needle, int *line, int *column)
size_t sr_strspn_location(const char *s, const char *accept, int *line, int *column)
bool sr_skip_char(const char **input, char c)
bool sr_parse_char_limited(const char **input, const char *allowed, char *result)