Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2001:
[Freeciv-Dev] Re: registry
Home

[Freeciv-Dev] Re: registry

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Andrew Sutton <ansutton@xxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: registry
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 5 Dec 2001 18:21:59 +0100
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Wed, Dec 05, 2001 at 08:44:52AM -0500, Andrew Sutton wrote:
> char *secfile_lookup_str(struct section_file *my_section_file,
>                        char *path, ...)
> {
>   struct entry *pentry;
>   char buf[MAX_LEN_BUFFER];
>   va_list ap;
> 
>   va_start(ap, path);
>   my_vsnprintf(buf, sizeof(buf), path, ap);
>   va_end(ap);
> 
>   if(!(pentry=section_file_lookup_internal(my_section_file, buf))) {
>     freelog(LOG_FATAL, "sectionfile %s doesn't contain a '%s' entry",
>           secfile_filename(my_section_file), buf);
>     exit(1);
>   }
> 
>   if(!pentry->svalue) {
>     freelog(LOG_FATAL, "sectionfile %s entry '%s' doesn't contain a string",
>           secfile_filename(my_section_file), buf);
>     exit(1);
>   }
>   
>   return pentry->svalue;
> }
> 
> why is it a fatal error that a section doesn't include a string. it might be 
> a really bad error, but i don't think it's worth exitting over... this 
> eliminates the possiblity of optional configuration directives.
> 
> the proper way to do this would be to handle missing required directives from 
> within the ruleset loader - not the parser.
> 
> i'm going to change this method since i need a little optionality for 
> extended capabilities so that it just returns 0. i'll see if i can't update 
> the ruleset code to actually check the error return instead of exitting.

Use section_file_lookup to test before or use
secfile_lookup_str_default to supply a default if the path isn't
found.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "I heard if you play the NT-4.0-CD backwards, you get a satanic message."
 "That's nothing, if you play it forward, it installs NT-4.0"


[Prev in Thread] Current Thread [Next in Thread]