| version 1.15, 2002/02/28 09:23:29 |
version 1.16, 2002/02/28 17:50:38 |
| Line 57 static struct cfg_option global_options[ |
|
| Line 57 static struct cfg_option global_options[ |
|
| {NULL, 'f', NULL, CFG_STRING + CFG_MULTI, (void *) &(global_cfg.config_file), 0}, |
{NULL, 'f', NULL, CFG_STRING + CFG_MULTI, (void *) &(global_cfg.config_file), 0}, |
| {"disable-global-config",'\0',NULL,CFG_BOOLEAN,(void*)&(global_cfg.disable_global_config),0}, |
{"disable-global-config",'\0',NULL,CFG_BOOLEAN,(void*)&(global_cfg.disable_global_config),0}, |
| {"disable-user-config",'\0',NULL,CFG_BOOLEAN,(void*)&(global_cfg.disable_user_config),0}, |
{"disable-user-config",'\0',NULL,CFG_BOOLEAN,(void*)&(global_cfg.disable_user_config),0}, |
| |
{"case-insensitive-names",'\0',NULL,CFG_BOOLEAN,(void*)&(global_cfg.case_insensitive_names),0}, |
| CFG_END_OF_LIST |
CFG_END_OF_LIST |
| }; |
}; |
| |
|
| Line 70 static struct cfg_option process_options |
|
| Line 71 static struct cfg_option process_options |
|
| {"input", 'i', "input", CFG_STRING+CFG_MULTI_SEPARATED, (void *) &(process_cfg.fd_str[0]), 0}, |
{"input", 'i', "input", CFG_STRING+CFG_MULTI_SEPARATED, (void *) &(process_cfg.fd_str[0]), 0}, |
| {"output", 'o', "output", CFG_STRING+CFG_MULTI_SEPARATED, (void *)&(process_cfg.fd_str[1]),0}, |
{"output", 'o', "output", CFG_STRING+CFG_MULTI_SEPARATED, (void *)&(process_cfg.fd_str[1]),0}, |
| {"errput", 'e', "errput", CFG_STRING+CFG_MULTI_SEPARATED, (void *)&(process_cfg.fd_str[2]),0}, |
{"errput", 'e', "errput", CFG_STRING+CFG_MULTI_SEPARATED, (void *)&(process_cfg.fd_str[2]),0}, |
| {NULL, '\0', "command", CFG_LEFTOVER_ARGS+CFG_STRING+CFG_MULTI,(void *)&(process_cfg.argv),0}, |
{NULL, '\0', "command", CFG_LEFTOVER_ARGS+CFG_STRING+CFG_MULTI_SEPARATED,(void *)&(process_cfg.argv),0}, |
| CFG_END_OF_LIST |
CFG_END_OF_LIST |
| }; |
}; |
| |
|
| Line 172 conf_parse_all(argc, argv) |
|
| Line 173 conf_parse_all(argc, argv) |
|
| |
|
| for (i = 0; i < start_idx_size - 1; i++) { |
for (i = 0; i < start_idx_size - 1; i++) { |
| |
|
| if (i >= 2 |
register char *filename; |
| || (i == 0 && ! global->disable_global_config) |
|
| |
if ((i == 0 && global->disable_global_config) |
| || (i == 1 && ! global->disable_user_config)) |
|| (i == 1 && ! global->disable_user_config)) |
| { |
continue; |
| register char *filename = i <= 0 ? conf_global_filename : i == 1 |
|
| ? get_user_config_filename() : global->config_file[i - 2]; |
filename = i <= 0 ? conf_global_filename : i == 1 |
| |
? get_user_config_filename() : global->config_file[i - 2]; |
| if (/* i == 1 && */ filename == NULL) { |
|
| msg_error_print("not enough memory\n"); |
if (/* i == 1 && */ filename == NULL) { |
| /* TODO: free structures */ |
msg_error_print("not enough memory\n"); |
| return NULL; |
/* TODO: free structures */ |
| } |
return NULL; |
| |
} |
| |
|
| #if DEBUG |
#if DEBUG |
| msg_debug_print("conf_parse_all(): parsing file '%s'\n", filename); |
msg_debug_print("conf_parse_all(): parsing file '%s'\n", filename); |
| #endif |
#endif |
| |
|
| ret = conf_cfgfile_parse(filename, &global_work, &processes_work); |
ret = conf_cfgfile_parse(filename, &global_work, &processes_work); |
| |
|
| /* TODO: Progressive config file type reporting in error messages. |
/* TODO: Progressive config file type reporting in error messages. |
| There are three types: global, local/user, user defined. */ |
There are three types: global, local/user, user defined. */ |
| |
|
| if (ret != CFG_OK && (i >= 2 |
if (ret != CFG_OK && (i >= 2 |
| || (i < 2 && ret != CFG_ERR_FILE_NOT_FOUND))) { |
|| (i < 2 && ret != CFG_ERR_FILE_NOT_FOUND))) { |
| msg_error_print("config file '%s' parsing error %d\n", |
msg_error_print("config file '%s' parsing error %d\n", |
| filename, ret); |
filename, ret); |
| /* TODO: free structures */ |
/* TODO: free structures */ |
| return NULL; |
return NULL; |
| } |
} |
| |
|
| for (start_idx[i + 1] = 0; processes_work != NULL |
for (start_idx[i + 1] = 0; processes_work != NULL |
| && processes_work[start_idx[i + 1]] != NULL; |
&& processes_work[start_idx[i + 1]] != NULL; |
| start_idx[i + 1]++) |
start_idx[i + 1]++) |
| ; |
; |
| start_idx[i + 1] += start_idx[i]; |
start_idx[i + 1] += start_idx[i]; |
| |
|
| if (! add_processes_to_processes(&processes, processes_work)) { |
if (! add_processes_to_processes(&processes, processes_work)) { |
| msg_error_print("not enough memory for config file '%s'" |
msg_error_print("not enough memory for config file '%s'" |
| "process table merging\n", filename); |
"process table merging\n", filename); |
| /* TODO: free structures */ |
/* TODO: free structures */ |
| return NULL; |
return NULL; |
| } |
} |
| |
|
| if (i == 1) |
if (i == 1) |
| free(filename); |
free(filename); |
| |
|
| free(global_work); |
free(global_work); |
| } |
|
| } |
} |
| |
|
| #if DEBUG |
#if DEBUG |
| Line 656 add_processes_to_proctable(p_ptbl, proce |
|
| Line 658 add_processes_to_proctable(p_ptbl, proce |
|
| int *start_idx; |
int *start_idx; |
| { |
{ |
| register int i, j, k, idx; |
register int i, j, k, idx; |
| register int ptbl_size; |
register int resource_idx = 0; |
| |
register int ptbl_size, new_ptbl_size; |
| PROCTABLE new_ptbl; |
PROCTABLE new_ptbl; |
| register int new_ptbl_size; |
|
| |
|
| register int resource_idx = 0; |
ptbl_size = proctable_get_size(*p_ptbl); |
| |
|
| for (new_ptbl_size = 0; processes != NULL |
for (new_ptbl_size = 0; processes != NULL |
| && processes[new_ptbl_size] != NULL; new_ptbl_size++) |
&& processes[new_ptbl_size] != NULL; new_ptbl_size++) |
| ; |
; |
| #if DEBUG |
#if DEBUG |
| msg_debug_print("add_processes_to_proctable(): new_ptbl_size = %d\n", |
msg_debug_print("add_processes_to_proctable():" |
| new_ptbl_size); |
" ptbl_size = %d, new_ptbl_size = %d\n", |
| |
ptbl_size, new_ptbl_size); |
| #endif |
#endif |
| |
|
| if ((new_ptbl = proctable_create(new_ptbl_size)) == NULL) |
if ((new_ptbl = proctable_create(new_ptbl_size)) == NULL) |
| return -1; |
return -1; |
| |
|
| ptbl_size = proctable_get_size(*p_ptbl); |
|
| |
|
| for (i = 0; i < new_ptbl_size; i++) { |
for (i = 0; i < new_ptbl_size; i++) { |
| |
|
| /* Counting resource_idx. */ |
/* Counting resource_idx. */ |
| Line 754 add_processes_to_proctable(p_ptbl, proce |
|
| Line 755 add_processes_to_proctable(p_ptbl, proce |
|
| if (link.proc_id == 0) /* 0 is always valid */ |
if (link.proc_id == 0) /* 0 is always valid */ |
| break; |
break; |
| |
|
| if (link.proc_id <= |
if (link.proc_id > 0) { |
| start_idx[resource_idx + 1] |
link.proc_id--; /* make real index */ |
| - start_idx[resource_idx]) { |
|
| |
|
| link.proc_id += start_idx[resource_idx]; |
if (link.proc_id <= |
| break; |
start_idx[resource_idx + 1] |
| |
- start_idx[resource_idx] - 1) { |
| |
|
| |
link.proc_id += ptbl_size; |
| |
link.proc_id += start_idx[resource_idx]; |
| |
break; |
| |
} |
| } |
} |
| } |
} |
| |
|
| Line 773 add_processes_to_proctable(p_ptbl, proce |
|
| Line 779 add_processes_to_proctable(p_ptbl, proce |
|
| * Process link initialization by name |
* Process link initialization by name |
| */ |
*/ |
| |
|
| /* Searching name in existing proctable. */ |
/* Searching name in original (old) proctable. */ |
| link.proc_id = proctable_get_process_index_by_name( |
link.proc_id = proctable_get_process_index_by_name( |
| new_ptbl, ar[0]); |
*p_ptbl, ar[0]); |
| |
|
| if (link.proc_id >= 0) |
if (link.proc_id >= 0) |
| break; |
break; |
| |
|
| |
/* Searching name in existing new proctable. |
| |
* THIS IS ABSOLUTELY WRONG! |
| |
* You cannot search proctable which is not already |
| |
* built! |
| |
|
| |
link.proc_id = proctable_get_process_index_by_name( |
| |
new_ptbl, ar[0]); |
| |
|
| |
if (link.proc_id >= 0) { |
| |
link.proc_id += ptbl_size; |
| |
break; |
| |
} |
| |
*/ |
| |
|
| /* Searching name in processes. */ |
/* Searching name in processes. */ |
| link.proc_id = get_processes_index_by_name( |
link.proc_id = get_processes_index_by_name( |
| processes, ar[0]); |
processes, ar[0]); |
| |
|
| if (link.proc_id >= 0) { |
if (link.proc_id >= 0) { |
| link.proc_id += 1; |
link.proc_id += ptbl_size; |
| link.proc_id += start_idx[resource_idx]; |
/* link.proc_id += start_idx[resource_idx]; */ |
| break; |
break; |
| } |
} |
| |
|