本文整理汇总了C++中p_strdup函数的典型用法代码示例。如果您正苦于以下问题:C++ p_strdup函数的具体用法?C++ p_strdup怎么用?C++ p_strdup使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了p_strdup函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: index_mail_get_special
int index_mail_get_special(struct mail *_mail,
enum mail_fetch_field field, const char **value_r)
{
struct index_mail *mail = (struct index_mail *)_mail;
struct index_mail_data *data = &mail->data;
struct mail_cache_field *cache_fields = mail->ibox->cache_fields;
string_t *str;
switch (field) {
case MAIL_FETCH_IMAP_BODY: {
unsigned int body_cache_field =
cache_fields[MAIL_CACHE_IMAP_BODY].idx;
unsigned int bodystructure_cache_field =
cache_fields[MAIL_CACHE_IMAP_BODYSTRUCTURE].idx;
if (data->body != NULL) {
*value_r = data->body;
return 0;
}
/* 1) use plain-7bit-ascii flag if it exists
2) get BODY if it exists
3) get it using BODYSTRUCTURE if it exists
4) parse body structure, and save BODY/BODYSTRUCTURE
depending on what we want cached */
str = str_new(mail->data_pool, 128);
if ((mail->data.cache_flags &
MAIL_CACHE_FLAG_TEXT_PLAIN_7BIT_ASCII) != 0 &&
get_cached_parts(mail)) {
index_mail_get_plain_bodystructure(mail, str, FALSE);
data->body = str_c(str);
} else if (index_mail_cache_lookup_field(mail, str,
body_cache_field) > 0)
data->body = str_c(str);
else if (index_mail_cache_lookup_field(mail, str,
bodystructure_cache_field) > 0) {
data->bodystructure =
p_strdup(mail->data_pool, str_c(str));
str_truncate(str, 0);
if (imap_body_parse_from_bodystructure(
data->bodystructure, str))
data->body = str_c(str);
else {
/* broken, continue.. */
mail_set_cache_corrupted(_mail,
MAIL_FETCH_IMAP_BODYSTRUCTURE);
}
}
if (data->body == NULL) {
str_free(&str);
if (index_mail_parse_bodystructure(mail,
MAIL_CACHE_IMAP_BODY) < 0)
return -1;
}
i_assert(data->body != NULL);
*value_r = data->body;
return 0;
}
case MAIL_FETCH_IMAP_BODYSTRUCTURE: {
unsigned int bodystructure_cache_field =
cache_fields[MAIL_CACHE_IMAP_BODYSTRUCTURE].idx;
if (data->bodystructure != NULL) {
*value_r = data->bodystructure;
return 0;
}
str = str_new(mail->data_pool, 128);
if ((mail->data.cache_flags &
MAIL_CACHE_FLAG_TEXT_PLAIN_7BIT_ASCII) != 0 &&
get_cached_parts(mail)) {
index_mail_get_plain_bodystructure(mail, str, TRUE);
data->bodystructure = str_c(str);
} else if (index_mail_cache_lookup_field(mail, str,
bodystructure_cache_field) > 0) {
data->bodystructure = str_c(str);
} else {
str_free(&str);
if (index_mail_parse_bodystructure(mail,
MAIL_CACHE_IMAP_BODYSTRUCTURE) < 0)
return -1;
}
i_assert(data->bodystructure != NULL);
*value_r = data->bodystructure;
return 0;
}
case MAIL_FETCH_IMAP_ENVELOPE:
if (data->envelope == NULL) {
if (index_mail_headers_get_envelope(mail) < 0)
return -1;
}
*value_r = data->envelope;
return 0;
case MAIL_FETCH_FROM_ENVELOPE:
case MAIL_FETCH_UIDL_FILE_NAME:
case MAIL_FETCH_UIDL_BACKEND:
case MAIL_FETCH_SEARCH_SCORE:
//.........这里部分代码省略.........
开发者ID:via,项目名称:dovecot-clouddb,代码行数:101,代码来源:index-mail.c
示例17: args_directive
}
return TRUE;
}
static void args_directive(struct list_directives_context *ctx,
ARRAY_TYPE(imap_arg_list) *args_arr,
const char *directive)
{
const struct imap_arg *nextarg;
struct imap_arg *arg;
nextarg = array_idx(args_arr, 0);
arg = array_insert_space(args_arr, 0);
arg->parent = nextarg->parent;
arg->type = IMAP_ARG_ATOM;
arg->_data.str = p_strdup(ctx->parser->pool, directive);
}
static void test_add_default_directives(struct list_directives_context *ctx,
ARRAY_TYPE(imap_arg_list) *args_arr)
{
if (ctx->parent == NULL)
return;
if (strcmp(ctx->reply_name, "list") == 0 ||
strcmp(ctx->reply_name, "lsub") == 0) {
if (ctx->parent->parent == NULL &&
ctx->parent->parent_chain_idx == 0 &&
ctx->parent_chain_idx == 1) {
/* list|lsub (flags) sep mailbox */
args_directive(ctx, args_arr, "$!unordered");
开发者ID:dovecot,项目名称:imaptest,代码行数:31,代码来源:test-parser.c
示例18: imap_fetch_binary_init
bool imap_fetch_binary_init(struct imap_fetch_init_context *ctx)
{
struct imap_fetch_body_data *body;
const struct imap_arg *list_args;
unsigned int list_count;
const char *str, *p, *error;
i_assert(strncmp(ctx->name, "BINARY", 6) == 0);
p = ctx->name + 6;
body = p_new(ctx->pool, struct imap_fetch_body_data, 1);
body->binary = TRUE;
if (strncmp(p, ".SIZE", 5) == 0) {
/* fetch decoded size of the section */
p += 5;
body->binary_size = TRUE;
} else if (strncmp(p, ".PEEK", 5) == 0) {
p += 5;
} else {
ctx->fetch_ctx->flags_update_seen = TRUE;
}
if (*p != '[') {
ctx->error = "Invalid BINARY[..] parameter: Missing '['";
return FALSE;
}
if (imap_arg_get_list_full(&ctx->args[0], &list_args, &list_count)) {
/* BINARY[HEADER.FIELDS.. (headers list)] */
if (!imap_arg_get_atom(&ctx->args[1], &str) ||
str[0] != ']') {
ctx->error = "Invalid BINARY[..] parameter: Missing ']'";
return FALSE;
}
if (body_header_fields_parse(ctx, body, p+1,
list_args, list_count) < 0)
return FALSE;
p = str+1;
ctx->args += 2;
} else {
/* no headers list */
body->section = p+1;
p = strchr(body->section, ']');
if (p == NULL) {
ctx->error = "Invalid BINARY[..] parameter: Missing ']'";
return FALSE;
}
body->section = p_strdup_until(ctx->pool, body->section, p);
p++;
}
if (imap_msgpart_parse(body->section, &body->msgpart) < 0) {
ctx->error = "Invalid BINARY[..] section";
return FALSE;
}
imap_msgpart_set_decode_to_binary(body->msgpart);
ctx->fetch_ctx->fetch_data |=
imap_msgpart_get_fetch_data(body->msgpart);
if (!body->binary_size) {
if (body_parse_partial(body, p, &error) < 0) {
ctx->error = p_strdup_printf(ctx->pool,
"Invalid BINARY[..] parameter: %s", error);
return FALSE;
}
}
/* update the section name for the imap_fetch_add_handler() */
ctx->name = p_strdup(ctx->pool, get_body_name(body));
if (body->binary_size) {
imap_fetch_add_handler(ctx, IMAP_FETCH_HANDLER_FLAG_WANT_DEINIT,
"0", fetch_binary_size, body);
} else {
imap_fetch_add_handler(ctx, IMAP_FETCH_HANDLER_FLAG_WANT_DEINIT,
"NIL", fetch_body_msgpart, body);
}
return TRUE;
}
开发者ID:bsmr-dovecot,项目名称:core,代码行数:77,代码来源:imap-fetch-body.c
示例19: dsync_connect_tcp
static int
dsync_connect_tcp(struct dsync_cmd_context *ctx,
const struct mail_storage_settings *mail_set,
const char *target, bool ssl, const char **error_r)
{
struct doveadm_server *server;
struct server_connection *conn;
struct ioloop *ioloop;
string_t *cmd;
const char *error;
server = p_new(ctx->ctx.pool, struct doveadm_server, 1);
server->name = p_strdup(ctx->ctx.pool, target);
if (ssl) {
if (dsync_init_ssl_ctx(ctx, mail_set, &error) < 0) {
*error_r = t_strdup_printf(
"Couldn't initialize SSL context: %s", error);
return -1;
}
server->ssl_ctx = ctx->ssl_ctx;
}
p_array_init(&server->connections, ctx->ctx.pool, 1);
p_array_init(&server->queue, ctx->ctx.pool, 1);
ioloop = io_loop_create();
if (server_connection_create(server, &conn) < 0) {
*error_r = "Couldn't create server connection";
return -1;
}
/* <flags> <username> <command> [<args>] */
cmd = t_str_new(256);
if (doveadm_debug)
str_append_c(cmd, 'D');
str_append_c(cmd, '\t');
str_append_tabescaped(cmd, ctx->ctx.cur_username);
str_append(cmd, "\tdsync-server\t-u");
str_append_tabescaped(cmd, ctx->ctx.cur_username);
if (ctx->replicator_notify)
str_append(cmd, "\t-U");
str_append_c(cmd, '\n');
ctx->tcp_conn = conn;
server_connection_cmd(conn, str_c(cmd),
dsync_connected_callback, ctx);
io_loop_run(ioloop);
ctx->tcp_conn = NULL;
if (array_count(&server->connections) > 0)
server_connection_destroy(&conn);
io_loop_destroy(&ioloop);
if (ctx->error != NULL) {
*error_r = ctx->error;
ctx->error = NULL;
return -1;
}
ctx->run_type = DSYNC_RUN_TYPE_STREAM;
return 0;
}
开发者ID:damoxc,项目名称:dovecot,代码行数:61,代码来源:doveadm-dsync.c
示例20: memset
char *auth_cache_parse_key(pool_t pool, const char *query)
{
string_t *str;
bool key_seen[AUTH_REQUEST_VAR_TAB_COUNT];
const char *extra_vars;
unsigned int i, idx, size, tab_idx;
memset(key_seen, 0, sizeof(key_seen));
str = t_str_new(32);
for (; *query != '\0'; ) {
if (*query != '%') {
query++;
continue;
}
var_get_key_range(++query, &idx, &size);
if (size == 0) {
/* broken %variable ending too early */
break;
}
query += idx;
if (!auth_request_var_expand_tab_find(query, size, &tab_idx)) {
/* just add the key. it would be nice to prevent
duplicates here as well, but that's just too
much trouble and probably very rare. */
auth_cache_key_add_var(str, query, size);
} else {
i_assert(tab_idx < N_ELEMENTS(key_seen));
key_seen[tab_idx] = TRUE;
}
query += size;
}
if (key_seen[AUTH_REQUEST_VAR_TAB_USERNAME_IDX] &&
key_seen[AUTH_REQUEST_VAR_TAB_DOMAIN_IDX]) {
/* %n and %d both used -> replace with %u */
key_seen[AUTH_REQUEST_VAR_TAB_USER_IDX] = TRUE;
key_seen[AUTH_REQUEST_VAR_TAB_USERNAME_IDX] = FALSE;
key_seen[AUTH_REQUEST_VAR_TAB_DOMAIN_IDX] = FALSE;
}
/* we rely on these being at the beginning */
i_assert(AUTH_REQUEST_VAR_TAB_USER_IDX == 0);
i_assert(AUTH_REQUEST_VAR_TAB_USERNAME_IDX == 1);
i_assert(AUTH_REQUEST_VAR_TAB_DOMAIN_IDX == 2);
extra_vars = t_strdup(str_c(str));
str_truncate(str, 0);
for (i = 0; i < N_ELEMENTS(key_seen); i++) {
if (key_seen[i])
auth_cache_key_add_tab_idx(str, i);
}
if (*extra_vars != '\0') {
if (str_len(str) > 0)
str_append_c(str, '\t');
str_append(str, extra_vars);
}
return p_strdup(pool, str_c(str));
}
开发者ID:jkerihuel,项目名称:dovecot,代码行数:63,代码来源:auth-cache.c
注:本文中的p_strdup函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论