#include <stdio.h>
#include <string.h>
#include <errno.h>
#define ACB_YES 1
#define ACB_NO 2
#define ACB_ASK 3
int conf_alias(
cfg_t *cfg,
cfg_opt_t *opt,
int argc,
const char **argv)
{
if (argc < 2) {
return -1;
}
printf("got alias '%s' = '%s'\n", argv[0], argv[1]);
return 0;
}
int conf_parse_acb(
cfg_t *cfg,
cfg_opt_t *opt,
const char *value,
void *result)
{
if (strcmp(value, "yes") == 0)
*(int *)result = ACB_YES;
else if (strcmp(value, "no") == 0)
*(int *)result = ACB_NO;
else if (strcmp(value, "ask") == 0)
*(int *)result = ACB_ASK;
else {
return -1;
}
return 0;
}
{
if (value <= 0) {
return -1;
}
return 0;
}
{
cfg_error(cfg,
"missing required option 'host' in bookmark");
return -1;
}
return 0;
}
cfg_t *parse_conf(
const char *filename)
{
};
};
case CFG_FILE_ERROR:
printf("warning: configuration file '%s' could not be read: %s\n", filename, strerror(errno));
printf("continuing with default values...\n\n");
break;
case CFG_PARSE_ERROR:
return 0;
}
return cfg;
}
int main(int argc, char **argv)
{
cfg_t *cfg = parse_conf(argc > 1 ? argv[1] :
"ftp.conf");
if (cfg) {
unsigned int i;
printf(
"passive-mode = %s\n",
cfg_getbool(cfg,
"passive-mode") ?
"true" :
"false");
printf(
"remote-completion = %s\n",
cfg_getbool(cfg,
"remote-completion") ?
"true" :
"false");
printf(
"number of bookmarks: %d\n",
cfg_size(cfg,
"bookmark"));
for (i = 0; i <
cfg_size(cfg,
"bookmark"); i++) {
printf(" bookmark #%d: %s:%s@%s:%ld%s\n", i + 1,
}
for (i = 0; i <
cfg_size(cfg,
"xterm-terminals"); i++) {
printf(
"xterm-terminal #%d: %s\n", i + 1,
cfg_getnstr(cfg,
"xterm-terminals", i));
}
printf(
"auto-create-bookmark = %ld\n",
cfg_getint(cfg,
"auto-create-bookmark"));
}
return 0;
}