#include "moroz.h"
#include "ANTbin.h"
int ANTbin_cfg(char **args) {
for (int i = 1; args[i] != NULL; i++) {
if (strcmp(args[i], "-r") == 0 || strcmp(args[i], "--read") == 0) {
system("cat ANT.cfg");
prt(stderr, "\n");
}
if (strcmp(args[i], "-c") == 0 || strcmp(args[i], "--check") == 0) {
char *name = MRZ_RFILE("ANT.cfg", "name");
if (name != NULL && name[0] != '\0') {
prt(stdout, "Found name in config: %s\n", name);
} else {
prt(stderr, TXT_RED "No name in config's !\n" TXT_RESET);
prt(stderr, "Default name is \"pin\"\n");
}
char *nthn = MRZ_RFILE("ANT.cfg", "hthn");
if (nthn != NULL && strcmp(nthn, "true") == 0) {
prt(stdout, "hthn (host to host name) this: %s\n", nthn);
} else if (nthn != NULL && strcmp(nthn, "false") == 0) {
char *nhost = MRZ_RFILE("ANT.cfg", "nhost");
if (nhost != NULL && nhost[0] != '\0') {
prt(stdout, "Found custom name host in config is: %s\n", nhost);
} else {
prt(stderr, TXT_RED "No hthn or nhost in config !\n" TXT_RESET);
return 1;
}
} else if (nthn != NULL && nthn[0] != '\0') {
prt(stdout, TXT_YELLOW "What is \"%s\" ???\n" TXT_RESET, nthn);
char *nhost = MRZ_RFILE("ANT.cfg", "nhost");
if (nhost != NULL && nhost[0] != '\0') {
prt(stdout, "Found custom name host in config is: %s\n", nhost);
} else {
prt(stderr, TXT_RED "No hthn or nhost in config !\n" TXT_RESET);
return 1;
}
}
char *welcome = MRZ_RFILE("ANT.cfg", "welcome");
if (welcome != NULL && strcmp(welcome, "true") == 0) {
prt(stdout, "Welcome is true: %s\n", welcome);
} else if (welcome != NULL && strcmp(welcome, "false") == 0) {
prt(stdout, "Welcome is false: %s\n", welcome);
} else if (welcome != NULL && welcome[0] != '\0') {
prt(stdout, TXT_YELLOW "What is \"%s\" ???\n" TXT_RESET, welcome);
} else {
prt(stderr, TXT_RED "No welcome (false or true) in config !\n" TXT_RESET);
}
}
}
return 0;
}