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


C++ xdr_free函数代码示例

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


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

示例1: gpm_free_xdrs

void gpm_free_xdrs(int proc, union gp_rpc_arg *arg, union gp_rpc_res *res)
{
    xdr_free(gpm_xdr_set[proc].arg_fn, (char *)arg);
    xdr_free(gpm_xdr_set[proc].res_fn, (char *)res);
}
开发者ID:frozencemetery,项目名称:gssproxy,代码行数:5,代码来源:gpm_common.c

示例2: virNetServerProgramDispatchCall


//.........这里部分代码省略.........
           support the VIR_ERR_AUTH_FAILED error code */
        virReportError(VIR_ERR_RPC,
                       "%s", _("authentication required"));
        goto error;
    }

    if (VIR_ALLOC_N(arg, dispatcher->arg_len) < 0)
        goto error;
    if (VIR_ALLOC_N(ret, dispatcher->ret_len) < 0)
        goto error;

    if (virNetMessageDecodePayload(msg, dispatcher->arg_filter, arg) < 0)
        goto error;

    if (!(identity = virNetServerClientGetIdentity(client)))
        goto error;

    if (virIdentitySetCurrent(identity) < 0)
        goto error;

    /*
     * When the RPC handler is called:
     *
     *  - Server object is unlocked
     *  - Client object is unlocked
     *
     * Without locking, it is safe to use:
     *
     *   'args and 'ret'
     */
    rv = (dispatcher->func)(server, client, msg, &rerr, arg, ret);

    if (virIdentitySetCurrent(NULL) < 0)
        goto error;

    /*
     * If rv == 1, this indicates the dispatch func has
     * populated 'msg' with a list of FDs to return to
     * the caller.
     *
     * Otherwise we must clear out the FDs we got from
     * the client originally.
     *
     */
    if (rv != 1) {
        for (i = 0; i < msg->nfds; i++)
            VIR_FORCE_CLOSE(msg->fds[i]);
        VIR_FREE(msg->fds);
        msg->nfds = 0;
    }

    xdr_free(dispatcher->arg_filter, arg);

    if (rv < 0)
        goto error;

    /* Return header. We're re-using same message object, so
     * only need to tweak type/status fields */
    /*msg->header.prog = msg->header.prog;*/
    /*msg->header.vers = msg->header.vers;*/
    /*msg->header.proc = msg->header.proc;*/
    msg->header.type = msg->nfds ? VIR_NET_REPLY_WITH_FDS : VIR_NET_REPLY;
    /*msg->header.serial = msg->header.serial;*/
    msg->header.status = VIR_NET_OK;

    if (virNetMessageEncodeHeader(msg) < 0) {
        xdr_free(dispatcher->ret_filter, ret);
        goto error;
    }

    if (msg->nfds &&
        virNetMessageEncodeNumFDs(msg) < 0) {
        xdr_free(dispatcher->ret_filter, ret);
        goto error;
    }

    if (virNetMessageEncodePayload(msg, dispatcher->ret_filter, ret) < 0) {
        xdr_free(dispatcher->ret_filter, ret);
        goto error;
    }

    xdr_free(dispatcher->ret_filter, ret);
    VIR_FREE(arg);
    VIR_FREE(ret);

    virObjectUnref(identity);
    /* Put reply on end of tx queue to send out  */
    return virNetServerClientSendMessage(client, msg);

 error:
    /* Bad stuff (de-)serializing message, but we have an
     * RPC error message we can send back to the client */
    rv = virNetServerProgramSendReplyError(prog, client, msg, &rerr, &msg->header);

    VIR_FREE(arg);
    VIR_FREE(ret);
    virObjectUnref(identity);

    return rv;
}
开发者ID:aruiz,项目名称:libvirt,代码行数:101,代码来源:virnetserverprogram.c

示例3: gss_acquire_cred

OM_uint32
gss_acquire_cred(OM_uint32 *minor_status,
    const gss_name_t desired_name,
    OM_uint32 time_req,
    const gss_OID_set desired_mechs,
    gss_cred_usage_t cred_usage,
    gss_cred_id_t *output_cred_handle,
    gss_OID_set *actual_mechs,
    OM_uint32 *time_rec)
{
	OM_uint32 major_status;
	struct acquire_cred_res res;
	struct acquire_cred_args args;
	enum clnt_stat stat;
	gss_cred_id_t cred;
	int i;
	CLIENT *cl;

	*minor_status = 0;
	cl = kgss_gssd_client();
	if (cl == NULL)
		return (GSS_S_FAILURE);

	args.uid = curthread->td_ucred->cr_uid;
	if (desired_name)
		args.desired_name = desired_name->handle;
	else
		args.desired_name = 0;
	args.time_req = time_req;
	args.desired_mechs = desired_mechs;
	args.cred_usage = cred_usage;

	bzero(&res, sizeof(res));
	stat = gssd_acquire_cred_1(&args, &res, cl);
	CLNT_RELEASE(cl);
	if (stat != RPC_SUCCESS) {
		*minor_status = stat;
		return (GSS_S_FAILURE);
	}

	if (res.major_status != GSS_S_COMPLETE) {
		*minor_status = res.minor_status;
		return (res.major_status);
	}

	cred = malloc(sizeof(struct _gss_cred_id_t), M_GSSAPI, M_WAITOK);
	cred->handle = res.output_cred;
	*output_cred_handle = cred;
	if (actual_mechs) {
		major_status = gss_create_empty_oid_set(minor_status,
		    actual_mechs);
		if (major_status)
			return (major_status);
		for (i = 0; i < res.actual_mechs->count; i++) {
			major_status = gss_add_oid_set_member(minor_status,
			    &res.actual_mechs->elements[i], actual_mechs);
			if (major_status)
				return (major_status);
		}
	}
	if (time_rec)
		*time_rec = res.time_rec;

	xdr_free((xdrproc_t) xdr_acquire_cred_res, &res);

	return (GSS_S_COMPLETE);
}
开发者ID:dcui,项目名称:FreeBSD-9.3_kernel,代码行数:67,代码来源:gss_acquire_cred.c

示例4: internal_nisplus_getpwent_r

static enum nss_status
internal_nisplus_getpwent_r (struct passwd *pw, char *buffer, size_t buflen,
			     int *errnop)
{
  int parse_res = -1;
  enum nss_status retval = NSS_STATUS_SUCCESS;

  /* Get the next entry until we found a correct one. */
  do
    {
      nis_error status;
      nis_result result;
      memset (&result, '\0', sizeof (result));

      if (cursor.n_bytes == NULL)
	{
	  if (ibreq == NULL)
	    {
	      retval = internal_nisplus_setpwent (errnop);
	      if (retval != NSS_STATUS_SUCCESS)
		return retval;
	    }

	  status = __do_niscall3 (&bptr, NIS_IBFIRST,
				  (xdrproc_t) _xdr_ib_request,
				  (caddr_t) ibreq,
				  (xdrproc_t) _xdr_nis_result,
				  (caddr_t) &result,
				  0, NULL);
	}
      else
	{
	  ibreq->ibr_cookie.n_bytes = cursor.n_bytes;
	  ibreq->ibr_cookie.n_len = cursor.n_len;

	  status = __do_niscall3 (&bptr, NIS_IBNEXT,
				  (xdrproc_t) _xdr_ib_request,
				  (caddr_t) ibreq,
				  (xdrproc_t) _xdr_nis_result,
				  (caddr_t) &result,
				  0, NULL);

	  ibreq->ibr_cookie.n_bytes = NULL;
	  ibreq->ibr_cookie.n_len = 0;
	}

      if (status != NIS_SUCCESS)
	return niserr2nss (status);

      if (NIS_RES_STATUS (&result) == NIS_NOTFOUND)
	{
	  /* No more entries on this server.  This means we have to go
	     to the next server on the path.  */
	  status = __follow_path (&tablepath, &tableptr, ibreq, &bptr);
	  if (status != NIS_SUCCESS)
	    return niserr2nss (status);

	  directory_obj *newdir = NULL;
	  dir_binding newbptr;
	  status = __prepare_niscall (ibreq->ibr_name, &newdir, &newbptr, 0);
	  if (status != NIS_SUCCESS)
	    return niserr2nss (status);

	  nis_free_directory (dir);
	  dir = newdir;
	  __nisbind_destroy (&bptr);
	  bptr = newbptr;

	  xdr_free ((xdrproc_t) xdr_netobj, (char *) &result.cookie);
	  result.cookie.n_bytes = NULL;
	  result.cookie.n_len = 0;
	  parse_res = 0;
	  goto next;
	}
      else if (NIS_RES_STATUS (&result) != NIS_SUCCESS)
	return niserr2nss (NIS_RES_STATUS (&result));

      parse_res = _nss_nisplus_parse_pwent (&result, pw, buffer,
					    buflen, errnop);

      if (parse_res == -1)
	{
	  *errnop = ERANGE;
	  retval = NSS_STATUS_TRYAGAIN;
	  goto freeres;
	}

    next:
      /* Free the old cursor.  */
      xdr_free ((xdrproc_t) xdr_netobj, (char *) &cursor);
      /* Remember the new one.  */
      cursor.n_bytes = result.cookie.n_bytes;
      cursor.n_len = result.cookie.n_len;
      /* Free the result structure.  NB: we do not remove the cookie.  */
      result.cookie.n_bytes = NULL;
      result.cookie.n_len = 0;
    freeres:
      xdr_free ((xdrproc_t) _xdr_nis_result, (char *) &result);
      memset (&result, '\0', sizeof (result));
    }
//.........这里部分代码省略.........
开发者ID:thkukuk,项目名称:libnss_nisplus,代码行数:101,代码来源:nisplus-pwd.c

示例5: metad_2_freeresult

/*ARGSUSED*/
bool_t
metad_2_freeresult(SVCXPRT *unused, xdrproc_t xdr_result, caddr_t result)
{
	xdr_free(xdr_result, result);
	return (TRUE);
}
开发者ID:AlainODea,项目名称:illumos-gate,代码行数:7,代码来源:metad_freeresult.c

示例6: ssdd_text_1_freeresult

//Liberar memoria de los resultados.
int ssdd_text_1_freeresult(SVCXPRT *svcx_prt, xdrproc_t xdr_proc, caddr_t c_addr) {
	xdr_free(xdr_proc, c_addr);
	return 1;
}
开发者ID:Noltari,项目名称:UC3M,代码行数:5,代码来源:server.c

示例7: pr_IDListExpandedMembers

int
pr_IDListExpandedMembers(afs_int32 aid, namelist * lnames)
{
    afs_int32 code;
    afs_int32 gid;
    idlist lids;
    prlist alist;
    afs_int32 over;
    struct idhash *members = NULL;
    afs_int32 *stack = NULL;
    afs_int32 maxstack = ID_STACK_SIZE;
    int n = 0;			/* number of ids stacked */
    int i;
    int firstpass = 1;

    code = AllocateIdHash(&members);
    if (code) {
	return code;
    }
    stack = malloc(sizeof(afs_int32) * maxstack);
    if (!stack) {
	code = ENOMEM;
	goto done;
    }

    stack[n++] = aid;
    while (n) {
	gid = stack[--n];	/* pop next group id */
	alist.prlist_len = 0;
	alist.prlist_val = NULL;
	if (firstpass || aid < 0) {
	    firstpass = 0;
	    code = ubik_PR_ListElements(pruclient, 0, gid, &alist, &over);
	} else {
	    code = ubik_PR_ListSuperGroups(pruclient, 0, gid, &alist, &over);
	    if (code == RXGEN_OPCODE) {
	        alist.prlist_len = 0;
		alist.prlist_val = NULL;
		code = 0; /* server does not support supergroups. */
	    }
	}
	if (code)
	    goto done;
	if (over) {
	    fprintf(stderr,
		    "membership list for id %d exceeds display limit\n", gid);
	}
	for (i = 0; i < alist.prlist_len; i++) {
	    afs_int32 found;
	    afs_int32 id;

	    id = alist.prlist_val[i];
	    found = FindId(members, id);
	    if (found < 0) {
		code = found;
		xdr_free((xdrproc_t) xdr_prlist, &alist);
		goto done;
	    }
	    if (found == 0 && id < 0) {
		if (n == maxstack) {	/* need more stack space */
		    afs_int32 *tmp;
		    maxstack += n;
		    tmp = realloc(stack, maxstack * sizeof(afs_int32));
		    if (!tmp) {
			code = ENOMEM;
			xdr_free((xdrproc_t) xdr_prlist, &alist);
			goto done;
		    }
		    stack = tmp;
		}
		stack[n++] = id;	/* push group id */
	    }
	}
	xdr_free((xdrproc_t) xdr_prlist, &alist);
    }

    code = CreateIdList(members, &lids, (aid < 0 ? PRUSERS : PRGROUPS));
    if (code) {
	goto done;
    } else if (lids.idlist_len == 0) {
	/* Avoid the RPC when there's nothing to look up. */
	lnames->namelist_len = 0;
	lnames->namelist_val = NULL;
	goto done;
    }
    code = pr_IdToName(&lids, lnames);
    free(lids.idlist_val);

  done:
    if (stack)
	free(stack);
    if (members)
	FreeIdHash(members);
    return code;
}
开发者ID:bagdxk,项目名称:openafs,代码行数:95,代码来源:ptuser.c

示例8: gssrpc__svcauth_gssapi

enum auth_stat gssrpc__svcauth_gssapi(
     register struct svc_req *rqst,
     register struct rpc_msg *msg,
     bool_t *no_dispatch)
{
     XDR xdrs;
     auth_gssapi_creds creds;
     auth_gssapi_init_arg call_arg;
     auth_gssapi_init_res call_res;
     gss_buffer_desc output_token, in_buf, out_buf;
     gss_cred_id_t server_creds;
     struct gss_channel_bindings_struct bindings, *bindp;
     OM_uint32 gssstat, minor_stat, time_rec;
     struct opaque_auth *cred, *verf;
     svc_auth_gssapi_data *client_data;
     int i;
     enum auth_stat ret;
     OM_uint32 ret_flags;
     uint32_t seq_num;

     PRINTF(("svcauth_gssapi: starting\n"));
     
     /* clean up expired entries */
     clean_client();

     /* use AUTH_NONE until there is a client_handle */
     rqst->rq_xprt->xp_auth = &svc_auth_none;
     
     memset((char *) &call_res, 0, sizeof(call_res));
     creds.client_handle.length = 0;
     creds.client_handle.value = NULL;
     
     cred = &msg->rm_call.cb_cred;
     verf = &msg->rm_call.cb_verf;
     
     if (cred->oa_length == 0) {
	  PRINTF(("svcauth_gssapi: empty creds, failing\n"));
	  LOG_MISCERR("empty client credentials");
	  ret = AUTH_BADCRED;
	  goto error;
     }

     PRINTF(("svcauth_gssapi: decoding credentials\n"));
     xdrmem_create(&xdrs, cred->oa_base, cred->oa_length, XDR_DECODE); 
     memset((char *) &creds, 0, sizeof(creds));
     if (! xdr_authgssapi_creds(&xdrs, &creds)) {
	  PRINTF(("svcauth_gssapi: failed decoding creds\n"));
	  LOG_MISCERR("protocol error in client credentials");
	  xdr_free(xdr_authgssapi_creds, &creds);
	  XDR_DESTROY(&xdrs);
	  ret = AUTH_BADCRED;
	  goto error;
     }
     XDR_DESTROY(&xdrs);

     PRINTF(("svcauth_gssapi: got credentials, version %d, client_handle len %d\n",
	     creds.version, (int) creds.client_handle.length));

     if (creds.version != 2) {
 	  PRINTF(("svcauth_gssapi: bad credential version\n"));
 	  LOG_MISCERR("unsupported client credentials version");
 	  ret = AUTH_BADCRED;
 	  goto error;
     }

#ifdef DEBUG_GSSAPI
     if (svc_debug_gssapi) {
	  if (creds.auth_msg && rqst->rq_proc == AUTH_GSSAPI_EXIT) {
	       PRINTF(("svcauth_gssapi: GSSAPI_EXIT, cleaning up\n"));
	       svc_sendreply(rqst->rq_xprt, xdr_void, NULL);
	       xdr_free(xdr_authgssapi_creds, &creds);
	       cleanup();
	       exit(0);
	  }
     }
#endif
	  
     /*
      * If this is an auth_msg and proc is GSSAPI_INIT, then create a
      * client handle for this client.  Otherwise, look up the
      * existing handle.
      */
     if (creds.auth_msg && rqst->rq_proc == AUTH_GSSAPI_INIT) {
	  if (creds.client_handle.length != 0) {
	       PRINTF(("svcauth_gssapi: non-empty handle on GSSAPI_INIT\n"));
	       LOG_MISCERR("protocol error in client handle");
	       ret = AUTH_FAILED;
	       goto error;
	  }
	       
	  PRINTF(("svcauth_gssapi: GSSAPI_INIT, creating client.\n"));
	  
	  client_data = create_client();
	  if (client_data == NULL) {
	       PRINTF(("svcauth_gssapi: create_client failed\n"));
	       LOG_MISCERR("internal error creating client record");
	       ret = AUTH_FAILED;
	       goto error;
	  }
     } else {
//.........这里部分代码省略.........
开发者ID:FarazShaikh,项目名称:LikewiseSMB2,代码行数:101,代码来源:svc_auth_gssapi.c

示例9: gss_init_sec_context

OM_uint32
gss_init_sec_context(OM_uint32 * minor_status,
    const gss_cred_id_t initiator_cred_handle,
    gss_ctx_id_t * context_handle,
    const gss_name_t target_name,
    const gss_OID input_mech_type,
    OM_uint32 req_flags,
    OM_uint32 time_req,
    const gss_channel_bindings_t input_chan_bindings,
    const gss_buffer_t input_token,
    gss_OID * actual_mech_type,
    gss_buffer_t output_token,
    OM_uint32 * ret_flags,
    OM_uint32 * time_rec)
{
	struct init_sec_context_res res;
	struct init_sec_context_args args;
	enum clnt_stat stat;
	gss_ctx_id_t ctx = *context_handle;

	*minor_status = 0;

	if (!kgss_gssd_handle)
		return (GSS_S_FAILURE);

	args.uid = curthread->td_ucred->cr_uid;
	if  (initiator_cred_handle)
		args.cred = initiator_cred_handle->handle;
	else
		args.cred = 0;
	if (ctx)
		args.ctx = ctx->handle;
	else
		args.ctx = 0;
	args.name = target_name->handle;
	args.mech_type = input_mech_type;
	args.req_flags = req_flags;
	args.time_req = time_req;
	args.input_chan_bindings = input_chan_bindings;
	if (input_token)
		args.input_token = *input_token;
	else {
		args.input_token.length = 0;
		args.input_token.value = NULL;
	}

	bzero(&res, sizeof(res));
	stat = gssd_init_sec_context_1(&args, &res, kgss_gssd_handle);
	if (stat != RPC_SUCCESS) {
		*minor_status = stat;
		return (GSS_S_FAILURE);
	}

	if (res.major_status != GSS_S_COMPLETE
	    && res.major_status != GSS_S_CONTINUE_NEEDED) {
		*minor_status = res.minor_status;
		xdr_free((xdrproc_t) xdr_init_sec_context_res, &res);
		return (res.major_status);
	}

	*minor_status = res.minor_status;

	if (!ctx) {
		ctx = kgss_create_context(res.actual_mech_type);
		if (!ctx) {
			xdr_free((xdrproc_t) xdr_init_sec_context_res, &res);
			*minor_status = 0;
			return (GSS_S_BAD_MECH);
		}
	}
	*context_handle = ctx;
	ctx->handle = res.ctx;
	if (actual_mech_type)
		*actual_mech_type = KGSS_MECH_TYPE(ctx);
	kgss_copy_buffer(&res.output_token, output_token);
	if (ret_flags)
		*ret_flags = res.ret_flags;
	if (time_rec)
		*time_rec = res.time_rec;

	xdr_free((xdrproc_t) xdr_init_sec_context_res, &res);

	/*
	 * If the context establishment is complete, export it from
	 * userland and hand the result (which includes key material
	 * etc.) to the kernel implementation.
	 */
	if (res.major_status == GSS_S_COMPLETE)
		res.major_status = kgss_transfer_context(ctx);

	return (res.major_status);
}
开发者ID:edgar-pek,项目名称:PerspicuOS,代码行数:92,代码来源:gss_init_sec_context.c

示例10: sfs_stat2names

/* Return -1 on error, 0 otherwise */
int
sfs_stat2names (sfs_names *snp, const struct stat *sb)
{


  const char *fs;
  int cdfd;
  sfsctl_getidnames_res res;
  struct passwd *pw;
  struct group *gr;
  bool_t remote = FALSE;

  bool_t uname = FALSE;
  bool_t gname = FALSE;
  struct id_dat *id_elm;
  struct id_cache *ic;
  u_int hval;

  ic = lookup_ic (sb->st_dev);
  
  if (!ic)
    return -1;

  for (id_elm = id2name_chain (&ic->uidtab, sb->st_uid); 
       id_elm && (sb->st_uid != id_elm->id);
       id_elm = id2name_next (id_elm))
    ;
  if (id_elm)
    {	 
      namecpy (snp->uidname, id_elm->name);
      uname = TRUE;
    }


  for (id_elm = id2name_chain (&ic->gidtab, sb->st_gid); 
       id_elm && (sb->st_gid != id_elm->id);
       id_elm = id2name_next (id_elm))
    ;
  if (id_elm)
    {	 
      namecpy (snp->gidname, id_elm->name);
      gname = TRUE;
    }


  if (gname && uname)
    return 0;

  bzero (&res, sizeof (res));
  if (devcon_lookup (&cdfd, &fs, sb->st_dev)) {
    sfsctl_getidnames_arg arg;
    remote = TRUE;
    arg.filesys = (char *) fs;
    arg.nums.uid = sb->st_uid;
    arg.nums.gid = sb->st_gid;
    srpc_call (&sfsctl_prog_1, cdfd, SFSCTL_GETIDNAMES, &arg, &res);
  }

  if (!uname)
    {
      pw = getpwuid (sb->st_uid);
      if (remote && !res.status && res.u.names.uidname.present) {
	if (pw && !strcmp (pw->pw_name, res.u.names.uidname.u.name))
	  namecpy (snp->uidname, pw->pw_name);
	else {
	  snp->uidname[0] = '%';
	  namecpy (snp->uidname + 1, res.u.names.uidname.u.name);
	}
      }
      else if (!remote && pw)
	namecpy (snp->uidname, pw->pw_name);
      else
	sprintf (snp->uidname, "%u", (int) sb->st_uid);

      id_elm = malloc (sizeof (*id_elm));

      if (!id_elm)
	{
	  xdr_free ((xdrproc_t) xdr_sfsctl_getidnames_res, (char *) &res);
	  return -1;
	}

      bzero (id_elm->name, sizeof (id_elm->name));
      namecpy (id_elm->name, snp->uidname);
      id_elm->id = sb->st_uid;
      hval = hash_string (id_elm->name);

      id2name_insert (&ic->uidtab,   id_elm, id_elm->id);
      name2id_insert (&ic->unametab, id_elm, hval);
    }

  if (!gname)
    {
      gr = getgrgid (sb->st_gid);
      if (remote && !res.status && res.u.names.gidname.present) {
	if (gr && !strcmp (gr->gr_name, res.u.names.gidname.u.name))
	  namecpy (snp->gidname, gr->gr_name);
	else {
	  snp->gidname[0] = '%';
//.........这里部分代码省略.........
开发者ID:gildafnai82,项目名称:craq,代码行数:101,代码来源:sfsops.c

示例11: lookup_id

int
lookup_id (struct id_cache *ic, bool_t gid, char *name)
{
  struct id_dat *id_elm;
  char *orig_name = name;
  const char *fs;
  int cdfd;
  u_int hval;

  if (*name == '%')
    name++;

  hval = hash_string (name);

  for (id_elm = name2id_chain ((gid ? &ic->gnametab : &ic->unametab), 
			       hval); 
       id_elm && strcmp (name, id_elm->name);
       id_elm = name2id_next (id_elm))
    ;
  if (id_elm)
    return id_elm->id;

  id_elm = malloc (sizeof (*id_elm));
  if (!id_elm)
    return -1;

  bzero (id_elm->name, sizeof (id_elm->name));
  namecpy (id_elm->name, name);

  name = orig_name;

  /* Get the id either locally or via SFS */
  if (*name != '%' || (++name, !devcon_lookup (&cdfd, &fs, ic->dev))) {
    if (gid) {
      struct group *gr = getgrnam (name);
      if (gr)
	id_elm->id = gr->gr_gid;
      else
	id_elm->id = -1;
    }
    else {
      struct passwd *pw = getpwnam (name);
      if (pw)
	id_elm->id = pw->pw_uid;
      else 
	id_elm->id = -1;
    }
  }
  else if (strlen (name) > sfs_idnamelen)
    {
      free (id_elm);
      return -1;
    }
  else {

    sfsctl_getidnums_arg arg;
    sfsctl_getidnums_res res;
    sfs_opt_idname *sid;

    bzero (&arg, sizeof (arg));
    bzero (&res, sizeof (res));
    arg.filesys = (char *) fs;
    sid = gid ? &arg.names.gidname : &arg.names.uidname;
    sid->present = TRUE;
    sid->u.name = (char *) name;
    
    srpc_call (&sfsctl_prog_1, cdfd, SFSCTL_GETIDNUMS, &arg, &res);

    if (!res.status)
      id_elm->id = gid ? res.u.nums.gid : res.u.nums.uid;
    else {
      free (id_elm);
      xdr_free ((xdrproc_t) xdr_sfsctl_getidnums_res, (char *) &res);
      return -1;
    }

    
    xdr_free ((xdrproc_t) xdr_sfsctl_getidnums_res, (char *) &res);


  }

  id2name_insert (gid ? &ic->gidtab   : &ic->uidtab,   id_elm, id_elm->id);
  name2id_insert (gid ? &ic->gnametab : &ic->unametab, id_elm, hval);

  return id_elm->id;
}
开发者ID:gildafnai82,项目名称:craq,代码行数:87,代码来源:sfsops.c

示例12: socket


//.........这里部分代码省略.........
		local = (char *(*)(char *, struct svc_req *)) ep_rename_1_svc;
		break;

	case EP_READDIR:
         START_PROFILING_EXPGW(expgw_ctx_p,ep_readdir);
		_xdr_argument = (xdrproc_t) xdr_ep_readdir_arg_t;
		_xdr_result = (xdrproc_t) xdr_ep_readdir_ret_t;
		local = (char *(*)(char *, struct svc_req *)) ep_readdir_1_svc;
		break;

	case EP_READ_BLOCK:
         START_PROFILING_EXPGW(expgw_ctx_p,ep_read_block);
		_xdr_argument = (xdrproc_t) xdr_ep_io_arg_t;
		_xdr_result = (xdrproc_t) xdr_ep_read_block_ret_t;
		local = (char *(*)(char *, struct svc_req *)) ep_read_block_1_svc;
		break;
#endif
	case EP_WRITE_BLOCK:
         START_PROFILING_EXPGW(expgw_ctx_p,ep_write_block);
		_xdr_argument = (xdrproc_t) xdr_epgw_write_block_arg_t;
		_xdr_result = (xdrproc_t) xdr_epgw_mattr_ret_t;
		local = (char *(*)(char *, struct svc_req *)) expgw_write_block_1_svc;
		break;

	case EP_LINK:
         START_PROFILING_EXPGW(expgw_ctx_p,ep_link);
		_xdr_argument = (xdrproc_t) xdr_epgw_link_arg_t;
		_xdr_result = (xdrproc_t) xdr_epgw_mattr_ret_t;
		local = (char *(*)(char *, struct svc_req *)) expgw_link_1_svc;
		break;
#if 0
	case EP_SETXATTR:
         START_PROFILING_EXPGW(expgw_ctx_p,ep_setxattr);
		_xdr_argument = (xdrproc_t) xdr_ep_setxattr_arg_t;
		_xdr_result = (xdrproc_t) xdr_epgw_status_ret_t;
		local = (char *(*)(char *, struct svc_req *)) ep_setxattr_1_svc;
		break;

	case EP_GETXATTR:
         START_PROFILING_EXPGW(expgw_ctx_p,ep_getxattr);
		_xdr_argument = (xdrproc_t) xdr_ep_getxattr_arg_t;
		_xdr_result = (xdrproc_t) xdr_ep_getxattr_ret_t;
		local = (char *(*)(char *, struct svc_req *)) ep_getxattr_1_svc;
		break;

	case EP_REMOVEXATTR:
         START_PROFILING_EXPGW(expgw_ctx_p,ep_removexattr);
		_xdr_argument = (xdrproc_t) xdr_ep_removexattr_arg_t;
		_xdr_result = (xdrproc_t) xdr_epgw_status_ret_t;
		local = (char *(*)(char *, struct svc_req *)) ep_removexattr_1_svc;
		break;

	case EP_LISTXATTR:
         START_PROFILING_EXPGW(expgw_ctx_p,ep_listxattr);
		_xdr_argument = (xdrproc_t) xdr_ep_listxattr_arg_t;
		_xdr_result = (xdrproc_t) xdr_ep_listxattr_ret_t;
		local = (char *(*)(char *, struct svc_req *)) ep_listxattr_1_svc;
		break;

	case EP_LIST_CLUSTER:
		_xdr_argument = (xdrproc_t) xdr_uint16_t;
		_xdr_result = (xdrproc_t) xdr_ep_cluster_ret_t;
		local = (char *(*)(char *, struct svc_req *)) ep_list_cluster_1_svc;
		break;
#endif
	default:
        expgw_ctx_p->xmitBuf = expgw_ctx_p->recv_buf;
        expgw_ctx_p->recv_buf = NULL;
        errno = EPROTO;
        expgw_reply_error(expgw_ctx_p,errno);		
        expgw_release_context(expgw_ctx_p);    
        return;
	}
	memset ((char *)&argument, 0, sizeof (argument));
    
    /*
    ** save the result encoding/decoding function
    */
    expgw_ctx_p->xdr_result = _xdr_result;
    
	if (!expgw_getargs (recv_buf, (xdrproc_t) _xdr_argument, (caddr_t) &argument)) {
        expgw_ctx_p->xmitBuf = expgw_ctx_p->recv_buf;
        expgw_ctx_p->recv_buf = NULL;
        expgw_reply_error(expgw_ctx_p,errno);
        /*
        ** release the context
        */
        xdr_free((xdrproc_t)_xdr_argument, (caddr_t) &argument);
        expgw_release_context(expgw_ctx_p);    
		return;
	}
    /*
    ** call the user call-back
    */
	(*local)((char *)&argument, (void*)expgw_ctx_p);
    /*
    ** release any data allocated while decoding
    */
     xdr_free((xdrproc_t)_xdr_argument, (caddr_t) &argument);
}
开发者ID:baoboa,项目名称:rozofs,代码行数:101,代码来源:expgw_eprotosvc.c

示例13: borrarasociacion_1_svc

Estado *
borrarasociacion_1_svc(ID arg1, Clave arg2,  struct svc_req *rqstp)
{
	static Estado  result;

	if(root==NULL) { // No hay ningún diccionario
		result = FALLO;
	} else { // Hay algún diccionario
		DiccionarioPtr dicPtr = root;
		bool encontradoID = false;
		if(dicPtr->id==arg1) {
			encontradoID = true;
		}
		if(encontradoID==true) { // Es el primer diccionario
			EntradaPtr entPtr = dicPtr->first;
			bool encontradoClave = false;
			if(strcmp(entPtr->clave,arg2)==0) {
				encontradoClave = true;
			}
			if(encontradoClave==true) { // Es la primera clave
				if(entPtr->sig==NULL) { // Es la unica clave
					root = dicPtr->sig;
					dicPtr->sig = NULL;
					xdr_free((xdrproc_t)xdr_Diccionario,(char*)dicPtr);
					result = OK;
				} else { // No es la unica clave
					dicPtr->first = entPtr->sig;
					entPtr->sig = NULL;
					xdr_free((xdrproc_t)xdr_Entrada,(char*)entPtr);
					result = OK;
				}
			} else { // No es la primera asociacion
				EntradaPtr entPtrAnt = entPtr;
				while(encontradoClave==false && entPtr->sig!=NULL) { // Buscar entrada
					entPtrAnt = entPtr;
					entPtr = entPtr->sig;
					if(strcmp(entPtr->clave,arg2)==0) {
						encontradoClave = true;
					}
				}
				if(encontradoClave==true) { // Clave encontrada
					entPtrAnt->sig = entPtr->sig;
					entPtr->sig = NULL;
					xdr_free((xdrproc_t)xdr_Entrada,(char*)entPtr);
					result = OK;
				} else { // Clave no encontrada
					result = FALLO;
				}
			}
		} else { // No es el primer diccionario
			DiccionarioPtr dicPtrAnt;
			while(encontradoID==false && dicPtr->sig!=NULL) { // Buscar diccionario
				dicPtrAnt = dicPtr;
				dicPtr = dicPtr->sig;
				if(dicPtr->id==arg1) {
					encontradoID = true;
				}
			}
			if(encontradoID==true) { // Diccionario encontrado
				EntradaPtr entPtr = dicPtr->first;
				bool encontradoClave = false;
				if(strcmp(entPtr->clave,arg2)==0) {
					encontradoClave = true;
				}
				if(encontradoClave==true) { // Es la primera clave
					if(entPtr->sig==NULL) { // Es la unica clave
						dicPtrAnt->sig = dicPtr->sig;
						dicPtr->sig = NULL;
						xdr_free((xdrproc_t)xdr_Diccionario,(char*)dicPtr);
						result = OK;
					} else { // No es la unica clave
						dicPtr->first = entPtr->sig;
						entPtr->sig = NULL;
						xdr_free((xdrproc_t)xdr_Entrada,(char*)entPtr);
						result = OK;
					}
				} else { // No es la primera asociacion
					EntradaPtr entPtrAnt = entPtr;
					while(encontradoClave==false && entPtr->sig!=NULL) { // Buscar entrada
						entPtrAnt = entPtr;
						entPtr = entPtr->sig;
						if(strcmp(entPtr->clave,arg2)==0) {
							encontradoClave = true;
						}
					}
					if(encontradoClave==true) { // Clave encontrada
						entPtrAnt->sig = entPtr->sig;
						entPtr->sig = NULL;
						xdr_free((xdrproc_t)xdr_Entrada,(char*)entPtr);
						result = OK;
					} else { // Clave no encontrada
						result = FALLO;
					}
				}
			} else { // Diccionario no encontrado
				result = FALLO;
			}
		} 
	}

//.........这里部分代码省略.........
开发者ID:huseynlilkin,项目名称:grado_informatica-DSD,代码行数:101,代码来源:asociacion_server.c

示例14: RFSnfsReadDirectory

RFSnfsReadDirectory(LPCLIENT         ClientPointer,
                    nfs_fh          *NfsDirectoryHandlePointer,
                    RFSItemSize      ChunkSize,
                    RFSnfsRDCallBack CallBackFunc,
                    LPVOID           CallBackParam,
                    nfscookie       *CookiePointer,
                    LPRFSBool CallMeAgainPointer,
                    LPRFSBool AnEntryFoundPointer)
{
    RFSBool      CallBackStatus;
    RFSnfsStatus YerStatus;
    readdirres  *results;
    readdirargs *argumentsPointer; /* 40 bytes */
    entry       *entry_p;


    argumentsPointer = (readdirargs *)calloc(1, sizeof(readdirargs));
    if (argumentsPointer == NULL)
        return RFSnfsNullResult;

    ClearNBlock(argumentsPointer, sizeof(readdirargs));
    readdirargsDirectoryHandle(argumentsPointer) = *NfsDirectoryHandlePointer;
    CopyCookie(readdirargsCookie(argumentsPointer), *CookiePointer);
    readdirargsCount(argumentsPointer) = ChunkSize;

    *AnEntryFoundPointer = RFSFalse;
    *CallMeAgainPointer  = RFSFalse;

    results = nfsproc_readdir_2_clnt(argumentsPointer, ClientPointer);

    free(argumentsPointer);
    if (results == NULL)
    {
        return(RFSnfsNullResult);
    }
    YerStatus = NfsToRFSnfs(readdirresStatus(results));

    if ((readdirresStatus(results)) != NFS_OK)
    {
        xdr_free(xdr_readdirres, (char *)results);
        return YerStatus;
    }

/* loop through all the returned entries and call the */
/* callback once for each entry. */

    entry_p = readdirresFirstEntry(results);
    while (entry_p != NULL)
    {
        *AnEntryFoundPointer = RFSTrue; /* we saw an entry */
        CopyCookie(*CookiePointer, entry_p->cookie);
        CallBackStatus = (*CallBackFunc)(entry_p->name,
                                         entry_p->cookie,
                                         CallBackParam);
        if (CallBackStatus != RFSTrue)
        {
            xdr_free(xdr_readdirres, (char *)results);
            return RFSCallBackError;
        }
        entry_p = entry_p->nextentry;
    } /* for all directory entries */

/* If we didn't hit the EOF then we want to be called again. */

    if (readdirresEOF(results) != TRUE)
        *CallMeAgainPointer = RFSTrue;
    xdr_free(xdr_readdirres, (char *)results);
    return RFSNFS_OK;
} /* RFSnfsReadDirectory */
开发者ID:mingpen,项目名称:OpenNT,代码行数:69,代码来源:rfsnfs.c

示例15: yp_match

int
yp_match(const char *indomain, const char *inmap, const char *inkey,
	int inkeylen, char **outval, int *outvallen)
{
	struct dom_binding *ysd;
	struct ypresp_val yprv;
	struct ypreq_key yprk;
	int r, nerrs = 0;

	if (outval == NULL || outvallen == NULL)
		return YPERR_BADARGS;
	*outval = NULL;
	*outvallen = 0;

	if (_yp_invalid_domain(indomain))
		return YPERR_BADARGS;
	if (inmap == NULL || *inmap == '\0'
	    || strlen(inmap) > YPMAXMAP)
		return YPERR_BADARGS;
	if (inkey == NULL || inkeylen == 0)
		return YPERR_BADARGS;

again:
	if (_yp_dobind(indomain, &ysd) != 0)
		return YPERR_DOMAIN;

#ifdef YPMATCHCACHE
	if (!strcmp(_yp_domain, indomain) && ypmatch_find(inmap, inkey,
			 inkeylen, &yprv.valdat.dptr, &yprv.valdat.dsize)) {
		*outvallen = yprv.valdat.dsize;
		if ((*outval = malloc((size_t)(*outvallen + 1))) == NULL)
			return YPERR_YPERR;
		(void)memcpy(*outval, yprv.valdat.dptr, (size_t)*outvallen);
		(*outval)[*outvallen] = '\0';
		return 0;
	}
#endif

	yprk.domain = indomain;
	yprk.map = inmap;
	yprk.keydat.dptr = __UNCONST(inkey);
	yprk.keydat.dsize = inkeylen;

	memset(&yprv, 0, sizeof yprv);

	r = clnt_call(ysd->dom_client, (rpcproc_t)YPPROC_MATCH,
		      (xdrproc_t)xdr_ypreq_key, &yprk,
		      (xdrproc_t)xdr_ypresp_val, &yprv, 
		      _yplib_timeout);
	if (r != RPC_SUCCESS) {
		if (_yplib_bindtries <= 0 && ++nerrs == _yplib_nerrs) {
			clnt_perror(ysd->dom_client, "yp_match: clnt_call");
			nerrs = 0;
		}
		else if (_yplib_bindtries > 0 && ++nerrs == _yplib_bindtries) {
			return YPERR_YPSERV;
		}
		ysd->dom_vers = -1;
		goto again;
	}
	if (!(r = ypprot_err(yprv.status))) {
		*outvallen = yprv.valdat.dsize;
		if ((*outval = malloc((size_t)(*outvallen + 1))) == NULL)
			return YPERR_YPERR;
		(void)memcpy(*outval, yprv.valdat.dptr, (size_t)*outvallen);
		(*outval)[*outvallen] = '\0';
#ifdef YPMATCHCACHE
		if (strcmp(_yp_domain, indomain) == 0)
			if (!ypmatch_add(inmap, inkey, inkeylen,
					 *outval, *outvallen))
				r = YPERR_RESRC;
#endif
	}
	xdr_free((xdrproc_t)xdr_ypresp_val, (char *)(void *)&yprv);
	__yp_unbind(ysd);
	if (r != 0) {
		if (*outval) {
			free(*outval);
			*outval = NULL;
		}
	}
	return r;
}
开发者ID:AgamAgarwal,项目名称:minix,代码行数:83,代码来源:yp_match.c


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