/*************************************************************************** * main.c * * Sun Dec 21 12:10:00 2003 * Copyright 2003 Ryan McDougall * ryanm cpsc ucalgary ca ****************************************************************************/ /* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ //============================================================================== // Includes and Defines #include //============================================================================== // Functions and Objects gboolean clash_console_source_prepare (GSource *source, gint *timeout) { printf ("prepare\n"); return TRUE; } gboolean clash_console_source_check (GSource *source) { printf ("check\n"); return TRUE; } gboolean clash_console_source_dispatch (GSource *source, GSourceFunc callback, gpointer user_data) { printf ("dispatch\n"); return TRUE; } void clash_console_source_finalize (GSource *source) { printf ("finalize\n"); } //============================================================================== // Main entry-point int main () { // Create the functions used by the main loop to operate with console source GSourceFuncs clash_console_source_funcs; clash_console_source_funcs.prepare = &clash_console_source_prepare; clash_console_source_funcs.check = &clash_console_source_check; clash_console_source_funcs.dispatch = &clash_console_source_dispatch; clash_console_source_funcs.finalize = &clash_console_source_finalize; g_print ("%d\n", sizeof (clash_console_source_funcs) ); // Create the source GSource* clash_console_source = g_source_new (&clash_console_source_funcs, sizeof (clash_console_source_funcs)); if (clash_console_source == NULL) { g_printerr ("Could not create GSource.\n"); exit (0); } else {} // Create the context GMainContext* clash_main_context = g_main_context_new (); if (clash_main_context == NULL) { g_printerr ("Could not create GMainContext.\n"); exit (0); } else {} // Attach the source to the context g_source_attach (clash_console_source, clash_main_context); // Create and run main loop GMainLoop* clash_main_loop = g_main_loop_new (clash_main_context, FALSE); g_main_loop_run (clash_main_loop); return (0); }