当前位置: 首页>>代码示例>>C++>>正文


C++ xdr_destroy函数代码示例

本文整理汇总了C++中xdr_destroy函数的典型用法代码示例。如果您正苦于以下问题:C++ xdr_destroy函数的具体用法?C++ xdr_destroy怎么用?C++ xdr_destroy使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了xdr_destroy函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: send_trans_tok

int send_trans_tok(BIO *bio, struct trans_tok *t)
{
	char *buf = calloc(BUFSIZ, sizeof(char));
	XDR xdr;
	xdrmem_create(&xdr, buf, BUFSIZ, XDR_ENCODE);
	if(!xdr_trans_tok(&xdr, t)) {
		perror("could not encode trans tok\n");
		return -1;
	}
	int result = send_char_buf(bio, buf, BUFSIZ);
	xdr_destroy(&xdr);
	free(buf);
	return result;
}
开发者ID:RaphByrne,项目名称:Cloud-Provider,代码行数:14,代码来源:b_messages.c

示例2: virNetMessageEncodePayloadEmpty

int virNetMessageEncodePayloadEmpty(virNetMessagePtr msg)
{
    XDR xdr;
    unsigned int msglen;

    /* Re-encode the length word. */
    VIR_DEBUG("Encode length as %zu", msg->bufferOffset);
    xdrmem_create(&xdr, msg->buffer, VIR_NET_MESSAGE_HEADER_XDR_LEN, XDR_ENCODE);
    msglen = msg->bufferOffset;
    if (!xdr_u_int(&xdr, &msglen)) {
        virReportError(VIR_ERR_RPC, "%s", _("Unable to encode message length"));
        goto error;
    }
    xdr_destroy(&xdr);

    msg->bufferLength = msg->bufferOffset;
    msg->bufferOffset = 0;
    return 0;

error:
    xdr_destroy(&xdr);
    return -1;
}
开发者ID:emaste,项目名称:libvirt,代码行数:23,代码来源:virnetmessage.c

示例3: nfs2_reply

void
nfs2_reply(struct xid_map *xm, struct tuple4 *addr, u_char *buf, int len)
{
	XDR xdrs;
	struct diropres dres;
	struct readres rres;
	
	switch (xm->proc) {
		
	case NFSPROC_LOOKUP:
		xdrmem_create(&xdrs, buf, len, XDR_DECODE);
		memset(&dres, 0, sizeof(dres));
		
		if (xdr_diropres(&xdrs, &dres)) {
			if (dres.status == NFS_OK)
				fh_map_add((char *)xm->data,
					   dres.diropres_u.diropres.file.data,
					   NFS_FHSIZE);
		}
		xdr_destroy(&xdrs);
		break;
		
	case NFSPROC_READ:
		xdrmem_create(&xdrs, buf, len, XDR_DECODE);
		memset(&rres, 0, sizeof(rres));
		
		if (xdr_readres(&xdrs, &rres)) {
			if (rres.status == NFS_OK) {
				nfs_save(addr, (struct myreadargs *)xm->data,
					 rres.readres_u.reply.data.data_val,
					 rres.readres_u.reply.data.data_len);
			}
		}
		xdr_destroy(&xdrs);
		break;
	}
}
开发者ID:IFGHou,项目名称:dsniff,代码行数:37,代码来源:filesnarf.c

示例4: rclose

static int
rclose(int sock, struct LSFHeader *hdr)
{
    static char fname[] = "rclose()";
    int reqfd;
    char buf[LSRCP_MSGSIZE];
    XDR xdrs;

    xdrmem_create(&xdrs, buf, LSRCP_MSGSIZE, XDR_DECODE);
    if (readDecodeMsg_(sock, buf, hdr, SOCK_READ_FIX, &xdrs, (char *) &reqfd,
                       xdr_int, NULL)) {
        ls_errlog(stderr, I18N_FUNC_FAIL_MM, fname, "readDecodeMsg_");
        xdr_destroy(&xdrs);
        closesocket(sock);
        return -1;
    }
    xdr_destroy(&xdrs);

    if (close(reqfd) == -1) {
        if (lsSendMsg_(sock, -errnoEncode_(errno), 0, NULL, buf,
                       sizeof(struct LSFHeader), NULL, SOCK_WRITE_FIX, NULL)
            < 0) {
            ls_errlog(stderr, I18N_FUNC_FAIL_MM, fname, "lsSendMsg_");
            close(sock);
        }
        return 0;
    }

    if (lsSendMsg_(sock, 0, 0, NULL, buf,
                   sizeof(struct LSFHeader), NULL, SOCK_WRITE_FIX, NULL) < 0) {
        ls_errlog(stderr, I18N_FUNC_FAIL_MM, fname, "lsSendMsg_");
        close(sock);
        return -1;
    }

    return 0;
}
开发者ID:CraigNoble,项目名称:openlava,代码行数:37,代码来源:res.rf.c

示例5: sped_populate_npools

void
sped_populate_npools(spe_npool *p)
{
    struct nfsspe_args	args;
    XDR			xdrs;
    char			*buf;
    size_t			len = 0;

    args.nsa_opcode = SPE_OP_NPOOL_POPULATE;
    args.nsa_did = 0xdead4ead;

    if (!p)
        return;

    args.nsa_xdr_len =
        xdr_sizeof((xdrproc_t)xdr_spe_npool, (void *)p);

    args.nsa_xdr = calloc(args.nsa_xdr_len, sizeof (char));
    if (!args.nsa_xdr)
        return;

    xdrmem_create(&xdrs, args.nsa_xdr, args.nsa_xdr_len, XDR_ENCODE);
    if (!xdr_spe_npool(&xdrs, p)) {
        free(args.nsa_xdr);
        xdr_destroy(&xdrs);
        return;
    }

#if 0
    sped_xdr_dump(args.nsa_xdr, args.nsa_xdr_len);
#endif

    (void) _nfssys(NFS_SPE, &args);

    free(args.nsa_xdr);
    xdr_destroy(&xdrs);
}
开发者ID:CoryXie,项目名称:opensolaris,代码行数:37,代码来源:sped_server.c

示例6: recv_rply

static notify_list *
recv_rply(u_long *portp)
{
	char			msgbuf[NSM_MAXMSGSIZE];
	ssize_t			msglen;
	notify_list		*lp = NULL;
	XDR			xdr;
	struct sockaddr_in	sin;
	socklen_t		alen = (socklen_t)sizeof(sin);
	uint32_t		xid;

	memset(msgbuf, 0, sizeof(msgbuf));
	msglen = recvfrom(sockfd, msgbuf, sizeof(msgbuf), 0,
				(struct sockaddr *)(char *)&sin, &alen);
	if (msglen == (ssize_t)-1) {
		xlog_warn("%s: recvfrom failed: %m", __func__);
		return NULL;
	}

	memset(&xdr, 0, sizeof(xdr));
	xdrmem_create(&xdr, msgbuf, (unsigned int)msglen, XDR_DECODE);
	xid = nsm_parse_reply(&xdr);
	if (xid == 0)
		goto done;
	if (sin.sin_addr.s_addr != htonl(INADDR_LOOPBACK)) {
		struct in_addr addr = sin.sin_addr;
		char buf[INET_ADDRSTRLEN];

		xlog_warn("%s: Unrecognized reply from %s", __func__,
				inet_ntop(AF_INET, &addr, buf,
						(socklen_t)sizeof(buf)));
		goto done;
	}

	for (lp = notify; lp != NULL; lp = lp->next) {
		/* LH - this was a bug... it should have been checking
		 * the xid from the response message from the client,
		 * not the static, internal xid */
		if (lp->xid != xid)
			continue;
		if (lp->port == 0)
			*portp = nsm_recv_getport(&xdr);
		break;
	}

done:
	xdr_destroy(&xdr);
	return lp;
}
开发者ID:KunX,项目名称:nfs-utils,代码行数:49,代码来源:rmtcall.c

示例7: gvir_sandbox_rpcpacket_encode_header

/*
 * @msg: the outgoing message, whose header to encode
 *
 * Encodes the length word and header of the message, setting the
 * message offset ready to encode the payload. Leaves space
 * for the length field later. Upon return bufferLength will
 * refer to the total available space for message, while
 * bufferOffset will refer to current space used by header
 *
 * returns 0 if successfully encoded, -1 upon fatal error
 */
gboolean gvir_sandbox_rpcpacket_encode_header(GVirSandboxRPCPacket *msg,
                                              GError **error)
{
    XDR xdr;
    gboolean ret = FALSE;
    unsigned int len = 0;

    msg->bufferLength = sizeof(msg->buffer);
    msg->bufferOffset = 0;

    /* Format the header. */
    xdrmem_create(&xdr,
                  msg->buffer,
                  msg->bufferLength,
                  XDR_ENCODE);

    /* The real value is filled in shortly */
    if (!xdr_u_int(&xdr, &len)) {
        g_set_error(error, 0, 0,
                    "%s", "Unable to encode message length");
        goto cleanup;
    }

    if (!xdr_GVirSandboxProtocolHeader(&xdr, &msg->header)) {
        g_set_error(error, 0, 0,
                    "%s", "Unable to encode message header");
        goto cleanup;
    }

    len = xdr_getpos(&xdr);
    xdr_setpos(&xdr, 0);

    /* Fill in current length - may be re-written later
     * if a payload is added
     */
    if (!xdr_u_int(&xdr, &len)) {
        g_set_error(error, 0, 0,
                    "%s", "Unable to re-encode message length");
        goto cleanup;
    }

    msg->bufferOffset += len;

    ret = TRUE;

cleanup:
    xdr_destroy(&xdr);
    return ret;
}
开发者ID:aristeu,项目名称:libvirt-sandbox,代码行数:60,代码来源:libvirt-sandbox-rpcpacket.c

示例8: virNetMessageEncodeHeader

/*
 * @msg: the outgoing message, whose header to encode
 *
 * Encodes the length word and header of the message, setting the
 * message offset ready to encode the payload. Leaves space
 * for the length field later. Upon return bufferLength will
 * refer to the total available space for message, while
 * bufferOffset will refer to current space used by header
 *
 * returns 0 if successfully encoded, -1 upon fatal error
 */
int virNetMessageEncodeHeader(virNetMessagePtr msg)
{
    XDR xdr;
    int ret = -1;
    unsigned int len = 0;

    msg->bufferLength = VIR_NET_MESSAGE_MAX + VIR_NET_MESSAGE_LEN_MAX;
    if (VIR_REALLOC_N(msg->buffer, msg->bufferLength) < 0) {
        virReportOOMError();
        return ret;
    }
    msg->bufferOffset = 0;

    /* Format the header. */
    xdrmem_create(&xdr,
                  msg->buffer,
                  msg->bufferLength,
                  XDR_ENCODE);

    /* The real value is filled in shortly */
    if (!xdr_u_int(&xdr, &len)) {
        virReportError(VIR_ERR_RPC, "%s", _("Unable to encode message length"));
        goto cleanup;
    }

    if (!xdr_virNetMessageHeader(&xdr, &msg->header)) {
        virReportError(VIR_ERR_RPC, "%s", _("Unable to encode message header"));
        goto cleanup;
    }

    len = xdr_getpos(&xdr);
    xdr_setpos(&xdr, 0);

    /* Fill in current length - may be re-written later
     * if a payload is added
     */
    if (!xdr_u_int(&xdr, &len)) {
        virReportError(VIR_ERR_RPC, "%s", _("Unable to re-encode message length"));
        goto cleanup;
    }

    msg->bufferOffset += len;

    ret = 0;

cleanup:
    xdr_destroy(&xdr);
    return ret;
}
开发者ID:emaste,项目名称:libvirt,代码行数:60,代码来源:virnetmessage.c

示例9: writeInput

void writeInput(void)
{
  const char routineName[] = "writeInput";

  bool_t  result=TRUE, PRD_angle_dep, XRD, big_endian;
  FILE   *fp_out;
  XDR     xdrs;

  if (!strcmp(INPUT_DOT_OUT, "none")) return;

  if ((fp_out = fopen(INPUT_DOT_OUT, "w")) == NULL) {
    sprintf(messageStr, "Unable to open output file %s",
	    INPUT_DOT_OUT);
    Error(ERROR_LEVEL_1, routineName, messageStr);
    return;
  }
  xdrstdio_create(&xdrs, fp_out, XDR_ENCODE);

  PRD_angle_dep = (input.PRD_angle_dep != PRD_ANGLE_INDEP  &&  atmos.NPRDactive > 0);
  XRD           = (input.XRD  &&  atmos.NPRDactive > 0);

  /* --- Write various input parameters to file --     -------------- */      

  result &= xdr_bool(&xdrs, &input.magneto_optical);
  result &= xdr_bool(&xdrs, &PRD_angle_dep);
  result &= xdr_bool(&xdrs, &XRD);

  result &= xdr_enum(&xdrs, (enum_t *) &input.startJ);
  result &= xdr_enum(&xdrs, (enum_t *) &input.StokesMode);

  result &= xdr_double(&xdrs, &input.metallicity);

  result &= xdr_bool(&xdrs, &input.backgr_pol);

  /* --- Write Endianness of compute architecture so that J can be
         read properly in the analysis --              -------------- */

  big_endian = is_big_endian();
  result &= xdr_bool(&xdrs, &big_endian);


  if (!result) {
    sprintf(messageStr, "Unable to write proper amount to output file %s",
	    INPUT_DOT_OUT);
    Error(ERROR_LEVEL_1, routineName, messageStr);
  }
  xdr_destroy(&xdrs);
  fclose(fp_out);
}
开发者ID:kouui,项目名称:rh,代码行数:49,代码来源:writeinput_xdr.c

示例10: gvir_sandbox_rpcpacket_encode_payload_empty

gboolean gvir_sandbox_rpcpacket_encode_payload_empty(GVirSandboxRPCPacket *msg,
                                                     GError **error)
{
    XDR xdr;
    unsigned int msglen;

    /* Re-encode the length word. */
    xdrmem_create(&xdr, msg->buffer, GVIR_SANDBOX_PROTOCOL_LEN_MAX, XDR_ENCODE);
    msglen = msg->bufferOffset;
    if (!xdr_u_int(&xdr, &msglen)) {
        g_set_error(error, 0, 0,
                    "%s", "Unable to encode message length");
        goto error;
    }
    xdr_destroy(&xdr);

    msg->bufferLength = msg->bufferOffset;
    msg->bufferOffset = 0;
    return TRUE;

error:
    xdr_destroy(&xdr);
    return FALSE;
}
开发者ID:aristeu,项目名称:libvirt-sandbox,代码行数:24,代码来源:libvirt-sandbox-rpcpacket.c

示例11: gvir_sandbox_rpcpacket_encode_payload_raw

gboolean gvir_sandbox_rpcpacket_encode_payload_raw(GVirSandboxRPCPacket *msg,
                                                   const char *data,
                                                   gsize len,
                                                   GError **error)
{
    XDR xdr;
    unsigned int msglen;

    if ((msg->bufferLength - msg->bufferOffset) < len) {
        g_set_error(error, 0, 0,
                    "Raw data too long to send (%zu bytes needed, %zu bytes available)",
                    len, (msg->bufferLength - msg->bufferOffset));
        return FALSE;
    }

    memcpy(msg->buffer + msg->bufferOffset, data, len);
    msg->bufferOffset += len;

    /* Re-encode the length word. */
    xdrmem_create(&xdr, msg->buffer, GVIR_SANDBOX_PROTOCOL_LEN_MAX, XDR_ENCODE);
    msglen = msg->bufferOffset;
    if (!xdr_u_int(&xdr, &msglen)) {
        g_set_error(error, 0, 0,
                    "%s", "Unable to encode message length");
        goto error;
    }
    xdr_destroy(&xdr);

    msg->bufferLength = msg->bufferOffset;
    msg->bufferOffset = 0;
    return TRUE;

error:
    xdr_destroy(&xdr);
    return FALSE;
}
开发者ID:aristeu,项目名称:libvirt-sandbox,代码行数:36,代码来源:libvirt-sandbox-rpcpacket.c

示例12: send_chunk

static int
send_chunk (const guestfs_chunk *chunk)
{
  const size_t buf_len = GUESTFS_MAX_CHUNK_SIZE + 48;
  CLEANUP_FREE char *buf = NULL;
  char lenbuf[4];
  XDR xdr;
  uint32_t len;

  buf = malloc (buf_len);
  if (buf == NULL) {
    perror ("malloc");
    return -1;
  }

  xdrmem_create (&xdr, buf, buf_len, XDR_ENCODE);
  if (!xdr_guestfs_chunk (&xdr, (guestfs_chunk *) chunk)) {
    fprintf (stderr, "guestfsd: send_chunk: failed to encode chunk\n");
    xdr_destroy (&xdr);
    return -1;
  }

  len = xdr_getpos (&xdr);
  xdr_destroy (&xdr);

  xdrmem_create (&xdr, lenbuf, 4, XDR_ENCODE);
  xdr_u_int (&xdr, &len);
  xdr_destroy (&xdr);

  const int err = (xwrite (sock, lenbuf, 4) == 0
                   && xwrite (sock, buf, len) == 0 ? 0 : -1);
  if (err)
    error (EXIT_FAILURE, 0, "send_chunk: write failed");

  return err;
}
开发者ID:libguestfs,项目名称:libguestfs,代码行数:36,代码来源:proto.c

示例13: do_sbdDebug

void
do_sbdDebug(XDR * xdrs, int chfd, struct LSFHeader * reqHdr)
{
    static char       fname[] = "do_sbdDebug()";
    struct debugReq    debugReq;
    char               reply_buf[MSGSIZE / 8];
    XDR                xdrs2;
    sbdReplyType       reply;
    struct LSFHeader   replyHdr;

    if (!xdr_debugReq(xdrs, &debugReq, reqHdr)) {
        reply = LSBE_XDR;
        ls_syslog(LOG_ERR, I18N_FUNC_FAIL, fname, "xdr_debugReq");
    }
    else
        reply = ctrlSbdDebug(&debugReq);
    xdrmem_create(&xdrs2, reply_buf, MSGSIZE / 8, XDR_ENCODE);
    initLSFHeader_(&replyHdr);
    replyHdr.opCode = reply;
    if (!xdr_encodeMsg(&xdrs2, (char *) 0, &replyHdr, 0, 0, NULL)) {
        ls_syslog(LOG_ERR, I18N_FUNC_FAIL, fname, "xdr_encodeMsg");
        xdr_destroy(&xdrs2);
        return;
    }

    if (chanWrite_(chfd, reply_buf, XDR_GETPOS(&xdrs2)) <= 0) {
        ls_syslog(LOG_ERR, _i18n_msg_get(ls_catd , NL_SETN, 5833,
                                         "%s: Sending  reply to master failed : %m"), /* catgets 5833 */
                  fname);
        xdr_destroy(&xdrs2);
        return;
    }
    xdr_destroy(&xdrs2);
    return;

}
开发者ID:CraigNoble,项目名称:openlava,代码行数:36,代码来源:sbd.serv.c

示例14: rgetpidCompletionHandler_

int 
rgetpidCompletionHandler_(struct lsRequest *request)
{
    struct resPid pidReply;
    XDR xdrs;
    int rc;

    
    rc = resRC2LSErr_(request->rc);
    if (rc != 0)
	return(-1);

    xdrmem_create(&xdrs, request->replyBuf, sizeof(struct resPid), XDR_DECODE);
    if (! xdr_resGetpid(&xdrs, &pidReply, NULL)) {
	lserrno = LSE_BAD_XDR;
	xdr_destroy(&xdrs);
	return(-1);
    }
    
    *((int *)request->extra) = pidReply.pid;
    xdr_destroy(&xdrs);
    return(0);

} 
开发者ID:ReiAyanamiQH,项目名称:jhlava,代码行数:24,代码来源:lib.rtask.c

示例15: write_nis_obj

static bool_t
write_nis_obj (const char *name, const void *obj, iofct_t writefct)
{
  FILE *out = fopen (name, "wce");
  if (out == NULL)
    return FALSE;

  XDR xdrs;
  xdrstdio_create (&xdrs, out, XDR_ENCODE);
  bool_t status = writefct (&xdrs, (void *) obj);
  xdr_destroy (&xdrs);
  fclose (out);

  return status;
}
开发者ID:jengelh,项目名称:libnsl,代码行数:15,代码来源:nis_file.c


注:本文中的xdr_destroy函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。