#include "repo.h"
int repoconfig(const char *config, char repos[MAX_REPOS][MAX_URL_LENGTH], int *repocnt) {
FILE *file = fopen(config, "r");
char line[MAX_URL_LENGTH];
*repocnt = 0;
if (!file) {
perror("/etc/fugu/config.cnfを開けられません");
return -1;
}
while (fgets(line, sizeof(line), file)) {
if (*repocnt >= MAX_REPOS) break;
line[strcspn(line, "\n")] = 0;
strncpy(repos[*repocnt], line, MAX_URL_LENGTH);
(*repocnt)++;
}
fclose(file);
return 0;
}