[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Antiright-devel] antiright/gshterm command_line.c gshterm.c gsht...
From: |
Jeffrey Bedard |
Subject: |
[Antiright-devel] antiright/gshterm command_line.c gshterm.c gsht... |
Date: |
Mon, 26 Feb 2007 19:38:39 +0000 |
CVSROOT: /sources/antiright
Module name: antiright
Changes by: Jeffrey Bedard <jefbed> 07/02/26 19:38:39
Modified files:
gshterm : command_line.c gshterm.c gshterm.h main.c
script.c
Log message:
Use direct file I/O for command script creation. Added -s option to
specify
font size separately from font name.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/antiright/gshterm/command_line.c?cvsroot=antiright&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/antiright/gshterm/gshterm.c?cvsroot=antiright&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/antiright/gshterm/gshterm.h?cvsroot=antiright&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/antiright/gshterm/main.c?cvsroot=antiright&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/antiright/gshterm/script.c?cvsroot=antiright&r1=1.4&r2=1.5
Patches:
Index: command_line.c
===================================================================
RCS file: /sources/antiright/antiright/gshterm/command_line.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- command_line.c 26 Feb 2007 15:30:19 -0000 1.5
+++ command_line.c 26 Feb 2007 19:38:39 -0000 1.6
@@ -49,7 +49,11 @@
gshterm_handle_command_line_option (
struct GSHTerm * term, gchar option, gchar * arg)
{
- assert (arg);
+ ARIFNP(arg)
+ {
+ ARWARN("gshterm: invalid argument");
+ return FALSE;
+ }
#ifdef DEBUG
putchar (option);
@@ -59,15 +63,17 @@
{
case 'e':
return TRUE;
- break;
case 'f':
ar_asprintf (&term->font, arg);
break;
case 'g':
ar_asprintf (&term->gsh->geometry, arg);
break;
+ case 's':
+ term->font_size=(gint)atoi(arg);
+ break;
default:
- g_printerr ("unknown option: %c\n", option);
+ g_warning ("gshterm: unknown option: -%c\n", option);
}
return FALSE;
}
Index: gshterm.c
===================================================================
RCS file: /sources/antiright/antiright/gshterm/gshterm.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- gshterm.c 23 Feb 2007 22:52:36 -0000 1.8
+++ gshterm.c 26 Feb 2007 19:38:39 -0000 1.9
@@ -22,6 +22,27 @@
#include "gshterm.h"
+static void
+set_font(struct GSHTerm * term)
+{
+ gchar *final_font;
+
+ ARIFNP(term->font)
+ ar_asprintf(&final_font, "Mono 12");
+ else
+ {
+ if(term->font_size == 0) /* Default font size. */
+ term->font_size=12;
+
+ ar_asprintf(&final_font, "%s %d", term->font, term->font_size);
+ g_free(term->font);
+ term->font=NULL;
+ }
+
+ vte_terminal_set_font_from_string (VTE_TERMINAL (term->widget),
+ final_font);
+ g_free(final_font);
+}
void
gshterm_set_terminal_options (struct GSHTerm * term)
{
@@ -29,13 +50,7 @@
vte_terminal_set_allow_bold (VTE_TERMINAL (term->widget), TRUE);
vte_terminal_set_backspace_binding (VTE_TERMINAL (term->widget),
VTE_ERASE_ASCII_BACKSPACE);
-
- ARIFNP(term->font)
- ar_asprintf (&term->font, "Mono 14");
-
- vte_terminal_set_font_from_string (VTE_TERMINAL (term->widget), term->font);
- free (term->font);
- term->font=NULL;
+ set_font(term);
vte_terminal_set_background_transparent (
VTE_TERMINAL (term->widget), TRUE);
@@ -46,14 +61,33 @@
{
#ifdef DEBUG
- assert (term);
- assert (term->gsh);
- assert (term->gsh->window);
+ ARPASSERT (term);
+ ARPASSERT (term->gsh);
+ ARPASSERT (term->gsh->window);
#endif /* DEBUG */
term->widget = vte_terminal_new ();
gtk_container_add (GTK_CONTAINER (term->gsh->window), term->widget);
gshterm_set_terminal_options (term);
gtk_widget_show (term->widget);
+
return (term);
}
+
+struct GSHTerm *
+GSHTerm_new()
+{
+ struct GSHTerm *term;
+
+ term = (struct GSHTerm *) xmalloc (sizeof (struct GSHTerm));
+
+ ARPASSERT(term);
+
+ term->gsh=NULL;
+ term->font=NULL;
+ term->font_size=0;
+ term->widget=NULL;
+
+ return term;
+}
+
Index: gshterm.h
===================================================================
RCS file: /sources/antiright/antiright/gshterm/gshterm.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- gshterm.h 20 Feb 2007 04:29:43 -0000 1.6
+++ gshterm.h 26 Feb 2007 19:38:39 -0000 1.7
@@ -32,6 +32,7 @@
struct GSH *gsh;
gchar *script;
gchar *font;
+ gint font_size;
GtkWidget *widget;
};
@@ -43,4 +44,8 @@
struct GSHTerm *
gshterm_setup_terminal ();
+
+struct GSHTerm *
+GSHTerm_new();
+
#endif
Index: main.c
===================================================================
RCS file: /sources/antiright/antiright/gshterm/main.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- main.c 25 Feb 2007 21:33:11 -0000 1.11
+++ main.c 26 Feb 2007 19:38:39 -0000 1.12
@@ -29,9 +29,7 @@
{
struct GSHTerm *term;
- term = (struct GSHTerm *) xmalloc (sizeof (struct GSHTerm));
-
- ARPASSERT(term);
+ term = GSHTerm_new();
term->gsh = gsh_init (argc, argv);
@@ -40,11 +38,11 @@
ARPASSERT (term->gsh->window);
#endif /* DEBUG */
- term->font=NULL;
+ term->script = gshterm_command_script
+ (gshterm_construct_command (term, *argc, *argv));
- term->script = gshterm_command_script (
- gshterm_construct_command (term, *argc, *argv));
+ gshterm_setup_terminal(term);
return (term);
}
@@ -57,7 +55,7 @@
/* Initialize GTK, GSH, and GSHTerm. */
term = gshterm_init_and_script (&argc, &argv);
- term = gshterm_setup_terminal (term);
+
gsh_check_and_set_geometry (term->gsh);
g_signal_connect (G_OBJECT (term->widget), "child-exited",
@@ -65,7 +63,8 @@
/* Run the script in the terminal widget. */
vte_terminal_fork_command (
- VTE_TERMINAL (term->widget), term->script, NULL, NULL, NULL,
+ VTE_TERMINAL (term->widget),
+ term->script, NULL, NULL, NULL,
TRUE, TRUE, TRUE);
script = term->script;
Index: script.c
===================================================================
RCS file: /sources/antiright/antiright/gshterm/script.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- script.c 23 Feb 2007 22:52:36 -0000 1.4
+++ script.c 26 Feb 2007 19:38:39 -0000 1.5
@@ -21,11 +21,14 @@
*/
#include "gshterm.h"
+#include <sys/types.h>
+#include <sys/stat.h>
char *
gshterm_command_script (char *command)
{
- char *script_name;
+ gchar *script_name;
+ FILE *script;
pid_t pid;
#ifdef DEBUG
@@ -35,13 +38,25 @@
/* This is a workaround for vte's fscking up of option arrays. */
pid = getpid ();
-
ar_asprintf (&script_name, "/tmp/gshterm.%d", (int) pid);
+ script=fopen(script_name, "w");
+ ARIFNP(script)
+ ARERR("script file could not be opened");
+
+ fflush(script);
+
+ /* Do this immediately after opening in order to
+ * reduce the possiblity of script modification exploit. */
+
+ if(chmod(script_name, S_IXUSR | S_IRUSR | S_IWUSR) != 0)
+ ARERR("script file does not exist");
+
+ fprintf (script, "#!/bin/sh\n");
+ fprintf (script, "%s\n", command);
+ g_free (command);
+ fflush(script);
+ fclose(script);
- sysprintf ("echo '#!/bin/sh' > %s", script_name);
- sysprintf ("echo %s >> %s", command, script_name);
- free (command);
- sysprintf ("chmod +x %s", script_name);
#ifdef DEBUG
sysprintf ("cat %s", script_name);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Antiright-devel] antiright/gshterm command_line.c gshterm.c gsht...,
Jeffrey Bedard <=