aboutsummaryrefslogtreecommitdiff
path: root/src/calculer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/calculer.c')
-rw-r--r--src/calculer.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/calculer.c b/src/calculer.c
index 3ea19ad..34e2fa6 100644
--- a/src/calculer.c
+++ b/src/calculer.c
@@ -26,6 +26,7 @@
#include <unistd.h>
#include "_readline.h"
+#include "disp.h"
static int lower = 0;
static int upper = 100;
@@ -115,11 +116,30 @@ print_version(void)
printf("%s\n", VERSION);
}
+void
+set_disp_name(char **dest, char const *optarg)
+{
+ if (strcmp(optarg, "cli") == 0)
+ {
+ *dest = DISP_CLI;
+ }
+ else if (strcmp(optarg, "gui") == 0)
+ {
+ *dest = DISP_RAY;
+ }
+ else
+ {
+ fprintf(stderr, "calculer: invalid interface \"%s\"\n", optarg);
+ print_usage(stderr);
+ exit(1);
+ }
+}
+
int
main(int argc, char *argv[])
{
char *logpath = "./calculer.log";
-
+ char *disp_name = DISP_RAY;
srand(time(NULL));
/* Store the prefix "YYYY-MM-DD" in LOGBUF. */
@@ -129,7 +149,7 @@ main(int argc, char *argv[])
assert(bytes_written);
int opt;
- while ((opt = getopt(argc, argv, ":Vhl:m:M:")) != -1)
+ while ((opt = getopt(argc, argv, ":Vhl:m:M:i:")) != -1)
{
switch (opt)
{
@@ -148,6 +168,9 @@ main(int argc, char *argv[])
case 'M':
upper = atoi(optarg);
break;
+ case 'i':
+ set_disp_name(&disp_name, optarg);
+ break;
case ':':
fprintf(stderr,
"calculer: option %d requires an argument\n",