mirror of https://github.com/D4-project/d4-core
Merge branch 'master' of https://github.com/D4-project/d4-core
commit
c37250f869
13
client/d4.c
13
client/d4.c
|
@ -112,6 +112,8 @@ int d4_load_config(d4_t* d4)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int fd;
|
int fd;
|
||||||
|
int n;
|
||||||
|
int j;
|
||||||
char *buf;
|
char *buf;
|
||||||
buf=calloc(1,2*FILENAME_MAX);
|
buf=calloc(1,2*FILENAME_MAX);
|
||||||
if (buf) {
|
if (buf) {
|
||||||
|
@ -120,7 +122,16 @@ int d4_load_config(d4_t* d4)
|
||||||
fd = open(buf,O_RDONLY);
|
fd = open(buf,O_RDONLY);
|
||||||
if (fd > 0) {
|
if (fd > 0) {
|
||||||
//FIXME error handling
|
//FIXME error handling
|
||||||
read(fd, d4->conf[i], SZCONFVALUE);
|
n = read(fd, d4->conf[i], SZCONFVALUE);
|
||||||
|
if (n > 0) {
|
||||||
|
//Remove the last new line
|
||||||
|
for (j=n; j>=0; --j) {
|
||||||
|
if (d4->conf[i][j]== '\n') {
|
||||||
|
d4->conf[i][j] = '\0';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
close(fd);
|
close(fd);
|
||||||
} else {
|
} else {
|
||||||
d4->errno_copy = errno;
|
d4->errno_copy = errno;
|
||||||
|
|
Loading…
Reference in New Issue