PatchworkOS  3984a1d
A non-POSIX operating system.
Loading...
Searching...
No Matches
main.c
Go to the documentation of this file.
1#include "taskbar.h"
2
4#include <stdio.h>
5#include <stdlib.h>
6
7int main(void)
8{
9 fd_t klog = open("/dev/klog");
10 if (klog == ERR)
11 {
12 printf("taskbar: failed to open klog\n");
13 return EXIT_FAILURE;
14 }
16 {
17 printf("taskbar: failed to redirect stdout/stderr to klog\n");
18 close(klog);
19 return EXIT_FAILURE;
20 }
21 close(klog);
22
23 display_t* disp = display_new();
24 if (disp == NULL)
25 {
26 printf("taskbar: failed to create display\n");
27 return EXIT_FAILURE;
28 }
29
30 window_t* win = taskbar_new(disp);
31 if (win == NULL)
32 {
33 printf("taskbar: failed to create taskbar\n");
34 display_free(disp);
35 return EXIT_FAILURE;
36 }
37
38 event_t event = {0};
39 while (display_next(disp, &event, CLOCKS_NEVER) != ERR)
40 {
41 display_dispatch(disp, &event);
42 }
43
44 window_free(win);
45 display_free(disp);
46 return 0;
47}
int main(void)
Definition main.c:5
#define CLOCKS_NEVER
Definition clock_t.h:16
uint64_t display_next(display_t *disp, event_t *event, clock_t timeout)
Retrieve the next event from the display connection.
Definition display.c:211
uint64_t display_dispatch(display_t *disp, const event_t *event)
Dispatch an event to the appropriate surface.
Definition display.c:410
void display_free(display_t *disp)
Free a display connection.
Definition display.c:111
display_t * display_new(void)
Create a new display connection.
Definition display.c:46
void window_free(window_t *win)
Free a window.
Definition window.c:427
fd_t dup2(fd_t oldFd, fd_t newFd)
System call for duplicating file descriptors, with a destination.
Definition dup2.c:8
fd_t open(const char *path)
System call for opening files.
Definition open.c:8
uint64_t close(fd_t fd)
System call for closing files.
Definition close.c:8
#define STDOUT_FILENO
Standard output file descriptor.
Definition io.h:35
#define STDERR_FILENO
Standard error file descriptor.
Definition io.h:36
#define NULL
Pointer error value.
Definition NULL.h:23
#define ERR
Integer error value.
Definition ERR.h:17
__UINT64_TYPE__ fd_t
A file descriptor.
Definition fd_t.h:12
static dentry_t * klog
Definition log.c:29
_PUBLIC int printf(const char *_RESTRICT format,...)
Definition printf.c:3
#define EXIT_FAILURE
Definition stdlib.h:47
Opaque display structure.
Definition internal.h:68
Event structure.
Definition event.h:306
Opaque window structure.
Definition internal.h:44
window_t * taskbar_new(display_t *disp)
Definition taskbar.c:351