Changeset 4033
- Timestamp:
- 11/25/09 12:47:40 (4 years ago)
- Location:
- neercs/trunk/src
- Files:
-
- 1 added
- 1 deleted
- 5 edited
-
Makefile.am (modified) (1 diff)
-
input.c (modified) (1 diff)
-
interpreter.c (added)
-
neercs.h (modified) (5 diffs)
-
python.c (deleted)
-
screen_list.c (modified) (1 diff)
-
server.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
neercs/trunk/src/Makefile.am
r4026 r4033 5 5 term.c grab.c effects.c wm.c screensaver.c attach.c \ 6 6 configuration.c mytrace.c mytrace.h input.c lock.c server.c \ 7 client.c screen_list.c help.c python.c7 client.c screen_list.c help.c interpreter.c 8 8 neercs_CFLAGS = @CACA_CFLAGS@ @PYTHON3_CFLAGS@ 9 9 neercs_LDADD = @CACA_LIBS@ @UTIL_LIBS@ @PAM_LIBS@ @PYTHON3_LIBS@ -
neercs/trunk/src/input.c
r4027 r4033 182 182 case 'e': 183 183 screen_list->python_command = 1; 184 screen_list-> command_props.x = 0;185 screen_list-> command_props.y = 0;184 screen_list->interpreter_props.x = 0; 185 screen_list->interpreter_props.y = 0; 186 186 break; 187 187 #endif -
neercs/trunk/src/neercs.h
r4027 r4033 144 144 }; 145 145 146 struct command_props 147 { 146 struct interpreter_props 147 { 148 /* Input box */ 148 149 int x, y; 149 150 int size; 150 151 char *command; 152 char *output; 151 153 }; 152 154 153 155 struct screen_list 154 156 { 157 int outfd; /* Debug */ 155 158 int wm_type; /* Window manager type */ 156 159 int in_bell; /* Bell occuring in a window */ … … 192 195 struct cube_props cube; /* Cube */ 193 196 long long unsigned int last_switch; /* Cube */ 194 struct command_props command_props;197 struct interpreter_props interpreter_props; 195 198 196 199 /* ScreenSaver stuff */ … … 272 275 void refresh_screens(struct screen_list *screen_list); 273 276 int update_screens_contents(struct screen_list* screen_list); 277 int install_fds(struct screen_list *screen_list); 274 278 long long get_us(void); 275 279 … … 316 320 void draw_help(struct screen_list *screen_list); 317 321 int help_handle_key(struct screen_list *screen_list, unsigned int c); 318 #ifdef USE_PYTHON319 int python_command_handle_key(struct screen_list *screen_list, unsigned int c);320 void draw_python_command(struct screen_list *screen_list);321 #endif322 322 int update_window_list(int c, struct screen_list *screen_list); 323 323 void draw_list(struct screen_list *screen_list); … … 360 360 int get_key_value(char *line, struct option *option); 361 361 int fill_config(struct screen_list *screen_list); 362 363 364 /* Python interpreter */ 365 #ifdef USE_PYTHON 366 int python_init(struct screen_list *sl); 367 int python_close(struct screen_list *sl); 368 int python_command_handle_key(struct screen_list *screen_list, unsigned int c); 369 void draw_python_command(struct screen_list *screen_list); 370 #endif 362 371 363 372 #if defined DEBUG -
neercs/trunk/src/screen_list.c
r4027 r4033 98 98 99 99 screen_list->python_command = 0; 100 screen_list-> command_props.x = 0;101 screen_list-> command_props.y = 0;102 screen_list-> command_props.command = NULL;103 screen_list-> command_props.size = 0;100 screen_list->interpreter_props.x = 0; 101 screen_list->interpreter_props.y = 0; 102 screen_list->interpreter_props.command = NULL; 103 screen_list->interpreter_props.size = 0; 104 104 105 105 screen_list->recurrent_list = NULL; -
neercs/trunk/src/server.c
r4026 r4033 212 212 213 213 214 214 215 215 screen_list->last_key_time = 0; 216 216 screen_list->attached = 0; … … 220 220 221 221 server_init(screen_list); 222 #ifdef USE_PYTHON 223 python_init(screen_list); 224 #endif 222 225 223 226 for (;;) … … 300 303 free_screen_list(screen_list); 301 304 305 #ifdef USE_PYTHON 306 python_close(screen_list); 307 #endif 308 302 309 exit(0); 303 310 } … … 453 460 if (screen_list->help) 454 461 { 455 return help_handle_key(screen_list, c);462 return help_handle_key(screen_list, c); 456 463 } 457 464 #ifdef USE_PYTHON 458 if(screen_list->python_command)459 { 460 return python_command_handle_key(screen_list, c);461 } 462 #endif 463 465 if (screen_list->python_command) 466 { 467 return python_command_handle_key(screen_list, c); 468 } 469 #endif 470 464 471 /* CTRL-A has been pressed before, handle this as a command, except that 465 CTRL-A a sends literal CTRL-A */472 CTRL-A a sends literal CTRL-A */ 466 473 if (screen_list->command && (c != 'a')) 467 474 { … … 527 534 } 528 535 536 537 int install_fds(struct screen_list *screen_list) 538 { 539 int fd; 540 close(0); 541 close(1); 542 close(2); 543 fd = open("/dev/null", O_RDWR, 0); 544 if (fd < 0) 545 { 546 perror("Failed to open /dev/null"); 547 return -2; 548 } 549 dup2(fd, 0); 550 #ifndef DEBUG 551 dup2(fd, 1); 552 dup2(fd, 2); 553 if (fd > 2) 554 close(fd); 555 #else 556 if (fd != 0) 557 close(fd); 558 screen_list->outfd = 559 open("/tmp/neercs-debug.txt", O_TRUNC | O_RDWR | O_CREAT, 560 S_IRUSR | S_IWUSR); 561 dup2(screen_list->outfd, 1); 562 dup2(screen_list->outfd, 2); 563 if (screen_list->outfd > 2) 564 close(screen_list->outfd); 565 #endif 566 return 0; 567 } 568 529 569 int start_server(struct screen_list *screen_list) 530 570 { … … 539 579 if (pid == 0) 540 580 { 541 int fd; 542 close(0); 543 close(1); 544 close(2); 545 fd = open("/dev/null", O_RDWR, 0); 546 if (fd < 0) 547 { 548 perror("Failed to open /dev/null"); 549 return -2; 550 } 551 dup2(fd, 0); 552 #ifndef DEBUG 553 dup2(fd, 1); 554 dup2(fd, 2); 555 if (fd > 2) 556 close(fd); 557 #else 558 if (fd != 0) 559 close(fd); 560 fd = open("/tmp/neercs-debug.txt", O_TRUNC | O_RDWR | O_CREAT, 561 S_IRUSR | S_IWUSR); 562 dup2(fd, 1); 563 dup2(fd, 2); 564 if (fd > 2) 565 close(fd); 566 #endif 581 int r = install_fds(screen_list); 582 if(r) return r; 567 583 setsid(); 568 584 … … 570 586 /* Never returns */ 571 587 } 572 588 573 589 return 0; 574 590 }
Note: See TracChangeset
for help on using the changeset viewer.
