9front - general discussion about 9front
 help / color / mirror / Atom feed
From: telephil9@gmail.com
To: 9front@9front.org
Cc: telephil9@gmail.com
Subject: [PATCH] ape: add libplumb
Date: Fri, 29 May 2020 17:07:23 +0200	[thread overview]
Message-ID: <F9BDA130286B6E3C4BE32E6304E974BC@gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 246 bytes --]

Hi,

Here is a patch to add libplumb to APE.

I also had sent another APE patch on 05/24 (add eenter to ape/libdraw) that might have gone unnoticed due to the ongoing release.

These two patches are needed for the netsurf port.

Regards,
Philippe

[-- Attachment #2: Type: text/plain, Size: 2946 bytes --]

diff -r 318eaf3a920f sys/include/ape/plumb.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/include/ape/plumb.h	Fri May 29 16:58:58 2020 +0200
@@ -0,0 +1,57 @@
+#ifndef _PLAN9_SOURCE
+  This header file is an extension to ANSI/POSIX
+#endif
+
+#ifndef	__PLUMB_H_
+#define	__PLUMB_H_
+#pragma src "/sys/src/ape/lib/plumb"
+#pragma lib "/$M/lib/ape/libplumb.a"
+
+/*
+ * Message format:
+ *	source application\n
+ *	destination port\n
+ *	working directory\n
+ *	type\n
+ *	attributes\n
+ *	nbytes\n
+ *	n bytes of data
+ */
+
+typedef struct Plumbattr Plumbattr;
+typedef struct Plumbmsg Plumbmsg;
+
+struct Plumbmsg
+{
+	char		*src;
+	char		*dst;
+	char		*wdir;
+	char		*type;
+	Plumbattr	*attr;
+	int		ndata;
+	char		*data;
+};
+
+struct Plumbattr
+{
+	char		*name;
+	char		*value;
+	Plumbattr	*next;
+};
+
+int			plumbsend(int, Plumbmsg*);
+int			plumbsendtext(int, char*, char*, char*, char*);
+Plumbmsg*	plumbrecv(int);
+char*		plumbpack(Plumbmsg*, int*);
+Plumbmsg*	plumbunpack(char*, int);
+Plumbmsg*	plumbunpackpartial(char*, int, int*);
+char*		plumbpackattr(Plumbattr*);
+Plumbattr*	plumbunpackattr(char*);
+Plumbattr*	plumbaddattr(Plumbattr*, Plumbattr*);
+Plumbattr*	plumbdelattr(Plumbattr*, char*);
+void			plumbfree(Plumbmsg*);
+char*		plumblookup(Plumbattr*, char*);
+int			plumbopen(char*, int);
+int			eplumb(int, char*);
+
+#endif
diff -r 318eaf3a920f sys/src/ape/lib/9/libc.h
--- a/sys/src/ape/lib/9/libc.h	Sun May 17 23:46:09 2020 +0200
+++ b/sys/src/ape/lib/9/libc.h	Fri May 29 16:58:58 2020 +0200
@@ -159,6 +159,7 @@
 #define ERRMAX 128
 
 int errstr(char*, unsigned int);
+void rerrstr(char*, unsigned int);
 extern void sysfatal(char*, ...);
 
 extern	void		setmalloctag(void*, uintptr_t);
diff -r 318eaf3a920f sys/src/ape/lib/9/mkfile
--- a/sys/src/ape/lib/9/mkfile	Sun May 17 23:46:09 2020 +0200
+++ b/sys/src/ape/lib/9/mkfile	Fri May 29 16:58:58 2020 +0200
@@ -8,6 +8,7 @@
 	crypt.$O\
 	ctime.$O\
 	errstr.$O\
+	rerrstr.$O\
 	getcallerpc.$O\
 	getfcr.$O\
 	getfields.$O\
diff -r 318eaf3a920f sys/src/ape/lib/9/rerrstr.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/src/ape/lib/9/rerrstr.c	Fri May 29 16:58:58 2020 +0200
@@ -0,0 +1,12 @@
+#include "libc.h"
+
+void
+rerrstr(char *buf, uint nbuf)
+{
+	char tmp[ERRMAX];
+
+	tmp[0] = 0;
+	errstr(tmp, sizeof tmp);
+	utfecpy(buf, buf+nbuf, tmp);
+	errstr(tmp, sizeof tmp);
+}
diff -r 318eaf3a920f sys/src/ape/lib/plumb/mkfile
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/src/ape/lib/plumb/mkfile	Fri May 29 16:58:58 2020 +0200
@@ -0,0 +1,25 @@
+APE=/sys/src/ape
+<$APE/config
+
+LIB=/$objtype/lib/ape/libplumb.a
+
+OFILES=\
+	event.$O\
+	mesg.$O\
+	plumbsendtext.$O
+
+HFILES=\
+	/sys/include/ape/plumb.h\
+
+UPDATE=\
+	mkfile\
+	$HFILES\
+	${OFILES:%.$O=%.c}\
+	${LIB:/$objtype/%=/386/%}\
+
+</sys/src/cmd/mksyslib
+
+CFLAGS=-c $CFLAGS -D_POSIX_SOURCE -D_PLAN9_SOURCE -I../9
+
+%.$O: /sys/src/libplumb/%.c
+	$CC $CFLAGS /sys/src/libplumb/$stem.c

             reply	other threads:[~2020-05-29 15:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-29 15:07 telephil9 [this message]
2020-05-29 15:33 ` [9front] " ori

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=F9BDA130286B6E3C4BE32E6304E974BC@gmail.com \
    --to=telephil9@gmail.com \
    --cc=9front@9front.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).