FOSSology  4.4.0
Open Source License Compliance by Open Source Software
string_operations.h
1 /*
2  Author: Daniele Fognini, Andreas Wuerl
3  SPDX-FileCopyrightText: © 2013-2015 Siemens AG
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
7 
8 #ifndef MONK_AGENT_STRING_OPERATIONS_H
9 #define MONK_AGENT_STRING_OPERATIONS_H
10 
11 #include <glib.h>
12 #include <string.h>
13 #include <stdint.h>
14 
15 typedef struct {
16  unsigned int length;
17  unsigned int removedBefore;
18  uint32_t hashedContent;
19 } Token;
20 
21 #define token_length(token) (token).length
22 
23 #define tokens_new() g_array_new(FALSE, FALSE, sizeof (Token))
24 #define tokens_free(p) g_array_free((p), TRUE)
25 
26 #define tokens_index(tokens,i) &g_array_index((tokens), Token, (i))
27 
28 GArray* tokenize(const char* inputString, const char* delimiters);
29 
30 int streamTokenize(const char* inputChunk, size_t inputSize, const char* delimiters,
31  GArray** output, Token** remainder);
32 
33 #define tokenEquals(a, b) (((a)->length == (b)->length ) && ((a)->hashedContent == (b)->hashedContent))
34 
35 int tokensEquals(const GArray* a, const GArray* b);
36 
37 size_t token_position_of(size_t index, const GArray* tokens);
38 
39 char* normalize_escape_string(char* input);
40 
41 #endif // MONK_AGENT_STRING_OPERATIONS_H