diff mcabber/src/parsecfg.c @ 279:f5dd437c057b

Rewrite the settings system Settings now use glibc library, and can be used for aliases and bindings.
author Mikael Berthe <mikael@lilotux.net>
date Tue, 05 Jul 2005 23:50:50 +0100
parents 7604e3cdbb86
children 9bdfef4f4735 12f919be3da5
line wrap: on
line diff
--- a/mcabber/src/parsecfg.c	Tue Jul 05 23:30:10 2005 +0100
+++ b/mcabber/src/parsecfg.c	Tue Jul 05 23:50:50 2005 +0100
@@ -5,34 +5,9 @@
 #include <string.h>
 #include <glib.h>
 
-#include "list.h"
+#include "settings.h"
 #include "utils.h"
 
-#define MAX_LENGHT_INPUT 1024
-#define cfg_entry(n) list_entry(n, cfg_entry_t, list)
-
-typedef struct _cfg_entry_t {
-  char *key;
-  char *value;
-  struct list_head list;
-} cfg_entry_t;
-
-static LIST_HEAD(cfg_list);
-
-
-void push_in_list(char *key, char *value)
-{
-  cfg_entry_t *new_entry  = (cfg_entry_t*)g_new0(char, sizeof(cfg_entry_t));
-
-  new_entry->key          = g_new0(char, strlen(key) + 1);
-  new_entry->value        = g_new0(char, strlen(value) + 1);
-
-  strcpy(new_entry->key, key);
-  strcpy(new_entry->value, value);
-
-  list_add(&new_entry->list, &cfg_list);
-}
-
 int cfg_file(char *filename)
 {
   FILE *fp;
@@ -91,7 +66,7 @@
 	     && isspace((int) line[strlen(line) - 1]))
 	line[strlen(line) - 1] = '\0';
 
-      push_in_list(line, value);
+      settings_set(SETTINGS_TYPE_OPTION, line, value);
       continue;
     }
     fprintf(stderr, "CFG: orphaned line \"%s\"\n", line);
@@ -99,31 +74,3 @@
   g_free(buf);
   return 1;
 }
-
-char *cfg_read(char *key)
-{
-  struct list_head *n, *pos;
-  cfg_entry_t *search_entry = NULL;
-
-  list_for_each_safe(pos, n, &cfg_list) {
-    search_entry = cfg_entry(pos);
-    if (search_entry->key) {
-      if (!strcasecmp(search_entry->key, key)) {
-	return search_entry->value;
-      }
-    }
-  }
-  return NULL;
-}
-
-int cfg_read_int(char *key)
-{
-  char *optval;
-
-  optval = cfg_read(key);
-
-  if (optval)
-    return atoi(optval);
-
-  return 0;
-}