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


C++ rpc_call函数代码示例

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


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

示例1: mp_match

/**
 * Gets FSID and PID by path and cuts path to relative path for FS
 *  @param path Path to file
 *  @param parent If FS of parent directory of file is needed
 *  @return FSID
 */
static struct fslist_item *fsbypath(char *path,int parent) {
  if (path==NULL || path[0]==0) return NULL;
  struct fslist_item *fs = mp_match(path,parent);
  if (fs==NULL) {
    fs = malloc(sizeof(struct fslist_item));
    char *mountpoint = strdup(path);
    fs->id = rpc_call("vfs_getfsid",RPC_FLAG_RETPARAMS,path,parent);
    if (fs->id<0) {
      free(mountpoint);
      errno = -fs->id;
      return NULL;
    }
    fs->pid = rpc_call("vfs_getpid",0,fs->id);
    if (fs->pid<0) {
      errno = -fs->pid;
      return NULL;
    }
    mountpoint[strlen(mountpoint)-strlen(path)] = 0;
    fs->mountpoint = path_parse(mountpoint);
    fs->mountpoint_str = path_output(fs->mountpoint,NULL);
    free(mountpoint);
    llist_push(fslist,fs);
  }

  return fs;
}
开发者ID:jgraef,项目名称:meinOS,代码行数:32,代码来源:files.c

示例2: nfs_proc_get_root

/*
 * Bare-bones access to getattr: this is for nfs_read_super.
 */
static int
nfs_proc_get_root(struct nfs_server *server, struct nfs_fh *fhandle,
		  struct nfs_fsinfo *info)
{
	struct nfs_fattr *fattr = info->fattr;
	struct nfs2_fsstat fsinfo;
	int status;

	dprintk("%s: call getattr\n", __FUNCTION__);
	fattr->valid = 0;
	status = rpc_call(server->client_sys, NFSPROC_GETATTR, fhandle, fattr, 0);
	dprintk("%s: reply getattr %d\n", __FUNCTION__, status);
	if (status)
		return status;
	dprintk("%s: call statfs\n", __FUNCTION__);
	status = rpc_call(server->client_sys, NFSPROC_STATFS, fhandle, &fsinfo, 0);
	dprintk("%s: reply statfs %d\n", __FUNCTION__, status);
	if (status)
		return status;
	info->rtmax  = NFS_MAXDATA;
	info->rtpref = fsinfo.tsize;
	info->rtmult = fsinfo.bsize;
	info->wtmax  = NFS_MAXDATA;
	info->wtpref = fsinfo.tsize;
	info->wtmult = fsinfo.bsize;
	info->dtpref = fsinfo.tsize;
	info->maxfilesize = 0x7FFFFFFF;
	info->lease_time = 0;
	return 0;
}
开发者ID:FelipeFernandes1988,项目名称:Alice-1121-Modem,代码行数:33,代码来源:proc.c

示例3: main

int main(int argn, char *argc[])
{
	//Program parameters : argc[1] : HostName or Host IP
	//                                         argc[2] : Server Program Number
	//                                         other arguments depend on test case

	//run_mode can switch into stand alone program or program launch by shell script
	//1 : stand alone, debug mode, more screen information
	//0 : launch by shell script as test case, only one printf -> result status
	int run_mode = 0;
	int test_status = 1;	//Default test result set to FAILED
	int progNum = atoi(argc[2]);
	char nettype[16] = "visible";
	int sndVar = 0;
	int recVar = -1;
	struct timeval total_timeout;
	enum clnt_stat rslt;
	CLIENT *clnt = NULL;

	if (run_mode == 1) {
		printf("Server : %s\n", argc[1]);
		printf("Server # %d\n", progNum);
		printf("Net : %s\n", nettype);
	}
	//Initialisation
	total_timeout.tv_sec = 1;
	total_timeout.tv_usec = 1;
	/**/ clnt = clnt_create(argc[1], progNum, VERSNUM, nettype);

	//Multiple test case
	rslt = rpc_call(argc[1], progNum, VERSNUM, PROCNUM,
			(xdrproc_t) xdr_int, (char *)&sndVar,
			(xdrproc_t) xdr_int, (char *)&recVar, nettype);
	clnt_perror(clnt, "Success");

	rslt = rpc_call(argc[1], 1, VERSNUM, PROCNUM,
			(xdrproc_t) xdr_int, (char *)&sndVar,
			(xdrproc_t) xdr_int, (char *)&recVar, nettype);
	clnt_perror(clnt, "Wrong Prog");

	rslt = rpc_call(argc[1], progNum, 10, PROCNUM,
			(xdrproc_t) xdr_int, (char *)&sndVar,
			(xdrproc_t) xdr_int, (char *)&recVar, nettype);
	clnt_perror(clnt, "Wrong Vers");

	rslt = rpc_call(argc[1], progNum, VERSNUM, PROCNUM,
			(xdrproc_t) xdr_int, (char *)&sndVar,
			(xdrproc_t) xdr_int, (char *)&recVar, "wrong");
	clnt_perror(clnt, "Wrong Proto");

	//If we are here, test has passed
	test_status = 0;

	//This last printf gives the result status to the tests suite
	//normally should be 0: test has passed or 1: test has failed
	printf("%d\n", test_status);

	return test_status;
}
开发者ID:1587,项目名称:ltp,代码行数:59,代码来源:tirpc_clnt_perror_complex.c

示例4: rpc_call

YAAMP_JOB_TEMPLATE *coind_create_template_memorypool(YAAMP_COIND *coind)
{
	json_value *json = rpc_call(&coind->rpc, "getmemorypool");
	if(!json || json->type == json_null)
	{
		coind_error(coind, "getmemorypool");
		return NULL;
	}

	json_value *json_result = json_get_object(json, "result");
	if(!json_result || json_result->type == json_null)
	{
		coind_error(coind, "getmemorypool");
		json_value_free(json);

		return NULL;
	}

	YAAMP_JOB_TEMPLATE *templ = new YAAMP_JOB_TEMPLATE;
	memset(templ, 0, sizeof(YAAMP_JOB_TEMPLATE));

	templ->created = time(NULL);
	templ->value = json_get_int(json_result, "coinbasevalue");
//	templ->height = json_get_int(json_result, "height");
	sprintf(templ->version, "%08x", (unsigned int)json_get_int(json_result, "version"));
	sprintf(templ->ntime, "%08x", (unsigned int)json_get_int(json_result, "time"));
	strcpy(templ->nbits, json_get_string(json_result, "bits"));
	strcpy(templ->prevhash_hex, json_get_string(json_result, "previousblockhash"));

	json_value_free(json);

	json = rpc_call(&coind->rpc, "getinfo", "[]");
	if(!json || json->type == json_null)
	{
		coind_error(coind, "coind_getinfo");
		return NULL;
	}

	json_result = json_get_object(json, "result");
	if(!json_result || json_result->type == json_null)
	{
		coind_error(coind, "coind_getinfo");
		json_value_free(json);

		return NULL;
	}

	templ->height = json_get_int(json_result, "blocks")+1;
	json_value_free(json);

	if(coind->isaux)
		coind_getauxblock(coind);

	coind->usememorypool = true;
	return templ;
}
开发者ID:EdSchroedinger,项目名称:yaamp,代码行数:56,代码来源:coind_template.cpp

示例5: rpc_rcmd

static int8_t rpc_rcmd(node_id_t node, char *cmd)
{
    int8_t rc = NRK_OK;
    uint8_t reply_len = sizeof(reply_buf);
    uint8_t req_len = 0;

    LOG("remote cmd to "); LOGP("%u: ", node);
    LOGP("%s\r\n", cmd);

    req_len += strlen(cmd) + 1; /* include null byte */

    rc = rpc_call(&rcmd_endpoint.client, node,
                  PORT_RPC_SERVER_RCMD, RPC_RCMD, &rcmd_rpc_time_out,
                  (uint8_t *)cmd_buf, req_len, reply_buf, &reply_len);
    if (rc != NRK_OK) {
        LOG("WARN: rcmd rpc failed\r\n");
        return rc;
    }

#if 0 /* TODO: make cmds return a code */
    if (reply_len != RPC_RCMD_REPLY_LEN) {
        LOG("WARN: rcmd reply of unexpected length\r\n");
        return NRK_ERROR;
    }

    rc = reply_buf[RPC_RCMD_REPLY_RC_OFFSET];
    LOG("rpc rcmd rc: "); LOGP("%d\r\n", rc);
#endif

    return NRK_OK;
}
开发者ID:nishantP-10,项目名称:WSNS15IRFence,代码行数:31,代码来源:rcmd.c

示例6: rpc_call_result

static int rpc_call_result(rpc_t *rpc, rpc_request_t *req)
{
	LOG_ENTRY;
	int rc = -1;

	if (!rpc) {
		RPC_ERROR("rpc is NULL");
		goto fail;
	}

	if (!req) {
		RPC_ERROR("request is NULL");
		goto fail;
	}

	rc = rpc_call(rpc, req);
	if (rc < 0) {
		RPC_ERROR("rpc_call failed %d", rc);
		goto fail;
	}
	RPC_DEBUG("%s: rpc_call done", __func__);

	size_t idx = 0;
	RPC_UNPACK(req->reply.buffer, idx, rc);
fail:
	LOG_EXIT;
	return rc;
}
开发者ID:Ksys-labs,项目名称:gps-proxy,代码行数:28,代码来源:gps_library.c

示例7: map_getport

unsigned int
map_getport(mapping_t* pmap)
{
    int port;
    struct pbuf *pbuf;
    struct pbuf *ret;
    debug("Getting port\n");
    pmap->port = 0;
    
    /* add the xid */
    pbuf = initbuf(PMAP_NUMBER, PMAP_VERSION, PMAPPROC_GETPORT);
    
    /* pack up the map struct */
    addtobuf(pbuf, (char*) pmap, sizeof(mapping_t));
    
    /* make the call */
    ret = rpc_call(pbuf, PMAP_PORT);

    assert(ret != NULL);
    
    /* now we can extract the port */
    getfrombuf(ret, (char*) &port, sizeof(port));
    
    pmap->port = port;
    
    debug("Got port %d\n", port);

    return 0;
}
开发者ID:dafyddcrosby,项目名称:L4OS,代码行数:29,代码来源:nfsrpc.c

示例8: mnt_mount

unsigned int
mnt_mount(char *dir, struct cookie *pfh)
{
    struct pbuf *pbuf, *ret;
    int status;

    pbuf = initbuf(MNT_NUMBER, MNT_VERSION, MNTPROC_MNT);

    addstring(pbuf, dir);
    
    ret = rpc_call(pbuf, mount_port);

	 if (ret == 0) {
		 debug( "mount call failed :(\n" );
		 return 1;
	 }

    /* now we do some stuff :) */
    getfrombuf(ret, (char*) &status, sizeof(status));

	 if (status != 0) {
		 debug( "Could not mount %s, %d!\n", dir, status );
		 return 1;
	 }

	 debug("All seems good for mount: %s!\n", dir);

    getfrombuf(ret, (char*) pfh, sizeof(struct cookie));

    return 0;
}
开发者ID:dafyddcrosby,项目名称:L4OS,代码行数:31,代码来源:nfsrpc.c

示例9: nfs3_proc_get_root

/*
 * Bare-bones access to getattr: this is for nfs_read_super.
 */
static int
nfs3_proc_get_root(struct nfs_server *server, struct nfs_fh *fhandle,
		   struct nfs_fsinfo *info)
{
	int	status;

	dprintk("%s: call  fsinfo\n", __FUNCTION__);
	info->fattr->valid = 0;
	status = rpc_call(server->client_sys, NFS3PROC_FSINFO, fhandle, info, 0);
	dprintk("%s: reply fsinfo: %d\n", __FUNCTION__, status);
	if (!(info->fattr->valid & NFS_ATTR_FATTR)) {
		status = rpc_call(server->client_sys, NFS3PROC_GETATTR, fhandle, info->fattr, 0);
		dprintk("%s: reply getattr: %d\n", __FUNCTION__, status);
	}
	return status;
}
开发者ID:Dronevery,项目名称:JetsonTK1-kernel,代码行数:19,代码来源:nfs3proc.c

示例10: ril_ni_message

static void ril_ni_message(uint8_t *msg, size_t len) {
	LOG_ENTRY;
	
	if (!msg || !len) {
		RPC_ERROR("%s: msg is NULL", __func__);
		goto fail;
	}

	struct rpc_request_t req = {
		.header = {
			.code = RIL_NI_MSG,
		}
	};
	
	char *buf = req.header.buffer;
	size_t idx = 0;

	memset(req.header.buffer, 0, RPC_PAYLOAD_MAX);
	RPC_PACK(buf, idx, len);
	RPC_PACK_RAW(buf, idx, msg, len);
	req.header.buffer[RPC_PAYLOAD_MAX - 1] = '\0';

	rpc_call(gps_rpc, &req);
fail:
	LOG_EXIT;
}
开发者ID:Ksys-labs,项目名称:gps-proxy,代码行数:26,代码来源:gps_library.c

示例11: rpc_ping

static int8_t rpc_ping(node_id_t node, uint8_t token)
{
    int8_t rc = NRK_OK;
    uint8_t reply_token;
    uint8_t reply_len = sizeof(reply_buf);
    uint8_t req_len = 0;

    LOG("call ping rpc\r\n");

    req_buf[RPC_PING_REQ_TOKEN_OFFSET] = token;
    req_len += RPC_PING_REQ_TOKEN_LEN;

    rc = rpc_call(&rping_endpoint.client, node,
                  PORT_RPC_SERVER_PING, RPC_PING, &ping_time_out,
                  req_buf, req_len, reply_buf, &reply_len);
    if (rc != NRK_OK) {
        LOG("WARN: ping rpc failed\r\n");
        return rc;
    }
    if (reply_len != RPC_PING_REPLY_LEN) {
        LOG("WARN: ping reply of unexpected length\r\n");
        return NRK_ERROR;
    }

    reply_token = reply_buf[RPC_PING_REPLY_TOKEN_OFFSET];
    if (reply_token != token) {
        LOG("WARN: unexpected token in ping reply\r\n");
        return NRK_ERROR;
    }

    return rc;
}
开发者ID:nishantP-10,项目名称:WSNS15IRFence,代码行数:32,代码来源:rping.c

示例12: rpc_peer_call

int rpc_peer_call(struct rpc *r, uint32_t uuid, uint32_t cmd_id,
            const void *in_arg, size_t in_len,
            void *out_arg, size_t out_len)
{
    r->send_pkt.header.uuid_dst = uuid;
    return rpc_call(r, cmd_id, in_arg, in_len, out_arg, out_len);
}
开发者ID:xia0Hong,项目名称:libraries,代码行数:7,代码来源:librpc.c

示例13: rpc_heading

static int8_t rpc_heading(node_id_t node, int16_t *heading)
{
    int8_t rc = NRK_OK;
    uint8_t reply_len = sizeof(reply_buf);
    uint8_t req_len = 0;

    rc = rpc_call(&compass_endpoint.client, node, PORT_RPC_SERVER_COMPASS, RPC_HEADING,
                  &compass_rpc_time_out, req_buf, req_len, reply_buf, &reply_len);
    if (rc != NRK_OK) {
        LOG("WARN: heading rpc failed\r\n");
        return rc;
    }

    if (reply_len != RPC_HEADING_REPLY_LEN) {
        LOG("WARN: heading reply of unexpected length\r\n");
        return NRK_ERROR;
    }

    *heading = reply_buf[RPC_HEADING_REPLY_HEADING_OFFSET + 1];
    *heading <<= 8;
    *heading |= reply_buf[RPC_HEADING_REPLY_HEADING_OFFSET];

    memcpy(mag_uT, reply_buf + RPC_HEADING_REPLY_MAG_OFFSET, sizeof(mag_uT));

    return NRK_OK;
}
开发者ID:nishantP-10,项目名称:WSNS15IRFence,代码行数:26,代码来源:compass.c

示例14: coind_submitgetauxblock

bool coind_submitgetauxblock(YAAMP_COIND *coind, const char *hash, const char *block)
{
	int paramlen = strlen(block);

	char *params = (char *)malloc(paramlen+1024);
	if(!params) return false;

	sprintf(params, "[\"%s\",\"%s\"]", hash, block);
	json_value *json = rpc_call(&coind->rpc, "getauxblock", params);

	free(params);
	if(!json) return false;

	json_value *json_error = json_get_object(json, "error");
	if(json_error && json_error->type != json_null)
	{
		const char *p = json_get_string(json_error, "message");
		if(p) stratumlog("ERROR %s %s\n", coind->name, p);

	//	job_reset();
		json_value_free(json);

		return false;
	}

	json_value *json_result = json_get_object(json, "result");
	bool b = json_result && json_result->type == json_boolean && json_result->u.boolean;

	json_value_free(json);
	return b;
}
开发者ID:EdSchroedinger,项目名称:yaamp,代码行数:31,代码来源:coind_submit.cpp

示例15: fprintf

void *my_thread_process(void *arg)
{
	int i;
	struct datas vars;
	static double result = 0;

	if (run_mode == 1) {
		fprintf(stderr, "Thread %d\n", atoi(arg));
	}

	vars.a = getRand();
	vars.b = getRand();
	vars.c = getRand();

	resTbl[atoi(arg)].locRes = vars.a + (vars.b * vars.c);

	rpc_call(hostname, progNum, VERSNUM, CALCTHREADPROC, (xdrproc_t) xdr_datas, (char *)&vars,	// xdr_in
		 (xdrproc_t) xdr_double, (char *)&resTbl[atoi(arg)].svcRes,	// xdr_out
		 nettype);

	thread_array_result[atoi(arg)] =
	    (resTbl[atoi(arg)].svcRes == resTbl[atoi(arg)].locRes) ? 0 : 1;

	if (run_mode == 1) {
		fprintf(stderr, "Thread #%d calc : %lf, received : %lf\n",
			atoi(arg), resTbl[atoi(arg)].locRes,
			resTbl[atoi(arg)].svcRes);
	}

	pthread_exit(0);
}
开发者ID:Altiscale,项目名称:sig-core-t_ltp,代码行数:31,代码来源:tirpc_rpc_call_complex.c


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