Exemple #1
0
Fichier : xdr.c Projet : PADL/krb5
/*
 * XDR enumerations
 */
bool_t
xdr_enum(XDR *xdrs, enum_t *ep)
{
#ifndef lint
	enum sizecheck { SIZEVAL };	/* used to find the size of an enum */

	/*
	 * enums are treated as ints
	 */
	switch (xdrs->x_op) {
	case XDR_ENCODE:
		VALGRIND_CHECK_DEFINED(*ep);
		break;
	default:
		break;
	}
	if (sizeof (enum sizecheck) == sizeof (long)) {
		return (xdr_long(xdrs, (long *)(void *)ep));
	} else if (sizeof (enum sizecheck) == sizeof (int)) {
		return (xdr_int(xdrs, (int *)(void *)ep));
	} else if (sizeof (enum sizecheck) == sizeof (short)) {
		return (xdr_short(xdrs, (short *)(void *)ep));
	} else {
		return (FALSE);
	}
#else
	(void) (xdr_short(xdrs, (short *)(void *)ep));
	return (xdr_long(xdrs, (long *)(void *)ep));
#endif
}
Exemple #2
0
Fichier : xdr.c Projet : PADL/krb5
/*
 * XDR integers
 */
bool_t
xdr_int(XDR *xdrs, int *ip)
{
	long l;

	switch (xdrs->x_op) {

	case XDR_ENCODE:
		VALGRIND_CHECK_DEFINED(*ip);
		if (*ip > 0x7fffffffL || *ip < -0x7fffffffL - 1L)
			return (FALSE);

		l = (long) *ip;
		return (XDR_PUTLONG(xdrs, &l));

	case XDR_DECODE:
		if (!XDR_GETLONG(xdrs, &l))
			return (FALSE);

		if (l > INT_MAX || l < INT_MIN)
			return (FALSE);

		*ip = (int) l;

	case XDR_FREE:
		return (TRUE);
	}
	/*NOTREACHED*/
	return(FALSE);
}
Exemple #3
0
Fichier : xdr.c Projet : PADL/krb5
/*
 * XDR short integers
 */
bool_t
xdr_short(XDR *xdrs, short *sp)
{
	long l;

	switch (xdrs->x_op) {

	case XDR_ENCODE:
		VALGRIND_CHECK_DEFINED(*sp);
		l = (long) *sp;
		return (XDR_PUTLONG(xdrs, &l));

	case XDR_DECODE:
		if (!XDR_GETLONG(xdrs, &l)) {
			return (FALSE);
		}
		if (l > SHRT_MAX || l < SHRT_MIN)
			return (FALSE);

		*sp = (short) l;
		return (TRUE);

	case XDR_FREE:
		return (TRUE);
	}
	return (FALSE);
}
Exemple #4
0
Fichier : xdr.c Projet : PADL/krb5
/*
 * XDR unsigned integers
 */
bool_t
xdr_u_int(XDR *xdrs, u_int *up)
{
	u_long l;

	switch (xdrs->x_op) {

	case XDR_ENCODE:
		VALGRIND_CHECK_DEFINED(*up);
		if (*up > 0xffffffffUL)
			return (FALSE);

		l = (u_long)*up;
		return (XDR_PUTLONG(xdrs, (long *) &l));

	case XDR_DECODE:
		if (!XDR_GETLONG(xdrs, (long *) &l))
			return (FALSE);

		if ((uint32_t)l > UINT_MAX)
			return (FALSE);

		*up = (u_int) l;
		return (TRUE);

	case XDR_FREE:
		return (TRUE);
	}
	/*NOTREACHED*/
	return(FALSE);
}
Exemple #5
0
Fichier : xdr.c Projet : PADL/krb5
/*
 * XDR an unsigned char
 */
bool_t
xdr_u_char(XDR *xdrs, u_char *cp)
{
	u_int u;

	switch (xdrs->x_op) {
	case XDR_ENCODE:
		VALGRIND_CHECK_DEFINED(*cp);
		break;
	default:
		break;
	}
	u = (*cp);
	if (!xdr_u_int(xdrs, &u)) {
		return (FALSE);
	}
	*cp = u;
	return (TRUE);
}
Exemple #6
0
Fichier : xdr.c Projet : PADL/krb5
/*
 * XDR a char
 */
bool_t
xdr_char(XDR *xdrs, char *cp)
{
	int i;

	switch (xdrs->x_op) {
	case XDR_ENCODE:
		VALGRIND_CHECK_DEFINED(*cp);
		break;
	default:
		break;
	}
	i = (*cp);
	if (!xdr_int(xdrs, &i)) {
		return (FALSE);
	}
	*cp = i;
	return (TRUE);
}
Exemple #7
0
Fichier : xdr.c Projet : PADL/krb5
/*
 * XDR unsigned long integers
 */
bool_t
xdr_u_long(XDR *xdrs, u_long *ulp)
{

	switch (xdrs->x_op) {
	case XDR_ENCODE:
		VALGRIND_CHECK_DEFINED(*ulp);
		if (*ulp > 0xffffffffUL)
			return (FALSE);

		return (XDR_PUTLONG(xdrs, (long *) ulp));

	case XDR_DECODE:
		return (XDR_GETLONG(xdrs, (long *) ulp));

	case XDR_FREE:
		return (TRUE);
	}
	return (FALSE);
}
Exemple #8
0
Fichier : xdr.c Projet : PADL/krb5
/*
 * XDR long integers
 */
bool_t
xdr_long(XDR *xdrs, long *lp)
{

	switch (xdrs->x_op) {
	case XDR_ENCODE:
		VALGRIND_CHECK_DEFINED(*lp);
		if (*lp > 0x7fffffffL || *lp < -0x7fffffffL - 1L)
			return (FALSE);

		return (XDR_PUTLONG(xdrs, lp));

	case XDR_DECODE:
		return (XDR_GETLONG(xdrs, lp));

	case XDR_FREE:
		return (TRUE);
	}
	return (FALSE);
}
Exemple #9
0
Fichier : xdr.c Projet : PADL/krb5
bool_t
xdr_u_int32(XDR *xdrs, uint32_t *up)
{
	u_long ul;

	switch (xdrs->x_op) {

	case XDR_ENCODE:
		VALGRIND_CHECK_DEFINED(*up);
		ul = *up;
		return (xdr_u_long(xdrs, &ul));

	case XDR_DECODE:
		if (!xdr_u_long(xdrs, &ul)) {
			return (FALSE);
		}
		*up = ul;
		return (TRUE);

	case XDR_FREE:
		return (TRUE);
	}
	return (FALSE);
}
Exemple #10
0
Fichier : xdr.c Projet : PADL/krb5
bool_t
xdr_int32(XDR *xdrs, int32_t *ip)
{
	long l;

	switch (xdrs->x_op) {

	case XDR_ENCODE:
		VALGRIND_CHECK_DEFINED(*ip);
		l = *ip;
		return (xdr_long(xdrs, &l));

	case XDR_DECODE:
		if (!xdr_long(xdrs, &l)) {
			return (FALSE);
		}
		*ip = l;
		return (TRUE);

	case XDR_FREE:
		return (TRUE);
	}
	return (FALSE);
}
Exemple #11
0
Fichier : xdr.c Projet : PADL/krb5
/*
 * XDR booleans
 */
bool_t
xdr_bool(XDR *xdrs, bool_t *bp)
{
	long lb;

	switch (xdrs->x_op) {

	case XDR_ENCODE:
		VALGRIND_CHECK_DEFINED(*bp);
		lb = *bp ? XDR_TRUE : XDR_FALSE;
		return (XDR_PUTLONG(xdrs, &lb));

	case XDR_DECODE:
		if (!XDR_GETLONG(xdrs, &lb)) {
			return (FALSE);
		}
		*bp = (lb == XDR_FALSE) ? FALSE : TRUE;
		return (TRUE);

	case XDR_FREE:
		return (TRUE);
	}
	return (FALSE);
}
Exemple #12
0
Fichier : xdr.c Projet : PADL/krb5
/*
 * XDR unsigned short integers
 */
bool_t
xdr_u_short(XDR *xdrs, u_short *usp)
{
	u_long l;

	switch (xdrs->x_op) {

	case XDR_ENCODE:
		VALGRIND_CHECK_DEFINED(*usp);
		l = (u_long) *usp;
		return (XDR_PUTLONG(xdrs, (long *) &l));

	case XDR_DECODE:
		if (!XDR_GETLONG(xdrs, (long *) &l)) {
			return (FALSE);
		}
		*usp = (u_short) l;
		return (TRUE);

	case XDR_FREE:
		return (TRUE);
	}
	return (FALSE);
}
Exemple #13
0
int main1 ( void )
{
  int xxx, i;
  for (i = 0; i < 10; i++) VALGRIND_CHECK_DEFINED(xxx);
  return 0;
}