summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Woodward2005-02-16 15:01:49 +0000
committerJason Woodward2005-02-16 15:01:49 +0000
commit6a921cfa96806b995dc3fd4c612866de15e74c51 (patch)
tree56a8dd961d627e8613e79e433f62fdfed4440304 /src
parentb35d8c2ba530c055f4b31d2ebf2a645ce62c412a (diff)
downloadslapt-get-6a921cfa96806b995dc3fd4c612866de15e74c51.tar.gz
added public add_exclude() to configuration.c (libslapt)
Diffstat (limited to 'src')
-rw-r--r--src/configuration.c38
-rw-r--r--src/configuration.h1
2 files changed, 19 insertions, 20 deletions
diff --git a/src/configuration.c b/src/configuration.c
index d553500..ba0005b 100644
--- a/src/configuration.c
+++ b/src/configuration.c
@@ -182,23 +182,13 @@ static struct exclude_list *parse_exclude(char *line){
len = strlen(line);
while( position < len ){
- char **realloc_tmp;
- char *buffer = NULL;
- char *pointer = NULL;
if( strstr(line + position,",") == NULL ){
+ char *pointer = NULL;
pointer = line + position;
- realloc_tmp = realloc( list->excludes, sizeof *list->excludes * (list->count + 1) );
- if( realloc_tmp != NULL ){
- list->excludes = realloc_tmp;
- list->excludes[ list->count ] = strndup(
- pointer, strlen(pointer)
- );
- list->excludes[ list->count ][strlen(pointer)] = '\0';
- ++list->count;
- }
+ add_exclude(list,pointer);
break;
}else{
@@ -207,6 +197,7 @@ static struct exclude_list *parse_exclude(char *line){
++position;
continue;
}else{
+ char *buffer = NULL,*pointer = NULL;
pointer = strchr(line + position,',');
buffer = strndup(
@@ -214,14 +205,8 @@ static struct exclude_list *parse_exclude(char *line){
strlen(line + position) - strlen(pointer)
);
- realloc_tmp = realloc( list->excludes, sizeof *list->excludes * (list->count + 1) );
- if( realloc_tmp != NULL ){
- list->excludes = realloc_tmp;
- list->excludes[ list->count ] = buffer;
- list->excludes[ list->count ][strlen(buffer)] = '\0';
- ++list->count;
- }
-
+ add_exclude(list,buffer);
+ free(buffer);
position += (strlen(line + position) - strlen(pointer) );
}
continue;
@@ -231,4 +216,17 @@ static struct exclude_list *parse_exclude(char *line){
return list;
}
+void add_exclude(struct exclude_list *list, char *e){
+ char **realloc_tmp;
+
+ realloc_tmp = realloc( list->excludes, sizeof *list->excludes * (list->count + 1) );
+
+ if( realloc_tmp == NULL ) return;
+
+ list->excludes = realloc_tmp;
+ list->excludes[ list->count ] = strndup(e, strlen(e));
+ list->excludes[ list->count ][strlen(e)] = '\0';
+ ++list->count;
+
+}
diff --git a/src/configuration.h b/src/configuration.h
index fe283ea..9f9fb36 100644
--- a/src/configuration.h
+++ b/src/configuration.h
@@ -54,3 +54,4 @@ typedef struct {
rc_config *read_rc_config(const char *file_name);
void working_dir_init(const rc_config *global_config);
void free_rc_config(rc_config *global_config);
+void add_exclude(struct exclude_list *list, char *e);