aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Woodward2008-11-26 06:04:14 +0000
committerJason Woodward2008-11-26 06:04:14 +0000
commit685e494a80f9a395b724d631613bba3c4917541a (patch)
treef4acc115fee78b7d94a8e20d0999728982d54bf2
parent65dd53a9ad61f76287ce6b807476a317b201ca32 (diff)
downloadslapt-get-685e494a80f9a395b724d631613bba3c4917541a.tar.gz
made parsing of configuration file more correct
-rw-r--r--src/configuration.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/src/configuration.c b/src/configuration.c
index 88f9b09..2aa82a8 100644
--- a/src/configuration.c
+++ b/src/configuration.c
@@ -64,50 +64,54 @@ slapt_rc_config *slapt_read_rc_config(const char *file_name)
exit(EXIT_FAILURE);
while ( (g_size = getline(&getline_buffer,&gb_length,rc) ) != EOF ) {
+ char *token_ptr = NULL;
getline_buffer[g_size - 1] = '\0';
/* check to see if it has our key and value seperated by our token */
/* and extract them */
+ if ( (strchr(getline_buffer,'#') != NULL) && (strstr(getline_buffer, SLAPT_DISABLED_SOURCE_TOKEN) == NULL) )
+ continue;
+
- if ( strstr(getline_buffer,SLAPT_SOURCE_TOKEN) != NULL ) {
+ if ( (token_ptr = strstr(getline_buffer,SLAPT_SOURCE_TOKEN)) != NULL ) {
/* SOURCE URL */
- if ( strlen(getline_buffer) > strlen(SLAPT_SOURCE_TOKEN) ) {
- slapt_source_t *s = slapt_init_source(getline_buffer + strlen(SLAPT_SOURCE_TOKEN));
+ if ( strlen(token_ptr) > strlen(SLAPT_SOURCE_TOKEN) ) {
+ slapt_source_t *s = slapt_init_source(token_ptr + strlen(SLAPT_SOURCE_TOKEN));
if (s != NULL) {
slapt_add_source(global_config->sources,s);
}
}
- } else if ( strstr(getline_buffer,SLAPT_DISABLED_SOURCE_TOKEN) != NULL ) {
+ } else if ( (token_ptr = strstr(getline_buffer,SLAPT_DISABLED_SOURCE_TOKEN)) != NULL ) {
/* DISABLED SOURCE */
- if (strlen(getline_buffer) > strlen(SLAPT_DISABLED_SOURCE_TOKEN) ) {
- slapt_source_t *s = slapt_init_source(getline_buffer + strlen(SLAPT_DISABLED_SOURCE_TOKEN));
+ if (strlen(token_ptr) > strlen(SLAPT_DISABLED_SOURCE_TOKEN) ) {
+ slapt_source_t *s = slapt_init_source(token_ptr + strlen(SLAPT_DISABLED_SOURCE_TOKEN));
if (s != NULL) {
s->disabled = SLAPT_TRUE;
slapt_add_source(global_config->sources,s);
}
}
- } else if ( strstr(getline_buffer,SLAPT_WORKINGDIR_TOKEN) != NULL ) {
+ } else if ( (token_ptr = strstr(getline_buffer,SLAPT_WORKINGDIR_TOKEN)) != NULL ) {
/* WORKING DIR */
- if ( strlen(getline_buffer) > strlen(SLAPT_WORKINGDIR_TOKEN) ) {
+ if ( strlen(token_ptr) > strlen(SLAPT_WORKINGDIR_TOKEN) ) {
strncpy(
global_config->working_dir,
- getline_buffer + strlen(SLAPT_WORKINGDIR_TOKEN),
- (strlen(getline_buffer) - strlen(SLAPT_WORKINGDIR_TOKEN))
+ token_ptr + strlen(SLAPT_WORKINGDIR_TOKEN),
+ (strlen(token_ptr) - strlen(SLAPT_WORKINGDIR_TOKEN))
);
global_config->working_dir[
- (strlen(getline_buffer) - strlen(SLAPT_WORKINGDIR_TOKEN))
+ (strlen(token_ptr) - strlen(SLAPT_WORKINGDIR_TOKEN))
] = '\0';
}
- } else if ( strstr(getline_buffer,SLAPT_EXCLUDE_TOKEN) != NULL ) {
+ } else if ( (token_ptr = strstr(getline_buffer,SLAPT_EXCLUDE_TOKEN)) != NULL ) {
/* exclude list */
slapt_free_exclude_list(global_config->exclude_list);
- global_config->exclude_list = parse_exclude(getline_buffer);
+ global_config->exclude_list = parse_exclude(token_ptr);
}
}