-
Notifications
You must be signed in to change notification settings - Fork 5
/
qs_parse.h
54 lines (35 loc) · 1.73 KB
/
qs_parse.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <string.h>
#ifndef BG_QSPARSE_H_
#define BG_QSPARSE_H_
#ifdef __cplusplus
extern "C" {
#endif
/* string.h needed for strcspn() and strlen() */
/* Similar to strncmp, but handles URL-encoding for either string */
int qs_strncmp(const char * s, const char * qs, register size_t n);
/* Finds the beginning of each key/value pair and stores a pointer in qs_kv.
* Also decodes the value portion of the k/v pair *in-place*. In a future
* enhancement it will also have a compile-time option of sorting qs_kv
* alphabetically by key. */
int qs_parse(char * qs, char * qs_kv[], int qs_kv_size);
/* Used by qs_parse to decode the value portion of a k/v pair */
int qs_decode(char * qs);
/* Looks up the value according to the key on a pre-processed query string
* A future enhancement will be a compile-time option to look up the key
* in a pre-sorted qs_kv array via a binary search. */
char * qs_k2v(const char * key, char * qs_kv[], int qs_kv_size);
/* Non-destructive lookup of value, based on key. User provides the
* destinaton string and length. */
char * qs_scanvalue(const char * key, const char * qs, char * val, size_t val_len);
/* Converts the 3 or 6 (RGB), or 4 or 8 (RGBA) hex chars in the color string
* to double values in the range 0.0-1.0. Returns the number of converted
* chars. */
int hex2dcolor(char * color, double * r, double * g, double * b, double * a);
/* Converts the 3/6 (RGB) or 4/8 (RGBA) hex chars in the color string to
* values spanning the full range of unsigned char, 0-255. Returns the
* number of converted chars. */
int hex2ccolor(char * color, unsigned char * r, unsigned char * g, unsigned char * b, unsigned char * a);
#ifdef __cplusplus
}
#endif
#endif // BG_QSPARSE_H_