shithub: svcfs

Download patch

ref: 3d0b6a15a45a2ec0afca34ce8d9041735be42513
parent: b466085c9ff2765a85dd12000ba6348937bc3db5
author: Michael Misch <michaelmisch1985@gmail.com>
date: Sun Jun 16 16:03:41 EDT 2024

Finish our basic string file handling in buffer/client

--- a/TODO
+++ b/TODO
@@ -1,16 +1,7 @@
- Commands:
- - markup, will need to import the state machine parser to pre-parse the output into just text
- - tabs could be a command?
+## Client
 
-Post a descriptor to /srv for each given service, that a client can connect into
-alt/fs sname, then in that namespace run the service binary 
-It mounts to /mnt/alt, which is what the service reads and writes to, then the client will do the other side
+### Brief overview
 
-if(isInitial) could be set to true on spinup, then we attach and flag appropriately; then negate isInitial so we can always assume a client attach after
-
- - Do a Srv + postmountsrv in main, then Srv + postsrv or listensrv in client.c which is fired off after attach from a service and initialization is complete
-Client
-
 ```
 #!/bin/rc
 
@@ -22,13 +13,31 @@
 Connects with aname = desired buffer, or gets just whichever is first (usually a `server`, but just in added-order)
  - if no buffers exist, exit error. We don't support hung states!
 
-Service
+### TODO: 
 
-`/mnt/alt` is served by the alt/fs
-- service will write the service name to `/mnt/alt/clone`
+- Add in command to toggle markup 
+
+## Service
+
+### Brief overview 
+
+- service reads from /mnt/alt/clone to get n
+- service will write the service name to `/mnt/alt/n/ctl`
 	- If a service exists in /srv by that name, an error will be returned. rm the service first!
 	- If the name is not valid filechars, an error will be returned (this is used in /srv, after all)
-- the service reads and writes to the returned fd until it closes, signalling completion
+	- the service reads and writes to the returned fd until it closes, signalling completion
 
+### TODO
 
-Add a stats/info file to /mnt/alt? something anyways.
+- handle `input` and `ctl` callbacks!
+- Add a stats/info file to root of /mnt/alt
+
+## Notifications:
+
+- Create and update them, integrate with tabs
+- Install fmt for printing
+
+## Tabs:
+
+- Track unread from clients
+- Install fmt for printing
--- a/alt.h
+++ b/alt.h
@@ -4,9 +4,9 @@
 struct Buffer
 {
 	char	*name;
-	char	*title;
-	char	*status;
-	char	*aside;
+	char	title[1024];
+	char	status[1024];
+	char	aside[1024];
 	int	fd;
 	Notify	*notify;
 
--- a/buffer.c
+++ b/buffer.c
@@ -50,6 +50,9 @@
 	b->name = estrdup(name);
 	b->notify = nil;
 	b->input = base->input;
+	memset(b->title, 0, sizeof(b->title));
+	memset(b->status, 0, sizeof(b->status));
+	memset(b->aside, 0, sizeof(b->aside));
 	snprint(p, sizeof(p), "%s/%s/%s", logdir, base->name, name);
 	if(access(p, 0) == 0)
 		b->fd = open(p, OWRITE);
--- a/client.c
+++ b/client.c
@@ -8,25 +8,27 @@
 
 enum {
 	Qcroot,
+		Qtabs,
+		Qctl,
+		Qinput,
 		Qtitle,
 		Qstatus,
 		Qaside,
 		Qfeed,
-		Qinput,
 		Qnotify,
-		Qctl,
 	Qmax,
 };
 
 static char *cltab[] = {
 	"/",
+		"tabs",
+		"ctl",
+		"input",
 		"title",
 		"status",
 		"aside",
 		"feed",
-		"input",
 		"notify",
-		"ctl",
 	nil,
 };
 
@@ -207,6 +209,7 @@
 clread(Req *r)
 {
 	Clfid *f;
+	Notify *np;
 	char buf[1024];
 
 	f = r->fid->aux;
@@ -215,26 +218,47 @@
 		dirread9p(r, rootgen, f->cl);
 		respond(r, nil);
 		return;
-	case Qtitle:
-		if(f->cl->current){
-			memset(buf, 0, sizeof(buf));
-			snprint(buf, sizeof(buf), "%s", f->cl->current->title);
-			readstr(r, buf);
-			respond(r, nil);
-		} else
-			respond(r, "no buffer selected");
-		return;
-	//case Qstatus:
-	//case Qaside:
-	//case Qnotify:
 	case Qfeed:
 		memset(buf, 0, sizeof(buf));
 		pread(f->cl->fd, buf, sizeof(buf), f->cl->offset);
+String:
 		readstr(r, buf);
 		respond(r, nil);
 		return;
+	case Qtitle:
+		if(f->cl->current && f->cl->current->title){
+			memset(buf, 0, sizeof(buf));
+			snprint(buf, sizeof(buf), "%s", f->cl->current->title);
+			goto String;
+		}
+	case Qstatus:
+		if(f->cl->current && f->cl->current->status){
+			memset(buf, 0, sizeof(buf));
+			snprint(buf, sizeof(buf), "%s", f->cl->current->status);
+			goto String;
+		}
+	case Qaside:
+		if(f->cl->current && f->cl->current->aside){
+			memset(buf, 0, sizeof(buf));
+			snprint(buf, sizeof(buf), "%s", f->cl->current->aside);
+			goto String;
+		}
+	case Qnotify:
+		if(f->cl->current && f->cl->current->notify){
+			memset(buf, 0, sizeof(buf));
+			for(np = f->cl->current->notify; np->next; np = np->next)
+				// TODO: Really test this out. this likely overwrites what we have
+				snprint(buf, sizeof(buf), "%s\n", np->data);
+			goto String;
+		}
+	//case Qtabs:
+	// Iterate through base and show up all 'o them
+		
 	}
-	respond(r, "not implemented");
+	if(!f->cl->current)
+		respond(r, "no buffer selected");
+	else
+		respond(r, "no data available");
 }
 
 void
@@ -303,6 +327,7 @@
 clstart(Srv *s)
 {
 	root = emalloc(sizeof(*root));
+	USED(root);
 	root = (Buffer*)s->aux;
 	time0 = time(0);
 }
--