本文整理汇总了C++中i_unreached函数的典型用法代码示例。如果您正苦于以下问题:C++ i_unreached函数的具体用法?C++ i_unreached怎么用?C++ i_unreached使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了i_unreached函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ldap_connect_next_message
static int
ldap_connect_next_message(struct ldap_connection *conn,
struct ldap_op_queue_entry *req, bool *finished_r)
{
int ret;
*finished_r = TRUE;
switch(conn->state) {
case LDAP_STATE_DISCONNECT:
/* if we should not disable SSL, and the URI is not ldaps:// */
if (!conn->set.start_tls || strstr(conn->set.uri, "ldaps://") == NULL) {
ret = ldap_start_tls(conn->conn, NULL, NULL, &(req->msgid));
if (ret != LDAP_SUCCESS) {
ldap_connection_result_failure(conn, req, ret, t_strdup_printf(
"ldap_start_tls(uri=%s) failed: %s",
conn->set.uri, ldap_err2string(ret)));
return ret;
}
conn->state = LDAP_STATE_TLS;
break;
} else {
conn->state = LDAP_STATE_AUTH;
/* we let it slide intentionally to next case */
}
case LDAP_STATE_AUTH:
ret = ldap_sasl_bind(conn->conn,
conn->set.bind_dn,
LDAP_SASL_SIMPLE,
&(conn->cred),
NULL,
NULL,
&(req->msgid));
if (ret != LDAP_SUCCESS) {
ldap_connection_result_failure(conn, req, ret, t_strdup_printf(
"ldap_sasl_bind(uri=%s, dn=%s) failed: %s",
conn->set.uri, conn->set.bind_dn, ldap_err2string(ret)));
return ret;
}
break;
case LDAP_STATE_CONNECT:
ldap_connection_result_success(conn, req);
return LDAP_SUCCESS; /* we are done here */
default:
i_unreached();
};
req->conn = conn;
*finished_r = FALSE;
return LDAP_SUCCESS;
}
示例2: stats_carbon_send
int
stats_carbon_send(const char *endpoint, const char *data,
void (*callback)(void *), void *cb_ctx,
struct stats_send_ctx **ctx_r)
{
const char *host;
in_port_t port;
struct ip_addr ip;
if (net_str2hostport(endpoint, CARBON_SERVER_DEFAULT_PORT,
&host, &port) < 0 ||
net_addr2ip(host, &ip) < 0) {
i_error("stats_submit: Cannot parse endpoint '%s'",
endpoint);
return -1;
}
pool_t pool = pool_alloconly_create("stats carbon send", 1024);
struct stats_send_ctx *ctx = p_new(pool,
struct stats_send_ctx, 1);
ctx->pool = pool;
ctx->str = p_strdup(ctx->pool, data);
ctx->fd = net_connect_ip(&ip, port, NULL);
if (ctx->fd < 0) {
i_error("connect(%s) failed: %m", endpoint);
stats_carbon_callback(ctx);
return -1;
}
ctx->io = io_add(ctx->fd, IO_WRITE,
stats_carbon_connected,
ctx);
/* give time for almost until next update
this is to ensure we leave a little pause between
attempts. Multiplier 800 gives us 20% window, and
ensures the number stays positive. */
ctx->to_msecs = stats_settings->carbon_interval*800;
ctx->to = timeout_add(ctx->to_msecs,
stats_carbon_timeout,
ctx);
if (net_ipport2str(&ip, port, &host) < 0)
i_unreached();
ctx->endpoint = p_strdup(ctx->pool, host);
ctx->callback = callback;
ctx->ctx = cb_ctx;
*ctx_r = ctx;
return 0;
}
示例3: o_stream_lzma_send_flush
static int o_stream_lzma_send_flush(struct lzma_ostream *zstream)
{
lzma_stream *zs = &zstream->strm;
unsigned int len;
bool done = FALSE;
int ret;
if (zs->avail_in != 0) {
i_assert(zstream->ostream.ostream.last_failed_errno != 0);
zstream->ostream.ostream.stream_errno =
zstream->ostream.ostream.last_failed_errno;
return -1;
}
if (zstream->flushed)
return 0;
if ((ret = o_stream_zlib_send_outbuf(zstream)) <= 0)
return ret;
i_assert(zstream->outbuf_used == 0);
do {
len = sizeof(zstream->outbuf) - zs->avail_out;
if (len != 0) {
zs->next_out = zstream->outbuf;
zs->avail_out = sizeof(zstream->outbuf);
zstream->outbuf_used = len;
if ((ret = o_stream_zlib_send_outbuf(zstream)) <= 0)
return ret;
if (done)
break;
}
ret = lzma_code(zs, LZMA_FINISH);
switch (ret) {
case LZMA_STREAM_END:
done = TRUE;
break;
case LZMA_MEM_ERROR:
i_fatal_status(FATAL_OUTOFMEM,
"lzma.write(%s): Out of memory",
o_stream_get_name(&zstream->ostream.ostream));
default:
i_unreached();
}
} while (zs->avail_out != sizeof(zstream->outbuf));
zstream->flushed = TRUE;
return 0;
}
示例4: o_stream_bzlib_send_flush
static int o_stream_bzlib_send_flush(struct bzlib_ostream *zstream)
{
bz_stream *zs = &zstream->zs;
unsigned int len;
bool done = FALSE;
int ret;
if (zs->avail_in != 0) {
i_assert(zstream->ostream.ostream.last_failed_errno != 0);
zstream->ostream.ostream.stream_errno =
zstream->ostream.ostream.last_failed_errno;
return -1;
}
if (zstream->flushed)
return 0;
if ((ret = o_stream_flush_parent_if_needed(&zstream->ostream)) <= 0)
return ret;
if ((ret = o_stream_zlib_send_outbuf(zstream)) <= 0)
return ret;
i_assert(zstream->outbuf_used == 0);
do {
len = sizeof(zstream->outbuf) - zs->avail_out;
if (len != 0) {
zs->next_out = zstream->outbuf;
zs->avail_out = sizeof(zstream->outbuf);
zstream->outbuf_used = len;
if ((ret = o_stream_zlib_send_outbuf(zstream)) <= 0)
return ret;
if (done)
break;
}
ret = BZ2_bzCompress(zs, BZ_FINISH);
switch (ret) {
case BZ_STREAM_END:
done = TRUE;
break;
case BZ_FINISH_OK:
break;
default:
i_unreached();
}
} while (zs->avail_out != sizeof(zstream->outbuf));
zstream->flushed = TRUE;
return 0;
}
示例5: pkcs5_pbkdf
int pkcs5_pbkdf(enum pkcs5_pbkdf_mode mode, const struct hash_method *hash,
const unsigned char *password, size_t password_len,
const unsigned char *salt, size_t salt_len,
unsigned int iterations, uint32_t dk_len,
buffer_t *result)
{
if (mode == PKCS5_PBKDF1)
return pkcs5_pbkdf1(hash,password,password_len,
salt,salt_len,iterations,dk_len,result);
else if (mode == PKCS5_PBKDF2)
return pkcs5_pbkdf2(hash,password,password_len,
salt,salt_len,iterations,dk_len,result);
i_unreached();
}
示例6: is_inbox_file
static bool
is_inbox_file(struct mailbox_list *list, const char *path, const char *fname)
{
const char *inbox_path;
if (strcasecmp(fname, "INBOX") != 0)
return FALSE;
if (mailbox_list_get_path(list, "INBOX",
MAILBOX_LIST_PATH_TYPE_MAILBOX,
&inbox_path) <= 0)
i_unreached();
return strcmp(inbox_path, path) == 0;
}
示例7: key_get_prefixed
static const char *
key_get_prefixed(enum mail_attribute_type type, const char *mailbox_prefix,
const char *key)
{
switch (type) {
case MAIL_ATTRIBUTE_TYPE_PRIVATE:
return t_strconcat(DICT_PATH_PRIVATE, mailbox_prefix, "/",
key, NULL);
case MAIL_ATTRIBUTE_TYPE_SHARED:
return t_strconcat(DICT_PATH_SHARED, mailbox_prefix, "/",
key, NULL);
}
i_unreached();
}
示例8: keywords_update_records
static int
keywords_update_records(struct mail_index_sync_map_ctx *ctx,
const struct mail_index_ext *ext,
unsigned int keyword_idx, enum modify_type type,
uint32_t uid1, uint32_t uid2)
{
struct mail_index_view *view = ctx->view;
struct mail_index_record *rec;
unsigned char *data, data_mask;
unsigned int data_offset;
uint32_t seq1, seq2;
i_assert(keyword_idx != UINT_MAX);
if (!mail_index_lookup_seq_range(view, uid1, uid2, &seq1, &seq2))
return 1;
mail_index_modseq_update_keyword(ctx->modseq_ctx, keyword_idx,
seq1, seq2);
data_offset = keyword_idx / CHAR_BIT;
data_mask = 1 << (keyword_idx % CHAR_BIT);
i_assert(data_offset < ext->record_size);
data_offset += ext->record_offset;
i_assert(data_offset >= MAIL_INDEX_RECORD_MIN_SIZE);
switch (type) {
case MODIFY_ADD:
for (; seq1 <= seq2; seq1++) {
rec = MAIL_INDEX_REC_AT_SEQ(view->map, seq1);
data = PTR_OFFSET(rec, data_offset);
*data |= data_mask;
}
break;
case MODIFY_REMOVE:
data_mask = ~data_mask;
for (; seq1 <= seq2; seq1++) {
rec = MAIL_INDEX_REC_AT_SEQ(view->map, seq1);
data = PTR_OFFSET(rec, data_offset);
*data &= data_mask;
}
break;
default:
i_unreached();
}
return 1;
}
示例9: io_stream_remove_destroy_callback
void io_stream_remove_destroy_callback(struct iostream_private *stream,
void (*callback)(void *))
{
const struct iostream_destroy_callback *dcs;
unsigned int i, count;
dcs = array_get(&stream->destroy_callbacks, &count);
for (i = 0; i < count; i++) {
if (dcs[i].callback == callback) {
array_delete(&stream->destroy_callbacks, i, 1);
return;
}
}
i_unreached();
}
示例10: imap_zlib_client_skip_line
static void imap_zlib_client_skip_line(struct client *client)
{
const unsigned char *data;
size_t data_size;
data = i_stream_get_data(client->input, &data_size);
i_assert(data_size > 0);
if (data[0] == '\n')
i_stream_skip(client->input, 1);
else if (data[0] == '\r' && data_size > 1 && data[1] == '\n')
i_stream_skip(client->input, 2);
else
i_unreached();
client->input_skip_line = FALSE;
}
示例11: i_unreached
static bool cmd_test_imap_metadata_generate
(const struct sieve_codegen_env *cgenv, struct sieve_command *cmd)
{
/* Emit operation */
if ( sieve_command_is(cmd, cmd_test_imap_metadata_set) )
sieve_operation_emit
(cgenv->sblock, cmd->ext, &test_imap_metadata_set_operation);
else
i_unreached();
/* Generate arguments */
if ( !sieve_generate_arguments(cgenv, cmd, NULL) )
return FALSE;
return TRUE;
}
示例12: cmd_acl_get_right
static void cmd_acl_get_right(const struct acl_rights *rights)
{
const char *id = "";
string_t *str;
switch (rights->id_type) {
case ACL_ID_ANYONE:
id = ACL_ID_NAME_ANYONE;
break;
case ACL_ID_AUTHENTICATED:
id = ACL_ID_NAME_AUTHENTICATED;
break;
case ACL_ID_OWNER:
id = ACL_ID_NAME_OWNER;
break;
case ACL_ID_USER:
id = t_strconcat(ACL_ID_NAME_USER_PREFIX,
rights->identifier, NULL);
break;
case ACL_ID_GROUP:
id = t_strconcat(ACL_ID_NAME_GROUP_PREFIX,
rights->identifier, NULL);
break;
case ACL_ID_GROUP_OVERRIDE:
id = t_strconcat(ACL_ID_NAME_GROUP_OVERRIDE_PREFIX,
rights->identifier, NULL);
break;
case ACL_ID_TYPE_COUNT:
i_unreached();
}
doveadm_print(id);
if (rights->global)
doveadm_print("global");
else
doveadm_print("");
str = t_str_new(256);
if (rights->rights != NULL)
str_append(str, t_strarray_join(rights->rights, " "));
if (rights->neg_rights != NULL) {
if (str_len(str) > 0)
str_append_c(str, ' ');
str_append_c(str, '-');
str_append(str, t_strarray_join(rights->neg_rights, " -"));
}
doveadm_print(str_c(str));
}
示例13: index_mail_parse_bodystructure
static int index_mail_parse_bodystructure(struct index_mail *mail,
enum index_cache_field field)
{
struct index_mail_data *data = &mail->data;
string_t *str;
if (data->parsed_bodystructure) {
/* we have everything parsed already, but just not written to
a string */
index_mail_body_parsed_cache_bodystructure(mail, field);
} else {
if (data->save_bodystructure_header ||
!data->save_bodystructure_body) {
/* we haven't parsed the header yet */
data->save_bodystructure_header = TRUE;
data->save_bodystructure_body = TRUE;
(void)get_cached_parts(mail);
if (index_mail_parse_headers(mail, NULL) < 0)
return -1;
}
if (index_mail_parse_body(mail, field) < 0)
return -1;
}
i_assert(data->parts != NULL);
/* if we didn't want to have the body(structure) cached,
it's still not written. */
switch (field) {
case MAIL_CACHE_IMAP_BODY:
if (data->body == NULL) {
str = str_new(mail->data_pool, 128);
imap_bodystructure_write(data->parts, str, FALSE);
data->body = str_c(str);
}
break;
case MAIL_CACHE_IMAP_BODYSTRUCTURE:
if (data->bodystructure == NULL) {
str = str_new(mail->data_pool, 128);
imap_bodystructure_write(data->parts, str, TRUE);
data->bodystructure = str_c(str);
}
break;
default:
i_unreached();
}
return 0;
}
示例14: managesieve_parser_save_arg
static void managesieve_parser_save_arg(struct managesieve_parser *parser,
const unsigned char *data, size_t size)
{
struct managesieve_arg *arg;
arg = managesieve_arg_create(parser);
switch (parser->cur_type) {
case ARG_PARSE_ATOM:
/* simply save the string */
arg->type = MANAGESIEVE_ARG_ATOM;
arg->_data.str = p_strndup(parser->pool, data, size);
break;
case ARG_PARSE_STRING:
/* data is quoted and may contain escapes. */
i_assert(size > 0);
arg->type = MANAGESIEVE_ARG_STRING;
arg->_data.str = p_strndup(parser->pool, data+1, size-1);
/* remove the escapes */
if (parser->str_first_escape >= 0 &&
(parser->flags & MANAGESIEVE_PARSE_FLAG_NO_UNESCAPE) == 0) {
/* -1 because we skipped the '"' prefix */
str_unescape(arg->_data.str +
parser->str_first_escape-1);
}
break;
case ARG_PARSE_LITERAL_DATA:
if ((parser->flags & MANAGESIEVE_PARSE_FLAG_LITERAL_SIZE) != 0) {
/* save literal size */
arg->type = MANAGESIEVE_ARG_LITERAL_SIZE;
arg->_data.literal_size = parser->literal_size;
} else if ((parser->flags &
MANAGESIEVE_PARSE_FLAG_LITERAL_TYPE) != 0) {
arg->type = MANAGESIEVE_ARG_LITERAL;
arg->_data.str = p_strndup(parser->pool, data, size);
} else {
arg->type = MANAGESIEVE_ARG_STRING;
arg->_data.str = p_strndup(parser->pool, data, size);
}
break;
default:
i_unreached();
}
parser->cur_type = ARG_PARSE_NONE;
}
示例15: o_stream_zlib_send_flush
static int o_stream_zlib_send_flush(struct zlib_ostream *zstream)
{
z_stream *zs = &zstream->zs;
unsigned int len;
bool done = FALSE;
int ret;
i_assert(zs->avail_in == 0);
if (zstream->flushed)
return 0;
if (!zstream->header_sent)
o_stream_zlib_send_gz_header(zstream);
do {
len = sizeof(zstream->outbuf) - zs->avail_out;
if (len != 0) {
zs->next_out = zstream->outbuf;
zs->avail_out = sizeof(zstream->outbuf);
ret = o_stream_send(zstream->output,
zstream->outbuf, len);
if (ret != (int)len) {
zstream_copy_error(zstream);
return -1;
}
if (done)
break;
}
switch (deflate(zs, zstream->gz ? Z_FINISH : Z_SYNC_FLUSH)) {
case Z_OK:
case Z_BUF_ERROR:
break;
case Z_STREAM_END:
done = TRUE;
break;
default:
i_unreached();
}
} while (zs->avail_out != sizeof(zstream->outbuf));
if (o_stream_zlib_send_gz_trailer(zstream) < 0)
return -1;
zstream->flushed = TRUE;
return 0;
}