mirror of
https://github.com/0intro/conterm
synced 2024-11-21 13:21:50 +03:00
a
This commit is contained in:
parent
934846f35c
commit
6519a0a6f2
16
libauthsrv/_asgetticket.c
Normal file
16
libauthsrv/_asgetticket.c
Normal file
@ -0,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);
|
||||
}
|
56
libauthsrv/_asrdresp.c
Normal file
56
libauthsrv/_asrdresp.c
Normal file
@ -0,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;
|
||||
}
|
22
mklib-Windows
Normal file
22
mklib-Windows
Normal file
@ -0,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
|
Loading…
Reference in New Issue
Block a user