emile_config_get() return -1 if tag is not found

This commit is contained in:
Laurent Vivier 2007-08-24 09:20:55 +00:00
parent 51c3298ddd
commit b9431c6cf7

View File

@ -317,6 +317,7 @@ int emile_config_get(emile_config* config, int tag, ...)
va_list arg; va_list arg;
char **s; char **s;
int *v; int *v;
int *p;
va_start(arg, tag); va_start(arg, tag);
switch(tag) switch(tag)
@ -326,13 +327,17 @@ int emile_config_get(emile_config* config, int tag, ...)
case CONFIG_SECOND_LEVEL: case CONFIG_SECOND_LEVEL:
s = va_arg(arg, char**); s = va_arg(arg, char**);
*s = get_tag(config->header, tag); *s = get_tag(config->header, tag);
ret = 0; ret = (*s == NULL) ? -1 : 0;
break; break;
case CONFIG_TIMEOUT: case CONFIG_TIMEOUT:
case CONFIG_DEFAULT: case CONFIG_DEFAULT:
v = va_arg(arg, int*); v = va_arg(arg, int*);
*v = *(int*)get_tag(config->header, tag); p = (int*)get_tag(config->header, tag);
ret = 0; if (p != NULL)
{
ret = 0;
*v = *p;
}
break; break;
case CONFIG_TITLE: case CONFIG_TITLE:
case CONFIG_KERNEL: case CONFIG_KERNEL:
@ -340,7 +345,7 @@ int emile_config_get(emile_config* config, int tag, ...)
case CONFIG_INITRD: case CONFIG_INITRD:
s = va_arg(arg, char**); s = va_arg(arg, char**);
*s = get_tag(config->current, tag); *s = get_tag(config->current, tag);
ret = 0; ret = (*s == NULL) ? -1 : 0;
break; break;
} }
va_end(arg); va_end(arg);