shithub: svcfs

Download patch

ref: e805b8fac9c9fb8beab55ecc93db526d2b3b8cfc
parent: 5280b703011ef49503f520de93f6eb20fd340d8b
author: Michael Misch <michaelmisch1985@gmail.com>
date: Fri Jan 16 20:58:19 EST 2026

Updates basically decoupling from Altid

--- a/buffer.c
+++ b/buffer.c
@@ -4,7 +4,7 @@
 #include <thread.h>
 #include <9p.h>
 
-#include "alt.h"
+#include "svc.h"
 
 static void
 bufferFree(Buffer *match)
--- a/client.c
+++ b/client.c
@@ -4,7 +4,7 @@
 #include <thread.h>
 #include <9p.h>
 
-#include "alt.h"
+#include "svc.h"
 
 enum {
 	Qcroot,
--- a/cmd.c
+++ b/cmd.c
@@ -4,7 +4,7 @@
 #include <thread.h>
 #include <9p.h>
 
-#include "alt.h"
+#include "svc.h"
 
 int
 Cconv(Fmt *fp)
--- a/convS2C.c
+++ b/convS2C.c
@@ -3,7 +3,7 @@
 #include <fcall.h>
 #include <thread.h>
 #include <9p.h>
-#include "alt.h"
+#include "svc.h"
 
 // TODO: Read runes instead of ascii
 
--- a/fs.c
+++ b/fs.c
@@ -5,7 +5,7 @@
 #include <thread.h>
 #include <9p.h>
 
-#include "alt.h"
+#include "svc.h"
 
 void*
 emalloc(int n)
@@ -54,8 +54,8 @@
 	fmtinstall('!', Nconv);
 	fmtinstall('C', Cconv);
 	user = getuser();
-	mtpt = "/mnt/alt";
-	logdir = "/tmp/alt";
+	mtpt = "/mnt/svc";
+	logdir = "/tmp/svc";
 
 	ARGBEGIN {
 	case 'D': 
--- a/mkfile
+++ b/mkfile
@@ -1,10 +1,10 @@
 </$objtype/mkfile
 
-BIN=/$objtype/bin/alt
+BIN=/$objtype/bin/svc
 
 TARG=fs
 
-HFILES=alt.h
+HFILES=svc.h
 
 OFILES=\
 	fs.$O\
--- a/notification.c
+++ b/notification.c
@@ -4,7 +4,7 @@
 #include <thread.h>
 #include <9p.h>
 
-#include "alt.h"
+#include "svc.h"
 
 int
 Nconv(Fmt *fp)
--- a/service.c
+++ b/service.c
@@ -4,7 +4,7 @@
 #include <thread.h>
 #include <9p.h>
 
-#include "alt.h"
+#include "svc.h"
 
 #define SERVICEID(c)	((int)(((Service*)(c)) - service))
 
--- /dev/null
+++ b/svc.h
@@ -1,0 +1,109 @@
+typedef struct Buffer Buffer;
+typedef struct Notify Notify;
+typedef struct Cmd Cmd;
+
+enum
+{
+	CloneCmd,
+	CreateCmd,
+	DeleteCmd,
+	RemoveCmd,
+	NotifyCmd,
+	ErrorCmd,
+	StatusCmd,
+	SideCmd,
+	NavCmd,
+	TitleCmd,
+	ImageCmd,
+	FeedCmd,
+	QuitCmd,
+	ServiceCmd,
+	InputCmd,
+	FlushCmd,
+	BufferCmd,
+	OpenCmd,
+	MarkdownCmd,
+
+	// TODO: Move data to the stack
+	MaxBuflen = 128,
+	MaxDatalen = 1024,
+	CmdSize = MaxBuflen * 2 + 1 + MaxDatalen,
+};
+
+struct Buffer
+{
+	QLock       l;
+	char	name[MaxBuflen];
+	char	title[512];
+	char	status[512];
+	char	*aside;
+	int	fd;	// feed
+	int	tag;	// feed
+	int	unread;
+	Channel	*cmds;
+	Channel   *input;
+	Notify	*notify;
+	Buffer	*next;
+	Rendez	rz;
+};
+
+struct Notify
+{
+	char	*data;
+	Notify	*next;
+};
+
+struct Cmd
+{
+	// Potentially big
+	int	type;
+	char	buffer[MaxBuflen];
+	char	svccmd[MaxBuflen];
+	char	*data;
+};
+
+Buffer *bufferCreate(Channel*, Channel*);
+Buffer *bufferSearch(Buffer*, char*);
+Buffer *bufferSearchTag(Buffer*, ulong);
+char *bufferDrop(Buffer*, char*);
+char *bufferPush(Buffer*, char*);
+void bufferDestroy(Buffer*);
+
+int Tconv(Fmt*);
+int Nconv(Fmt*);
+int Cconv(Fmt*);
+
+void* emalloc(int);
+char* estrdup(char*);
+
+char *mtpt;
+char *srvpt;
+char *user;
+char *logdir;
+int debug;
+
+uint convS2C(Cmd*, char*, uint);
+
+void clattach(Req*);
+void clstat(Req*);
+char *clwalk1(Fid*, char*, Qid*);
+char *clclone(Fid*, Fid*);
+void clopen(Req*);
+void clread(Req*);
+void clwrite(Req*);
+void clflush(Req*);
+void cldestroyfid(Fid*);
+void clstart(Srv*);
+void clend(Srv*);
+
+void svcattach(Req*);
+void svcstat(Req*);
+char *svcwalk1(Fid*, char*, Qid*);
+char *svcclone(Fid*, Fid*);
+void svcopen(Req*);
+void svcread(Req*);
+void svcwrite(Req*);
+void svcflush(Req*);
+void svcdestroyfid(Fid*);
+void svcstart(Srv*);
+void svcend(Srv*);
--- /dev/null
+++ b/tabs.c
@@ -1,0 +1,21 @@
+#include <u.h>
+#include <libc.h>
+#include <fcall.h>
+#include <thread.h>
+#include <9p.h>
+
+#include "svc.h"
+
+int
+Tconv(Fmt *fp)
+{
+	char s[1024];
+	Buffer *b;
+
+	b = va_arg(fp->args, Buffer*);
+	if(b->notify)
+		snprint(s, sizeof(s), "![%d] %s", b->unread, b->name);
+	else
+		snprint(s, sizeof(s), "[%d] %s", b->unread, b->name);
+	return fmtstrcpy(fp, s);
+}
--