Changeset 2591 for neercs/trunk
- Timestamp:
- Jul 27, 2008, 10:25:32 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
neercs/trunk/src/main.c
r2589 r2591 84 84 int i, args, s=0; 85 85 long long unsigned int last_key_time = 0; 86 int mainret = 0;86 int mainret = -1; 87 87 int attach = 0, forceattach = 0; 88 88 int *to_grab = NULL; … … 97 97 { 98 98 fprintf(stderr, "Environment variable SHELL not set and no arguments given. kthxbye.\n"); 99 return -1;99 goto end; 100 100 } 101 101 … … 125 125 { 126 126 fprintf(stderr, "Can't allocate memory at %s:%d\n", __FUNCTION__, __LINE__); 127 return -1;127 goto end; 128 128 } 129 129 screen_list->recurrent_list->count = 0; … … 179 179 { 180 180 fprintf(stderr, "Can't allocate memory at %s:%d\n", __FUNCTION__, __LINE__); 181 return -1;181 goto end; 182 182 } 183 183 } … … 192 192 { 193 193 fprintf(stderr, "Attaching can only be requested once\n"); 194 return -1;194 goto end; 195 195 } 196 196 if(myoptarg) … … 206 206 case 'h': /* --help */ 207 207 usage(argc, argv); 208 return 0; 208 mainret = 0; 209 goto end; 209 210 break; 210 211 case 'v': /* --version */ 211 212 version(); 212 return 0; 213 mainret = 0; 214 goto end; 213 215 break; 214 216 default: 215 217 fprintf(stderr, "Unknown argument #%d\n", myoptind); 216 return -1;218 goto end; 217 219 break; 218 220 } … … 225 227 { 226 228 fprintf(stderr, "Can't allocate memory at %s:%d\n", __FUNCTION__, __LINE__); 227 return -1;229 goto end; 228 230 } 229 231 for(i=0; i<(argc-1) - s; i++) … … 250 252 { 251 253 fprintf(stderr, "-R can not be associated with commands or pids!\n"); 252 return -1;254 goto end; 253 255 } 254 256 … … 259 261 for(i=0; sockets[i]; i++); 260 262 i--; 261 screen_list->s_socket_path = s ockets[i];263 screen_list->s_socket_path = strdup(sockets[i]); 262 264 session = connect_server(screen_list); 263 265 if(session) … … 267 269 screen_list->dp = caca_create_display(screen_list->cv); 268 270 if(!screen_list->dp) 269 return 1;271 goto end; 270 272 caca_set_cursor(screen_list->dp, 1); 271 273 … … 294 296 } 295 297 if(forceattach && !attach) 296 return -1;298 goto end; 297 299 } 298 300 … … 307 309 { 308 310 fprintf(stderr, "Can't allocate memory at %s:%d\n", __FUNCTION__, __LINE__); 309 return -1;311 goto end; 310 312 } 311 313 } … … 327 329 { 328 330 fprintf(stderr, "Failed to create child process\n"); 329 return -1;331 goto end; 330 332 } 331 333 if(pid == 0) … … 361 363 screen_list->dp = caca_create_display(screen_list->cv); 362 364 if(!screen_list->dp) 363 return 1;365 goto end; 364 366 caca_set_cursor(screen_list->dp, 1); 365 367 … … 417 419 418 420 /* Clean up */ 419 if(screen_list->dp) 420 caca_free_display(screen_list->dp); 421 422 cucul_free_canvas(screen_list->cv); 423 424 for(i = 0; i < screen_list->count; i++) 425 { 426 destroy_screen(screen_list->screen[i]); 427 } 428 429 if(screen_list->s_socket_path) 430 free(screen_list->s_socket_path); 431 432 if(screen_list->c_socket_path) 433 { 434 unlink(screen_list->c_socket_path); 435 free(screen_list->c_socket_path); 436 } 437 438 if(screen_list->c_socket) 439 close(screen_list->c_socket); 440 441 if(screen_list->s_socket) 442 close(screen_list->s_socket); 443 444 if(screen_list->screen) free(screen_list->screen); 445 446 447 struct option *option = screen_list->config; 448 449 while(option) 450 { 451 struct option *kromeugnon = option; 452 option = option->next; 453 if(kromeugnon->key) free(kromeugnon->key); 454 if(kromeugnon->value) free(kromeugnon->value); 455 free(kromeugnon); 456 } 457 458 for(i=0; i<screen_list->recurrent_list->count; i++) 459 { 460 remove_recurrent(screen_list->recurrent_list, i); 461 i = 0; 462 } 463 464 if(screen_list->recurrent_list->recurrent) free(screen_list->recurrent_list->recurrent); 465 if(screen_list->recurrent_list) free(screen_list->recurrent_list); 466 467 if(screen_list->session_name) 468 free(screen_list->session_name); 469 421 mainret = 0; 422 end: 470 423 if(screen_list) 424 { 425 if(screen_list->dp) 426 caca_free_display(screen_list->dp); 427 428 if(screen_list->cv) 429 cucul_free_canvas(screen_list->cv); 430 431 for(i = 0; i < screen_list->count; i++) 432 { 433 destroy_screen(screen_list->screen[i]); 434 } 435 436 if(screen_list->s_socket_path) 437 free(screen_list->s_socket_path); 438 439 if(screen_list->c_socket_path) 440 { 441 unlink(screen_list->c_socket_path); 442 free(screen_list->c_socket_path); 443 } 444 445 if(screen_list->c_socket) 446 close(screen_list->c_socket); 447 448 if(screen_list->s_socket) 449 close(screen_list->s_socket); 450 451 if(screen_list->screen) 452 free(screen_list->screen); 453 454 struct option *option = screen_list->config; 455 456 while(option) 457 { 458 struct option *kromeugnon = option; 459 option = option->next; 460 if(kromeugnon->key) free(kromeugnon->key); 461 if(kromeugnon->value) free(kromeugnon->value); 462 free(kromeugnon); 463 } 464 465 for(i=0; i<screen_list->recurrent_list->count; i++) 466 { 467 remove_recurrent(screen_list->recurrent_list, i); 468 i = 0; 469 } 470 471 if(screen_list->recurrent_list->recurrent) 472 free(screen_list->recurrent_list->recurrent); 473 if(screen_list->recurrent_list) 474 free(screen_list->recurrent_list); 475 476 if(screen_list->session_name) 477 free(screen_list->session_name); 478 471 479 free(screen_list); 480 } 472 481 473 482 return mainret;
Note: See TracChangeset
for help on using the changeset viewer.