-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.h
More file actions
66 lines (56 loc) · 1.2 KB
/
Copy pathutils.h
File metadata and controls
66 lines (56 loc) · 1.2 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
#pragma once
#include <stdio.h>
#include <stdint.h>
static void skipLine(FILE * file) {
char buf;
while (fread(&buf, 1, 1, file)) {
if (buf == '\n') break;
}
}
//Read until space and skip comments
void parseSpace(FILE *file, uint8_t *buffer);
inline uint8_t char2Int(uint8_t c) {
return (uint8_t)(c-48);
}
//TOken stuff
struct token {
char val[4];
};
struct tokenizedLine {
unsigned short tokCount;
struct token tokens [4];
enum ARG_TYPE type;
};
inline int isNumber(char c) {
return ((c > 47) && (c < 58));
}
inline int stringToInt(const char *string) {
int i = 0;
int out = 0;
while (string[i] != '\0') {
if (!isNumber(string[i])) {
i++;
continue;
}
out *= 10;
out += string[i]-48;
i++;
}
return out;
}
inline void tokenizeLine(struct tokenizedLine *tl, char *line) {
//printf("Symbols in line: %lu\n", sizeof(line));
uint8_t linePos = 0, tokenPos = 0;
char *targ, *src = &line[linePos];
tl->tokCount = 0;
printf("Len of line: %lu", sizeof(line));
while (*src != '\0') {
src = &line[linePos];
targ = &tl->tokens[tl->tokCount].val[tokenPos];
*targ = *src;
tokenPos++; linePos++;
if (*src == ' ') { tokenPos = 0; tl->tokCount++; }
}
printf("\n");
tl->tokCount++;
}