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