summaryrefslogtreecommitdiffstats
path: root/src/cyn-server.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cyn-server.c')
-rw-r--r--src/cyn-server.c34
1 files changed, 30 insertions, 4 deletions
diff --git a/src/cyn-server.c b/src/cyn-server.c
index 78143a4..8339d09 100644
--- a/src/cyn-server.c
+++ b/src/cyn-server.c
@@ -272,7 +272,7 @@ entercb(
/** translate optional expire value */
static
const char *
-exp2txt(
+exp2check(
time_t expire,
char *buffer,
size_t bufsz
@@ -280,11 +280,37 @@ exp2txt(
if (!expire)
return NULL;
+ if (expire < 0)
+ return "-"; /* no cache */
+
/* TODO: check size */
snprintf(buffer, bufsz, "%lld", (long long)expire);
return buffer;
}
+/** translate optional expire value */
+static
+const char *
+exp2get(
+ time_t expire,
+ char *buffer,
+ size_t bufsz
+) {
+ if (!expire)
+ return NULL;
+
+ if (expire < 0) {
+ expire = -(expire + 1);
+ if (!expire)
+ return "-";
+ *buffer++ = '-';
+ bufsz--;
+ }
+
+ snprintf(buffer, bufsz, "%lld", (long long)expire);
+ return buffer;
+}
+
/** callback of checking */
static
void
@@ -299,7 +325,7 @@ testcheckcb(
if (!value) {
vtxt = _no_;
- etxt = 0;
+ etxt = NULL;
} else {
if (!strcmp(value->value, ALLOW))
vtxt = _yes_;
@@ -307,7 +333,7 @@ testcheckcb(
vtxt = _no_;
else
vtxt = _done_;
- etxt = exp2txt(value->expire, text, sizeof text);
+ etxt = exp2check(value->expire, text, sizeof text);
}
putx(cli, vtxt, etxt, NULL);
flushw(cli);
@@ -346,7 +372,7 @@ getcb(
char text[30];
putx(cli, _item_, key->client, key->session, key->user, key->permission,
- value->value, exp2txt(value->expire, text, sizeof text), NULL);
+ value->value, exp2get(value->expire, text, sizeof text), NULL);
}
/** handle a request */