--- config.c.orig 2009-05-15 16:02:47.000000000 +0200 +++ config.c 2010-08-25 13:21:51.000000000 +0200 @@ -65,6 +65,7 @@ #define DISPLAY_HOSTDEPENDENCIES 11 #define DISPLAY_HOSTESCALATIONS 12 #define DISPLAY_SERVICEGROUPS 15 +#define DISPLAY_COMMAND_EXPANSION 16211 void document_header(int); void document_footer(void); @@ -84,6 +85,7 @@ void display_serviceescalations(void); void display_hostdependencies(void); void display_hostescalations(void); +void display_command_expansion(void); void unauthorized_message(void); @@ -91,6 +93,10 @@ authdata current_authdata; int display_type=DISPLAY_NONE; +char to_expand[MAX_COMMAND_BUFFER]; +char *command_args[MAX_COMMAND_ARGUMENTS]; +int arg_count[MAX_COMMAND_ARGUMENTS]; +char hashed_color[8]; int embedded=FALSE; @@ -217,6 +223,10 @@ case DISPLAY_HOSTESCALATIONS: display_context_help(CONTEXTHELP_CONFIG_HOSTESCALATIONS); break; + case DISPLAY_COMMAND_EXPANSION: + /* Reusing DISPLAY_COMMANDS help until further notice */ + display_context_help(CONTEXTHELP_CONFIG_COMMANDS); + break; default: display_context_help(CONTEXTHELP_CONFIG_MENU); break; @@ -266,6 +276,9 @@ case DISPLAY_HOSTESCALATIONS: display_hostescalations(); break; + case DISPLAY_COMMAND_EXPANSION: + display_command_expansion(); + break; default: display_options(); break; @@ -340,6 +353,7 @@ int x; variables=getcgivars(); + to_expand[0]='\0'; for(x=0;variables[x]!=NULL;x++){ @@ -382,12 +396,26 @@ display_type=DISPLAY_HOSTDEPENDENCIES; else if(!strcmp(variables[x],"hostescalations")) display_type=DISPLAY_HOSTESCALATIONS; + else if(!strcmp(variables[x],"command")) + display_type=DISPLAY_COMMAND_EXPANSION; /* we found the embed option */ else if(!strcmp(variables[x],"embedded")) embedded=TRUE; } + /* we found the string-to-expand argument */ + else if(!strcmp(variables[x],"expand")){ + x++; + if(variables[x]==NULL){ + error=TRUE; + break; + } + strncpy(to_expand,variables[x],MAX_COMMAND_BUFFER); + to_expand[MAX_COMMAND_BUFFER-1]='\0'; + } + + /* we received an invalid argument */ else error=TRUE; @@ -420,7 +448,8 @@ return; } - printf("
%s | \n",bg_class,url_encode(temp_host->name),temp_host->name); + printf("%s | \n",bg_class, + url_encode(temp_host->name),CONFIG_CGI,url_encode(temp_host->name),temp_host->name); printf("%s | \n",bg_class,temp_host->alias); printf("%s | \n",bg_class,temp_host->address); @@ -494,7 +524,7 @@ if(temp_hostsmember!=temp_host->parent_hosts) printf(", "); - printf("%s\n",CONFIG_CGI,url_encode(temp_hostsmember->host_name),temp_hostsmember->host_name); + printf("%s\n",CONFIG_CGI,url_encode(temp_hostsmember->host_name),temp_hostsmember->host_name); } if(temp_host->parent_hosts==NULL) printf(" "); @@ -512,14 +542,15 @@ if(temp_host->host_check_command==NULL) printf(" "); else - printf("%s\n",CONFIG_CGI,url_encode(temp_host->host_check_command),html_encode(temp_host->host_check_command,FALSE)); + /* printf("%s\n",CONFIG_CGI,url_encode(strtok(temp_host->host_check_command,"!")),html_encode(temp_host->host_check_command,FALSE)); */ + printf("%s\n",CONFIG_CGI,url_encode(temp_host->host_check_command),html_encode(temp_host->host_check_command,FALSE)); printf("\n"); printf("",bg_class); if(temp_host->check_period==NULL) printf(" "); else - printf("%s",CONFIG_CGI,url_encode(temp_host->check_period),temp_host->check_period); + printf("%s",CONFIG_CGI,url_encode(temp_host->check_period),temp_host->check_period); printf(" | \n"); printf("%s | \n",bg_class,(temp_host->obsess_over_host==TRUE)?"Yes":"No"); @@ -546,13 +577,13 @@ if(contact>1) printf(", "); - printf("%s\n",CONFIG_CGI,url_encode(temp_contactsmember->contact_name),temp_contactsmember->contact_name); + printf("%s\n",CONFIG_CGI,url_encode(temp_contactsmember->contact_name),temp_contactsmember->contact_name); } for(temp_contactgroupsmember=temp_host->contact_groups;temp_contactgroupsmember!=NULL;temp_contactgroupsmember=temp_contactgroupsmember->next){ contact++; if(contact>1) printf(", "); - printf("%s\n",CONFIG_CGI,url_encode(temp_contactgroupsmember->group_name),temp_contactgroupsmember->group_name); + printf("%s\n",CONFIG_CGI,url_encode(temp_contactgroupsmember->group_name),temp_contactgroupsmember->group_name); } if(contact==0) printf(" "); @@ -594,14 +625,15 @@ if(temp_host->notification_period==NULL) printf(" "); else - printf("%s",CONFIG_CGI,url_encode(temp_host->notification_period),temp_host->notification_period); + printf("%s",CONFIG_CGI,url_encode(temp_host->notification_period),temp_host->notification_period); printf("\n"); printf("",bg_class); if(temp_host->event_handler==NULL) printf(" "); else - printf("%s | \n",CONFIG_CGI,url_encode(temp_host->event_handler),temp_host->event_handler); + /* printf("%s\n",CONFIG_CGI,url_encode(strtok(temp_host->event_handler,"!")),temp_host->event_handler); */ + printf("%s\n",CONFIG_CGI,url_encode(temp_host->event_handler),temp_host->event_handler); printf("\n"); printf("",bg_class);
@@ -746,7 +778,8 @@
return;
}
- printf(" Host Groups \n");
+ printf("Host Group%s%s \n",
+ (*to_expand=='\0'?"s":" "),(*to_expand=='\0'?"":html_encode(to_expand,FALSE)));
printf("\n"); printf(" \n");
@@ -762,7 +795,7 @@
printf(" | \n",bg_class); if(temp_contact->host_notification_period==NULL) printf(" "); else - printf("%s",CONFIG_CGI,url_encode(temp_contact->host_notification_period),temp_contact->host_notification_period); + printf("%s",CONFIG_CGI,url_encode(temp_contact->host_notification_period),temp_contact->host_notification_period); printf(" | \n"); printf("",bg_class);
@@ -1015,7 +1050,8 @@
if(temp_commandsmember!=temp_contact->service_notification_commands)
printf(", ");
- printf("%s",CONFIG_CGI,url_encode(temp_commandsmember->command),temp_commandsmember->command);
+ /* printf("%s",CONFIG_CGI,url_encode(strtok(temp_commandsmember->command,"!")),temp_commandsmember->command); */
+ printf("%s",CONFIG_CGI,url_encode(temp_commandsmember->command),temp_commandsmember->command);
found=TRUE;
}
@@ -1030,7 +1066,8 @@
if(temp_commandsmember!=temp_contact->host_notification_commands)
printf(", ");
- printf("%s",CONFIG_CGI,url_encode(temp_commandsmember->command),temp_commandsmember->command);
+ /* printf("%s",CONFIG_CGI,url_encode(strtok(temp_commandsmember->command,"!")),temp_commandsmember->command); */
+ printf("%s",CONFIG_CGI,url_encode(temp_commandsmember->command),temp_commandsmember->command);
found=TRUE;
}
@@ -1077,7 +1114,8 @@
}
- printf(" Contact Groups \n");
+ printf("Contact Group%s%s \n",
+ (*to_expand=='\0'?"s":" "),(*to_expand=='\0'?"":html_encode(to_expand,FALSE)));
printf("\n"); printf(" \n");
@@ -1091,7 +1129,7 @@
printf("\n");
/* check all the contact groups... */
- for(temp_contactgroup=contactgroup_list;temp_contactgroup!=NULL;temp_contactgroup=temp_contactgroup->next){
+ for(temp_contactgroup=contactgroup_list;temp_contactgroup!=NULL;temp_contactgroup=temp_contactgroup->next) if (((*to_expand)=='\0')||(!strcmp(to_expand,temp_contactgroup->group_name))){
if(odd){
odd=0;
@@ -1114,7 +1152,7 @@
if(temp_contactsmember!=temp_contactgroup->members)
printf(", ");
- printf("%s\n",CONFIG_CGI,url_encode(temp_contactsmember->contact_name),temp_contactsmember->contact_name);
+ printf("%s\n",CONFIG_CGI,url_encode(temp_contactsmember->contact_name),temp_contactsmember->contact_name);
}
printf(" | \n");
@@ -1150,7 +1188,8 @@
return;
}
- printf("",url_encode(temp_service->description)); - printf("%s | \n",CONFIG_CGI,url_encode(temp_service->host_name),temp_service->host_name); + printf("%s\n",CONFIG_CGI,url_encode(temp_service->host_name),temp_service->host_name); printf("%s | \n",bg_class,temp_service->description); @@ -1232,12 +1272,13 @@ command_line[sizeof(command_line)-1]='\x0'; command_name=strtok(command_line,"!"); - printf("%s | \n",bg_class,CONFIG_CGI,url_encode(command_name),html_encode(temp_service->service_check_command,FALSE)); + /* printf("%s | \n",bg_class,CONFIG_CGI,url_encode(command_name),html_encode(temp_service->service_check_command,FALSE)); */ + printf("%s | \n",bg_class,CONFIG_CGI,url_encode(temp_service->service_check_command),html_encode(temp_service->service_check_command,FALSE)); printf("",bg_class); if(temp_service->check_period==NULL) printf(" "); else - printf("%s",CONFIG_CGI,url_encode(temp_service->check_period),temp_service->check_period); + printf("%s",CONFIG_CGI,url_encode(temp_service->check_period),temp_service->check_period); printf(" | \n"); printf("%s | \n",bg_class,(temp_service->parallelize==TRUE)?"Yes":"No"); @@ -1265,13 +1306,13 @@ contact++; if(contact>1) printf(", "); - printf("%s",CONFIG_CGI,url_encode(temp_contactsmember->contact_name),temp_contactsmember->contact_name); + printf("%s",CONFIG_CGI,url_encode(temp_contactsmember->contact_name),temp_contactsmember->contact_name); } for(temp_contactgroupsmember=temp_service->contact_groups;temp_contactgroupsmember!=NULL;temp_contactgroupsmember=temp_contactgroupsmember->next){ contact++; if(contact>1) printf(", "); - printf("%s\n",CONFIG_CGI,url_encode(temp_contactgroupsmember->group_name),temp_contactgroupsmember->group_name); + printf("%s\n",CONFIG_CGI,url_encode(temp_contactgroupsmember->group_name),temp_contactgroupsmember->group_name); } if(contact==0) printf(" "); @@ -1320,13 +1361,14 @@ if(temp_service->notification_period==NULL) printf(" "); else - printf("%s",CONFIG_CGI,url_encode(temp_service->notification_period),temp_service->notification_period); + printf("%s",CONFIG_CGI,url_encode(temp_service->notification_period),temp_service->notification_period); printf("\n"); printf("",bg_class); if(temp_service->event_handler==NULL) printf(" "); else - printf("%s",CONFIG_CGI,url_encode(temp_service->event_handler),temp_service->event_handler); + /* printf("%s",CONFIG_CGI,url_encode(strtok(temp_service->event_handler,"!")),temp_service->event_handler); */ + printf("%s",CONFIG_CGI,url_encode(temp_service->event_handler),temp_service->event_handler); printf(" | \n"); printf("",bg_class);
@@ -1471,7 +1513,8 @@
return;
}
- printf(" Time Periods \n");
+ printf("Time Period%s%s \n",
+ (*to_expand=='\0'?"s":" "),(*to_expand=='\0'?"":html_encode(to_expand,FALSE)));
printf("\n"); printf(" \n");
@@ -1486,7 +1529,7 @@
printf("\n");
/* check all the time periods... */
- for(temp_timeperiod=timeperiod_list;temp_timeperiod!=NULL;temp_timeperiod=temp_timeperiod->next){
+ for(temp_timeperiod=timeperiod_list;temp_timeperiod!=NULL;temp_timeperiod=temp_timeperiod->next) if (((*to_expand)=='\0')||(!strcmp(to_expand,temp_timeperiod->name))){
if(odd){
odd=0;
@@ -1655,14 +1698,15 @@
return;
}
- printf(" Commands \n");
+ printf("Command%s%s \n",
+ (*to_expand=='\0'?"s":" "),(*to_expand=='\0'?"":html_encode(to_expand,FALSE)));
printf("\n");
printf("
|