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


C++ p_strdup函数代码示例

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


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

示例1: lmtp_client_add_rcpt

void lmtp_client_add_rcpt(struct lmtp_client *client, const char *address,
			  lmtp_callback_t *rcpt_to_callback,
			  lmtp_callback_t *data_callback, void *context)
{
	struct lmtp_rcpt *rcpt;

	rcpt = array_append_space(&client->recipients);
	rcpt->address = p_strdup(client->pool, address);
	rcpt->rcpt_to_callback = rcpt_to_callback;
	rcpt->data_callback = data_callback;
	rcpt->context = context;

	if (client->global_fail_string != NULL) {
		client->rcpt_next_receive_idx++;
		i_assert(client->rcpt_next_receive_idx ==
			 array_count(&client->recipients));

		rcpt->failed = TRUE;
		rcpt_to_callback(FALSE, client->global_fail_string, context);
	} else if (client->input_state == LMTP_INPUT_STATE_RCPT_TO)
		lmtp_client_send_rcpts(client);
}
开发者ID:dhultin,项目名称:dovecot-pop-uidl-proxy,代码行数:22,代码来源:lmtp-client.c

示例2: user_callback

static bool user_callback(const char *reply, void *context)
{
	struct auth_request *request = context;
	enum userdb_result result;
	const char *username, *args;

	if (str_begins(reply, "FAIL\t")) {
		result = USERDB_RESULT_INTERNAL_FAILURE;
		args = reply + 5;
	} else if (str_begins(reply, "NOTFOUND\t")) {
		result = USERDB_RESULT_USER_UNKNOWN;
		args = reply + 9;
	} else if (str_begins(reply, "OK\t")) {
		result = USERDB_RESULT_OK;
		username = reply + 3;
		args = strchr(username, '\t');
		if (args == NULL)
			args = "";
		else
			username = t_strdup_until(username, args++);
		if (username[0] != '\0' && strcmp(request->user, username) != 0)
			request->user = p_strdup(request->pool, username);
	} else {
		result = USERDB_RESULT_INTERNAL_FAILURE;
		i_error("BUG: auth-worker sent invalid user reply");
		args = "";
	}

	if (*args != '\0') {
		auth_fields_import(request->userdb_reply, args, 0);
		if (auth_fields_exists(request->userdb_reply, "tempfail"))
			request->userdb_lookup_tempfailed = TRUE;
	}

        auth_request_userdb_callback(result, request);
	auth_request_unref(&request);
	return TRUE;
}
开发者ID:zatsepin,项目名称:core,代码行数:38,代码来源:userdb-blocking.c

示例3: passwd_file_preinit

static struct userdb_module *
passwd_file_preinit(pool_t pool, const char *args)
{
    struct passwd_file_userdb_module *module;
    const char *format = PASSWD_FILE_DEFAULT_USERNAME_FORMAT;
    const char *p;

    if (strncmp(args, "username_format=", 16) == 0) {
        args += 16;
        p = strchr(args, ' ');
        if (p == NULL) {
            format = p_strdup(pool, args);
            args = "";
        } else {
            format = p_strdup_until(pool, args, p);
            args = p + 1;
        }
    }

    if (*args == '\0')
        i_fatal("userdb passwd-file: Missing args");

    module = p_new(pool, struct passwd_file_userdb_module, 1);
    module->pwf = db_passwd_file_init(args, TRUE,
                                      global_auth_settings->debug);
    module->username_format = format;

    if (!module->pwf->vars)
        module->module.cache_key = PASSWD_FILE_CACHE_KEY;
    else {
        module->module.cache_key =
            auth_cache_parse_key(pool,
                                 t_strconcat(PASSWD_FILE_CACHE_KEY,
                                             module->pwf->path,
                                             NULL));
    }
    return &module->module;
}
开发者ID:bdraco,项目名称:dovecot,代码行数:38,代码来源:userdb-passwd-file.c

示例4: ldap_bind_lookup_dn_callback

static void ldap_bind_lookup_dn_callback(struct ldap_connection *conn,
					 struct ldap_request *ldap_request,
					 LDAPMessage *res)
{
	struct passdb_ldap_request *passdb_ldap_request =
		(struct passdb_ldap_request *)ldap_request;
	struct auth_request *auth_request = ldap_request->auth_request;
	struct ldap_request_bind *brequest;
	char *dn;

	if (res != NULL && ldap_msgtype(res) == LDAP_RES_SEARCH_ENTRY) {
		if (passdb_ldap_request->entries++ > 0) {
			/* too many replies */
			return;
		}

		/* first entry */
		ldap_query_save_result(conn, auth_request,
				       &passdb_ldap_request->request.search, res);

		/* save dn */
		dn = ldap_get_dn(conn->ld, res);
		passdb_ldap_request->dn = p_strdup(auth_request->pool, dn);
		ldap_memfree(dn);
	} else if (res == NULL || passdb_ldap_request->entries != 1) {
		/* failure */
		ldap_bind_lookup_dn_fail(auth_request, passdb_ldap_request, res);
	} else {
		/* convert search request to bind request */
		brequest = &passdb_ldap_request->request.bind;
		memset(brequest, 0, sizeof(*brequest));
		brequest->request.type = LDAP_REQUEST_TYPE_BIND;
		brequest->request.auth_request = auth_request;
		brequest->dn = passdb_ldap_request->dn;

		ldap_auth_bind(conn, brequest);
	}
}
开发者ID:Distrotech,项目名称:dovecot,代码行数:38,代码来源:passdb-ldap.c

示例5: client_read_args

bool client_read_args(struct client_command_context *cmd, unsigned int count,
		      unsigned int flags, const struct imap_arg **args_r)
{
	string_t *str;
	int ret;

	i_assert(count <= INT_MAX);

	ret = imap_parser_read_args(cmd->parser, count, flags, args_r);
	if (ret >= (int)count) {
		/* all parameters read successfully */
		i_assert(cmd->client->input_lock == NULL ||
			 cmd->client->input_lock == cmd);

		str = t_str_new(256);
		imap_write_args(str, *args_r);
		cmd->args = p_strdup(cmd->pool, str_c(str));
		cmd->start_time = ioloop_timeval;
		cmd->start_ioloop_wait_usecs =
			io_loop_get_wait_usecs(current_ioloop);

		cmd->client->input_lock = NULL;
		return TRUE;
	} else if (ret == -2) {
		/* need more data */
		if (cmd->client->input->closed) {
			/* disconnected */
			cmd->state = CLIENT_COMMAND_STATE_DONE;
		}
		return FALSE;
	} else {
		/* error, or missing arguments */
		client_send_command_error(cmd, ret < 0 ? NULL :
					  "Missing arguments");
		return FALSE;
	}
}
开发者ID:Dexus,项目名称:ubuntu-trusty-dovecot,代码行数:37,代码来源:imap-client.c

示例6: sieve_setting_get

static void ext_editheader_config_headers
(struct sieve_instance *svinst,
	struct ext_editheader_config *ext_config,
	const char *setting, bool forbid_add, bool forbid_delete)
{
	const char *setval;

	setval = sieve_setting_get(svinst, setting);
	if ( setval != NULL ) {
		const char **headers = t_strsplit_spaces(setval, " \t");

		while ( *headers != NULL ) {
			struct ext_editheader_header *header;

			if ( !rfc2822_header_field_name_verify
				(*headers, strlen(*headers)) ) {
				sieve_sys_warning(svinst, "editheader: "
					"setting %s contains invalid header field name "
					"`%s' (ignored)", setting, *headers);
				continue;
			}

			header=ext_editheader_config_header_find(ext_config, *headers);
			if ( header == NULL ) {
				header = array_append_space(&ext_config->headers);
				header->name = p_strdup(ext_config->pool, *headers);
			}

			if (forbid_add)
				header->forbid_add = TRUE;
			if (forbid_delete)
				header->forbid_delete = TRUE;

			headers++;
		}
	}
}
开发者ID:Dexus,项目名称:ubuntu-trusty-dovecot,代码行数:37,代码来源:ext-editheader-common.c

示例7: acllist_append

static int
acllist_append(struct acl_backend_vfile *backend, struct ostream *output,
	       const char *vname)
{
	struct acl_object *aclobj;
	struct acl_object_list_iter *iter;
	struct acl_rights rights;
	struct acl_backend_vfile_acllist acllist;
	const char *name;
	int ret;

	name = mail_namespace_get_storage_name(backend->backend.list->ns,
					       vname);
	acl_cache_flush(backend->backend.cache, name);
	aclobj = acl_object_init_from_name(&backend->backend, name);

	iter = acl_object_list_init(aclobj);
	while ((ret = acl_object_list_next(iter, &rights)) > 0) {
		if (acl_rights_has_nonowner_lookup_changes(&rights))
			break;
	}
	acl_object_list_deinit(&iter);

	if (acl_backend_vfile_object_get_mtime(aclobj, &acllist.mtime) < 0)
		ret = -1;

	if (ret > 0) {
		acllist.name = p_strdup(backend->acllist_pool, name);
		array_append(&backend->acllist, &acllist, 1);

		T_BEGIN {
			const char *line;
			line = t_strdup_printf("%s %s\n",
					       dec2str(acllist.mtime), name);
			o_stream_send_str(output, line);
		} T_END;
	}
开发者ID:aosm,项目名称:dovecot,代码行数:37,代码来源:acl-backend-vfile-acllist.c

示例8: cmd_copy_init

static void cmd_copy_init(struct doveadm_mail_cmd_context *_ctx,
			  const char *const args[])
{
	struct copy_cmd_context *ctx = (struct copy_cmd_context *)_ctx;
	const char *destname = args[0], *cmdname = ctx->move ? "move" : "copy";

	if (destname == NULL || args[1] == NULL)
		doveadm_mail_help_name(cmdname);
	args++;

	if (args[0] != NULL && args[1] != NULL &&
	    strcasecmp(args[0], "user") == 0) {
		if ((_ctx->service_flags &
		     MAIL_STORAGE_SERVICE_FLAG_USERDB_LOOKUP) == 0)
			i_fatal("Use -u parameter to specify destination user");

		cmd_copy_alloc_source_user(ctx, args[1]);
		args += 2;
	}

	ctx->destname = p_strdup(ctx->ctx.pool, destname);
	_ctx->search_args = doveadm_mail_build_search_args(args);
	expunge_search_args_check(ctx->ctx.search_args, cmdname);
}
开发者ID:Distrotech,项目名称:dovecot,代码行数:24,代码来源:doveadm-mail-copymove.c

示例9: mail_search_build

int mail_search_build(struct mail_search_register *reg,
		      struct mail_search_parser *parser, const char *charset,
		      struct mail_search_args **args_r, const char **error_r)
{
        struct mail_search_build_context ctx;
	struct mail_search_args *args;
	struct mail_search_arg *root;

	*args_r = NULL;
	*error_r = NULL;

	args = mail_search_build_init();
	args->charset = p_strdup(args->pool, charset);

	memset(&ctx, 0, sizeof(ctx));
	ctx.pool = args->pool;
	ctx.reg = reg;
	ctx.parser = parser;

	if (mail_search_build_list(&ctx, &root) < 0) {
		*error_r = ctx._error != NULL ? t_strdup(ctx._error) :
			t_strdup(mail_search_parser_get_error(parser));
		pool_unref(&args->pool);
		return -1;
	}

	if (root->type == SEARCH_SUB && !root->not) {
		/* simple SUB root */
		args->args = root->value.subargs;
	} else {
		args->args = root;
	}

	*args_r = args;
	return 0;
}
开发者ID:via,项目名称:dovecot-clouddb,代码行数:36,代码来源:mail-search-build.c

示例10: get_body_human_name

static const char *
get_body_human_name(pool_t pool, struct imap_fetch_body_data *body)
{
	string_t *str;
	uoff_t partial_offset, partial_size;

	str = t_str_new(64);
	if (body->binary)
		str_append(str, "BINARY[");
	else
		str_append(str, "BODY[");
	str_append(str, body->section);
	str_append_c(str, ']');

	partial_offset = imap_msgpart_get_partial_offset(body->msgpart);
	partial_size = imap_msgpart_get_partial_size(body->msgpart);
	if (partial_offset != 0 || partial_size != (uoff_t)-1) {
		str_printfa(str, "<%"PRIuUOFF_T, partial_offset);
		if (partial_size != (uoff_t)-1)
			str_printfa(str, ".%"PRIuUOFF_T, partial_size);
		str_append_c(str, '>');
	}
	return p_strdup(pool, str_c(str));
}
开发者ID:bsmr-dovecot,项目名称:core,代码行数:24,代码来源:imap-fetch-body.c

示例11: auth_fields_add

void auth_fields_add(struct auth_fields *fields,
		     const char *key, const char *value,
		     enum auth_field_flags flags)
{
	struct auth_field *field;
	unsigned int idx;

	i_assert(*key != '\0');
	i_assert(strchr(key, '\t') == NULL &&
		 strchr(key, '\n') == NULL);

	if (!auth_fields_find_idx(fields, key, &idx)) {
		if (!array_is_created(&fields->fields))
			p_array_init(&fields->fields, fields->pool, 16);

		field = array_append_space(&fields->fields);
		field->key = p_strdup(fields->pool, key);
	} else {
		auth_fields_snapshot_preserve(fields);
		field = array_idx_modifiable(&fields->fields, idx);
	}
	field->value = p_strdup_empty(fields->pool, value);
	field->flags = flags | AUTH_FIELD_FLAG_CHANGED;
}
开发者ID:dhultin,项目名称:dovecot-pop-uidl-proxy,代码行数:24,代码来源:auth-fields.c

示例12: lmtp_client_set_data_header

void lmtp_client_set_data_header(struct lmtp_client *client, const char *str)
{
	client->data_header = p_strdup(client->pool, str);
}
开发者ID:jkerihuel,项目名称:dovecot,代码行数:4,代码来源:lmtp-client.c

示例13: client_create

struct client *
client_create(int fd, bool ssl, pool_t pool,
	      const struct master_service_connection *conn,
	      const struct login_settings *set,
	      const struct master_service_ssl_settings *ssl_set,
	      void **other_sets)
{
	struct client *client;

	i_assert(fd != -1);

	client = login_binary->client_vfuncs->alloc(pool);
	client->v = *login_binary->client_vfuncs;
	if (client->v.auth_send_challenge == NULL)
		client->v.auth_send_challenge = client_auth_send_challenge;
	if (client->v.auth_parse_response == NULL)
		client->v.auth_parse_response = client_auth_parse_response;

	client->created = ioloop_time;
	client->refcount = 1;

	client->pool = pool;
	client->set = set;
	client->ssl_set = ssl_set;
	p_array_init(&client->module_contexts, client->pool, 5);

	client->fd = fd;
	client->tls = ssl;

	client->local_ip = conn->local_ip;
	client->local_port = conn->local_port;
	client->ip = conn->remote_ip;
	client->remote_port = conn->remote_port;
	client->real_local_ip = conn->real_local_ip;
	client->real_local_port = conn->real_local_port;
	client->real_remote_ip = conn->real_remote_ip;
	client->real_remote_port = conn->real_remote_port;
	client->listener_name = p_strdup(client->pool, conn->name);

	client->trusted = client_is_trusted(client);
	client->secured = ssl || client->trusted ||
		net_ip_compare(&conn->real_remote_ip, &conn->real_local_ip);
	client->proxy_ttl = LOGIN_PROXY_TTL;

	if (last_client == NULL)
		last_client = client;
	DLLIST_PREPEND(&clients, client);
	clients_count++;

	client->to_disconnect =
		timeout_add(CLIENT_LOGIN_TIMEOUT_MSECS,
			    client_idle_disconnect_timeout, client);
	client_open_streams(client);

	hook_client_allocated(client);
	client->v.create(client, other_sets);

	if (auth_client_is_connected(auth_client))
		client_notify_auth_ready(client);
	else
		client_set_auth_waiting(client);

	login_refresh_proctitle();
	return client;
}
开发者ID:aclindsa,项目名称:dovecot_core,代码行数:65,代码来源:client-common.c

示例14: test_parse_header_line

static bool
test_parse_header_line(struct test_parser *parser, struct test *test,
		       const char *line, const char **error_r)
{
	struct test_connection *test_conn;
	const char *key, *value;
	unsigned int idx;

	value = strchr(line, ':');
	if (value == NULL) {
		*error_r = "Missing ':'";
		return FALSE;
	}

	for (key = value; key[-1] == ' '; key--) ;
	key = t_str_lcase(t_strdup_until(line, key));
	for (value++; *value == ' '; value++) ;

	if (strcmp(key, "capabilities") == 0) {
		test->required_capabilities = (const char *const *)
			p_strsplit_spaces(parser->pool, value, " ");
		return TRUE;
	}
	if (strcmp(key, "connections") == 0) {
		test->connection_count = strcmp(value, "n") == 0 ? 2 :
			strtoul(value, NULL, 10);
		return TRUE;
	}
	if (strncmp(key, "user ", 5) == 0 &&
	    str_to_uint(key+5, &idx) == 0 && idx != 0) {
		/* FIXME: kludgy kludgy */
		if (strcmp(value, "$user2") == 0 ||
		    strcmp(value, "${user2}") == 0) {
			test->require_user2 = TRUE;
			value = conf.username2_template;
		}
		test_conn = array_idx_modifiable(&test->connections, idx-1);
		test_conn->username = p_strdup(parser->pool, value);
		return TRUE;
	}
	if (strcmp(key, "messages") == 0) {
		test->message_count = strcmp(value, "all") == 0 ? UINT_MAX :
			strtoul(value, NULL, 10);
		return TRUE;
	}
	if (strcmp(key, "state") == 0) {
		if (strcasecmp(value, "nonauth") == 0)
			test->startup_state = TEST_STARTUP_STATE_NONAUTH;
		else if (strcasecmp(value, "auth") == 0)
			test->startup_state = TEST_STARTUP_STATE_DELETED;
		else if (strcasecmp(value, "created") == 0)
			test->startup_state = TEST_STARTUP_STATE_CREATED;
		else if (strcasecmp(value, "appended") == 0)
			test->startup_state = TEST_STARTUP_STATE_APPENDED;
		else if (strcasecmp(value, "selected") == 0)
			test->startup_state = TEST_STARTUP_STATE_SELECTED;
		else {
			*error_r = "Unknown state value";
			return FALSE;
		}
		return TRUE;
	}

	*error_r = "Unknown setting";
	return FALSE;
}
开发者ID:dovecot,项目名称:imaptest,代码行数:66,代码来源:test-parser.c

示例15: maildir_storage_create

    storage->storage = maildir_storage;
    storage->storage.pool = pool;
    return &storage->storage;
}

static int
maildir_storage_create(struct mail_storage *_storage, struct mail_namespace *ns,
                       const char **error_r ATTR_UNUSED)
{
    struct maildir_storage *storage = (struct maildir_storage *)_storage;
    struct mailbox_list *list = ns->list;
    const char *dir;

    storage->set = mail_storage_get_driver_settings(_storage);

    storage->temp_prefix = p_strdup(_storage->pool,
                                    mailbox_list_get_temp_prefix(list));

    if (list->set.control_dir == NULL && list->set.inbox_path == NULL &&
            (ns->flags & NAMESPACE_FLAG_INBOX_ANY) != 0) {
        /* put the temp files into tmp/ directory preferrably */
        storage->temp_prefix = p_strconcat(_storage->pool, "tmp/",
                                           storage->temp_prefix, NULL);
        dir = mailbox_list_get_root_forced(list, MAILBOX_LIST_PATH_TYPE_DIR);
    } else {
        /* control dir should also be writable */
        dir = mailbox_list_get_root_forced(list, MAILBOX_LIST_PATH_TYPE_CONTROL);
    }
    _storage->temp_path_prefix = p_strconcat(_storage->pool, dir, "/",
                                 storage->temp_prefix, NULL);
    return 0;
}
开发者ID:jwm,项目名称:dovecot-notmuch,代码行数:32,代码来源:maildir-storage.c


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