Compare commits
2 Commits
a2e0694efc
...
fa589f3122
Author | SHA1 | Date |
---|---|---|
Alexander Andreev | fa589f3122 | |
Alexander Andreev | d95b4c3089 |
|
@ -46,9 +46,12 @@ int addrbook_load(addrbook_t *ab, FILE *in) {
|
||||||
char *line = NULL;
|
char *line = NULL;
|
||||||
size_t line_len = 0;
|
size_t line_len = 0;
|
||||||
size_t lines = 0;
|
size_t lines = 0;
|
||||||
|
while (getline(&line, &line_len, in) != -1) {
|
||||||
while (getline(&line, &line_len, in) != -1)
|
|
||||||
++lines;
|
++lines;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lines == 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
if (ab->entries != NULL)
|
if (ab->entries != NULL)
|
||||||
free(ab->entries);
|
free(ab->entries);
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
#define CHANNELS 1
|
#define CHANNELS 1
|
||||||
#define SAMPLE_RATE 48000
|
#define SAMPLE_RATE 48000
|
||||||
|
@ -24,6 +25,10 @@ int main(int argc, char **argv) {
|
||||||
addrbook_t ab = {0};
|
addrbook_t ab = {0};
|
||||||
|
|
||||||
FILE *in = fopen("addressbook_key", "r");
|
FILE *in = fopen("addressbook_key", "r");
|
||||||
|
if (in == NULL) {
|
||||||
|
fprintf(stderr, "An addressbook file wasn't open: %s\n", strerror(errno));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
addrbook_load(&ab, in);
|
addrbook_load(&ab, in);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue