From 6ea6f9be6bfe521b32bcd0c320f105c105d19c0c Mon Sep 17 00:00:00 2001 From: Derek Stevens Date: Thu, 1 Jul 2021 19:59:56 -0600 Subject: [PATCH] fix typos and tested writing to ctl from uxn. it works! --- xrxs.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/xrxs.c b/xrxs.c index 9bc5498..743e462 100644 --- a/xrxs.c +++ b/xrxs.c @@ -34,6 +34,8 @@ static char Ebad[] = "something bad happened"; static char Enomem[] = "no memory"; static char Euname[] = "username is already taken"; +static Tree* tree; + typedef enum { CTL = 1, USERS, CARTS, SLOT, DATA, REALMS, UNIVERSE } FileType; typedef struct Aux Aux; @@ -61,6 +63,11 @@ struct UserInfo { static UserInfo users_table[64]; void xrxs_attach(Req* r) { + /* As it is, once the user detaches, they will stay in the table + * until the server restarts. We have to figure out some way + * to detect a detach to remove them... You can't delay respond() + * or the attach will never complete. + */ static ushort id = 1; int i = 0; int l = 0; @@ -73,9 +80,10 @@ void xrxs_attach(Req* r) { } for (i = 0; i < 64; i++) { usr = users_table[i].name; - if (scmp(usr, username)) + if (scmp(usr, username)){ respond(r, Euname); return; + } if (*usr == 0) { scpy(username, usr, l+1); users_table[i].id = id++; @@ -149,16 +157,17 @@ void write_ctl(Req* r) { char* c = r->ifcall.data; int i; - for (i = 0; i < r->ifcall.count; i++) { + /*for (i = 0; i < r->ifcall.count; i++) { ccat(cmd, *c++); } unsigned long long const cmd_hashv = hash(cmd); switch (cmd_hashv) { - default: - break; - } + default:*/ + createfile(tree->root, "success", nil, 0777, nil); + /*break; + }*/ r->ofcall.count = r->ifcall.count; r->fid->file->dir.length = r->ifcall.count; respond(r, nil); @@ -268,13 +277,11 @@ Srv fs = { .open = fsopen, .read = xrxs_read, .write = xrxs_write, - .create = fsopen, .wstat = wstat}; int threadmaybackground(void) { return 1; } void threadmain(int argc, char* argv[]) { - Tree* tree; char* mtpt = nil; char* usocket = nil; int i;