- Timestamp:
- Nov 27, 2009, 1:46:25 PM (10 years ago)
- Location:
- neercs/trunk/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
neercs/trunk/src/screensaver.c
r3975 r4052 33 33 void screensaver_init(struct screen_list *screen_list) 34 34 { 35 36 35 screensaver_flying_toasters_init(screen_list); 37 36 } … … 39 38 void screensaver_kill(struct screen_list *screen_list) 40 39 { 41 42 40 screensaver_flying_toasters_kill(screen_list); 43 41 } -
neercs/trunk/src/server.c
r4051 r4052 42 42 static int handle_attach(struct screen_list *screen_list, char *buf); 43 43 44 static int send_to_client(const char *msg, int size, struct screen_list *screen_list) 44 static int send_to_client(const char *msg, int size, 45 struct screen_list *screen_list) 45 46 { 46 47 int ret; … … 149 150 written = 0; 150 151 sprintf(buf2, "UPDATE %10d %10d", x, y); 151 ret = send_to_client(buf2, strlen(buf2) +1, screen_list);152 ret = send_to_client(buf2, strlen(buf2) + 1, screen_list); 152 153 if (ret < 29 && errno != EAGAIN) 153 154 { … … 161 162 /* Block to write the end of the message */ 162 163 fcntl(screen_list->socket[SOCK_CLIENT], F_SETFL, 0); 163 n = send_to_client((char*) buf+written, towrite > bufsize ? bufsize : towrite, screen_list); 164 n = send_to_client((char *)buf + written, 165 towrite > bufsize ? bufsize : towrite, 166 screen_list); 164 167 if (n < 0) 165 168 { … … 178 181 caca_get_cursor_y(screen_list->cv)); 179 182 /* FIXME check value of r */ 180 int r = send_to_client(buf2, strlen(buf2) + 1,screen_list);183 int r = send_to_client(buf2, strlen(buf2) + 1, screen_list); 181 184 (void)r; 182 185 #if defined HAVE_CACA_DIRTY_RECTANGLES … … 201 204 } 202 205 206 static int server_iteration(struct screen_list *screen_list) 207 { 208 int i; 209 int eof = 0, refresh = 0; 210 211 int quit = 0; 212 ssize_t n; 213 char buf[128]; 214 215 /* Read program output */ 216 refresh |= update_screens_contents(screen_list); 217 218 /* Check if we got something from the client */ 219 while (screen_list->socket[SOCK_SERVER] 220 && (n = 221 read(screen_list->socket[SOCK_SERVER], buf, 222 sizeof(buf) - 1)) > 0) 223 { 224 buf[n] = 0; 225 debug("Received command %s", buf); 226 if (!strncmp("ATTACH ", buf, 7)) 227 { 228 refresh |= handle_attach(screen_list, buf); 229 } 230 else if (!strncmp("QUIT", buf, 4)) 231 { 232 quit = 1; 233 } 234 else if (!strncmp("DELAY ", buf, 6)) 235 { 236 /* FIXME check the length before calling atoi */ 237 screen_list->delay = atoi(buf + 6); 238 } 239 else if (!strncmp("RESIZE ", buf, 7)) 240 { 241 caca_free_canvas(screen_list->cv); 242 /* FIXME check the length before calling atoi */ 243 screen_list->cv = 244 caca_create_canvas(atoi(buf + 7), atoi(buf + 18)); 245 screen_list->changed = 1; 246 refresh = 1; 247 } 248 else if (!strncmp("KEY ", buf, 4)) 249 { 250 unsigned int c = atoi(buf + 4); 251 refresh |= handle_key(screen_list, c, refresh); 252 } 253 else 254 { 255 fprintf(stderr, "Unknown command received: %s\n", buf); 256 } 257 } 258 259 /* No more screens, exit */ 260 if (!screen_list->count) 261 return -1; 262 263 /* User requested to exit */ 264 if (quit) 265 return -2; 266 267 /* Update each screen canvas */ 268 refresh |= update_terms(screen_list); 269 270 /* Launch recurrents if any */ 271 refresh |= handle_recurrents(screen_list); 272 273 /* Refresh screen */ 274 refresh |= refresh_screen(screen_list, refresh); 275 276 eof = 1; 277 for (i = 0; i < screen_list->count; i++) 278 if (screen_list->screen[i]->fd >= 0) 279 eof = 0; 280 if (eof) 281 return -3; 282 283 } 284 203 285 static void server_main(struct screen_list *screen_list) 204 286 { 205 int i;206 int eof = 0, refresh = 1;207 208 209 210 287 screen_list->last_key_time = 0; 211 288 screen_list->attached = 0; … … 221 298 for (;;) 222 299 { 223 int quit = 0; 224 ssize_t n; 225 char buf[128]; 226 227 /* Read program output */ 228 refresh |= update_screens_contents(screen_list); 229 230 /* Check if we got something from the client */ 231 while (screen_list->socket[SOCK_SERVER] 232 && (n = 233 read(screen_list->socket[SOCK_SERVER], buf, 234 sizeof(buf) - 1)) > 0) 235 { 236 buf[n] = 0; 237 debug("Received command %s", buf); 238 if (!strncmp("ATTACH ", buf, 7)) 239 { 240 refresh |= handle_attach(screen_list, buf); 241 } 242 else if (!strncmp("QUIT", buf, 4)) 243 { 244 quit = 1; 245 } 246 else if (!strncmp("DELAY ", buf, 6)) 247 { 248 /* FIXME check the length before calling atoi */ 249 screen_list->delay = atoi(buf + 6); 250 } 251 else if (!strncmp("RESIZE ", buf, 7)) 252 { 253 caca_free_canvas(screen_list->cv); 254 /* FIXME check the length before calling atoi */ 255 screen_list->cv = 256 caca_create_canvas(atoi(buf + 7), atoi(buf + 18)); 257 screen_list->changed = 1; 258 refresh = 1; 259 } 260 else if (!strncmp("KEY ", buf, 4)) 261 { 262 unsigned int c = atoi(buf + 4); 263 refresh |= handle_key(screen_list, c, refresh); 264 } 265 else 266 { 267 fprintf(stderr, "Unknown command received: %s\n", buf); 268 } 269 } 270 271 /* No more screens, exit */ 272 if (!screen_list->count) 273 break; 274 275 /* User requested to exit */ 276 if (quit) 277 break; 278 279 /* Update each screen canvas */ 280 refresh |= update_terms(screen_list); 281 282 /* Launch recurrents if any */ 283 refresh |= handle_recurrents(screen_list); 284 285 /* Refresh screen */ 286 refresh |= refresh_screen(screen_list, refresh); 287 288 eof = 1; 289 for (i = 0; i < screen_list->count; i++) 290 if (screen_list->screen[i]->fd >= 0) 291 eof = 0; 292 if (eof) 293 break; 300 if(server_iteration(screen_list)) break; 294 301 } 295 302 … … 301 308 python_close(screen_list); 302 309 #endif 303 310 304 311 exit(0); 305 312 } … … 318 325 long long int tdiff = 319 326 (current_time - screen_list->last_refresh_time) / 1000; 320 327 321 328 if (screen_list->force_refresh) 322 329 { … … 380 387 int i; 381 388 debug("Screen list at %p\n", screen_list); 382 389 383 390 /* Create socket and bind it */ 384 391 create_socket(screen_list, SOCK_SERVER); … … 560 567 close(screen_list->outfd); 561 568 #endif 562 569 return 0; 563 570 } 564 571 … … 576 583 { 577 584 int r = install_fds(screen_list); 578 if(r) return r; 585 if (r) 586 return r; 579 587 setsid(); 580 588 -
neercs/trunk/src/term.c
r4049 r4052 146 146 { 147 147 if (!sc->bell) 148 screen_list->in_bell =10;148 screen_list->in_bell = 10; 149 149 sc->bell = 1; 150 150 } … … 442 442 } 443 443 } 444 x = 0; 445 y = 0; 444 446 skip += 2; 445 447 break; … … 658 660 } 659 661 case 'c': /* DA -- Device Attributes */ 660 /* 661 0 Base VT100, no options 662 1 Processor options (STP) 663 2 Advanced video option (AVO) 664 3 AVO and STP 665 4 Graphics processor option (GPO) 666 5 GPO and STP 667 6 GPO and AVO 668 7 GPO, STP, and AVO 669 */ 670 /* Warning, argument is Pn */ 671 debug("ansi Got command c, argc %d, argv[0] (%d)\n", argc, argv[0], argv[0]); 662 /* 663 0 Base VT100, no options 1 Processor options (STP) 2 664 Advanced video option (AVO) 3 AVO and STP 4 Graphics 665 processor option (GPO) 5 GPO and STP 6 GPO and AVO 7 666 GPO, STP, and AVO */ 667 /* Warning, argument is Pn */ 668 debug("ansi Got command c, argc %d, argv[0] (%d)\n", argc, 669 argv[0], argv[0]); 672 670 if (!argc || argv[0] == 0) 673 671 { 674 672 send_ansi_sequence(screen_list, "\x1b[?1;0c"); 675 673 } 676 else 674 else 677 675 { 678 676 switch (argv[0]) … … 699 697 send_ansi_sequence(screen_list, "\x1b[?\x1;\x7c"); 700 698 break; 701 702 703 699 default: 700 debug("Unsupported DA option '%d'\n", argv[0]); 701 break; 704 702 } 705 703 } … … 737 735 break; 738 736 case 'n': 739 debug("ansi command n, argc %d, argv[0] %d\n", argc, argv[0]); 740 if(!argc) break; 741 742 switch(argv[0]) 743 { 744 case 5: 745 /* Term ok */ 746 send_ansi_sequence(screen_list, "\x1b[0n"); 747 break; 748 case 6: 749 /* Cursor Position */ 750 sprintf(b, "\x1b[%d;%dR", 751 y+1, 752 x+1); 753 send_ansi_sequence(screen_list, b); 754 break; 755 } 756 737 debug("ansi command n, argc %d, argv[0] %d\n", argc, argv[0]); 738 if (!argc) 739 break; 740 741 switch (argv[0]) 742 { 743 case 5: 744 /* Term ok */ 745 send_ansi_sequence(screen_list, "\x1b[0n"); 746 break; 747 case 6: 748 /* Cursor Position */ 749 sprintf(b, "\x1b[%d;%dR", y + 1, x + 1); 750 send_ansi_sequence(screen_list, b); 751 break; 752 } 753 757 754 break; 758 755 case 's': /* Private (save cursor position) */ … … 846 843 if (((ch > ' ') && (ch <= '~')) 847 844 && 848 (sc->conv_state. 849 gn[sc->conv_state.ss ? sc->conv_state. 850 gn[sc->conv_state.ss] : sc->conv_state.glr[0]] == '0')) 845 (sc-> 846 conv_state.gn[sc->conv_state.ss ? sc-> 847 conv_state.gn[sc->conv_state.ss] : sc-> 848 conv_state.glr[0]] == '0')) 851 849 { 852 850 ch = dec_acs(ch);
Note: See TracChangeset
for help on using the changeset viewer.