}
+// remove this when finished
+void diag_hexdump_str(char *str, char *desc) {
+ printf("%s\n", desc);
+ FILE *fp = popen("hexdump -C", "w");
+ if (fp) {
+ fwrite(str, strlen(str), 1, fp);
+ pclose(fp);
+ }
+}
+
+
// Client is requesting a mailbox summary of the current room
void json_mailbox(struct http_transaction *h, struct ctdlsession *c) {
char buf[1024];
ctdl_readline(c, buf, sizeof(buf));
if (buf[0] == '1') {
while (ctdl_readline(c, buf, sizeof(buf)), (strcmp(buf, "000"))) {
- utf8ify_rfc822_string(buf);
+ diag_hexdump_str(buf, "line received from server");
JsonValue *jmsg = NewJsonObject(HKEY("message"));
JsonObjectAppend(jmsg, NewJsonNumber(HKEY("msgnum"), extract_long(buf, 0)));
JsonObjectAppend(jmsg, NewJsonNumber(HKEY("time"), extract_long(buf, 1)));
extract_token(field, buf, 2, '|', sizeof field);
+ utf8ify_rfc822_string(field);
JsonObjectAppend(jmsg, NewJsonPlainString(HKEY("author"), field, -1));
extract_token(field, buf, 4, '|', sizeof field);
+ utf8ify_rfc822_string(field);
JsonObjectAppend(jmsg, NewJsonPlainString(HKEY("addr"), field, -1));
extract_token(field, buf, 5, '|', sizeof field);
+ utf8ify_rfc822_string(field);
JsonObjectAppend(jmsg, NewJsonPlainString(HKEY("subject"), field, -1));
JsonObjectAppend(jmsg, NewJsonNumber(HKEY("msgidhash"), extract_long(buf, 6)));
extract_token(field, buf, 7, '|', sizeof field);
+ utf8ify_rfc822_string(field);
JsonObjectAppend(jmsg, NewJsonPlainString(HKEY("references"), field, -1));
JsonArrayAppend(j, jmsg); // add the message to the array
}
// A sixth component in the URL can be one of two things:
// (1) a MIME part specifier, in which case the client wants to download that component within the message
// (2) a content-type, in which ase the client wants us to try to render it a certain way
- if (num_tokens(h->url, '/') == 6) {
+ if (num_tokens(h->url, '/') >= 6) {
extract_token(buf, h->url, 5, '/', sizeof buf);
if (!IsEmptyStr(buf)) {
if (!strcasecmp(buf, "json")) {
}
return;
}
- if (num_tokens(h->url, '/') == 6) {
+ if (num_tokens(h->url, '/') >= 6) {
object_in_room(h, c); // /ctdl/r/roomname/object/ or possibly /ctdl/r/roomname/object/component
return;
}