code: drawterm

Download patch

ref: 6519a0a6f21e7935c2db7ed75ed4afa9001f7b7c
parent: 934846f35caaf236b554c5253cabc1032af2a27a
author: Russ Cox <rsc@swtch.com>
date: Mon Aug 8 08:50:38 EDT 2005

a

--- /dev/null
+++ b/libauthsrv/_asgetticket.c
@@ -1,0 +1,16 @@
+#include <u.h>
+#include <libc.h>
+#include <authsrv.h>
+
+static char *pbmsg = "AS protocol botch";
+
+int
+_asgetticket(int fd, char *trbuf, char *tbuf)
+{
+	if(write(fd, trbuf, TICKREQLEN) < 0){
+		close(fd);
+		werrstr(pbmsg);
+		return -1;
+	}
+	return _asrdresp(fd, tbuf, 2*TICKETLEN);
+}
--- /dev/null
+++ b/libauthsrv/_asrdresp.c
@@ -1,0 +1,56 @@
+#include <u.h>
+#include <libc.h>
+#include <authsrv.h>
+
+static char *pbmsg = "AS protocol botch";
+
+int
+_asrdresp(int fd, char *buf, int len)
+{
+	int n;
+	char error[64];
+
+	if(read(fd, buf, 1) != 1){
+		werrstr(pbmsg);
+		return -1;
+	}
+
+	n = len;
+	switch(buf[0]){
+	case AuthOK:
+		if(readn(fd, buf, len) != len){
+			werrstr(pbmsg);
+			return -1;
+		}
+		break;
+	case AuthErr:
+		if(readn(fd, error, sizeof error) != sizeof error){
+			werrstr(pbmsg);
+			return -1;
+		}
+		error[sizeof error-1] = '\0';
+		werrstr("remote: %s", error);
+		return -1;
+	case AuthOKvar:
+		if(readn(fd, error, 5) != 5){
+			werrstr(pbmsg);
+			return -1;
+		}
+		error[5] = 0;
+		n = atoi(error);
+		if(n <= 0 || n > len){
+			werrstr(pbmsg);
+			return -1;
+		}
+		memset(buf, 0, len);
+		if(readn(fd, buf, n) != n){
+			werrstr(pbmsg);
+			return -1;
+		}
+		break;
+	default:
+		werrstr(pbmsg);
+		return -1;
+	}
+	return n;
+}
--- /dev/null
+++ b/mklib-Windows
@@ -1,0 +1,22 @@
+TARGOBJ=${OFILES:%=$TARG(%)}
+
+all:V:	$TARG.all
+
+inc:V:	$TARG
+
+$TARG:	$TARGOBJ
+	$AR $ARFLAGS -out:$TARG $newmember
+
+$TARG.all:V: $OFILES
+	rm -f $TARG
+	$AR $ARFLAGS -out:$TARG $OFILES
+
+%.$O:	$HFILES			# don't combine with following %.$O rules
+
+%.$O:	%.c
+	$CC $CFLAGS $stem.c
+
+%.$O:	%.s
+	$AS $AFLAGS $stem.s
+
+$TARG(%.$O):N:	%.$O