xref: /plan9/sys/src/cmd/unix/drawterm/libauthsrv/convM2PR.c (revision 8ccd4a6360d974db7bd7bbd4f37e7018419ea908)
1 #include <u.h>
2 #include <libc.h>
3 #include <authsrv.h>
4 
5 #define	CHAR(x)		f->x = *p++
6 #define	SHORT(x)	f->x = (p[0] | (p[1]<<8)); p += 2
7 #define	VLONG(q)	q = (p[0] | (p[1]<<8) | (p[2]<<16) | (p[3]<<24)); p += 4
8 #define	LONG(x)		VLONG(f->x)
9 #define	STRING(x,n)	memmove(f->x, p, n); p += n
10 
11 void
convM2PR(char * ap,Passwordreq * f,char * key)12 convM2PR(char *ap, Passwordreq *f, char *key)
13 {
14 	uchar *p;
15 
16 	p = (uchar*)ap;
17 	if(key)
18 		decrypt(key, ap, PASSREQLEN);
19 	CHAR(num);
20 	STRING(old, ANAMELEN);
21 	f->old[ANAMELEN-1] = 0;
22 	STRING(new, ANAMELEN);
23 	f->new[ANAMELEN-1] = 0;
24 	CHAR(changesecret);
25 	STRING(secret, SECRETLEN);
26 	f->secret[SECRETLEN-1] = 0;
27 	USED(p);
28 }
29