X-Git-Url: http://git.mutantstargoat.com?p=winnie;a=blobdiff_plain;f=libwinnie%2Fsrc%2Fwinnie.cc;h=121c7d6c4515746266ab09b1e733bd7897eaed40;hp=ffbe94d45f318c37c40fe70c2ae1bd1a46699cf7;hb=87255f9ad8bb7f8aea8b8c073e869b9a53c07322;hpb=7b5d2df884abb7084d71f17cc29a618c0b6f47ef
diff --git a/libwinnie/src/winnie.cc b/libwinnie/src/winnie.cc
index ffbe94d..121c7d6 100644
--- a/libwinnie/src/winnie.cc
+++ b/libwinnie/src/winnie.cc
@@ -19,6 +19,13 @@ along with this program. If not, see .
Author: Eleni Maria Stea
*/
+#include
+#include
+#include
+
+#include
+#include
+#include
#include
#include "keyboard.h"
@@ -75,6 +82,65 @@ void winnie_shutdown()
destroy_shared_memory();
}
+static int fd;
+static void *pool;
+
+bool winnie_open()
+{
+ if(((fd = shm_open(SHMNAME, O_RDWR, S_IRWXU)) == -1)) {
+ fprintf(stderr, "Failed to open shared memory: %s\n", strerror(errno));
+ return false;
+ }
+
+ if((pool = mmap(0, POOL_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0)) == (void*)-1) {
+ fprintf(stderr, "Failed to map shared memory: %s\n", strerror(errno));
+ return false;
+ }
+ shm_unlink(SHMNAME);
+
+ subsys = (Subsys*)pool;
+
+ if(!client_open_gfx(pool, subsys->graphics_offset)) {
+ fprintf(stderr, "Failed to open graphics.\n");
+ return false;
+ }
+
+ if(!client_open_keyboard(pool, subsys->keyboard_offset)) {
+ fprintf(stderr, "Failed to open keyboard.\n");
+ return false;
+ }
+
+ if(!client_open_mouse(pool, subsys->mouse_offset)) {
+ fprintf(stderr, "Failed to open mouse.\n");
+ return false;
+ }
+
+ if(!client_open_text(pool, subsys->text_offset)) {
+ fprintf(stderr, "Failed to open text.\n");
+ return false;
+ }
+
+ if(!client_open_wm(pool, subsys->wm_offset)) {
+ fprintf(stderr, "Failed to open the window manager.\n");
+ return false;
+ }
+
+ return true;
+}
+
+void winnie_close()
+{
+ client_close_gfx();
+ client_close_keyboard();
+ client_close_mouse();
+ client_close_text();
+ client_close_wm();
+
+ if(munmap(pool, POOL_SIZE) == -1) {
+ fprintf(stderr, "Failed to unmap shared memory: %s\n", strerror(errno));
+ }
+}
+
long winnie_get_time()
{
static struct timeval init_tv;