-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstrutils.h
46 lines (32 loc) · 848 Bytes
/
strutils.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
/* String utils */
#ifndef STRUTILS_H
#define STRUTILS_H
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#ifdef __cplusplus
extern "C" {
#endif
struct url_info {
char *scheme;
char *hostn;
int port;
char *path;
};
void split_url(struct url_info *ui, char *url);
/* split_url() - split url to its parts and store in a struct
Usage:
struct url_info urlp;
char url[] = "https://foo/bar";
parse_url(&urlp, url);
// now urlp.scheme contains "https", urlp.host contains "foo"
// urlp.path contains "/bar" and urlp.port contains int 443.
*/
/* ------------------------------------------------------------------------ */
// convert a hex string such as "A489B1" into an array like [0xA4, 0x89, 0xB1].
void hexToBytes(uint8_t *byteArray, const char *hexString);
#ifdef __cplusplus
}
#endif
#endif