Changeset 2487 for neercs/trunk
- Timestamp:
- Jun 24, 2008, 11:14:32 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
neercs/trunk/src/main.c
r2486 r2487 68 68 printf("Example : %s zsh top \n\n", argv[0]); 69 69 printf("Options :\n"); 70 printf("\t--config\t\t-c <file>\t\tuse given config file\n"); 70 71 printf("\t--pid\t\t-P <pid>\t\tattach <pid>\n"); 71 72 printf("\t\t\t-R\t\t\tre-attach another neercs\n"); … … 102 103 if(args==0) 103 104 args = 1; 105 106 /* Build local config file path */ 107 user_info = getpwuid(getuid()); 108 if(user_info) 109 { 110 user_path = malloc(strlen(user_info->pw_dir) + strlen("/.neercsrc") + 1); 111 sprintf(user_path, "%s/%s", user_info->pw_dir, ".neercsrc"); 112 } 104 113 105 114 /* Create screen list */ … … 136 145 memset(screen_list->lockpass, 0, 1024); 137 146 138 139 /* Read global configuration first */140 read_configuration_file("/etc/neercsrc", screen_list);141 142 /* Then local one */143 user_info = getpwuid(getuid());144 if(user_info)145 {146 user_path = malloc(strlen(user_info->pw_dir) + strlen("/.neercsrc") + 1);147 sprintf(user_path, "%s/%s", user_info->pw_dir, ".neercsrc");148 read_configuration_file(user_path, screen_list);149 free(user_path);150 }151 152 153 147 recurrent_list = (struct recurrent_list*) malloc(sizeof(struct recurrent_list)); 154 148 recurrent_list->recurrent = (struct recurrent**) malloc(sizeof(struct recurrent*)); … … 166 160 static struct myoption long_options[] = 167 161 { 162 { "config", 1, NULL, 'c' }, 168 163 #if defined USE_GRAB 169 164 { "pid", 1, NULL, 'P' }, … … 173 168 }; 174 169 #if defined USE_GRAB 175 int c = mygetopt(argc, argv, " RP:hv", long_options, &option_index);170 int c = mygetopt(argc, argv, "c:RP:hv", long_options, &option_index); 176 171 #else 177 int c = mygetopt(argc, argv, " Rhv", long_options, &option_index);172 int c = mygetopt(argc, argv, "c:Rhv", long_options, &option_index); 178 173 #endif 179 174 if(c == -1) … … 182 177 switch(c) 183 178 { 179 case 'c': /* --config */ 180 if(user_path) 181 free(user_path); 182 user_path = strdup(myoptarg); 183 s+=2; 184 break; 184 185 case 'P': /* --pid */ 185 186 pidopt = atoi(myoptarg); … … 221 222 break; 222 223 } 224 } 225 226 /* Read global configuration first */ 227 read_configuration_file("/etc/neercsrc", screen_list); 228 229 /* Then local one */ 230 if(user_path) 231 { 232 read_configuration_file(user_path, screen_list); 233 free(user_path); 223 234 } 224 235
Note: See TracChangeset
for help on using the changeset viewer.