This commit is contained in:
2023-08-31 03:26:16 +02:00
parent 47fed0fafa
commit 00b5cb548a
50 changed files with 21616 additions and 262 deletions

39
clib/cflexer_test.c Normal file
View File

@@ -0,0 +1,39 @@
/*
* Copyright 2023 Oleg Borodin <borodin@unix7.org>
*/
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <fcntl.h>
#include <massert.h>
#include <rcache.h>
#include <cflexer.h>
int main(void) {
int fd = open("test.conf", O_RDONLY);
MASSERT(fd > 0);
rcache_t cache;
rcache_init(&cache, fd);
cflexer_t lexer;
cflexer_init(&lexer, &cache);
char token[1024];
int type = 0;
while ((type = cflexer_gettoken(&lexer, token)) != CFLEXTOK_END) {
printf("[%d]: [%s]\n", type, token);
}
printf("[%d]: [%s]\n", type, token);
rcache_destroy(&cache);
return 0;
}