Plan 9 from Bell Labs’s /usr/web/sources/extra/9hist/gnot/fcall.c

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


## diffname gnot/fcall.c 1990/03091
## diff -e /dev/null /n/bootesdump/1990/03091/sys/src/9/68020/fcall.c
0a
#include	<u.h>
#include	"lib.h"
#include	"fcall.h"

#define	CHAR(x)		*p++ = f->x
#define	SHORT(x)	p[0] = f->x; p[1] = f->x>>8; p += 2
#define	LONG(x)		p[0] = f->x; p[1] = f->x>>8; p[2] = f->x>>16; p[3] = f->x>>24; p += 4
#define	VLONG(x)	p[0] = f->x; p[1] = f->x>>8; p[2] = f->x>>16; p[3] = f->x>>24;\
			p[4] = 0; p[5] = 0; p[6] = 0; p[7] = 0; p += 8
#define	STRING(x,n)	memcpy(p, f->x, n); p += n

int
convS2M(Fcall *f, char *ap)
{
	uchar *p;

	p = (uchar*)ap;
	CHAR(type);
	switch(f->type)
	{
	default:
		print("bad type: %d\n", f->type);
		return 0;

	case Tnop:
	case Rnop:
		break;

	case Tsession:
		CHAR(lang);
		break;

	case Tattach:
		SHORT(fid);
		STRING(uname, sizeof(f->uname));
		STRING(aname, sizeof(f->aname));
		break;

	case Tclone:
		SHORT(fid);
		SHORT(newfid);
		break;

	case Twalk:
	case Tremove:
		SHORT(fid);
		STRING(name, sizeof(f->name));
		break;

	case Topen:
		SHORT(fid);
		CHAR(mode);
		break;

	case Tcreate:
		SHORT(fid);
		STRING(name, sizeof(f->name));
		LONG(perm);
		CHAR(mode);
		break;

	case Toread:
	case Tread:
		SHORT(fid);
		VLONG(offset);
		SHORT(count);
		break;

	case Towrite:
		SHORT(fid);
		VLONG(offset);
		SHORT(count);
		STRING(data, f->count);
		break;

	case Twrite:
		SHORT(fid);
		VLONG(offset);
		SHORT(count);
		p++;
		STRING(data, f->count);
		break;

	case Tclunk:
	case Tstat:
		SHORT(fid);
		break;

	case Twstat:
		SHORT(fid);
		STRING(stat, sizeof(f->stat));
		break;

	case Terrstr:
		SHORT(fid);
		SHORT(err);
		break;

	case Tuserstr:
		SHORT(fid);
		SHORT(uid);
		break;
/*
 */
	case Rsession:
		SHORT(err);
		break;

	case Rclone:
	case Rclunk:
	case Rremove:
	case Rwstat:
		SHORT(fid);
		SHORT(err);
		break;

	case Rwalk:
	case Rattach:
	case Ropen:
	case Rcreate:
		SHORT(fid);
		SHORT(err);
		LONG(qid);
		break;

	case Roread:
		SHORT(fid);
		SHORT(err);
		SHORT(count);
		STRING(data, f->count);
		break;

	case Rread:
		SHORT(fid);
		SHORT(err);
		SHORT(count);
		p++;
		STRING(data, f->count);
		break;

	case Rowrite:
	case Rwrite:
		SHORT(fid);
		SHORT(err);
		SHORT(count);
		break;

	case Rstat:
		SHORT(fid);
		SHORT(err);
		STRING(stat, sizeof(f->stat));
		break;

	case Rerrstr:
		SHORT(fid);
		SHORT(err);
		STRING(ename, sizeof(f->ename));
		break;

	case Ruserstr:
		SHORT(fid);
		SHORT(err);
		STRING(uname, sizeof(f->uname));
		break;
	}
	return p - (uchar*)ap;
}

int
convD2M(Dir *f, char *ap)
{
	uchar *p;

	p = (uchar*)ap;
	STRING(name, sizeof(f->name));
	LONG(qid);
	p += 4;
	LONG(mode);
	LONG(atime);
	LONG(mtime);
	VLONG(length);
	SHORT(uid);
	SHORT(gid);
	SHORT(type);
	SHORT(dev);
	return p - (uchar*)ap;
}

#undef	CHAR
#undef	SHORT
#undef	LONG
#undef	VLONG
#undef	STRING

#define	CHAR(x)		f->x = *p++
#define	SHORT(x)	f->x = (p[0] | (p[1]<<8)); p += 2
#define	LONG(x)		f->x = (p[0] | (p[1]<<8) |\
			(p[2]<<16) | (p[3]<<24)); p += 4
#define	VLONG(x)	f->x = (p[0] | (p[1]<<8) |\
			(p[2]<<16) | (p[3]<<24)); p += 8
#define	STRING(x,n)	memcpy(f->x, p, n); p += n

int
convM2S(char *ap, Fcall *f, int n)
{
	uchar *p;

	p = (uchar*)ap;
	CHAR(type);
	switch(f->type)
	{
	default:
		print("bad type: %d\n", f->type);
		return 0;

	case Tnop:
	case Rnop:
		break;

	case Tsession:
		CHAR(lang);
		break;

	case Tattach:
		SHORT(fid);
		STRING(uname, sizeof(f->uname));
		STRING(aname, sizeof(f->aname));
		break;

	case Tclone:
		SHORT(fid);
		SHORT(newfid);
		break;

	case Twalk:
	case Tremove:
		SHORT(fid);
		STRING(name, sizeof(f->name));
		break;

	case Topen:
		SHORT(fid);
		CHAR(mode);
		break;

	case Tcreate:
		SHORT(fid);
		STRING(name, sizeof(f->name));
		LONG(perm);
		CHAR(mode);
		break;

	case Toread:
	case Tread:
		SHORT(fid);
		VLONG(offset);
		SHORT(count);
		break;

	case Towrite:
		SHORT(fid);
		VLONG(offset);
		SHORT(count);
		f->data = (char*)p; p += f->count;
		break;

	case Twrite:
		SHORT(fid);
		VLONG(offset);
		SHORT(count);
		p++;
		f->data = (char*)p; p += f->count;
		break;

	case Tclunk:
	case Tstat:
		SHORT(fid);
		break;

	case Twstat:
		SHORT(fid);
		STRING(stat, sizeof(f->stat));
		break;

	case Terrstr:
		SHORT(fid);
		SHORT(err);
		break;

	case Tuserstr:
		SHORT(fid);
		SHORT(uid);
		break;

	case Rsession:
		SHORT(err);
		break;

	case Rclone:
	case Rclunk:
	case Rremove:
	case Rwstat:
		SHORT(fid);
		SHORT(err);
		break;

	case Rwalk:
	case Rattach:
	case Ropen:
	case Rcreate:
		SHORT(fid);
		SHORT(err);
		LONG(qid);
		break;

	case Roread:
		SHORT(fid);
		SHORT(err);
		SHORT(count);
		f->data = (char*)p; p += f->count;
		break;

	case Rread:
		SHORT(fid);
		SHORT(err);
		SHORT(count);
		p++;
		f->data = (char*)p; p += f->count;
		break;

	case Rowrite:
	case Rwrite:
		SHORT(fid);
		SHORT(err);
		SHORT(count);
		break;

	case Rstat:
		SHORT(fid);
		SHORT(err);
		STRING(stat, sizeof(f->stat));
		break;

	case Rerrstr:
		SHORT(fid);
		SHORT(err);
		STRING(ename, sizeof(f->ename));
		break;

	case Ruserstr:
		SHORT(fid);
		SHORT(err);
		STRING(uname, sizeof(f->uname));
		break;
	}
	if((uchar*)ap+n == p)
		return n;
	return 0;
}

int
convM2D(char *ap, Dir *f)
{
	uchar *p;

	p = (uchar*)ap;
	STRING(name, sizeof(f->name));
	LONG(qid);
	p += 4;
	LONG(mode);
	LONG(atime);
	LONG(mtime);
	VLONG(length);
	SHORT(uid);
	SHORT(gid);
	SHORT(type);
	SHORT(dev);
	return p - (uchar*)ap;
}
.
## diffname gnot/fcall.c 1990/11211
## diff -e /n/bootesdump/1990/03091/sys/src/9/68020/fcall.c /n/bootesdump/1990/11211/sys/src/9/68020/fcall.c
374,375d
368,369c
	STRING(uid, sizeof(f->uid));
	STRING(gid, sizeof(f->gid));
	LONG(qid.path);
	LONG(qid.vers);
.
354a

	case Rwstat:
		SHORT(fid);
		break;
.
352,353c
		STRING(stat, sizeof(f->stat));
.
350c
	case Rstat:
.
346,347d
344c
	case Rremove:
.
340,341d
338c
	case Rclunk:
.
334d
331d
327c
		p++;	/* pad(1) */
.
325d
318,320c
		LONG(qid.path);
		LONG(qid.vers);
.
316c
	case Rcreate:
.
312,313c
		LONG(qid.path);
		LONG(qid.vers);
.
310d
308c
		SHORT(fid);
		LONG(qid.path);
		LONG(qid.vers);
		break;

.
304d
300,302d
298a
	case Rattach:
		SHORT(fid);
		LONG(qid.path);
		LONG(qid.vers);
		break;

.
295,296c
	case Rflush:
.
290,292c
	case Rerror:
		STRING(ename, sizeof(f->ename));
.
285,287c
	case Rsession:
.
283a
/*
 */
	case Rnop:
		break;
.
275c
	case Tremove:
		SHORT(fid);
		break;

.
269,272d
267c
	case Tclunk:
.
263a
		p++;	/* pad(1) */
.
260c
	case Twrite:
.
253d
236d
227a
		STRING(auth, sizeof(f->auth));
.
223a
	case Tflush:
		SHORT(oldtag);
		break;

.
221d
217d
213c
		print("fcall: bad type: %d\n", f->type);
.
209a
	SHORT(tag);
.
200c
				(p[2]<<16) | (p[3]<<24)); p += 8
.
198c
				(p[2]<<16) | (p[3]<<24)); p += 4
.
182,183d
176,177c
	STRING(uid, sizeof(f->uid));
	STRING(gid, sizeof(f->gid));
	LONG(qid.path);
	LONG(qid.vers);
.
164a

	case Rwstat:
		SHORT(fid);
		break;
.
162,163c
		STRING(stat, sizeof(f->stat));
.
160c
	case Rstat:
.
156,157d
154c
	case Rremove:
.
150,151d
148c
	case Rclunk:
.
144d
141d
137c
		p++;	/* pad(1) */
.
135d
128,130c
		LONG(qid.path);
		LONG(qid.vers);
.
126c
	case Rcreate:
.
122,123c
		LONG(qid.path);
		LONG(qid.vers);
.
120d
118c
		SHORT(fid);
		LONG(qid.path);
		LONG(qid.vers);
		break;

.
114d
110,112d
108a
	case Rerror:
		STRING(ename, sizeof(f->ename));
		break;

	case Rflush:
		break;

	case Rattach:
		SHORT(fid);
		LONG(qid.path);
		LONG(qid.vers);
		break;

.
106d
104a
	case Rnop:
		break;

.
101c
		STRING(stat, sizeof(f->stat));
.
99c
	case Twstat:
.
96d
94c
	case Tstat:
.
91d
89c
	case Tremove:
.
85d
80c
		p++;	/* pad(1) */
.
69,75d
62d
45d
36a
		STRING(auth, sizeof(f->auth));
.
32a
	case Tflush:
		SHORT(oldtag);
		break;

.
30d
26d
22c
		print("fcall: bad type: %d\n", f->type);
.
18a
	SHORT(tag);
.
9c
				p[4] = 0; p[5] = 0; p[6] = 0; p[7] = 0; p += 8
.
2,3c
#include	<Nlibc.h>
#include	<Nfcall.h>
.
## diffname gnot/fcall.c 1990/1122
## diff -e /n/bootesdump/1990/11211/sys/src/9/68020/fcall.c /n/bootesdump/1990/1122/sys/src/9/68020/fcall.c
2,3c
#include	<libc.h>
#include	<fcall.h>
.
## diffname gnot/fcall.c 1990/1210 # deleted
## diff -e /n/bootesdump/1990/1122/sys/src/9/68020/fcall.c /n/bootesdump/1990/1210/sys/src/9/68020/fcall.c
1,382d

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.