-
-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathmain.c
More file actions
69 lines (62 loc) · 2.19 KB
/
Copy pathmain.c
File metadata and controls
69 lines (62 loc) · 2.19 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
67
68
69
#include "filesystem.h"
#include "global.h"
#include "remres.h"
#include "config.h"
#include "widget.h"
#include <stdint.h>
#include <stdio.h>
#include <minwindef.h>
#include <limits.h>
int WINAPI
WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR pCmdLine, int nCmdShow)
{
char dir[PATH_MAX];
if (ww_default_widgets_dir(dir, sizeof(dir) - 1) == 0)
{
fprintf(stderr, "Failed to create the default folder\n");
return EXIT_REASON_IO_FAILURE;
}
char url[PATH_MAX], file[PATH_MAX];
if (ww_read_resource_string("remoteUrl", url, sizeof(url) - 1) > 0 &&
ww_read_resource_string("archiveName", file, sizeof(file) - 1) > 0)
{
char zip[PATH_MAX];
const size_t bytes = sizeof(zip) - 1;
ww_get_default_resource_from_remote(url, dir, zip, bytes, file);
ww_unzip_archive(zip);
}
char html[BUFFSIZE];
if (ww_default_index_html(html) == true)
{
fprintf(stderr, "Failed to get the default index webpage\n");
return EXIT_REASON_IO_FAILURE;
}
// Creating the default window. This is the window manager
// that displays a list of all the available widgets.
ww_window_ctx window = {
.width = 1000,
.height = 1000,
.x = 0,
.y = 0,
.index = 0, // Not really needed, but for consistency
.title_bar = false,
.child = false,
.top_most = true,
.title = "WinWidgets",
.opacity = 1,
.radius = 0};
const size_t len = strlen(html);
if (len >= BUFFSIZE)
{
fprintf(stderr,
"Buffer size of filename was larger than expected\n");
return EXIT_REASON_MEM_FAILURE;
}
memcpy(window.filename, html, len);
window.filename[len] = '\0';
if (ww_init_main(hInstance, nCmdShow, pCmdLine, &window) == true)
{
fprintf(stderr, "Failed to create the widget\n");
}
return EXIT_REASON_TERMINATED;
}