aboutsummaryrefslogtreecommitdiffstats
path: root/src/confparser.c
diff options
context:
space:
mode:
authorgramanas <anastasis.gramm2@gmail.com>2018-05-08 16:44:05 +0300
committergramanas <anastasis.gramm2@gmail.com>2018-05-08 16:44:05 +0300
commitfb7e3e1352aeca03909ae3720c8cae90fcd57186 (patch)
tree73ec2c99e3a8c578c1791e83a5ec74749a8316af /src/confparser.c
parent00faacfa1ba2af7dd6dbd441e0ede57029d92686 (diff)
downloadck-fb7e3e1352aeca03909ae3720c8cae90fcd57186.tar.gz
ck-fb7e3e1352aeca03909ae3720c8cae90fcd57186.tar.bz2
ck-fb7e3e1352aeca03909ae3720c8cae90fcd57186.zip
user args an now cklist type
Diffstat (limited to 'src/confparser.c')
-rw-r--r--src/confparser.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/confparser.c b/src/confparser.c
index 80120c8..2d17c81 100644
--- a/src/confparser.c
+++ b/src/confparser.c
@@ -13,6 +13,7 @@
#include <stdio.h>
#include "ckutil.h"
+#include "cklist.h"
#include "confparser.h"
@@ -138,14 +139,16 @@ void free_conf(Conf *conf) {
}
int init_create_config_file(UserOpt *opt) {
- char tmp[200];
- if (!util_file_exists(opt->argv[0])) {
- printf("Version control directory: %s\ndoes not exist.\n", opt->argv[0]);
+ list_rewind(opt->args);
+
+ if (!util_file_exists(list_get(opt->args))) {
+ printf("Version control directory: %s\ndoes not exist.\n", list_get(opt->args));
return 1;
}
- if (!util_file_exists(opt->argv[1])) {
- printf("Secret directory: %s\ndoes not exist.\n", opt->argv[1]);
+ list_next(opt->args);
+ if (!util_file_exists(list_get(opt->args))) {
+ printf("Secret directory: %s\ndoes not exist.\n", list_get(opt->args));
return 1;
}
@@ -159,17 +162,21 @@ int init_create_config_file(UserOpt *opt) {
if ((f = fopen(confName, "w")) == NULL) {
return 1;
}
-
+
+ list_rewind(opt->args);
+ char tmp[200];
strcpy(tmp, "version_control_dir = ");
- strcat(tmp, opt->argv[0]);
+ strcat(tmp, list_get(opt->args));
strcat(tmp, "\n");
fputs(tmp, f);
+ list_next(opt->args);
strcpy(tmp, "secret_dir = ");
- strcat(tmp, opt->argv[1]);
+ strcat(tmp, list_get(opt->args));
strcat(tmp, "\n");
fputs(tmp, f);
- fclose(f);
+ fclose(f);
+ list_rewind(opt->args);
return 0;
}