summaryrefslogtreecommitdiff
path: root/uicc
diff options
context:
space:
mode:
Diffstat (limited to 'uicc')
-rw-r--r--uicc/main.c9
-rw-r--r--uicc/meson.build8
-rw-r--r--uicc/reader.c37
-rw-r--r--uicc/tokenizer.c15
4 files changed, 69 insertions, 0 deletions
diff --git a/uicc/main.c b/uicc/main.c
new file mode 100644
index 0000000..6f0d276
--- /dev/null
+++ b/uicc/main.c
@@ -0,0 +1,9 @@
+#include "arena.c"
+#include "reader.c"
+#include "tokenizer.c"
+#include "utils.c"
+
+int main(int argc, char **argv) {
+ printf("teste: %s\n", argv[0]);
+ return 0;
+}
diff --git a/uicc/meson.build b/uicc/meson.build
new file mode 100644
index 0000000..9696dba
--- /dev/null
+++ b/uicc/meson.build
@@ -0,0 +1,8 @@
+preprocessorSources = files('main.c', 'reader.c', 'tokenizer.c')
+
+executable(
+ 'uicc',
+ preprocessorSources,
+ include_directories: ui_include,
+ install: true,
+)
diff --git a/uicc/reader.c b/uicc/reader.c
new file mode 100644
index 0000000..ea21b82
--- /dev/null
+++ b/uicc/reader.c
@@ -0,0 +1,37 @@
+#include <ui_utils.h>
+
+typedef struct {
+ int fd;
+ uint64_t buffer_size;
+ char *buffer;
+} Reader;
+
+Reader *reader_open(Arena *arena, const char *path, uint64_t buffer_size) {
+ Reader *reader = {0};
+ int fd;
+
+ assert_failure(fd = open(path, O_RDONLY, O_NOFOLLOW), -1);
+
+ reader = arena_type(arena, Reader);
+ reader->fd = fd;
+ reader->buffer_size = buffer_size;
+ reader->buffer = arena_array(arena, char, reader->buffer_size);
+
+ return reader;
+}
+
+void reader_advance(Reader *self, uint32_t *start, uint32_t *end) {
+ if (*end > self->buffer_size) {
+ if (*start == 0) {
+ /* TODO(roberto): maybe reallocate the buffer instead of crashing */
+ crash_error("ERROR: token is too long\n");
+ }
+
+ assert_errno(lseek(self->fd, *start * -1, SEEK_CUR));
+ assert_errno(read(self->fd, self->buffer, self->buffer_size));
+ *end -= *start;
+ *start = 0;
+ }
+}
+
+void reader_close(Reader *self) { close(self->fd); }
diff --git a/uicc/tokenizer.c b/uicc/tokenizer.c
new file mode 100644
index 0000000..90ac274
--- /dev/null
+++ b/uicc/tokenizer.c
@@ -0,0 +1,15 @@
+/**
+ * Definição de elemento
+ * Elemento {
+ * propriedade: valor
+ * }
+ *
+ * Definição do layout
+ * <ContainerList>
+ * <Button label="Olá">
+ * </ContainerList>
+ */
+
+#include "reader.c"
+
+void tokenizeElement(int fd) {}