Changeset 2645
- Timestamp:
- Aug 2, 2008, 2:29:15 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
neercs/trunk/src/main.c
r2642 r2645 80 80 { 81 81 struct screen_list *screen_list = NULL; 82 int i, args , s=0;82 int i, args; 83 83 long long unsigned int last_key_time = 0; 84 84 int mainret = -1; … … 95 95 } 96 96 97 if(args==0) 98 args = 1; 99 100 101 s = handle_command_line(argc, argv, screen_list); 102 if(s<0) goto end; 103 104 if(s < argc - 1) 105 { 106 screen_list->to_start = (char**)malloc((argc-s)*sizeof(char*)); 107 if(!screen_list->to_start) 108 { 109 fprintf(stderr, "Can't allocate memory at %s:%d\n", __FUNCTION__, __LINE__); 110 goto end; 111 } 112 for(i=0; i<(argc-1) - s; i++) 113 { 114 screen_list->to_start[i] = strdup(argv[i+s+1]); 115 } 116 screen_list->to_start[argc-1-s] = NULL; 117 } 97 if(handle_command_line(argc, argv, screen_list) < 0) 98 goto end; 118 99 119 100 /* Read global configuration first */ … … 130 111 { 131 112 char **sockets; 132 if(screen_list->nb_to_grab || (argc-1 > s))113 if(screen_list->nb_to_grab || screen_list->to_start) 133 114 { 134 115 fprintf(stderr, "-R can not be associated with commands or pids!\n"); … … 434 415 int handle_command_line(int argc, char *argv[], struct screen_list *screen_list) 435 416 { 436 int s = 0 ;417 int s = 0, i; 437 418 for(;;) 438 419 { … … 524 505 } 525 506 } 507 if(s >= 0 && s < argc - 1) 508 { 509 screen_list->to_start = (char**)malloc((argc-s)*sizeof(char*)); 510 if(!screen_list->to_start) 511 { 512 fprintf(stderr, "Can't allocate memory at %s:%d\n", __FUNCTION__, __LINE__); 513 return -1; 514 } 515 for(i=0; i<(argc-1) - s; i++) 516 { 517 screen_list->to_start[i] = strdup(argv[i+s+1]); 518 } 519 screen_list->to_start[argc-1-s] = NULL; 520 } 526 521 return s; 527 522 }
Note: See TracChangeset
for help on using the changeset viewer.