From: Philip Chimento Date: Thu, 21 May 2009 13:14:11 +0000 (+0000) Subject: Defined glui32 and glsi32 in terms of the 32-bit integer types in , instead... X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=aa4120fb3479bcd17f69c0c1cffea4fc9107975b;p=rodin%2Fchimara.git Defined glui32 and glsi32 in terms of the 32-bit integer types in , instead of those in GLib. Now the entire GLib interface is not exposed to Glk plugins anymore. git-svn-id: http://lassie.dyndns-server.com/svn/gargoyle-gtk@59 ddfedd41-794f-dd11-ae45-00112f111e67 --- diff --git a/src/Makefile.am b/src/Makefile.am index 4f05a5b..ace6c6b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -43,19 +43,15 @@ pkglib_LTLIBRARIES = first.la model.la gridtest.la splittest.la PLUGIN_LIBTOOL_FLAGS=-module -avoid-version -export-symbols-regex "^glk_main$$" first_la_SOURCES = first.c -first_la_CFLAGS = @GLIB_CFLAGS@ first_la_LDFLAGS = $(PLUGIN_LIBTOOL_FLAGS) model_la_SOURCES = model.c -model_la_CFLAGS = @GLIB_CFLAGS@ model_la_LDFLAGS = $(PLUGIN_LIBTOOL_FLAGS) gridtest_la_SOURCES = gridtest.c -gridtest_la_CFLAGS = @GLIB_CFLAGS@ gridtest_la_LDFLAGS = $(PLUGIN_LIBTOOL_FLAGS) splittest_la_SOURCES = splittest.c -splittest_la_CFLAGS = @GLIB_CFLAGS@ splittest_la_LDFLAGS = $(PLUGIN_LIBTOOL_FLAGS) CLEANFILES = chimara.ui diff --git a/src/gestalt.c b/src/gestalt.c index 4b3b19c..5add1c3 100644 --- a/src/gestalt.c +++ b/src/gestalt.c @@ -1,3 +1,4 @@ +#include /* Surprisingly, the only symbol needed is NULL */ #include "glk.h" /* Version of the Glk specification implemented by this library */ diff --git a/src/glk.h b/src/glk.h index f1c5b3a..6b64f88 100644 --- a/src/glk.h +++ b/src/glk.h @@ -17,9 +17,9 @@ /* You may have to edit the definition of glui32 to make sure it's really a 32-bit unsigned integer type, and glsi32 to make sure it's really a 32-bit signed integer type. If they're not, horrible things will happen. */ -#include -typedef guint32 glui32; -typedef gint32 glsi32; +#include +typedef uint32_t glui32; +typedef int32_t glsi32; /* These are the compile-time conditionals that reveal various Glk optional modules. */ diff --git a/src/gridtest.c b/src/gridtest.c index 4c59f1d..cec6004 100644 --- a/src/gridtest.c +++ b/src/gridtest.c @@ -1,5 +1,7 @@ #include #include +#include +#include #include "glk.h" void glk_main(void) @@ -17,7 +19,7 @@ void glk_main(void) for(count = 0; count < 30; count++) glk_put_string("I want to write past the end of this text buffer! "); - guint32 width, height; + glui32 width, height; glk_window_get_size(mainwin, &width, &height); fprintf(stderr, "\nWidth: %d\nHeight: %d\nPress a key in the window, not in the terminal.\n", width, height); glk_request_char_event(mainwin); @@ -43,7 +45,8 @@ void glk_main(void) break; } - gchar *buffer = g_malloc0(256); + char *buffer = calloc(256, sizeof(char)); + assert(buffer); fprintf(stderr, "Line input field until end of line\n"); glk_window_move_cursor(mainwin, 10, 20); @@ -63,9 +66,12 @@ void glk_main(void) break; } - gchar *text = g_strndup(buffer, ev.val1); + char *text = calloc(ev.val1 + 1, sizeof(char)); + assert(text); + strncpy(text, buffer, ev.val1); + text[ev.val1] = '\0'; fprintf(stderr, "Your string was: '%s'.\nPress another key to clear the window and exit.\n", text); - g_free(text); + free(text); glk_request_char_event(mainwin); while(1) { glk_select(&ev); @@ -74,5 +80,5 @@ void glk_main(void) } glk_window_clear(mainwin); - g_free(buffer); + free(buffer); }