1 #define _XOPEN_SOURCE 700
6 char credentials_file
[] = "../../test_credentials";
8 static int read_config(char **line
, int order
) {
17 file
= fopen(credentials_file
, "r");
19 fprintf(stderr
, "Could open %s\n", credentials_file
);
23 for (int i
= 0; i
< order
; i
++) {
24 if (-1 == getline(line
, &length
, file
)) {
25 fprintf(stderr
, "Could not read line #%d from %s: ",
26 i
+ 1, credentials_file
);
28 fprintf(stderr
, "error occured\n");
30 fprintf(stderr
, "end of file reached\n");
32 fprintf(stderr
, "I don't know why\n");
42 eol
= strpbrk(*line
, "\r\n");
48 const char *username(void) {
49 static char *username
;
52 username
= getenv("ISDS_USERNAME");
54 read_config(&username
, 1);
59 const char *password(void) {
60 static char *password
;
63 password
= getenv("ISDS_PASSWORD");
65 read_config(&password
, 2);