Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

test.C

Go to the documentation of this file.
00001 #include "bcsignals.h"
00002 #include "guicast.h"
00003 #include "keys.h"
00004 #include "language.h"
00005 #include "vframe.h"
00006 #include <ctype.h>
00007 #include <math.h>
00008 #include <stdio.h>
00009 #include <stdlib.h>
00010 #include <string.h>
00011 #include <sys/types.h>
00012 #include <sys/wait.h>
00013 #include <unistd.h>
00014 
00015 
00016 #define MAX_ARGS 32
00017 #define BCTEXTLEN 1024
00018 
00019 
00020 void thread_fork()
00021 {
00022         int filedes[2];
00023         int pid;
00024         char *command_line = "ls -l -s -S -r";
00025         char *arguments[MAX_ARGS];
00026         char path[BCTEXTLEN];
00027         int total_arguments;
00028         FILE *stdin_fd;
00029         int pipe_stdin = 0;
00030         char *path_ptr;
00031         char *ptr = command_line;
00032         char *argument_ptr;
00033         char argument[BCTEXTLEN];
00034 
00035 
00036         path_ptr = path;
00037         while(*ptr != ' ' && *ptr != 0)
00038         {
00039                 *path_ptr++ = *ptr++;
00040         }
00041         *path_ptr = 0;
00042 
00043         arguments[total_arguments] = new char[strlen(path) + 1];
00044         strcpy(arguments[total_arguments], path);
00045 printf("%s\n", arguments[total_arguments]);
00046         total_arguments++;
00047         arguments[total_arguments] = 0;
00048 
00049         while(*ptr != 0)
00050         {
00051                 ptr++;
00052                 argument_ptr = argument;
00053                 while(*ptr != ' ' && *ptr != 0)
00054                 {
00055                         *argument_ptr++ = *ptr++;
00056                 }
00057                 *argument_ptr = 0;
00058 printf("%s\n", argument);
00059 
00060                 arguments[total_arguments] = new char[strlen(argument) + 1];
00061                 strcpy(arguments[total_arguments], argument);
00062                 total_arguments++;
00063                 arguments[total_arguments] = 0;
00064         }
00065 
00066         pipe(filedes);
00067         stdin_fd = fdopen(filedes[1], "w");
00068         
00069         int new_pid = fork();
00070         
00071         if(new_pid == 0)
00072         {
00073                 dup2(filedes[0], fileno(stdin));
00074                 execvp(path, arguments);
00075                 perror("execvp");
00076         }
00077         else
00078         {
00079                 pid = new_pid;
00080                 int return_value;
00081                 if(waitpid(pid, &return_value, WUNTRACED) == -1)
00082                 {
00083                         perror("waitpid");
00084                 }
00085                 close(filedes[0]);
00086                 close(filedes[1]);
00087                 fclose(stdin_fd);
00088                 printf("Finished.\n");
00089         }
00090         
00091         
00092         
00093         
00094 }
00095 
00096 
00097 class TestWindow : public BC_Window
00098 {
00099 public:
00100         TestWindow() : BC_Window("test", 
00101                                 0,
00102                                 0,
00103                                 320, 
00104                                 240,
00105                                 -1,
00106                                 -1,
00107                                 0,
00108                                 0,
00109                                 1)
00110         {
00111                 current_cursor = 0;
00112                 test_keypress = 1;
00113         };
00114 
00115         int close_event()
00116         {
00117                 set_done(0);
00118                 return 1;
00119         };
00120 
00121         int keypress_event()
00122         {
00123                 switch(get_keypress())
00124                 {
00125                         case UP:
00126                                 current_cursor += 1;
00127                                 if(current_cursor >= XC_num_glyphs) current_cursor = 0;
00128                                 break;
00129                         
00130                         case DOWN:
00131                                 current_cursor -= 1;
00132                                 if(current_cursor <= 0) current_cursor = XC_num_glyphs - 1;
00133                                 break;
00134                 }
00135                 printf("%d\n", current_cursor);
00136                 set_x_cursor(current_cursor);
00137         }
00138         
00139         int current_cursor;
00140 };
00141 
00142 int main(int argc, char *argv[])
00143 {
00144         new BC_Signals;
00145         TestWindow window;
00146         int angles[] = { 180, 0 };
00147         float values[] = { 1, 0 };
00148 
00149         window.add_tool(new BC_Pan(10, 
00150                 120, 
00151                 100, 
00152                 1, 
00153                 2, 
00154                 angles, 
00155                 -1, 
00156                 -1,
00157                 values));
00158         window.add_tool(new BC_TextBox(10, 10, 200, 5, _("Mary Egbert\nhad a little lamb.")));
00159         BC_Title *title;
00160         window.add_tool(title = new BC_Title(10, 210, _("Hello world")));
00161         title->update("xyz");
00162         window.show_window();
00163 
00164 sleep(2);
00165         title->update("abc");
00166 
00167         window.run_window();
00168 
00169 //      thread_fork();
00170 }
00171 
00172 
00173 
00174 
00175 
00176 
00177 
00178 

Generated on Sun Jan 8 13:26:35 2006 for Guicast-svn by  doxygen 1.4.4