src/config.c
changeset 33 56571d34d754
parent 18 4435146391ae
child 36 6889aacd038e
equal deleted inserted replaced
32:89fb9c6611ca 33:56571d34d754
     8 #include <stdlib.h>
     8 #include <stdlib.h>
     9 #include <string.h>
     9 #include <string.h>
    10 
    10 
    11 #include <compat.h>
    11 #include <compat.h>
    12 #include <config.h>
    12 #include <config.h>
       
    13 #include "common.h"
    13 
    14 
    14 const
    15 const
    15 char *CONFIG_OPTIONS[] = {
    16 char *CONFIG_OPTIONS[] = {
    16     "NICK", "PASSWORD", "SERVER", "PORT",
    17     "NICK", "PASSWORD", "SERVER", "PORT",
    17     "CHANNEL", "TOPIC", NULL
    18     "CHANNEL", "TOPIC", NULL
    18 };
    19 };
    19 
    20 
    20 int config (UC * uc, char *fname)
    21 int config (UC * uc, char *fname)
    21 {
    22 {
    22     FILE *f;
    23     FILE *f;
    23     char buffer[513];
    24     char buffer[DEFAULT_BUF_SIZE];
    24     char **line;
    25     char **line;
    25     char *token;
    26     char *token;
    26     char *value;
    27     char *value;
    27     int i = 0;
    28     int i = 0;
    28 
    29 
    39      */
    40      */
    40     uc->nick = uc->pass = uc->server = uc->channel = uc->topic = NULL;
    41     uc->nick = uc->pass = uc->server = uc->channel = uc->topic = NULL;
    41     uc->port = 6667;
    42     uc->port = 6667;
    42 
    43 
    43     while (!feof (f)) {
    44     while (!feof (f)) {
    44         *buffer = '\0';
    45         (void)fgets (buffer, sizeof (buffer), f);
    45         (void)fgets (buffer, 512, f);
       
    46         token = buffer;
    46         token = buffer;
    47 
    47 
    48         while (*token == '\t')  /* Eat trailing tabs */
    48         while (*token == '\t')  /* Eat trailing tabs */
    49             token++;
    49             token++;
    50         while (*token == ' ')   /* Eat trailing whitespaces */
    50         while (*token == ' ')   /* Eat trailing whitespaces */