💾 Archived View for gemini.rmf-dev.com › repo › Vaati › Vgmi › files › 631cadd0a1a7f32739f5346548ef6… captured on 2023-12-28 at 15:43:40. Gemini links have been rewritten to link to archived content
-=-=-=-=-=-=-
0 /*
1 * ISC License
2 * Copyright (c) 2023 RMF <rawmonk@firemail.cc>
3 */
4 #include <stddef.h>
5 #include <stdio.h>
6 #include <string.h>
7 #include <unistd.h>
8 #include "macro.h"
9 #include "error.h"
10 #include "client.h"
11 #include "dns.h"
12 #include "page.h"
13 #include "request.h"
14 #include "parser.h"
15 #include "secure.h"
16 #include "image.h"
17 #include "tab.h"
18 #include "proc.h"
19 #include "storage.h"
20 #include "config.h"
21 #include "xdg.h"
22
23 int main(int argc, char *argv[]) {
24
25 struct client client = {0};
26 int ret;
27 const char *url = "about:newtab";
28
29 if (argc > 1) {
30 #ifdef ENABLE_IMAGE
31 if (!strcmp(argv[1], "--image")) {
32 if (storage_init()) return -1;
33 config_load();
34 storage_close();
35 image_parser(STDIN_FILENO, STDOUT_FILENO);
36 proc_exit();
37 return 0;
38 }
39 #endif
40 #ifndef DISABLE_XDG
41 if (!strcmp(argv[1], "--xdg")) {
42 xdg_proc(STDIN_FILENO, STDOUT_FILENO);
43 return 0;
44 }
45 #endif
46 if (!strcmp(argv[1], "--page")) {
47 parser_page(STDIN_FILENO, STDOUT_FILENO);
48 proc_exit();
49 return 0;
50 }
51 if (!strcmp(argv[1], "--request")) {
52 parser_request(STDIN_FILENO, STDOUT_FILENO);
53 proc_exit();
54 return 0;
55 }
56 url = argv[1];
57 }
58
59 proc_argv(argv);
60
61 if ((ret = client_init(&client))) {
62 char error[1024];
63 error_string(ret, V(error));
64 printf("Initialisation failure: %s\n", error);
65 return -1;
66 }
67
68 client.tab = tab_new();
69 tab_request(client.tab, url);
70
71 do {
72 client_display(&client);
73 } while (!client_input(&client));
74
75 client_destroy(&client);
76
77 return 0;
78 }
79