mirror of https://github.com/D4-project/d4-core
Read config parameters
parent
5e1cbfff30
commit
9bfc03f5c6
13
client/d4.c
13
client/d4.c
|
@ -3,17 +3,30 @@
|
|||
#include <stdint.h>
|
||||
#include <getopt.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "d4.h"
|
||||
//Returns -1 on error, 0 otherwise
|
||||
int d4_load_config(d4_t* d4)
|
||||
{
|
||||
int i;
|
||||
int fd;
|
||||
char *buf;
|
||||
buf=calloc(1,2*FILENAME_MAX);
|
||||
if (buf) {
|
||||
for (i=0; i < ND4PARAMS; i++) {
|
||||
snprintf(buf,2*FILENAME_MAX, "%s/%s",d4->confdir, d4params[i]);
|
||||
fd = open(buf,O_RDONLY);
|
||||
if (fd) {
|
||||
//FIXME error handling
|
||||
read(fd, d4->conf[i], SZCONFVALUE);
|
||||
} else {
|
||||
d4->errno_copy = errno;
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
|
|
Loading…
Reference in New Issue