summaryrefslogtreecommitdiffhomepage
path: root/mixgtk
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2001-04-08 20:23:37 +0000
committerJose Antonio Ortega Ruiz <jao@gnu.org>2001-04-08 20:23:37 +0000
commitea2d77a00733e7bd16766a825e2d38ba0b2f6ecc (patch)
treef0de9e7651ce4bf32ebfc62627cff81185b93837 /mixgtk
parent55ace62d617644c40da6fbcb93c5b5f830f55086 (diff)
downloadmdk-ea2d77a00733e7bd16766a825e2d38ba0b2f6ecc.tar.gz
mdk-ea2d77a00733e7bd16766a825e2d38ba0b2f6ecc.tar.bz2
compilation on FreeBSD fixed
Diffstat (limited to 'mixgtk')
-rw-r--r--mixgtk/mixgtk_cmd_dispatcher.c57
1 files changed, 35 insertions, 22 deletions
diff --git a/mixgtk/mixgtk_cmd_dispatcher.c b/mixgtk/mixgtk_cmd_dispatcher.c
index 180c480..d53e991 100644
--- a/mixgtk/mixgtk_cmd_dispatcher.c
+++ b/mixgtk/mixgtk_cmd_dispatcher.c
@@ -1,7 +1,7 @@
/* -*-c-*- -------------- mixgtk_cmd_dispatcher.c :
* Implementation of the functions declared in mixgtk_cmd_dispatcher.h
* ------------------------------------------------------------------
- * Last change: Time-stamp: "01/04/01 15:22:09 jose"
+ * Last change: Time-stamp: "2001-04-08 01:34:09 jao"
* ------------------------------------------------------------------
* Copyright (C) 2001 Free Software Foundation, Inc.
*
@@ -21,11 +21,12 @@
*
*/
-#define _GNU_SOURCE 1
-
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
#include <mixlib/mix_vm_command.h>
#include "mixgtk_cmd_dispatcher.h"
@@ -36,15 +37,14 @@
/* a mix vm command dispatcher */
struct mixgtk_dispatch_
{
- mix_vm_cmd_dispatcher_t *dispatcher;
- FILE *out;
- char *out_buffer;
- size_t out_buffer_size;
- GtkWidget *prompt;
- GtkWidget *log;
- GtkWidget *status;
- guint context;
- GCompletion *completions;
+ mix_vm_cmd_dispatcher_t *dispatcher; /* the underlying cmd dispatcher */
+ FILE *out; /* the dispatcher's output file */
+ int fildes[2]; /* pipe for communication with the dispatcher */
+ GtkWidget *prompt; /* the command prompt widget */
+ GtkWidget *log; /* the dispatcher's messages echo area */
+ GtkWidget *status; /* the status bar widget */
+ guint context; /* context of the status bar messages */
+ GCompletion *completions; /* mixvm command completions */
};
static struct mixgtk_dispatch_ dis_data_ = {NULL};
@@ -91,13 +91,19 @@ static void
global_post_hook_ (mix_vm_cmd_dispatcher_t *dis,
mix_vm_command_t cmd, const gchar *arg, gpointer data)
{
+ enum {BLKSIZE = 100};
+ static gchar BUFFER[BLKSIZE];
+
+ ssize_t k;
fflush (dis_data_.out);
- if (cmd < MIX_CMD_INVALID)
+ while ((k = read (dis_data_.fildes[0], BUFFER, BLKSIZE)) != 0)
{
- gtk_text_insert (GTK_TEXT (dis_data_.log), NULL, NULL, NULL,
- dis_data_.out_buffer, dis_data_.out_buffer_size);
+ if (k == -1 && errno != EINTR) break;
+ if (cmd < MIX_CMD_INVALID)
+ gtk_text_insert (GTK_TEXT (dis_data_.log), NULL, NULL, NULL,
+ BUFFER, k);
}
- rewind (dis_data_.out);
+
mixgtk_mixvm_update_vm_widgets ();
}
@@ -112,7 +118,8 @@ load_post_hook_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg,
gchar *file = g_strdup (arg);
mixgtk_mixal_load_file ();
mixgtk_mixal_update ();
-
+ mixgtk_mixal_update_bp_all ();
+
if (id != -1)
gtk_statusbar_remove (GTK_STATUSBAR (dis_data_.status),
dis_data_.context, (guint)id);
@@ -206,11 +213,17 @@ mixgtk_cmd_dispatcher_init (void)
if (!dis_data_.dispatcher)
{
- FILE *out = open_memstream (&(dis_data_.out_buffer),
- &(dis_data_.out_buffer_size));
- g_return_val_if_fail (out != NULL, FALSE);
- dis_data_.out = out;
- dis_data_.dispatcher = mix_vm_cmd_dispatcher_new (out, out);
+ int r = pipe (dis_data_.fildes);
+ g_return_val_if_fail (r == 0, FALSE);
+ dis_data_.out = fdopen (dis_data_.fildes[1], "w");
+ g_return_val_if_fail (dis_data_.out != NULL, FALSE);
+ r = fcntl (dis_data_.fildes[0], F_GETFL, 0);
+ g_return_val_if_fail (r != -1, FALSE);
+ r |= O_NONBLOCK;
+ r = fcntl(dis_data_.fildes[0], F_SETFL, r);
+ g_return_val_if_fail (r != -1, FALSE);
+ dis_data_.dispatcher =
+ mix_vm_cmd_dispatcher_new (dis_data_.out, dis_data_.out);
mix_vm_cmd_dispatcher_print_time (dis_data_.dispatcher, FALSE);
install_hooks_ ();
}