diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2012-01-12 00:14:22 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2012-01-12 00:14:22 (GMT) |
commit | d90aa93fc202fdf1ba4e4e7e799ce8d7e4632b7f (patch) | |
tree | fb364dfd226ea7977bc265d9a4e94ee56c0406db /src | |
parent | 486f0bf0a27ffed3e9fde2f183974ae029b45c54 (diff) |
Removed all references to libvte and the Python shell.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@224 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 5 | ||||
-rw-r--r-- | src/editor.c | 9 | ||||
-rw-r--r-- | src/shell.c | 345 | ||||
-rw-r--r-- | src/shell.h | 38 |
4 files changed, 5 insertions, 392 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 1d796cf..9432240 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -80,18 +80,17 @@ openida_SOURCES = \ main.c \ params.h params.c \ project.h project.c \ - shell.h shell.c \ xdg.h xdg.c -INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/intl $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) `pkg-config --cflags gthread-2.0` $(LIBPYTHON_CFLAGS) $(LIBVTE_CFLAGS) +INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/intl $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) `pkg-config --cflags gthread-2.0` $(LIBPYTHON_CFLAGS) AM_CPPFLAGS = AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS) -openida_LDFLAGS = $(LIBGTK_LIBS) -L/usr/X11R6/lib -ldl -lm $(LIBXML_LIBS) `pkg-config --libs gthread-2.0` $(LIBPYTHON_LIBS) $(LIBVTE_LIBS) \ +openida_LDFLAGS = $(LIBGTK_LIBS) -L/usr/X11R6/lib -ldl -lm $(LIBXML_LIBS) `pkg-config --libs gthread-2.0` $(LIBPYTHON_LIBS) \ -L.libs -loidaglibext -loidadisass -loidagtkext \ -Lcommon/.libs -lcommon \ -Lpanels/.libs -lpanels \ diff --git a/src/editor.c b/src/editor.c index fb0ccc7..e540e5e 100644 --- a/src/editor.c +++ b/src/editor.c @@ -63,9 +63,6 @@ -#include "shell.h" /* TODO : à virer -> plugin */ - - @@ -559,10 +556,10 @@ GtkWidget *create_editor(void) - panel = build_shell_panel(G_OBJECT(result)); + //panel = build_shell_panel(G_OBJECT(result)); - ditem = g_dock_item_new(_("Shell"), panel); - gtk_dock_panel_add_item(dpanel, ditem); + //ditem = g_dock_item_new(_("Shell"), panel); + //gtk_dock_panel_add_item(dpanel, ditem); diff --git a/src/shell.c b/src/shell.c deleted file mode 100644 index ffd5cc7..0000000 --- a/src/shell.c +++ /dev/null @@ -1,345 +0,0 @@ - -/* OpenIDA - Outil d'analyse de fichiers binaires - * shell.c - panneau d'affichage du shell Python - * - * Copyright (C) 2009-2011 Cyrille Bagard - * - * This file is part of OpenIDA. - * - * OpenIDA 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 3 of the License, or - * (at your option) any later version. - * - * OpenIDA 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 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 - */ - - -#include "shell.h" - - -#include <pty.h> -#include <stdio.h> -#include <string.h> -#include <sys/epoll.h> -#include <sys/types.h> -#include <vte/reaper.h> -#include <vte/vte.h> - - -#include <config.h> - - -#include <Python.h> - - -static pid_t child = 0; - - -#define _(str) str - - - -/* Réagit à la terminaison d'un shell Python lancé. */ -static void terminal_child_exited_cb(VteReaper *, GPid, gint, VteTerminal *); - -/* Lance un nouveau shell Python dans un terminal donné. */ -static void run_new_shell_in_terminal(VteTerminal *); - -/* Réagit aux premières lignes de l'interpréteur Python. */ -void python_started_cb(VteTerminal *, gpointer); - - - -/* Exécute un shell interprétant du Python. */ -static gpointer python_shell_thread(gpointer); - - - int amaster; - int aslave; - char name[64]; - - -/****************************************************************************** -* * -* Paramètres : ref = adresse de l'espace de référencements. * -* * -* Description : Construit le panneau d'affichage des symboles. * -* * -* Retour : Adresse du panneau mis en place. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GtkWidget *build_shell_panel(GObject *ref) -{ - GtkWidget *result; /* Panneau à retourner */ - GtkWidget *term; /* Terminal proprement dit */ - - - - GError *error; /* Bilan de création de thread */ - - - - term = vte_terminal_new(); - - result = gtk_scrolled_window_new(NULL, GTK_ADJUSTMENT(VTE_TERMINAL(term)->adjustment)); - gtk_widget_show(result); - - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(result), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(result), GTK_SHADOW_IN); - - gtk_widget_show(term); - gtk_container_add(GTK_CONTAINER(result), term); - - - vte_terminal_set_cursor_blinks(VTE_TERMINAL(term), TRUE); - - -#if 1 - //vte_terminal_fork_command (term, "/bin/sh", NULL, NULL, "/", 0, 0, 0); - return result; -#endif - - - openpty(&amaster, &aslave, name, NULL, NULL); - - - fprintf(stderr, "m = %d, s = %d, n = \"%s\"\n", amaster, - aslave, name); - - - vte_terminal_set_pty(VTE_TERMINAL(term), amaster); - - - if (!g_thread_create((GThreadFunc)python_shell_thread, term, FALSE, &error)) - { - printf ("Failed to create the thread: %s\n", error->message); - } - - - - - /* - g_signal_connect(vte_reaper_get(), "child-exited", - G_CALLBACK(terminal_child_exited_cb), term); - - - run_new_shell_in_terminal(VTE_TERMINAL(term)); - */ - - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : reaper = surveillant des processus exécuté dans le terminal. * -* pid = identifiant du processus terminé. * -* status = informations sur la sortie de l'interpréteur. * -* term = terminal affiché à l'écran. * -* * -* Description : Réagit à la terminaison d'un shell Python lancé. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void terminal_child_exited_cb(VteReaper *reaper, GPid pid, gint status, VteTerminal *term) -{ - - //vte_terminal_feed(term, ("Exit detected ; lauching an new Python shell...\n\r"), -1); - - - run_new_shell_in_terminal(term); - -} - - -/****************************************************************************** -* * -* Paramètres : term = terminal affiché à l'écran. * -* * -* Description : Lance un nouveau shell Python dans un terminal donné. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void run_new_shell_in_terminal(VteTerminal *term) -{ - gdouble refval; /* Attente active (bouh !) */ - size_t len; /* Longueur de chaîne */ - - char *args[] = { "python", NULL }; - -#ifdef DEBUG - char *env[] = { NULL, NULL }; -#else - char **env = NULL; -#endif - - refval = gtk_adjustment_get_value(GTK_ADJUSTMENT(term->adjustment)); - -#ifdef DEBUG - len = strlen("PYTHONPATH=") + strlen(PACKAGE_SOURCE_DIR) + strlen("/src/plugins/pyoida"); - - env[0] = (char *)calloc(len + 1, sizeof(char)); - - strcpy(env[0], "PYTHONPATH="); - strcat(env[0], PACKAGE_SOURCE_DIR); - strcat(env[0], "/src/plugins/pyoida"); -#endif - - child = vte_terminal_fork_command(VTE_TERMINAL(term), args[0], args, - env, NULL, 0, 0, 0); - - vte_reaper_add_child(child); - - printf("ref :: %g\n", refval); - - //while (refval == gtk_adjustment_get_value(GTK_ADJUSTMENT(term->adjustment))); - - - g_signal_connect(term, "contents-changed", - G_CALLBACK(python_started_cb), NULL); - -} - - -/****************************************************************************** -* * -* Paramètres : term = terminal affiché à l'écran. * -* data = adresse non utilisée ici. * -* * -* Description : Réagit aux premières lignes de l'interpréteur Python. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void python_started_cb(VteTerminal *term, gpointer data) -{ - static int counter = 0; /* Saut du prologue */ - - if (counter++ == 0) return; - else counter = 0; - - vte_terminal_feed_child(term, "import pyoida\n", -1); - - vte_terminal_feed_child(term, "from pyoida import *\n", -1); - - g_signal_handlers_disconnect_by_func(term, G_CALLBACK(python_started_cb), NULL); - -} - - - -/****************************************************************************** -* * -* Paramètres : ????????????????????????????????????????????????? * -* * -* Description : Exécute un shell interprétant du Python. * -* * -* Retour : ??? * -* * -* Remarques : - * -* * -******************************************************************************/ - -static gpointer python_shell_thread(gpointer data) -{ - FILE *stream; - - int stdout2; - FILE *out2; - - printf("==== FE :: '%s'\n", ptsname(amaster)); - printf("==== FE :: '%s'\n", ptsname(aslave)); - - - - - //stream = fopen("/dev/pts/21", "w+"); - stream = fdopen(aslave, "w+"); - if (stream == NULL) - { - perror("fdopen"); - return NULL; - } - - - /* Mise à jour des entrées/sorties */ - - stdout2 = dup(STDOUT_FILENO); - out2 = fdopen(stdout2, "w"); - - fprintf(out2, ">>> stdout2 :: %d\n", stdout2); - - -#if 1 - close(STDIN_FILENO); - close(STDOUT_FILENO); - close(STDERR_FILENO); - dup(aslave); - dup(aslave); - dup(aslave); -#endif - - - - Py_Initialize(); - - - //amaster = STDIN_FILENO; - - /* - write(amaster, "import pyoida\n", strlen("import pyoida\n")); - write(amaster, "from pyoida import *\n", strlen("from pyoida import *\n")); - - write(amaster, "logger.log_simple_message(2, 'uhih')\n", strlen("logger.log_simple_message(2, 'uhih')\n")); - - write(amaster, "for i in pyoida.current_binary().lines():\n", strlen("for i in pyoida.current_binary().lines():\n")); - write(amaster, "\tprint i\n", strlen("\tprint i\n")); - */ - - - write(amaster, "execfile('test.py')", strlen("execfile('test.py')")); - - - - fprintf(out2, ">>> stdout2 :: %d (inside)\n", stdout2); - - - - printf("+++++++++++++++++++++++++++looping\n"); - - PyRun_AnyFile(stream, NULL); - - printf("===========================looping\n"); - - - Py_Finalize(); - - - - return NULL; - -} diff --git a/src/shell.h b/src/shell.h deleted file mode 100644 index 90de5a1..0000000 --- a/src/shell.h +++ /dev/null @@ -1,38 +0,0 @@ - -/* OpenIDA - Outil d'analyse de fichiers binaires - * shell.h - prototypes pour le panneau d'affichage du shell Python - * - * Copyright (C) 2009 Cyrille Bagard - * - * This file is part of OpenIDA. - * - * OpenIDA 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 3 of the License, or - * (at your option) any later version. - * - * OpenIDA 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 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 - */ - - -#ifndef _PAN_SHELL_H -#define _PAN_SHELL_H - - -#include <gtk/gtk.h> - - - -/* Construit le panneau d'affichage des symboles. */ -GtkWidget *build_shell_panel(GObject *); - - - -#endif /* _PAN_SHELL_H */ |