您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ talloc_zero函数代码示例

51自学网 2021-06-03 08:40:11
  C++
这篇教程C++ talloc_zero函数代码示例写得很实用,希望能帮到您。

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

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

示例1: main

int main(int argc, char **argv){	const char *guid_str;    const char *attr_str;    const char *varname;	const char *keyfilename;    const char *certfilename;	varsign_context *ctx;	bool include_attrs;	int c = 0;    	unsigned char no_signing = 0;	unsigned char no_repack = 0;	ctx = talloc_zero(NULL, varsign_context);	keyfilename = NULL;	certfilename = NULL;	guid_str = NULL;	attr_str= NULL;	include_attrs = false;	for (;;) {		int idx;		c = getopt_long(argc, argv, "o:g:a:k:c:n:ivVh", options, &idx);		if (c == -1) {			break;        }		switch (c) {	case 'o':			ctx->outfilename = optarg;			break;        case 'g':			guid_str = optarg;			break;        case 'a':			attr_str = optarg;			break;        case 'k':			keyfilename = optarg;			break;        case 'c':			certfilename = optarg;			break;        case 'i':			include_attrs = true;			break;        case 'v':			ctx->verbose = 1;			break;        case 'V':			version();			return EXIT_SUCCESS;        case 'n':            no_signing = 1;            break;        case 'N':            no_signing = 1;            break;        case 'r':            no_repack = 1;            do_direct = 1;            break;        case 'R':            no_repack = 1;            do_direct = 1;            break;        case 'h':			usage();			return EXIT_SUCCESS;		}	}	if (argc != (optind + 2)) {		usage();		return EXIT_FAILURE;	}	if ((!keyfilename) && (!no_signing)) {		fprintf(stderr, "No signing key specified/n");		return EXIT_FAILURE;	}	if ((!certfilename) && (!no_signing)) {//.........这里部分代码省略.........
开发者ID:weihu811102,项目名称:sbsigntool_osx,代码行数:101,


示例2: demux_open_tv

//.........这里部分代码省略.........    if (tvh->tv_param->fps != -1.0f)        sh_video->fps = tvh->tv_param->fps;    /* If playback only mode, go to immediate mode, fail silently */    if(tvh->tv_param->immediate == 1)        {        funcs->control(tvh->priv, TVI_CONTROL_IMMEDIATE, 0);        tvh->tv_param->noaudio = 1;        }    /* set width */    funcs->control(tvh->priv, TVI_CONTROL_VID_GET_WIDTH, &sh_video->disp_w);    /* set height */    funcs->control(tvh->priv, TVI_CONTROL_VID_GET_HEIGHT, &sh_video->disp_h);    demuxer->seekable = 0;    /* here comes audio init */    if (tvh->tv_param->noaudio == 0 && funcs->control(tvh->priv, TVI_CONTROL_IS_AUDIO, 0) == TVI_CONTROL_TRUE)    {        int audio_format;        /* yeah, audio is present */        funcs->control(tvh->priv, TVI_CONTROL_AUD_SET_SAMPLERATE,                                  &tvh->tv_param->audiorate);        if (funcs->control(tvh->priv, TVI_CONTROL_AUD_GET_FORMAT, &audio_format) != TVI_CONTROL_TRUE)            goto no_audio;        switch(audio_format)        {            case AF_FORMAT_U8:            case AF_FORMAT_S8:            case AF_FORMAT_U16_LE:            case AF_FORMAT_U16_BE:            case AF_FORMAT_S16_LE:            case AF_FORMAT_S16_BE:            case AF_FORMAT_S32_LE:            case AF_FORMAT_S32_BE:                break;            case AF_FORMAT_MPEG2:            default:                MP_ERR(tvh, "Audio type '%s' unsupported!/n",                    af_fmt_to_str(audio_format));                goto no_audio;        }        struct sh_stream *sh_a = new_sh_stream(demuxer, STREAM_AUDIO);        sh_audio = sh_a->audio;        funcs->control(tvh->priv, TVI_CONTROL_AUD_GET_SAMPLERATE,                   &sh_audio->samplerate);        int nchannels = sh_audio->channels.num;        funcs->control(tvh->priv, TVI_CONTROL_AUD_GET_CHANNELS,                   &nchannels);        mp_chmap_from_channels(&sh_audio->channels, nchannels);        sh_a->codec = "mp-pcm";        sh_a->format = audio_format;        int samplesize = af_fmt2bits(audio_format) / 8;        sh_audio->i_bps =            sh_audio->samplerate * samplesize * sh_audio->channels.num;        // emulate WF for win32 codecs:        sh_audio->wf = talloc_zero(sh_audio, MP_WAVEFORMATEX);        sh_audio->wf->wFormatTag = sh_a->format;        sh_audio->wf->nChannels = sh_audio->channels.num;        sh_audio->wf->wBitsPerSample = samplesize * 8;        sh_audio->wf->nSamplesPerSec = sh_audio->samplerate;        sh_audio->wf->nBlockAlign = samplesize * sh_audio->channels.num;        sh_audio->wf->nAvgBytesPerSec = sh_audio->i_bps;        MP_VERBOSE(tvh, "  TV audio: %d channels, %d bits, %d Hz/n",          sh_audio->wf->nChannels, sh_audio->wf->wBitsPerSample,          sh_audio->wf->nSamplesPerSec);    }no_audio:    if(!(funcs->start(tvh->priv))){        // start failed :(        tv_uninit(tvh);        return -1;    }    /* set color eq */    tv_set_color_options(tvh, TV_COLOR_BRIGHTNESS, tvh->tv_param->brightness);    tv_set_color_options(tvh, TV_COLOR_HUE, tvh->tv_param->hue);    tv_set_color_options(tvh, TV_COLOR_SATURATION, tvh->tv_param->saturation);    tv_set_color_options(tvh, TV_COLOR_CONTRAST, tvh->tv_param->contrast);    if(tvh->tv_param->gain!=-1)        if(funcs->control(tvh->priv,TVI_CONTROL_VID_SET_GAIN,&tvh->tv_param->gain)!=TVI_CONTROL_TRUE)            MP_WARN(tvh, "Unable to set gain control!/n");    return 0;}
开发者ID:candux,项目名称:mpv,代码行数:101,


示例3: xlat_register

/** Register an xlat function. * * @param[in] name xlat name. * @param[in] func xlat function to be called. * @param[in] escape function to sanitize any sub expansions passed to the xlat function. * @param[in] instance of module that's registering the xlat function. * @return 0 on success, -1 on failure */int xlat_register(char const *name, RAD_XLAT_FUNC func, RADIUS_ESCAPE_STRING escape, void *instance){	xlat_t	*c;	xlat_t	my_xlat;	rbnode_t *node;	if (!name || !*name) {		DEBUG("xlat_register: Invalid xlat name");		return -1;	}	/*	 *	First time around, build up the tree...	 *	 *	FIXME: This code should be hoisted out of this function,	 *	and into a global "initialization".  But it isn't critical...	 */	if (!xlat_root) {#ifdef WITH_UNLANG		int i;#endif		xlat_root = rbtree_create(xlat_cmp, NULL, 0);		if (!xlat_root) {			DEBUG("xlat_register: Failed to create tree");			return -1;		}#ifdef WITH_UNLANG		for (i = 0; xlat_foreach_names[i] != NULL; i++) {			xlat_register(xlat_foreach_names[i],				      xlat_foreach, NULL, &xlat_inst[i]);			c = xlat_find(xlat_foreach_names[i]);			rad_assert(c != NULL);			c->internal = true;		}#endif#define XLAT_REGISTER(_x) xlat_register(STRINGIFY(_x), xlat_ ## _x, NULL, NULL); /		c = xlat_find(STRINGIFY(_x)); /		rad_assert(c != NULL); /		c->internal = true		XLAT_REGISTER(integer);		XLAT_REGISTER(strlen);		XLAT_REGISTER(length);		XLAT_REGISTER(hex);		XLAT_REGISTER(string);		XLAT_REGISTER(xlat);		XLAT_REGISTER(module);		XLAT_REGISTER(debug_attr);		xlat_register("debug", xlat_debug, NULL, &xlat_inst[0]);		c = xlat_find("debug");		rad_assert(c != NULL);		c->internal = true;	}	/*	 *	If it already exists, replace the instance.	 */	strlcpy(my_xlat.name, name, sizeof(my_xlat.name));	my_xlat.length = strlen(my_xlat.name);	c = rbtree_finddata(xlat_root, &my_xlat);	if (c) {		if (c->internal) {			DEBUG("xlat_register: Cannot re-define internal xlat");			return -1;		}		c->func = func;		c->escape = escape;		c->instance = instance;		return 0;	}	/*	 *	Doesn't exist.  Create it.	 */	c = talloc_zero(xlat_root, xlat_t);	c->func = func;	c->escape = escape;	strlcpy(c->name, name, sizeof(c->name));	c->length = strlen(c->name);	c->instance = instance;	node = rbtree_insert_node(xlat_root, c);	if (!node) {		talloc_free(c);		return -1;	}//.........这里部分代码省略.........
开发者ID:dleo,项目名称:freeradius-server,代码行数:101,


示例4: main

//.........这里部分代码省略.........		if (req->vps) pairfree(&req->vps);		if (readvp2(&req->vps, NULL, fp, &filedone) < 0) {			fr_perror("radeapclient");			break;		}		sendrecv_eap(req);	}	if(do_summary) {		printf("/n/t   Total approved auths:  %d/n", totalapp);		printf("/t     Total denied auths:  %d/n", totaldeny);	}	talloc_free(autofree);	return 0;}/* * given a radius request with some attributes in the EAP range, build * them all into a single EAP-Message body. * * Note that this function will build multiple EAP-Message bodies * if there are multiple eligible EAP-types. This is incorrect, as the * recipient will in fact concatenate them. * * XXX - we could break the loop once we process one type. Maybe this *       just deserves an assert? * */static void map_eap_methods(RADIUS_PACKET *req){	VALUE_PAIR *vp, *vpnext;	int id, eapcode;	int eap_method;	eap_packet_t *pt_ep = talloc_zero(req, eap_packet_t);	vp = pairfind(req->vps, ATTRIBUTE_EAP_ID, 0, TAG_ANY);	if(!vp) {		id = ((int)getpid() & 0xff);	} else {		id = vp->vp_integer;	}	vp = pairfind(req->vps, ATTRIBUTE_EAP_CODE, 0, TAG_ANY);	if(!vp) {		eapcode = PW_EAP_REQUEST;	} else {		eapcode = vp->vp_integer;	}	for(vp = req->vps; vp != NULL; vp = vpnext) {		/* save it in case it changes! */		vpnext = vp->next;		if(vp->da->attr >= ATTRIBUTE_EAP_BASE &&		   vp->da->attr < ATTRIBUTE_EAP_BASE+256) {			break;		}	}	if(!vp) {		return;	}	eap_method = vp->da->attr - ATTRIBUTE_EAP_BASE;	switch(eap_method) {	case PW_EAP_IDENTITY:	case PW_EAP_NOTIFICATION:	case PW_EAP_NAK:	case PW_EAP_MD5:	case PW_EAP_OTP:	case PW_EAP_GTC:	case PW_EAP_TLS:	case PW_EAP_LEAP:	case PW_EAP_TTLS:	case PW_EAP_PEAP:	default:		/*		 * no known special handling, it is just encoded as an		 * EAP-message with the given type.		 */		/* nuke any existing EAP-Messages */		pairdelete(&req->vps, PW_EAP_MESSAGE, 0, TAG_ANY);		pt_ep->code = eapcode;		pt_ep->id = id;		pt_ep->type.num = eap_method;		pt_ep->type.length = vp->length;		pt_ep->type.data = talloc_memdup(vp, vp->vp_octets, vp->length);		talloc_set_type(pt_ep->type.data, uint8_t);		eap_basic_compose(req, pt_ep);	}}
开发者ID:amirdaly,项目名称:freeradius-server,代码行数:101,


示例5: main

int main(int argc, char *argv[]){	int			c;	int			num_networks = 1;	int			num_workers = 2;	uint16_t		port16 = 0;	TALLOC_CTX		*autofree = talloc_autofree_context();	fr_schedule_t		*sched;	fr_listen_t		listen = { .app_io = &app_io, .app = &test_app };	fr_listen_test_t	*app_io_inst;	listen.app_io_instance = app_io_inst = talloc_zero(autofree, fr_listen_test_t);	fr_time_start();	fr_log_init(&default_log, false);	default_log.colourise = true;	memset(&my_ipaddr, 0, sizeof(my_ipaddr));	my_ipaddr.af = AF_INET;	my_ipaddr.prefix = 32;	my_ipaddr.addr.v4.s_addr = htonl(INADDR_LOOPBACK);	my_port = 1812;	while ((c = getopt(argc, argv, "i:n:s:w:x")) != EOF) switch (c) {		case 'i':			if (fr_inet_pton_port(&my_ipaddr, &port16, optarg, -1, AF_INET, true, false) < 0) {				fr_perror("Failed parsing ipaddr");				exit(EXIT_FAILURE);			}			my_port = port16;			break;		case 'n':			num_networks = atoi(optarg);			if ((num_networks <= 0) || (num_networks > 16)) usage();			break;		case 's':			secret = optarg;			break;		case 'w':			num_workers = atoi(optarg);			if ((num_workers <= 0) || (num_workers > 1024)) usage();			break;		case 'x':			debug_lvl++;			fr_debug_lvl++;			break;		case 'h':		default:			usage();	}#if 0	argc -= (optind - 1);	argv += (optind - 1);#endif	app_io_inst->ipaddr = my_ipaddr;	app_io_inst->port = my_port;	sched = fr_schedule_create(autofree, NULL, &default_log, debug_lvl, num_networks, num_workers, NULL, NULL);	if (!sched) {		fprintf(stderr, "schedule_test: Failed to create scheduler/n");		exit(EXIT_FAILURE);	}	if (listen.app_io->open(listen.app_io_instance, listen.app_io_instance) < 0) exit(EXIT_FAILURE);#if 0	/*	 *	Set up the KQ filter for reading.	 */	EV_SET(&events[0], sockfd, EVFILT_READ, EV_ADD | EV_ENABLE, 0, 0, NULL);	if (kevent(kq_master, events, 1, NULL, 0, NULL) < 0) {		fr_perror("Failed setting KQ for EVFILT_READ");		exit(EXIT_FAILURE);	}#endif	(void) fr_fault_setup(autofree, NULL, argv[0]);	(void) fr_schedule_listen_add(sched, &listen);	sleep(10);	(void) fr_schedule_destroy(sched);	exit(EXIT_SUCCESS);}
开发者ID:zi0r,项目名称:freeradius-server,代码行数:93,


示例6: map_eap_methods

/* * given a radius request with some attributes in the EAP range, build * them all into a single EAP-Message body. * * Note that this function will build multiple EAP-Message bodies * if there are multiple eligible EAP-types. This is incorrect, as the * recipient will in fact concatenate them. * * XXX - we could break the loop once we process one type. Maybe this *       just deserves an assert? * */static void map_eap_methods(RADIUS_PACKET *req){	VALUE_PAIR *vp, *vpnext;	int id, eapcode;	int eap_method;	eap_packet_t *pt_ep = talloc_zero(req, eap_packet_t);	vp = pairfind(req->vps, ATTRIBUTE_EAP_ID, 0, TAG_ANY);	if(!vp) {		id = ((int)getpid() & 0xff);	} else {		id = vp->vp_integer;	}	vp = pairfind(req->vps, ATTRIBUTE_EAP_CODE, 0, TAG_ANY);	if(!vp) {		eapcode = PW_EAP_REQUEST;	} else {		eapcode = vp->vp_integer;	}	for(vp = req->vps; vp != NULL; vp = vpnext) {		/* save it in case it changes! */		vpnext = vp->next;		if(vp->da->attr >= ATTRIBUTE_EAP_BASE &&		   vp->da->attr < ATTRIBUTE_EAP_BASE+256) {			break;		}	}	if(!vp) {		return;	}	eap_method = vp->da->attr - ATTRIBUTE_EAP_BASE;	switch(eap_method) {	case PW_EAP_IDENTITY:	case PW_EAP_NOTIFICATION:	case PW_EAP_NAK:	case PW_EAP_MD5:	case PW_EAP_OTP:	case PW_EAP_GTC:	case PW_EAP_TLS:	case PW_EAP_LEAP:	case PW_EAP_TTLS:	case PW_EAP_PEAP:	default:		/*		 * no known special handling, it is just encoded as an		 * EAP-message with the given type.		 */		/* nuke any existing EAP-Messages */		pairdelete(&req->vps, PW_EAP_MESSAGE, 0, TAG_ANY);		pt_ep->code = eapcode;		pt_ep->id = id;		pt_ep->type.num = eap_method;		pt_ep->type.length = vp->length;		pt_ep->type.data = talloc_memdup(vp, vp->vp_octets, vp->length);		talloc_set_type(pt_ep->type.data, uint8_t);		eap_basic_compose(req, pt_ep);	}}
开发者ID:capone1992,项目名称:freeradius-server,代码行数:81,


示例7: GetLastError

/**   /details Opens a specific message and retrieves a MAPI object that   can be used to get or set message properties.   This function opens a specific message defined by a combination of   object store, folder ID, and message ID and which read/write access   is defined by ulFlags.   /param obj_store the store to read from   /param id_folder the folder ID   /param id_message the message ID   /param obj_message the resulting message object   /param ulFlags   Possible ulFlags values:   - 0x0: read only access   - 0x1: ReadWrite   - 0x3: Create   - 0x4: OpenSoftDeleted   /return MAPI_E_SUCCESS on success, otherwise MAPI error.   /note Developers may also call GetLastError() to retrieve the last   MAPI error code. Possible MAPI error codes are:   - MAPI_E_NOT_INITIALIZED: MAPI subsystem has not been initialized   - MAPI_E_INVALID_PARAMETER: obj_store is undefined   - MAPI_E_CALL_FAILED: A network problem was encountered during the     transaction   /sa MAPIInitialize, GetLastError*/_PUBLIC_ enum MAPISTATUS OpenMessage(mapi_object_t *obj_store, 				     mapi_id_t id_folder, 				     mapi_id_t id_message, 				     mapi_object_t *obj_message,				     uint8_t ulFlags){	struct mapi_context		*mapi_ctx;	struct mapi_request		*mapi_request;	struct mapi_response		*mapi_response;	struct EcDoRpc_MAPI_REQ		*mapi_req;	struct OpenMessage_req		request;	struct OpenMessage_repl		*reply;	struct mapi_session		*session;	mapi_object_message_t		*message;	struct SPropValue		lpProp;	const char			*tstring;	NTSTATUS			status;	enum MAPISTATUS			retval;	uint32_t			size = 0;	TALLOC_CTX			*mem_ctx;	uint32_t			i = 0;	uint8_t				logon_id;	/* Sanity checks */	OPENCHANGE_RETVAL_IF(!obj_store, MAPI_E_INVALID_PARAMETER, NULL);	session = mapi_object_get_session(obj_store);	OPENCHANGE_RETVAL_IF(!session, MAPI_E_INVALID_PARAMETER, NULL);	mapi_ctx = session->mapi_ctx;	OPENCHANGE_RETVAL_IF(!mapi_ctx, MAPI_E_NOT_INITIALIZED, NULL);	if ((retval = mapi_object_get_logon_id(obj_store, &logon_id)) != MAPI_E_SUCCESS)		return retval;	mem_ctx = talloc_named(session, 0, "OpenMessage");	/* Fill the OpenMessage operation */	request.handle_idx = 0x1;	request.CodePageId = 0xfff;	request.FolderId = id_folder;	request.OpenModeFlags = (enum OpenMessage_OpenModeFlags)ulFlags;	request.MessageId = id_message;	size = sizeof (uint8_t) + sizeof(uint16_t) + sizeof(mapi_id_t) + sizeof(uint8_t) + sizeof(mapi_id_t);	/* Fill the MAPI_REQ request */	mapi_req = talloc_zero(mem_ctx, struct EcDoRpc_MAPI_REQ);	mapi_req->opnum = op_MAPI_OpenMessage;	mapi_req->logon_id = logon_id;	mapi_req->handle_idx = 0;	mapi_req->u.mapi_OpenMessage = request;	size += 5;	/* Fill the mapi_request structure */	mapi_request = talloc_zero(mem_ctx, struct mapi_request);	mapi_request->mapi_len = size + sizeof (uint32_t) * 2;	mapi_request->length = size;	mapi_request->mapi_req = mapi_req;	mapi_request->handles = talloc_array(mem_ctx, uint32_t, 2);	mapi_request->handles[0] = mapi_object_get_handle(obj_store);	mapi_request->handles[1] = 0xffffffff;	status = emsmdb_transaction_wrapper(session, mem_ctx, mapi_request, &mapi_response);	OPENCHANGE_RETVAL_IF(!NT_STATUS_IS_OK(status), MAPI_E_CALL_FAILED, mem_ctx);	OPENCHANGE_RETVAL_IF(!mapi_response->mapi_repl, MAPI_E_CALL_FAILED, mem_ctx);	retval = mapi_response->mapi_repl->error_code;	OPENCHANGE_RETVAL_IF(retval, retval, mem_ctx);	OPENCHANGE_CHECK_NOTIFICATION(session, mapi_response);//.........这里部分代码省略.........
开发者ID:EasyLinux,项目名称:Openchange,代码行数:101,


示例8: mod_session_init

static int mod_session_init (void *instance, eap_handler_t *handler){	pwd_session_t *session;	eap_pwd_t *inst = (eap_pwd_t *)instance;	VALUE_PAIR *vp;	pwd_id_packet_t *packet;	if (!inst || !handler) {		ERROR("rlm_eap_pwd: Initiate, NULL data provided");		return 0;	}	/*	* make sure the server's been configured properly	*/	if (!inst->server_id) {		ERROR("rlm_eap_pwd: Server ID is not configured");		return 0;	}	switch (inst->group) {	case 19:	case 20:	case 21:	case 25:	case 26:		break;	default:		ERROR("rlm_eap_pwd: Group is not supported");		return 0;	}	if ((session = talloc_zero(handler, pwd_session_t)) == NULL) return 0;	talloc_set_destructor(session, _free_pwd_session);	/*	 * set things up so they can be free'd reliably	 */	session->group_num = inst->group;	session->private_value = NULL;	session->peer_scalar = NULL;	session->my_scalar = NULL;	session->k = NULL;	session->my_element = NULL;	session->peer_element = NULL;	session->group = NULL;	session->pwe = NULL;	session->order = NULL;	session->prime = NULL;	/*	 *	The admin can dynamically change the MTU.	 */	session->mtu = inst->fragment_size;	vp = fr_pair_find_by_num(handler->request->packet->vps, PW_FRAMED_MTU, 0, TAG_ANY);	/*	 *	session->mtu is *our* MTU.  We need to subtract off the EAP	 *	overhead.	 *	 *	9 = 4 (EAPOL header) + 4 (EAP header) + 1 (EAP type)	 *	 *	The fragmentation code deals with the included length	 *	so we don't need to subtract that here.	 */	if (vp && (vp->vp_integer > 100) && (vp->vp_integer < session->mtu)) {		session->mtu = vp->vp_integer - 9;	}	session->state = PWD_STATE_ID_REQ;	session->in = NULL;	session->out_pos = 0;	handler->opaque = session;	/*	 * construct an EAP-pwd-ID/Request	 */	session->out_len = sizeof(pwd_id_packet_t) + strlen(inst->server_id);	if ((session->out = talloc_zero_array(session, uint8_t, session->out_len)) == NULL) {		return 0;	}	packet = (pwd_id_packet_t *)session->out;	packet->group_num = htons(session->group_num);	packet->random_function = EAP_PWD_DEF_RAND_FUN;	packet->prf = EAP_PWD_DEF_PRF;	session->token = fr_rand();	memcpy(packet->token, (char *)&session->token, 4);	packet->prep = EAP_PWD_PREP_NONE;	memcpy(packet->identity, inst->server_id, session->out_len - sizeof(pwd_id_packet_t) );	handler->stage = PROCESS;	return send_pwd_request(session, handler->eap_ds);}
开发者ID:janetuk,项目名称:freeradius,代码行数:94,


示例9: generate_sql_clients

static int generate_sql_clients(rlm_sql_t *inst){	rlm_sql_handle_t *handle;	rlm_sql_row_t row;	char querystr[MAX_QUERY_LEN];	RADCLIENT *c;	char *prefix_ptr = NULL;	unsigned int i = 0;	int numf = 0;	DEBUG("rlm_sql (%s): Processing generate_sql_clients",	      inst->config->xlat_name);	/* NAS query isn't xlat'ed */	strlcpy(querystr, inst->config->nas_query, sizeof(querystr));	DEBUG("rlm_sql (%s) in generate_sql_clients: query is %s",	      inst->config->xlat_name, querystr);	handle = sql_get_socket(inst);	if (handle == NULL)		return -1;	if (rlm_sql_select_query(&handle,inst,querystr)){		return -1;	}	while(rlm_sql_fetch_row(&handle, inst) == 0) {		i++;		row = handle->row;		if (row == NULL)			break;		/*		 *  The return data for each row MUST be in the following order:		 *		 *  0. Row ID (currently unused)		 *  1. Name (or IP address)		 *  2. Shortname		 *  3. Type		 *  4. Secret		 *  5. Virtual Server (optional)		 */		if (!row[0]){			radlog(L_ERR, "rlm_sql (%s): No row id found on pass %d",inst->config->xlat_name,i);			continue;		}		if (!row[1]){			radlog(L_ERR, "rlm_sql (%s): No nasname found for row %s",inst->config->xlat_name,row[0]);			continue;		}		if (!row[2]){			radlog(L_ERR, "rlm_sql (%s): No short name found for row %s",inst->config->xlat_name,row[0]);			continue;		}		if (!row[4]){			radlog(L_ERR, "rlm_sql (%s): No secret found for row %s",inst->config->xlat_name,row[0]);			continue;		}		DEBUG("rlm_sql (%s): Read entry nasname=%s,shortname=%s,secret=%s",inst->config->xlat_name,			row[1],row[2],row[4]);		c = talloc_zero(inst, RADCLIENT);#ifdef WITH_DYNAMIC_CLIENTS		c->dynamic = 1;#endif		/*		 *	Look for prefixes		 */		c->prefix = -1;		prefix_ptr = strchr(row[1], '/');		if (prefix_ptr) {			c->prefix = atoi(prefix_ptr + 1);			if ((c->prefix < 0) || (c->prefix > 128)) {				radlog(L_ERR, "rlm_sql (%s): Invalid Prefix value '%s' for IP.",				       inst->config->xlat_name, prefix_ptr + 1);				talloc_free(c);				continue;			}			/* Replace '/' with '/0' */			*prefix_ptr = '/0';		}		/*		 *	Always get the numeric representation of IP		 */		if (ip_hton(row[1], AF_UNSPEC, &c->ipaddr) < 0) {			radlog(L_ERR, "rlm_sql (%s): Failed to look up hostname %s: %s",			       inst->config->xlat_name,			       row[1], fr_strerror());			talloc_free(c);			continue;		} else {			char buffer[256];			ip_ntoh(&c->ipaddr, buffer, sizeof(buffer));			c->longname = talloc_strdup(c, buffer);		}		if (c->prefix < 0) switch (c->ipaddr.af) {		case AF_INET://.........这里部分代码省略.........
开发者ID:Gejove,项目名称:freeradius-server,代码行数:101,


示例10: main_config_init

//.........这里部分代码省略.........	/*	 *	This allows us to figure out where, relative to	 *	radiusd.conf, the other configuration files exist.	 */	if (cf_section_parse(cs, NULL, server_config) < 0) {		return -1;	}	/*	 *	We ignore colourization of output until after the	 *	configuration files have been parsed.	 */	p = getenv("TERM");	if (do_colourise && p && isatty(default_log.fd) && strstr(p, "xterm")) {		default_log.colourise = true;	} else {		default_log.colourise = false;	}	/*	 *	Starting the server, WITHOUT "-x" on the	 *	command-line: use whatever is in the config	 *	file.	 */	if (debug_flag == 0) {		debug_flag = main_config.debug_level;	}	fr_debug_flag = debug_flag;	FR_INTEGER_COND_CHECK("max_request_time", main_config.max_request_time, (main_config.max_request_time != 0), 100);	FR_INTEGER_BOUND_CHECK("reject_delay", main_config.reject_delay, <=, 10);	FR_INTEGER_BOUND_CHECK("cleanup_delay", main_config.cleanup_delay, <=, 10);	/*	 * Set default initial request processing delay to 1/3 of a second.	 * Will be updated by the lowest response window across all home servers,	 * if it is less than this.	 */	main_config.init_delay.tv_sec = 0;	main_config.init_delay.tv_usec = 1000000 / 3;	/*	 *	Free the old configuration items, and replace them	 *	with the new ones.	 *	 *	Note that where possible, we do atomic switch-overs,	 *	to ensure that the pointers are always valid.	 */	rad_assert(main_config.config == NULL);	root_config = main_config.config = cs;	DEBUG2("%s: #### Loading Realms and Home Servers ####", main_config.name);	if (!realms_init(cs)) {		return -1;	}	DEBUG2("%s: #### Loading Clients ####", main_config.name);	if (!clients_parse_section(cs, false)) {		return -1;	}	/*	 *  Register the %{config:section.subsection} xlat function.	 */	xlat_register("config", xlat_config, NULL, NULL);	xlat_register("client", xlat_client, NULL, NULL);	xlat_register("getclient", xlat_getclient, NULL, NULL);	/*	 *  Go update our behaviour, based on the configuration	 *  changes.	 */	/*	 *	Sanity check the configuration for internal	 *	consistency.	 */	FR_INTEGER_BOUND_CHECK("reject_delay", main_config.reject_delay, <=, main_config.cleanup_delay);	if (chroot_dir) {		if (chdir(radlog_dir) < 0) {			ERROR("Failed to 'chdir %s' after chroot: %s",			       radlog_dir, fr_syserror(errno));			return -1;		}	}	cc = talloc_zero(NULL, cached_config_t);	if (!cc) return -1;	cc->cs = talloc_steal(cc ,cs);	rad_assert(cs_cache == NULL);	cs_cache = cc;	/* Clear any unprocessed configuration errors */	(void) fr_strerror();	return 0;}
开发者ID:kzorba,项目名称:freeradius-server,代码行数:101,


示例11: fr_ldap_directory_alloc

/** Extract useful information from the rootDSE of the LDAP server * * @param[in] ctx	to allocate fr_ldap_directory_t in. * @param[out] out	where to write pointer to new fr_ldap_directory_t struct. * @param[in,out] pconn	connection for querying the directory. * @return *	- 0 on success. *	- 1 if we failed identifying the directory server. *	- -1 on error. */int fr_ldap_directory_alloc(TALLOC_CTX *ctx, fr_ldap_directory_t **out, fr_ldap_connection_t **pconn){	static char const	*attrs[] = { "vendorname",					     "vendorversion",					     "isGlobalCatalogReady",					     "objectClass",					     "orcldirectoryversion",					     NULL };	fr_ldap_rcode_t		status;	int			entry_cnt;	int			ldap_errno;	int			i, num;	int			rcode = 0;	struct			berval **values = NULL;	fr_ldap_directory_t	*directory;	LDAPMessage *result = NULL, *entry;	*out = NULL;	directory = talloc_zero(ctx, fr_ldap_directory_t);	if (!directory) return -2;	*out = directory;	directory->type = FR_LDAP_DIRECTORY_UNKNOWN;	status = fr_ldap_search(&result, NULL, pconn, "", LDAP_SCOPE_BASE, "(objectclass=*)",				attrs, NULL, NULL);	switch (status) {	case LDAP_PROC_SUCCESS:		break;	case LDAP_PROC_NO_RESULT:		WARN("Capability check failed: Can't access rootDSE");		rcode = 1;		goto finish;	default:		rcode = 1;		goto finish;	}	entry_cnt = ldap_count_entries((*pconn)->handle, result);	if (entry_cnt != 1) {		WARN("Capability check failed: Ambiguous result for rootDSE, expected 1 entry, got %i", entry_cnt);		rcode = 1;		goto finish;	}	entry = ldap_first_entry((*pconn)->handle, result);	if (!entry) {		ldap_get_option((*pconn)->handle, LDAP_OPT_RESULT_CODE, &ldap_errno);		WARN("Capability check failed: Failed retrieving entry: %s", ldap_err2string(ldap_errno));		rcode = 1;		goto finish;	}	values = ldap_get_values_len((*pconn)->handle, entry, "vendorname");	if (values) {		directory->vendor_str = fr_ldap_berval_to_string(directory, values[0]);		INFO("Directory vendor: %s", directory->vendor_str);		ldap_value_free_len(values);	}	values = ldap_get_values_len((*pconn)->handle, entry, "vendorversion");	if (values) {		directory->version_str = fr_ldap_berval_to_string(directory, values[0]);		INFO("Directory version: %s", directory->version_str);		ldap_value_free_len(values);	}	if (directory->vendor_str) {		if (strcasestr(directory->vendor_str, "International Business Machines")) {			directory->type = FR_LDAP_DIRECTORY_EDIRECTORY;		}		goto found;	}	if (directory->version_str) {		/*		 *	Novell eDirectory vendorversion contains eDirectory		 */		if (strcasestr(directory->version_str, "eDirectory")) {			directory->type = FR_LDAP_DIRECTORY_EDIRECTORY;		/*		 *	Oracle unified directory vendorversion contains Oracle Unified Directory//.........这里部分代码省略.........
开发者ID:FreeRADIUS,项目名称:freeradius-server,代码行数:101,


示例12: sql_socket_init

/************************************************************************* * *	Function: sql_create_socket * *	Purpose: Establish connection to the db * *************************************************************************/static int sql_socket_init(rlm_sql_handle_t *handle, rlm_sql_config_t *config){	rlm_sql_mysql_conn_t *conn;	unsigned long sql_flags;	MEM(conn = handle->conn = talloc_zero(handle, rlm_sql_mysql_conn_t));	talloc_set_destructor((void *) conn, sql_socket_destructor);	DEBUG("rlm_sql_mysql: Starting connect to MySQL server");	mysql_init(&(conn->db));	mysql_options(&(conn->db), MYSQL_READ_DEFAULT_GROUP, "freeradius");#if (MYSQL_VERSION_ID >= 50000)	if (config->query_timeout) {		unsigned int timeout = config->query_timeout;		/*		 *	3 retries are hard-coded into the MySQL library.		 *	We ensure that the REAL timeout is what the user		 *	set by accounting for that.		 */		if (timeout > 3) timeout /= 3;		mysql_options(&(conn->db), MYSQL_OPT_CONNECT_TIMEOUT,			      &timeout);		mysql_options(&(conn->db), MYSQL_OPT_READ_TIMEOUT,			      &timeout);		mysql_options(&(conn->db), MYSQL_OPT_WRITE_TIMEOUT,			      &timeout);	}#endif#if (MYSQL_VERSION_ID >= 40100)	sql_flags = CLIENT_MULTI_RESULTS | CLIENT_FOUND_ROWS;#else	sql_flags = CLIENT_FOUND_ROWS;#endif#ifdef CLIENT_MULTI_STATEMENTS	sql_flags |= CLIENT_MULTI_STATEMENTS;#endif	conn->sock = mysql_real_connect(&(conn->db),					config->sql_server,					config->sql_login,					config->sql_password,					config->sql_db,					atoi(config->sql_port),					NULL,					sql_flags);	if (!conn->sock) {		radlog(L_ERR, "rlm_sql_mysql: Couldn't connect socket to MySQL "		       "server %[email
C++ talloc_zero_array函数代码示例
C++ talloc_unlink函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。