|
|
@@ -101,29 +101,27 @@ static void app_dec(char *d, unsigned int *n, unsigned int v, unsigned int cap)
|
|
|
app_ch(d, n, tmp[i - 1 - j], cap);
|
|
|
}
|
|
|
|
|
|
-static void fetch_paths_init(int slot)
|
|
|
+static void fetch_path(char *out, unsigned int cap, const char *kind,
|
|
|
+ unsigned int session, int slot)
|
|
|
{
|
|
|
unsigned int n = 0;
|
|
|
|
|
|
- app_str(fp.req, &n, "/share/bfreq", sizeof(fp.req));
|
|
|
- if (slot >= 0)
|
|
|
- app_dec(fp.req, &n, (unsigned int)slot, sizeof(fp.req));
|
|
|
- n = 0;
|
|
|
- app_str(fp.body, &n, "/share/bfbody", sizeof(fp.body));
|
|
|
- if (slot >= 0)
|
|
|
- app_dec(fp.body, &n, (unsigned int)slot, sizeof(fp.body));
|
|
|
- n = 0;
|
|
|
- app_str(fp.meta, &n, "/share/bfmeta", sizeof(fp.meta));
|
|
|
- if (slot >= 0)
|
|
|
- app_dec(fp.meta, &n, (unsigned int)slot, sizeof(fp.meta));
|
|
|
- n = 0;
|
|
|
- app_str(fp.done, &n, "/share/bfdone", sizeof(fp.done));
|
|
|
- if (slot >= 0)
|
|
|
- app_dec(fp.done, &n, (unsigned int)slot, sizeof(fp.done));
|
|
|
- n = 0;
|
|
|
- app_str(fp.post, &n, "/share/bfpost", sizeof(fp.post));
|
|
|
- if (slot >= 0)
|
|
|
- app_dec(fp.post, &n, (unsigned int)slot, sizeof(fp.post));
|
|
|
+ app_str(out, &n, "/share/bf", cap);
|
|
|
+ if (slot >= 0) {
|
|
|
+ app_dec(out, &n, session, cap);
|
|
|
+ app_ch(out, &n, '_', cap);
|
|
|
+ app_dec(out, &n, (unsigned int)slot, cap);
|
|
|
+ }
|
|
|
+ app_str(out, &n, kind, cap);
|
|
|
+}
|
|
|
+
|
|
|
+static void fetch_paths_init(unsigned int session, int slot)
|
|
|
+{
|
|
|
+ fetch_path(fp.req, sizeof(fp.req), "req", session, slot);
|
|
|
+ fetch_path(fp.body, sizeof(fp.body), "body", session, slot);
|
|
|
+ fetch_path(fp.meta, sizeof(fp.meta), "meta", session, slot);
|
|
|
+ fetch_path(fp.done, sizeof(fp.done), "done", session, slot);
|
|
|
+ fetch_path(fp.post, sizeof(fp.post), "post", session, slot);
|
|
|
}
|
|
|
|
|
|
static void fetch_fail(unsigned int status, int err, const char *ctype,
|
|
|
@@ -214,7 +212,7 @@ static void fetch_once(void)
|
|
|
static struct uhttp h;
|
|
|
char req[768];
|
|
|
|
|
|
- fetch_paths_init(-1);
|
|
|
+ fetch_paths_init(0, -1);
|
|
|
unsigned char *buf;
|
|
|
unsigned int cap = 0;
|
|
|
unsigned int body_len = 0, body_trunc = 0;
|
|
|
@@ -269,7 +267,7 @@ static void fetch_serve(const char *arg)
|
|
|
static struct uhttp h;
|
|
|
char req[768];
|
|
|
unsigned char *buf, *post;
|
|
|
- unsigned int last_seq = 0, idle = 0;
|
|
|
+ unsigned int last_seq = 0, idle = 0, session = 0;
|
|
|
int slot = -1;
|
|
|
|
|
|
while (arg && *arg == ' ')
|
|
|
@@ -279,11 +277,17 @@ static void fetch_serve(const char *arg)
|
|
|
while (arg && *arg == ' ')
|
|
|
arg++;
|
|
|
if (arg && *arg >= '0' && *arg <= '9') {
|
|
|
- slot = 0;
|
|
|
while (*arg >= '0' && *arg <= '9')
|
|
|
- slot = slot * 10 + (*arg++ - '0');
|
|
|
+ session = session * 10 + (*arg++ - '0');
|
|
|
+ while (*arg == ' ')
|
|
|
+ arg++;
|
|
|
+ if (*arg >= '0' && *arg <= '9') {
|
|
|
+ slot = 0;
|
|
|
+ while (*arg >= '0' && *arg <= '9')
|
|
|
+ slot = slot * 10 + (*arg++ - '0');
|
|
|
+ }
|
|
|
}
|
|
|
- fetch_paths_init(slot);
|
|
|
+ fetch_paths_init(session, slot);
|
|
|
|
|
|
buf = (unsigned char *)malloc(FETCH_MAX);
|
|
|
post = (unsigned char *)malloc(FETCH_POST_MAX);
|