antiright-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Antiright-devel] antiright ACE-desktop/ACE gshterm/main.c gshter...


From: Jeffrey Bedard
Subject: [Antiright-devel] antiright ACE-desktop/ACE gshterm/main.c gshter...
Date: Fri, 23 Feb 2007 21:23:27 +0000

CVSROOT:        /sources/antiright
Module name:    antiright
Changes by:     Jeffrey Bedard <jefbed> 07/02/23 21:23:27

Modified files:
        ACE-desktop    : ACE 
        gshterm        : main.c script.c 
        gtkshell       : gtkshell.h 
        libantiright   : pipe.c string.c system.c system.h 

Log message:
        Reimplemented antiright_system.  Added ar_asprintf.  

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/antiright/ACE-desktop/ACE?cvsroot=antiright&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/antiright/gshterm/main.c?cvsroot=antiright&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/antiright/gshterm/script.c?cvsroot=antiright&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/gtkshell.h?cvsroot=antiright&r1=1.16&r2=1.17
http://cvs.savannah.gnu.org/viewcvs/antiright/libantiright/pipe.c?cvsroot=antiright&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/antiright/libantiright/string.c?cvsroot=antiright&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/antiright/libantiright/system.c?cvsroot=antiright&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/antiright/libantiright/system.h?cvsroot=antiright&r1=1.3&r2=1.4

Patches:
Index: ACE-desktop/ACE
===================================================================
RCS file: /sources/antiright/antiright/ACE-desktop/ACE,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- ACE-desktop/ACE     23 Feb 2007 19:15:05 -0000      1.9
+++ ACE-desktop/ACE     23 Feb 2007 21:23:26 -0000      1.10
@@ -26,6 +26,10 @@
                COUNTER=$(($COUNTER+1))
                echo $COUNTER
        }
+else
+       Debug()
+       {
+       }
 fi
 
 ARSHELL=gtkshell
@@ -42,19 +46,6 @@
     # In such the likely prefixes are what will be processed.
     if [ ! -f ~/.antiright ]; then
        cp $PREFIX/share/ACE-desktop/system.antiright ~/.antiright
-    else
-       # If ~/.antiright doesnt contain the text "revision" it does
-       # not keep track of revisions and therefore is an old version.
-       if [ "$(grep revision ~/.antiright)" = "" ]; then
-           # Backup customizations.
-           mv ~/.antiright ~/.antiright.old
-           # Restore2 ~/.antiright with a new instance.
-           ACE_Check_Configuration_File
-           # Alert the user.
-           echo 'Your old ~/.antiright has been saved to ~/.antiright.old'
-           echo 'This is due to the use of a new revision of the file,'
-           echo 'changing the theme support.'
-       fi
     fi
 }
 ACE_record_titles()
@@ -107,7 +98,7 @@
 swap_load()
 {
        echo -n '  '
-       swapctl -l | tail -n 1 | awk '{print $5}' | tr -d '\n'
+       swapctl -l | tail -n 1 | awk '{print $5}' | tr '\n' '\0'
 }
 taskbar_update()
 {
@@ -276,7 +267,7 @@
 
 ACE_Panel()
 {
-   $ARSHELL -os -or 4 \
+   $ARSHELL -os -or 5 \
        'ACE IRC' \
        'ACE CD_Player' \
        'ACE File_Manager' \
@@ -291,7 +282,6 @@
        'ACE -A Manual_Browser' \
        'ACE -A Publishing_Panel' \
        'ACE -A Calendar'\
-       'ACE -A OS_Specific'\
        'gtkshell -da & # About'
 
 }
@@ -416,7 +406,8 @@
     $ARSHELL -or 3 \
        'ACE -A Secure_Permissions'\
        'ACE Root_Shell'\
-       'ACE -A Monitoring_Panel'
+       'ACE -A Monitoring_Panel'\
+       'ACE -A OS_Specific'
 }
 System_Accounting()
 {

Index: gshterm/main.c
===================================================================
RCS file: /sources/antiright/antiright/gshterm/main.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- gshterm/main.c      20 Feb 2007 04:29:43 -0000      1.8
+++ gshterm/main.c      23 Feb 2007 21:23:26 -0000      1.9
@@ -31,6 +31,8 @@
 
   term = (struct GSHTerm *) xmalloc (sizeof (struct GSHTerm));
 
+       ARPASSERT(term);
+
   term->gsh = gsh_init (argc, argv);
 
 #ifdef DEBUG
@@ -55,6 +57,7 @@
   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",
                    G_CALLBACK (gtk_main_quit), NULL);
 
@@ -67,8 +70,9 @@
 
   gtk_widget_show (term->gsh->window);
 
-  g_free (term->gsh);
-  g_free (term);
+
+  //g_free (term->gsh);
+  //g_free (term);
 
   gtk_main ();
 

Index: gshterm/script.c
===================================================================
RCS file: /sources/antiright/antiright/gshterm/script.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- gshterm/script.c    20 Feb 2007 04:29:43 -0000      1.2
+++ gshterm/script.c    23 Feb 2007 21:23:26 -0000      1.3
@@ -28,6 +28,9 @@
   char *script_name;
   pid_t pid;
 
+#ifdef DEBUG
+       ARBUG("gshterm_command_script()");
+#endif /* DEBUG */
 
   /* This is a workaround for vte's fscking up of option arrays.  */
 
@@ -41,5 +44,9 @@
   sysprintf ("chmod +x %s", script_name);
   sysprintf ("cat %s", script_name);
 
+#ifdef DEBUG
+       ARBUG("end gshterm_command_script()");
+#endif /* DEBUG */
+
   return (script_name);
 }

Index: gtkshell/gtkshell.h
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/gtkshell.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- gtkshell/gtkshell.h 23 Feb 2007 19:15:05 -0000      1.16
+++ gtkshell/gtkshell.h 23 Feb 2007 21:23:27 -0000      1.17
@@ -80,6 +80,7 @@
 #include "row.h"
 #include "containers.h"
 #include "geometry.h"
+#include "font.h"
 
 void
   gsh_stack_init (struct GSH * gsh, int *argc, char ***argv);

Index: libantiright/pipe.c
===================================================================
RCS file: /sources/antiright/antiright/libantiright/pipe.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- libantiright/pipe.c 23 Feb 2007 15:57:53 -0000      1.3
+++ libantiright/pipe.c 23 Feb 2007 21:23:27 -0000      1.4
@@ -27,25 +27,42 @@
 char *
 antiright_pipe_read (char *command_string)
 {
+       /* Declare.  */
+
   char *text_string;
   char buffer[BUFSIZ];
   FILE *pipe;
   size_t read, total;
 
+       /* Initialize.  */
+
+       read=0;
+       total=0;
+       text_string=NULL;
+
+       ARPASSERT(command_string);
+
   /* Execute the command indicated by command_string.  */
   /* Pipe is read-only.  Stdout will be directed to it.  */
   pipe = popen (command_string, "r");
 
+       ARPASSERT(pipe);
+
+       ar_asprintf(&text_string, "\0");
   /* Read the command's stdout.  */
   while((read = fread (buffer, sizeof (char), BUFSIZ, pipe)) != 0)
    {
      total += read;
-     text_string = (char*) realloc (text_string, total);
-     snprintf(text_string, total-1, "%s%s", text_string, buffer);
+
+     text_string = (char*) realloc (text_string, total * sizeof (char));
+                ARPASSERT(text_string);
+
+                /* buffer[read-1]='\0'; */
+     snprintf(text_string, total, "%s%s", text_string, buffer);
    }
 
   /* Close the pipe once fgets() returns a false condition.  */
-  pclose (pipe);
+  (void) pclose (pipe);
 
   return (text_string);
 }

Index: libantiright/string.c
===================================================================
RCS file: /sources/antiright/antiright/libantiright/string.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- libantiright/string.c       20 Feb 2007 04:29:43 -0000      1.3
+++ libantiright/string.c       23 Feb 2007 21:23:27 -0000      1.4
@@ -22,7 +22,21 @@
 
 #include "library.h"
 
+gint
+ar_asprintf(gchar **string, const gchar *format, ...)
+{
+       va_list list;
+       gint return_value;
+
+       va_start (list, format);
+       return_value = g_vasprintf (string, format, list);
+       va_end (list);
+
+       return return_value;
+}
+
 /* Free the returned value!  */
+/* (This is rather scary) */
 char *
 antiright_beautified_label (char *current_argument_string)
 {

Index: libantiright/system.c
===================================================================
RCS file: /sources/antiright/antiright/libantiright/system.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- libantiright/system.c       23 Feb 2007 15:30:45 -0000      1.5
+++ libantiright/system.c       23 Feb 2007 21:23:27 -0000      1.6
@@ -22,47 +22,77 @@
 
 #include "library.h"
 
+static gboolean
+must_reformat(char *field_string)
+{
+       size_t length;
+       length=strlen(field_string);
+       if(field_string[length-1] != '&')
+               return TRUE;
+       else
+               return FALSE;
+}
+
+static char *
+get_command_string(char *field)
+{
+       char *new_field;
+       
+       ARIFB(must_reformat(field))
+               ar_asprintf(&new_field, "%s &", field);
+       else
+               ar_asprintf(&new_field, "%s", field);
+
+       return new_field;
+}
+
 int
 antiright_system (char *field_string)
 {
   /* Ensure that FIELD_STRING is not empty.  */
   ARIFP(field_string)
    {
-      GError *error;
-      ARIFNB(g_spawn_command_line_async(field_string, &error))
+                char *command;
+
+                command=get_command_string(field_string);
+       
+                if(system(command) == 0)
        {
-          ARWARN(error->message);
-          g_clear_error(&error);
-          return EXIT_FAILURE;
+                                g_free(command);
+
+                return EXIT_SUCCESS;
        }
       else
-        return EXIT_SUCCESS;
+                        {
+                                g_free(command);
+                                ARWARN ("command could not be executed");
+
+                                return EXIT_FAILURE;
+                        }
    }
   else
    {
     /* The user input is empty, so generate an error.  */
-    ARWARN ("FIELD_STRING is empty");
+    ARWARN ("field_string is NULL");
     return (EXIT_FAILURE);
   }
 }
 
 int
-vsysprintf (char *format, va_list list)
+vsysprintf (const char *format, va_list list)
 {
   char *command;
   int return_value;
 
-  ARIFNP(format)
-   format="\n";
-
-  vasprintf (&command, format, list);
+  g_vasprintf (&command, format, list);
   return_value = antiright_system (command);
-  free (command);
+  g_free (command);
+
   return (return_value);
 }
 
 int
-sysprintf (char *format,...)
+sysprintf (const char *format, ...)
 {
   va_list list;
   int return_value;

Index: libantiright/system.h
===================================================================
RCS file: /sources/antiright/antiright/libantiright/system.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- libantiright/system.h       20 Feb 2007 04:29:43 -0000      1.3
+++ libantiright/system.h       23 Feb 2007 21:23:27 -0000      1.4
@@ -27,8 +27,8 @@
   antiright_system (char *field_string);
 
 int
-  sysprintf (char *format,...);
+  sysprintf (const char *format,...);
 
 int
-  vsysprintf (char *format, va_list list);
+  vsysprintf (const char *format, va_list list);
 #endif                         /* LIBAR_SYSTEM_H */




reply via email to

[Prev in Thread] Current Thread [Next in Thread]