blob: d15207cec9cb81dedf9a36d9eba06d6577beaa49 (
plain)
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
|
#include <stdlib.h>
#include <string.h>
#include "parse.h"
static unsigned ifsrun(const char* input, const char* ift) {
unsigned i;
for (i = 0; input[i] != '\0' && strchr(ift, input[i]); i++);
return i;
}
int strtodata(const char* str, char** data, size_t* size) {
const char* ifs = IFS;
*size = 0;
size_t i;
size_t str_len = strlen(str);
// TODO: finish this parser
// for (i = 0; i < str_len; i++) {
// unsigned ifs_run = ifsrun(&str[i], ifs);
//
// }
*size = str_len;
*data = (char*) malloc(*size);
memcpy(*data, str, *size);
return 0;
}
|