aboutsummaryrefslogtreecommitdiffstats
path: root/service/src/printdoc.c
diff options
context:
space:
mode:
authorLouis Burda <quent.burda@gmail.com>2021-05-13 13:55:07 +0200
committerLouis Burda <quent.burda@gmail.com>2021-05-13 13:55:07 +0200
commit9d4f8aaceda37364748a4be8238ffde4c137a19c (patch)
tree0c641bbf257f606503edd04c3d4a1fd1fd559e62 /service/src/printdoc.c
parentf1285b65d59119b71c7c4f98dddcf2d6969922be (diff)
downloadenowars5-service-stldoctor-9d4f8aaceda37364748a4be8238ffde4c137a19c.tar.gz
enowars5-service-stldoctor-9d4f8aaceda37364748a4be8238ffde4c137a19c.zip
added cleanup script, improved poc test, addec echo for debugging and small fixes
Diffstat (limited to 'service/src/printdoc.c')
-rw-r--r--service/src/printdoc.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/service/src/printdoc.c b/service/src/printdoc.c
index 0eb3127..1e549c9 100644
--- a/service/src/printdoc.c
+++ b/service/src/printdoc.c
@@ -21,18 +21,23 @@ int save_submission(struct parseinfo *info, char *data, int len);
void cat_cmd(char *arg);
void list_cmd(char *arg);
+void exit_cmd(char *arg);
+void echo_cmd(char *arg);
void submit_cmd(char *arg);
void query_cmd(char *arg);
struct command commands[] = {
{ "cat", cat_cmd },
{ "help", list_cmd },
+ { "exit", exit_cmd },
+ { "echo", echo_cmd },
{ "submit", submit_cmd },
{ "query", query_cmd },
};
struct parseinfo cached;
const char *resultdir;
+int echo = 0;
int
save_submission(struct parseinfo *info, char *stldata, int stlsize)
@@ -97,6 +102,19 @@ list_cmd(char *arg)
}
void
+exit_cmd(char *arg)
+{
+ exit(0);
+}
+
+void
+echo_cmd(char *arg)
+{
+ echo ^= 1;
+ printf("Echo is %s\n", echo ? "enabled" : "disabled");
+}
+
+void
submit_cmd(char *arg)
{
const char *bufp;
@@ -212,6 +230,7 @@ cleanup:
void
cleanexit()
{
+ printf("see you later!\n");
free_info(&cached);
}
@@ -244,6 +263,8 @@ main()
if (linebuf[strlen(linebuf) - 1] == '\n')
linebuf[strlen(linebuf) - 1] = '\0';
+ if (echo) printf("%s\n", linebuf);
+
cp = strchr(linebuf, ' ');
arg = cp ? cp + 1 : NULL;
if (cp) *cp = 0;
@@ -258,7 +279,4 @@ main()
if (i == ARRSIZE(commands) && strlen(linebuf) != 0)
fprintf(stderr, "No such command!\n");
}
-
- printf("see you later!\n");
- free_info(&cached);
}