"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "xdata/xodtemplate.c" between
nagios-4.4.3.tar.gz and nagios-4.4.4.tar.gz

About: Nagios (Core) is an host/service/network monitoring system to identify and resolve IT infrastructure problems.

xodtemplate.c  (nagios-4.4.3):xodtemplate.c  (nagios-4.4.4)
skipping to change at line 507 skipping to change at line 507
} }
#endif #endif
bitmap_destroy(contact_map); bitmap_destroy(contact_map);
bitmap_destroy(host_map); bitmap_destroy(host_map);
bitmap_destroy(service_map); bitmap_destroy(service_map);
return result; return result;
} }
/* Destructively handles semicolons in the nagios configuration language.
* Escaped semicolons "\\;" are turned into semicolons
* The first non-escaped semicolon indicates the start of a comment,
* and the string is truncated at this point.
*/
void xodtemplate_handle_semicolons(char* input) {
/* These two integers only come into play if there are escaped semicolons
. */
int dest_end = 0; /* The index to input that we need to copy to */
int src_start = 0; /* The index to input that we need to copy from */
register int x = 0;
/* grab data before comment delimiter - faster than a strtok() and strncp
y()... */
for(x = 0; input[x] != '\x0'; x++) {
if(input[x] == ';') {
if(x == 0 || input[x - 1] != '\\') {
break;
}
/* We need to escape semicolons */
if (dest_end == 0) {
/* src_start is also uninitialized */
dest_end = x - 1;
src_start = x;
continue;
}
/* dest_end and src_start are initialized - we need to do
a copy. */
/* Copy from src_start (usually a semicolon) up to just b
efore the blackslash */
int copy_size = (x - 1) - src_start;
memmove(input + dest_end, input + src_start, copy_size);
dest_end += copy_size;
src_start = x;
}
}
if (dest_end != 0) {
memmove(input + dest_end, input + src_start, x - src_start);
x += dest_end - src_start;
}
input[x] = '\x0';
}
/* process all files in a specific config directory */ /* process all files in a specific config directory */
int xodtemplate_process_config_dir(char *dirname, int options) { int xodtemplate_process_config_dir(char *dirname, int options) {
char file[MAX_FILENAME_LENGTH]; char file[MAX_FILENAME_LENGTH];
DIR *dirp = NULL; DIR *dirp = NULL;
struct dirent *dirfile = NULL; struct dirent *dirfile = NULL;
int result = OK; int result = OK;
register int x = 0; register int x = 0;
struct stat stat_buf; struct stat stat_buf;
#ifdef NSCORE #ifdef NSCORE
skipping to change at line 629 skipping to change at line 675
/* free memory */ /* free memory */
my_free(input); my_free(input);
/* read the next line */ /* read the next line */
if((input = mmap_fgets_multiline(thefile)) == NULL) if((input = mmap_fgets_multiline(thefile)) == NULL)
break; break;
current_line = thefile->current_line; current_line = thefile->current_line;
/* grab data before comment delimiter - faster than a strtok() an /* Remove comments and handle escaped semicolons */
d strncpy()... */ xodtemplate_handle_semicolons(input);
for(x = 0; input[x] != '\x0'; x++) {
if(input[x] == ';') {
if(x == 0)
break;
else if(input[x - 1] != '\\')
break;
}
}
input[x] = '\x0';
/* strip input */ /* strip input */
strip(input); strip(input);
/* skip empty lines */ /* skip empty lines */
if(input[0] == '\x0' || input[0] == '#') if(input[0] == '\x0' || input[0] == '#')
continue; continue;
/* this is the start of an object definition */ /* this is the start of an object definition */
if(strstr(input, "define") == input) { if(strstr(input, "define") == input) {
 End of changes. 2 change blocks. 
11 lines changed or deleted 52 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)