comparison mcabber/src/parsecfg.c @ 170:ea5e101fd29e

[/trunk] Changeset 182 by mikael * Fix last commit, did not compile :-(
author mikael
date Wed, 04 May 2005 19:42:25 +0000
parents 0ed6099b5a54
children 7604e3cdbb86
comparison
equal deleted inserted replaced
169:0ed6099b5a54 170:ea5e101fd29e
4 #include <ctype.h> 4 #include <ctype.h>
5 #include <string.h> 5 #include <string.h>
6 #include <glib.h> 6 #include <glib.h>
7 7
8 #include "list.h" 8 #include "list.h"
9 #include "utils.h"
9 10
10 #define MAX_LENGHT_INPUT 1024 11 #define MAX_LENGHT_INPUT 1024
11 #define cfg_entry(n) list_entry(n, cfg_entry_t, list) 12 #define cfg_entry(n) list_entry(n, cfg_entry_t, list)
12 13
13 typedef struct _cfg_entry_t { 14 typedef struct _cfg_entry_t {
19 static LIST_HEAD(cfg_list); 20 static LIST_HEAD(cfg_list);
20 21
21 22
22 void push_in_list(char *key, char *value) 23 void push_in_list(char *key, char *value)
23 { 24 {
24 cfg_entry_t *new_entry = g_new0(1, sizeof(cfg_entry_t)); 25 cfg_entry_t *new_entry = (cfg_entry_t*)g_new0(char, sizeof(cfg_entry_t));
25 26
26 new_entry->key = (char *) g_new0(1, strlen(key) + 1); 27 new_entry->key = g_new0(char, strlen(key) + 1);
27 new_entry->value = (char *) g_new0(1, strlen(value) + 1); 28 new_entry->value = g_new0(char, strlen(value) + 1);
28 29
29 strcpy(new_entry->key, key); 30 strcpy(new_entry->key, key);
30 strcpy(new_entry->value, value); 31 strcpy(new_entry->value, value);
31 32
32 list_add(&new_entry->list, &cfg_list); 33 list_add(&new_entry->list, &cfg_list);
61 else if ((fp = fopen(filename, "r")) == NULL) { 62 else if ((fp = fopen(filename, "r")) == NULL) {
62 perror("fopen (parsecfg.c:46)"); 63 perror("fopen (parsecfg.c:46)");
63 exit(EXIT_FAILURE); 64 exit(EXIT_FAILURE);
64 } 65 }
65 66
66 buf = g_new(255); 67 buf = g_new(char, 256);
67 68
68 while (fgets(buf, 255, fp) != NULL) { 69 while (fgets(buf, 256, fp) != NULL) {
69 line = buf; 70 line = buf;
70 71
71 while (isspace((int) *line)) 72 while (isspace((int) *line))
72 line++; 73 line++;
73 74