From 4e14224a95f234ca8f7c232e1efa1a51a1eb00bd Mon Sep 17 00:00:00 2001 From: dtb Date: Tue, 27 Jun 2023 08:58:25 -0400 Subject: [PATCH] tentative implementation of liminality --- liminality/Makefile | 2 ++ liminality/libinality.h | 6 ++++++ liminality/liminal | 7 +++++++ liminality/liminality.c | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 47 insertions(+) create mode 100644 liminality/Makefile create mode 100644 liminality/libinality.h create mode 100755 liminality/liminal create mode 100644 liminality/liminality.c diff --git a/liminality/Makefile b/liminality/Makefile new file mode 100644 index 0000000..ac72864 --- /dev/null +++ b/liminality/Makefile @@ -0,0 +1,2 @@ +liminality: libinality.h liminality.c + $(CC) -g -o liminality liminality.c diff --git a/liminality/libinality.h b/liminality/libinality.h new file mode 100644 index 0000000..bae344b --- /dev/null +++ b/liminality/libinality.h @@ -0,0 +1,6 @@ +#ifndef _LIMINALITY_H +# define _LIMINALITY_H +static char *Liminality_prefix = "FROM "; +static char *Liminality_infix = "\nBODY "; +static char *Liminality_suffix = "\n"; +#endif /* ifndef _LIMINALITY_H */ diff --git a/liminality/liminal b/liminality/liminal new file mode 100755 index 0000000..eca85dc --- /dev/null +++ b/liminality/liminal @@ -0,0 +1,7 @@ +#!/bin/sh + +test -z "$2" || test -n "$3" \ + && printf "Usage: %s [server] [port]\n" "$0" >&2 \ + && exit 64 # sysexits(3) EX_USAGE + +liminality | nc "$1" "$2" diff --git a/liminality/liminality.c b/liminality/liminality.c new file mode 100644 index 0000000..90153ab --- /dev/null +++ b/liminality/liminality.c @@ -0,0 +1,32 @@ +#include +#include +#include "libinality.h" + +char *signoff = ""; +char *user = "user"; + +int main(int argc, char *argv[]){ + int c; + char exiting; + char *s; + + if((s = getenv("USER")) != NULL) + user = s; + + do{ + fputs(Liminality_prefix, stdout); + fputs(user, stdout); + fputs(Liminality_infix, stdout); + while((c = getc(stdin)) != '\n') + if(c != EOF) + putc(c, stdout); + else{ + exiting = 1; + fputs(signoff, stdout); + break; + } + fputs(Liminality_suffix, stdout); + }while(!exiting); + + return 0; +}