Пример #1
0
/*
 * Serializes/deserializes a stream of struct ypresp_key_val's.  This is used
 * only by the client side of the batch enumerate operation.
 */
bool
xdr_ypall(XDR *xdrs, struct ypall_callback *callback)
{
	bool_t more;
	struct ypresp_key_val kv;
	char keybuf[YPMAXRECORD];
	char valbuf[YPMAXRECORD];

	if (xdrs->x_op == XDR_ENCODE)
		return (FALSE);

	if (xdrs->x_op == XDR_FREE)
		return (TRUE);

	kv.keydat.dptr = keybuf;
	kv.valdat.dptr = valbuf;
	kv.keydat.dsize = YPMAXRECORD;
	kv.valdat.dsize = YPMAXRECORD;

	for (;;) {
		if (!xdr_bool(xdrs, &more))
			return (FALSE);

		if (!more)
			return (TRUE);

		if (!xdr_ypresp_key_val(xdrs, &kv))
			return (FALSE);
		if ((*callback->foreach)(kv.status, kv.keydat.dptr,
			    kv.keydat.dsize, kv.valdat.dptr, kv.valdat.dsize,
			    callback->data))
			return (TRUE);
	}
}
Пример #2
0
/*
 * Serializes a stream of struct ypresp_key_val's.  This is used
 * only by the ypserv side of the transaction.
 */
static bool
xdrypserv_ypall(XDR *xdrs, struct ypreq_nokey *req)
{
	bool_t more = TRUE;
	struct ypresp_key_val resp;
	DBM *fdb;

	resp.keydat.dptr = resp.valdat.dptr = (char *)NULL;
	resp.keydat.dsize = resp.valdat.dsize = 0;

	if ((fdb = ypset_current_map(req->map, req->domain,
					&resp.status)) != NULL) {
		ypfilter(fdb, (datum *) NULL, &resp.keydat, &resp.valdat,
				&resp.status, FALSE);

		while (resp.status == YP_TRUE) {
			if (!xdr_bool(xdrs, &more)) {
				return (FALSE);
			}

			if (!xdr_ypresp_key_val(xdrs, &resp)) {
				return (FALSE);
			}

			ypfilter(fdb, &resp.keydat, &resp.keydat, &resp.valdat,
					&resp.status, FALSE);
		}
	}

	if (!xdr_bool(xdrs, &more)) {
		return (FALSE);
	}

	if (!xdr_ypresp_key_val(xdrs, &resp)) {
		return (FALSE);
	}

	more = FALSE;

	if (!xdr_bool(xdrs, &more)) {
		return (FALSE);
	}

	return (TRUE);
}
Пример #3
0
bool_t
xdr_ypresp_all(XDR *xdrs, struct ypresp_all *objp)
{
	if (!xdr_bool(xdrs, &objp->more)) {
		return FALSE;
	}
	switch (objp->more) {
	case TRUE:
		return xdr_ypresp_key_val(xdrs, &objp->ypresp_all_u.val);
	case FALSE:
		return (TRUE);
	default:
		return FALSE;
	}
	/* NOTREACHED */
}
Пример #4
0
bool_t
xdr_ypresp_all (XDR *xdrs, ypresp_all *objp)
{
    if (!xdr_bool (xdrs, &objp->more))
        return FALSE;
    switch (objp->more)
    {
    case TRUE:
        return xdr_ypresp_key_val (xdrs, &objp->ypresp_all_u.val);
    case FALSE:
        break;
    default:
        return FALSE;
    }
    return TRUE;
}
Пример #5
0
bool_t
xdr_ypall(XDR *xdrs, struct ypall_callback *incallback)
{
    struct ypresp_key_val out;
    char key[YPMAXRECORD], val[YPMAXRECORD];

    /*
     * Set up key/val struct to be used during the transaction.
     */
    memset(&out, 0, sizeof out);
    out.key.keydat_val = key;
    out.key.keydat_len = sizeof(key);
    out.val.valdat_val = val;
    out.val.valdat_len = sizeof(val);

    for (;;) {
        bool_t more, status;

        /* Values pending? */
        if (!xdr_bool(xdrs, &more))
            return FALSE;           /* can't tell! */
        if (!more)
            return TRUE;            /* no more */

        /* Transfer key/value pair. */
        status = xdr_ypresp_key_val(xdrs, &out);

        /*
         * If we succeeded, call the callback function.
         * The callback will return TRUE when it wants
         * no more values.  If we fail, indicate the
         * error.
         */
        if (status) {
            if ((*incallback->foreach)(out.stat,
                                       (char *)out.key.keydat_val, out.key.keydat_len,
                                       (char *)out.val.valdat_val, out.val.valdat_len,
                                       incallback->data))
                return TRUE;
        } else
            return FALSE;
    }
}
Пример #6
0
bool_t
xdr_ypresp_all(XDR *xdrs, ypresp_all *objp)
{
  if (!xdr_bool(xdrs, &objp->more)) {
    return (FALSE);
  }
  switch (objp->more) {
  case TRUE:
    if (!xdr_ypresp_key_val(xdrs, &objp->ypresp_all_u.val)) {
      return (FALSE);
    }
    break;
  case FALSE:
    break;
  default:
    return (FALSE);
  }
  return (TRUE);
}
Пример #7
0
bool_t
xdr_ypresp_all(XDR *xdrs, ypresp_all *objp)
{
  if (xdrs->x_op == XDR_ENCODE)
    {
      while (1)
	{
	  if (xdr_bool(xdrs, &objp->more) == FALSE ||
	      xdr_ypresp_key_val(xdrs, &objp->ypresp_all_u.val) == FALSE)
	    {
	      if (xdr_ypall_cb.u.close != NULL)
		(*(xdr_ypall_cb.u.close))(xdr_ypall_cb.data);
	      
	      xdr_ypall_cb.data = NULL;
	      
	      return FALSE;
	    }
	  
	  if ((objp->ypresp_all_u.val.status != YP_TRUE) ||
	      (*xdr_ypall_cb.u.encode)(&objp->ypresp_all_u.val,
				       xdr_ypall_cb.data) != YP_TRUE)
	    {
	      objp->more = FALSE;
	      
	      if (xdr_ypall_cb.u.close != NULL)
		(*(xdr_ypall_cb.u.close))(xdr_ypall_cb.data);
	      
	      xdr_ypall_cb.data = NULL;
	      
	      if (!xdr_bool(xdrs, &objp->more))
		return FALSE;
	      
	      return TRUE;
	    }
	  
	}
    }
  
#ifdef NOTYET /* This code isn't needed in the server */
    else if (xdrs->x_op == XDR_DECODE)
    {
	int more = 0;


	while (1)
	{
	    if (!xdr_bool(xdrs, &objp->more))
		return FALSE;

	    switch (objp->more)
	    {
	      case TRUE:
		if (!xdr_ypresp_key_val(xdrs, &objp->ypresp_all_u.val))
		    return FALSE;

		if (more == 0)
		    more = (*xdr_ypall_callback->foreach.decoder)
			(&objp->ypresp_all_u.val, xdr_ypall_callback->data);
		break;

	      case FALSE:
		return TRUE;

	      default:
		return FALSE;
	    }
	}
	return FALSE;
    }
#endif

    return TRUE;
}