aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/main.c b/src/main.c
index b639f6a..ff04849 100644
--- a/src/main.c
+++ b/src/main.c
@@ -78,6 +78,12 @@ unlockfile(FILE **f)
}
int
+authorized(char prefix)
+{
+ return ((prefix == '.') == (loggedin > 0));
+}
+
+int
save_submission(struct parseinfo *info, char *stldata, int stlsize)
{
char *dirpath = NULL, *infopath = NULL, *modeldir = NULL,
@@ -317,7 +323,7 @@ search_cmd(const char *arg)
while ((c = fgetc(f)) > 0) {
if (c == '\n') {
matchlen = 0;
- } else if (!matchlen && (c == '.') != loggedin) {
+ } else if (!matchlen && !authorized(c)) {
matchlen = -1;
} else if (matchlen >= 0 && c == filename[matchlen]) {
matchlen += 1;
@@ -346,7 +352,7 @@ search_cmd(const char *arg)
while (1) {
resp = ask("> Enter %s [q to quit]: ",
resp ? "another" : "hash");
- if (strchr(resp, 'q')) break;
+ if (strchr(resp, 'q') || !*resp) break;
if (checkalph(resp, ".abcdef0123456789-") != OK) {
ERR("Invalid model id specified\n");
goto exit;
@@ -384,6 +390,8 @@ list_cmd(const char *arg)
if (*buf && buf[strlen(buf)-1] == '\n')
buf[strlen(buf)-1] = '\0';
+ if (!authorized(*buf)) continue;
+
printf(">> %s\n", buf);
path = aprintf("%s/%s/info", resultdir, buf);
if ((fn = fopen(path, "r")) && load_info(&info, fn) == OK) {