v0.1; add -v flag to print version info and /version file for client to know the version as well
This commit is contained in:
parent
30603241cb
commit
ca2e5b8e13
3 changed files with 22 additions and 2 deletions
|
@ -8,7 +8,7 @@ The client is a specialized [uxn](https://wiki.xxiivv.com/site/uxn.html) ROM tha
|
|||
|
||||
This is the working structure of the 9p filesystem:
|
||||
|
||||
* `/ctl`: Read/write control file for inputing system commands. Reading the file shows the status of the last input command: 1 for success, 0 for failure; `logout` is a special case, and the status code will be -1 if it was succesful. the following are valid command syntax:
|
||||
* `/ctl`: Read/write control file for inputing system commands. Reading the file shows the status of the last input command: 1 for success, 0 for failure; `logout` is a special case, and the status code will be -1 if it was succesful. the following are valid command syntax:
|
||||
* `login PW`: Authenticate with `xrxs` -- password is hashed against realm password hash.
|
||||
* `logout`: Gracefully remove yourself from the users table.
|
||||
* `load CART`: Load a cartridge.
|
||||
|
@ -39,6 +39,8 @@ This is the working structure of the 9p filesystem:
|
|||
|
||||
* `/grandom`: Read-only, get a random number from 0 to 99 -- These are doled out on a per-realm basis, and the number stays the same until everyone in the realm has had a chance to read it. If you've already read it this round or aren't in a realm, it will be empty.
|
||||
|
||||
* `/version`: Read-only, outputs the version of the `xrxs` server.
|
||||
|
||||
### realm format
|
||||
|
||||
Each realm directory on the server should have the following files:
|
||||
|
|
|
@ -11,6 +11,7 @@ typedef enum {
|
|||
SCOPE,
|
||||
RANDOM,
|
||||
GRANDOM,
|
||||
VERSION
|
||||
} FileType;
|
||||
|
||||
typedef struct Aux {
|
||||
|
@ -19,4 +20,4 @@ typedef struct Aux {
|
|||
int count;
|
||||
} Aux;
|
||||
|
||||
Aux* create_aux(FileType t);
|
||||
Aux* create_aux(FileType t);
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
#include "realm.h"
|
||||
#include "user.h"
|
||||
|
||||
char version[] = "0.1";
|
||||
|
||||
int chatty9p = 0;
|
||||
|
||||
static Tree* tree;
|
||||
|
@ -524,6 +526,13 @@ void read_grandom(Req* r) {
|
|||
respond(r, nil);
|
||||
}
|
||||
|
||||
void read_version(Req* r) {
|
||||
char buf[16];
|
||||
sprintf(buf, "%s\n", version);
|
||||
readstr(r, buf);
|
||||
respond(r, nil);
|
||||
}
|
||||
|
||||
void xrxs_read(Req* r) {
|
||||
Aux* a = r->fid->file->aux;
|
||||
switch (a->type) {
|
||||
|
@ -559,6 +568,9 @@ void xrxs_read(Req* r) {
|
|||
case GRANDOM:
|
||||
read_grandom(r);
|
||||
break;
|
||||
case VERSION:
|
||||
read_version(r);
|
||||
break;
|
||||
default:
|
||||
respond(r, nil);
|
||||
break;
|
||||
|
@ -610,12 +622,17 @@ void threadmain(int argc, char* argv[]) {
|
|||
if (scmp(argv[i], "-d")) {
|
||||
chatty9p = 1;
|
||||
}
|
||||
if (scmp(argv[i], "-v")) {
|
||||
printf("xrxs v%s\n", version);
|
||||
threadexits(0);
|
||||
}
|
||||
}
|
||||
|
||||
fs.foreground = 1;
|
||||
fs.tree = alloctree(nil, nil, DMDIR | 0777, fs_destroy_file);
|
||||
tree = fs.tree;
|
||||
|
||||
closefile(createfile(tree->root, "version", nil, 0400, create_aux(VERSION)));
|
||||
closefile(
|
||||
createfile(tree->root, "ctl", nil, DMAPPEND | 0600, create_aux(CTL)));
|
||||
closefile(createfile(tree->root, "carts", nil, 0400, create_aux(CARTS)));
|
||||
|
|
Loading…
Reference in a new issue