Code

Fix for regex input of '|', being output causing problems with Nagios' parsing of
[nagiosplug.git] / lib / parse_ini.c
index 57321753c5b0bff692d4b621d82de2eee7336ae4..004396fe803378c18c501bb17743364b8cb6508b 100644 (file)
@@ -5,9 +5,6 @@
 * License: GPL
 * Copyright (c) 2007 Nagios Plugins Development Team
 * 
-* Last Modified: $Date$
-* 
-* 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
@@ -21,7 +18,6 @@
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 
-* $Id$
 * 
 *****************************************************************************/
 
@@ -79,10 +75,13 @@ static void parse_locator(const char *locator, const char *def_stanza, np_ini_in
        /* if there is no @file part */
        if(stanza_len==locator_len){
                i->file=default_file();
+               if(strcmp(i->file, "") == 0){
+                       die(STATE_UNKNOWN, _("Cannot find '%s' or '%s' in any standard location.\n"), NP_DEFAULT_INI_FILENAME1, NP_DEFAULT_INI_FILENAME2);
+               }
        } else {
                i->file=strdup(&(locator[stanza_len+1]));
        }
-       
+
        if(i->file==NULL || i->stanza==NULL){
                die(STATE_UNKNOWN, _("malloc() failed!\n"));
        }
@@ -110,7 +109,7 @@ np_arg_list* np_get_defaults(const char *locator, const char *default_section){
                if(inifile!=stdin) fclose(inifile);
        }
        free(i.stanza);
-       return defaults;        
+       return defaults;
 }
 
 /* read_defaults is where the meat of the parsing takes place.
@@ -161,7 +160,7 @@ static int read_defaults(FILE *f, const char *stanza, np_arg_list **opts){
                        default:
                                switch(stanzastate){
                                        /* we never found the start of the first stanza, so
-                                        * we're dealing with a config error 
+                                        * we're dealing with a config error
                                         */
                                        case NOSTANZA:
                                                die(STATE_UNKNOWN, _("Config file error"));