1 |
/* $Id$ */ |
/* $Id$ */ |
2 |
/ * Copyright (c) 2002 Pedro Bastos <pbastos@rdc.puc-rio.br> |
/* Copyright (c) 2002 Pedro Bastos <pbastos@rdc.puc-rio.br> |
3 |
* All rights reserved. |
* All rights reserved. |
4 |
* |
* |
5 |
* Redistribution and use in source and binary forms, with or without |
* Redistribution and use in source and binary forms, with or without |
51 |
{ "proc" , PR_F, d_procs }, |
{ "proc" , PR_F, d_procs }, |
52 |
{ "mem" , ME_F, d_mbufs }, |
{ "mem" , ME_F, d_mbufs }, |
53 |
{ "ifs" , IF_F, d_ifs }, |
{ "ifs" , IF_F, d_ifs }, |
54 |
{ NULL , NULL, NULL }, |
{ 0 , 0, 0 }, |
55 |
}; |
}; |
56 |
|
|
57 |
static void conf_parse(char *, unsigned short int); |
static void conf_parse(char *, unsigned short int); |
59 |
int |
int |
60 |
get_conf(char *file) |
get_conf(char *file) |
61 |
{ |
{ |
62 |
char *buf, *dbuf; |
char fop[BUFSIZ]; |
63 |
|
char *buf, *dbuf; |
64 |
FILE *conf_file; |
FILE *conf_file; |
65 |
size_t l_len; |
size_t l_len; |
66 |
|
|
67 |
if ((conf_file = (FILE *) fopen(file, "r")) == NULL) |
if ((conf_file = (FILE *) fopen(file, "r")) == NULL) |
68 |
return (1); |
return (1); |
69 |
|
|
70 |
while ((buf = fgetln(conf_file, &l_len))) { |
// while ((buf== fgetln(conf_file, &l_len))) { |
71 |
if (buf[l_len - 1] == '\n') |
//if (buf[l_len - 1] == '\n') |
72 |
buf[--l_len] = '\0'; /* null terminate string */ |
// buf[--l_len] = '\0'; /* null terminate string */ |
73 |
|
|
74 |
|
while(fgets(fop, BUFSIZ, conf_file)){ |
75 |
|
if(fop[strlen(fop) - 1] == '\n'){ |
76 |
|
fop[strlen(fop) - 1] = 0;} |
77 |
|
|
78 |
else { |
else { |
79 |
dbuf = (char *) malloc(l_len + 1); |
dbuf = (char *) malloc(l_len + 1); |
80 |
if (dbuf == NULL) |
if (dbuf == NULL) |