/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1990-2011 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
/*
* system call message buffer support
*/
#include "msglib.h"
/*
* get encoded unsigned long from buf
*/
unsigned long
{
register int c;
register unsigned char* s;
register unsigned char* e;
register unsigned long v;
v = 0;
s = (unsigned char*)*buf;
e = (unsigned char*)end;
do
{
if (s >= e) return -1L;
c = *s++;
v = (v << 7) | (c & 0177);
} while (c & 0200);
*buf = (char*)s;
return v;
}
/*
* encode unsigned long into buf
*/
int
{
register char* s;
register char* t;
register int n;
*t = v & 0177;
while((v >>= 7) > 0)
*--t = (v & 0177) | 0200;
n = s - t + 1;
return 0;
switch (n)
{
default: for (v = n - 7; v-- > 0;) *s++ = *t++;
case 7: *s++ = *t++;
case 6: *s++ = *t++;
case 5: *s++ = *t++;
case 4: *s++ = *t++;
case 3: *s++ = *t++;
case 2: *s++ = *t++;
case 1: *s++ = *t++;
}
*buf = s;
return n;
}
/*
* copy <data,size> from buf
*/
{
register size_t n;
register size_t i;
if (n > i) n = i;
*buf += n;
return n;
}
/*
* copy <data,size> to buf
*/
int
{
register char* s;
register size_t n;
s = *buf;
n = end - s;
if (n)
{
{
*buf = s;
}
*buf += n;
}
return *buf - s;
}