本文整理汇总了C++中ARRAY_TYPE函数的典型用法代码示例。如果您正苦于以下问题:C++ ARRAY_TYPE函数的具体用法?C++ ARRAY_TYPE怎么用?C++ ARRAY_TYPE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ARRAY_TYPE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: get_metadata_cache_fields
static void
get_metadata_cache_fields(struct mailbox *box,
struct mailbox_metadata *metadata_r)
{
const struct mail_cache_field *fields;
enum mail_cache_decision_type dec;
ARRAY_TYPE(mailbox_cache_field) *cache_fields;
struct mailbox_cache_field *cf;
unsigned int i, count;
if (box->metadata_pool == NULL) {
box->metadata_pool =
pool_alloconly_create("mailbox metadata", 1024*3);
}
fields = mail_cache_register_get_list(box->cache,
box->metadata_pool, &count);
cache_fields = p_new(box->metadata_pool,
ARRAY_TYPE(mailbox_cache_field), 1);
p_array_init(cache_fields, box->metadata_pool, count);
for (i = 0; i < count; i++) {
dec = fields[i].decision & ~MAIL_CACHE_DECISION_FORCED;
if (dec != MAIL_CACHE_DECISION_NO) {
cf = array_append_space(cache_fields);
cf->name = fields[i].name;
cf->decision = fields[i].decision;
cf->last_used = fields[i].last_used;
}
}
metadata_r->cache_fields = cache_fields;
}
示例2: OPEN_ARRAY
void OCamlFGotoCodeGen::writeData()
{
if ( redFsm->anyToStateActions() ) {
OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), TSA() );
TO_STATE_ACTIONS();
CLOSE_ARRAY() <<
"\n";
}
if ( redFsm->anyFromStateActions() ) {
OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), FSA() );
FROM_STATE_ACTIONS();
CLOSE_ARRAY() <<
"\n";
}
if ( redFsm->anyEofActions() ) {
OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), EA() );
EOF_ACTIONS();
CLOSE_ARRAY() <<
"\n";
}
STATE_IDS();
out << "exception Goto_again" << TOP_SEP();
}
示例3: OPEN_ARRAY
void FGotoCodeGen::writeData()
{
if ( redFsm->anyToStateActions() ) {
OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), TSA() );
TO_STATE_ACTIONS();
CLOSE_ARRAY() <<
L"\n";
}
if ( redFsm->anyFromStateActions() ) {
OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), FSA() );
FROM_STATE_ACTIONS();
CLOSE_ARRAY() <<
L"\n";
}
if ( redFsm->anyEofActions() ) {
OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), EA() );
EOF_ACTIONS();
CLOSE_ARRAY() <<
L"\n";
}
STATE_IDS();
}
示例4: MAX
void CSharpTabCodeGen::initVarTypes()
{
int klenMax = MAX(MAX(redFsm->maxCondLen, redFsm->maxRangeLen),
redFsm->maxSingleLen);
int keysMax = MAX(MAX(redFsm->maxKeyOffset, klenMax),
redFsm->maxCondOffset);
int transMax = MAX(MAX(redFsm->maxIndex+1, redFsm->maxIndexOffset), keysMax);
transMax = MAX(transMax, klenMax);
transType = ARRAY_TYPE(transMax);
klenType = ARRAY_TYPE(klenMax);
keysType = ARRAY_TYPE(keysMax);
signedKeysType = ARRAY_TYPE(keysMax, true);
}
示例5: maildir_save_set_recent_flags
static uint32_t
maildir_save_set_recent_flags(struct maildir_save_context *ctx)
{
struct maildir_mailbox *mbox = ctx->mbox;
ARRAY_TYPE(seq_range) saved_sorted_uids;
const struct seq_range *uids;
unsigned int i, count;
uint32_t uid;
count = array_count(&ctx->ctx.transaction->changes->saved_uids);
if (count == 0)
return 0;
t_array_init(&saved_sorted_uids, count);
array_append_array(&saved_sorted_uids,
&ctx->ctx.transaction->changes->saved_uids);
array_sort(&saved_sorted_uids, seq_range_cmp);
uids = array_get(&saved_sorted_uids, &count);
for (i = 0; i < count; i++) {
for (uid = uids[i].seq1; uid <= uids[i].seq2; uid++)
mailbox_recent_flags_set_uid(&mbox->box, uid);
}
return uids[count-1].seq2 + 1;
}
示例6: virtual_mailbox_get_list_patterns
static void
virtual_mailbox_get_list_patterns(struct virtual_parse_context *ctx)
{
struct virtual_mailbox *mbox = ctx->mbox;
ARRAY_TYPE(mailbox_virtual_patterns) *dest;
struct mailbox_virtual_pattern pattern;
struct virtual_backend_box *const *bboxes;
unsigned int i, count;
memset(&pattern, 0, sizeof(pattern));
bboxes = array_get_modifiable(&mbox->backend_boxes, &count);
p_array_init(&mbox->list_include_patterns, ctx->pool, count);
p_array_init(&mbox->list_exclude_patterns, ctx->pool, count);
for (i = 0; i < count; i++) {
if (bboxes[i]->metadata_entry == NULL)
continue;
pattern.ns = bboxes[i]->ns;
pattern.pattern = bboxes[i]->name;
if (bboxes[i]->negative_match)
dest = &mbox->list_include_patterns;
else {
dest = &mbox->list_exclude_patterns;
pattern.pattern++;
}
array_append(dest, &pattern, 1);
}
}
示例7: ARRAY_TYPE
ARRAY_TYPE(imap_arg_list) *
test_parse_imap_args(pool_t pool, const char *line, unsigned int linelen,
const char **error_r)
{
struct imap_parser *imap_parser;
struct istream *input;
const struct imap_arg *args;
ARRAY_TYPE(imap_arg_list) *dup_args;
enum imap_parser_error fatal;
int ret;
input = i_stream_create_from_data(line, linelen);
imap_parser = imap_parser_create(input, NULL, (size_t)-1);
ret = imap_parser_finish_line(imap_parser, 0,
IMAP_PARSE_FLAG_LITERAL8 |
IMAP_PARSE_FLAG_LITERAL_TYPE |
IMAP_PARSE_FLAG_ATOM_ALLCHARS |
IMAP_PARSE_FLAG_MULTILINE_STR, &args);
if (ret < 0) {
dup_args = NULL;
if (ret == -2)
*error_r = "Missing data";
else {
*error_r = t_strdup(imap_parser_get_error(imap_parser,
&fatal));
}
} else {
dup_args = test_parse_imap_args_dup(pool, args);
}
imap_parser_unref(&imap_parser);
i_stream_unref(&input);
return dup_args;
}
示例8: env_clean_except_real
static void env_clean_except_real(const char *const preserve_envs[])
{
ARRAY_TYPE(const_string) copy;
const char *value, *const *envp;
unsigned int i;
t_array_init(©, 16);
for (i = 0; preserve_envs[i] != NULL; i++) {
const char *key = preserve_envs[i];
value = getenv(key);
if (value != NULL) {
value = t_strconcat(key, "=", value, NULL);
array_append(©, &value, 1);
}
}
/* Note that if the original environment was set with env_put(), the
environment strings will be invalid after env_clean(). That's why
we t_strconcat() them above. */
env_clean();
array_foreach(©, envp)
env_put(*envp);
}
示例9: test_seq_range_array_remove_nth
static void test_seq_range_array_remove_nth(void)
{
ARRAY_TYPE(seq_range) range;
const struct seq_range *r;
test_begin("seq_range_array_remove_nth()");
t_array_init(&range, 8);
seq_range_array_add_range(&range, 1, 5);
seq_range_array_add(&range, 7);
seq_range_array_add_range(&range, 10,20);
test_assert(array_count(&range) == 3);
seq_range_array_remove_nth(&range, 0, 2);
r = array_idx(&range, 0); test_assert(r->seq1 == 3 && r->seq2 == 5);
seq_range_array_remove_nth(&range, 1, 4);
r = array_idx(&range, 0); test_assert(r->seq1 == 3 && r->seq2 == 3);
r = array_idx(&range, 1); test_assert(r->seq1 == 11 && r->seq2 == 20);
seq_range_array_remove_nth(&range, 5, (uint32_t)-1);
r = array_idx(&range, 1); test_assert(r->seq1 == 11 && r->seq2 == 14);
test_assert(array_count(&range) == 2);
test_end();
}
示例10: cmd_deduplicate_uidlist
static int cmd_deduplicate_uidlist(struct mailbox *box, struct uidlist *uidlist)
{
struct mailbox_transaction_context *trans;
struct mail_search_context *search_ctx;
struct mail_search_args *search_args;
struct mail_search_arg *arg;
struct mail *mail;
ARRAY_TYPE(seq_range) uids;
int ret = 0;
/* the uidlist is reversed with oldest mails at the end.
we'll delete everything but the oldest mail. */
if (uidlist->next == NULL)
return 0;
t_array_init(&uids, 8);
for (; uidlist->next != NULL; uidlist = uidlist->next)
seq_range_array_add(&uids, uidlist->uid);
search_args = mail_search_build_init();
arg = mail_search_build_add(search_args, SEARCH_UIDSET);
arg->value.seqset = uids;
trans = mailbox_transaction_begin(box, 0);
search_ctx = mailbox_search_init(trans, search_args, NULL, 0, NULL);
mail_search_args_unref(&search_args);
while (mailbox_search_next(search_ctx, &mail))
mail_expunge(mail);
if (mailbox_search_deinit(&search_ctx) < 0)
ret = -1;
if (mailbox_transaction_commit(&trans) < 0)
ret = -1;
return ret;
}
示例11: dbox_sync_index_copy_from_old
static void
dbox_sync_index_copy_from_old(struct dbox_sync_rebuild_context *ctx,
struct mail_index_view *view,
uint32_t old_seq, uint32_t new_seq)
{
struct mail_index *index = mail_index_view_get_index(view);
const struct mail_index_record *rec;
ARRAY_TYPE(keyword_indexes) old_keywords;
struct mail_keywords *kw;
uint64_t modseq;
/* copy flags */
rec = mail_index_lookup(view, old_seq);
mail_index_update_flags(ctx->trans, new_seq,
MODIFY_REPLACE, rec->flags);
/* copy keywords */
t_array_init(&old_keywords, 32);
mail_index_lookup_keywords(view, old_seq, &old_keywords);
kw = mail_index_keywords_create_from_indexes(index, &old_keywords);
mail_index_update_keywords(ctx->trans, new_seq, MODIFY_REPLACE, kw);
mail_index_keywords_unref(&kw);
/* copy modseq */
modseq = mail_index_modseq_lookup(view, old_seq);
mail_index_update_modseq(ctx->trans, new_seq, modseq);
dbox_sync_index_copy_cache(ctx, view, old_seq, new_seq);
}
示例12: mirror_get_remote_cmd_line
static void
mirror_get_remote_cmd_line(const char *const *argv,
const char *const **cmd_args_r)
{
ARRAY_TYPE(const_string) cmd_args;
unsigned int i;
const char *p;
i_assert(argv[0] != NULL);
t_array_init(&cmd_args, 16);
for (i = 0; argv[i] != NULL; i++) {
p = argv[i];
array_append(&cmd_args, &p, 1);
}
if (legacy_dsync) {
/* we're executing dsync */
p = "server";
} else {
/* we're executing doveadm */
p = "dsync-server";
}
array_append(&cmd_args, &p, 1);
array_append_zero(&cmd_args);
*cmd_args_r = array_idx(&cmd_args, 0);
}
示例13: boundaries_permute
static void
boundaries_permute(uint32_t *input, unsigned int i, unsigned int count)
{
ARRAY_TYPE(seq_range) range;
const struct seq_range *seqs;
unsigned int seqs_count;
uint32_t tmp;
unsigned int j;
if (i+1 < count) {
for (j = i; j < count; j++) {
tmp = input[i]; input[i] = input[j]; input[j] = tmp;
boundaries_permute(input, i+1, count);
tmp = input[i]; input[i] = input[j]; input[j] = tmp;
}
return;
}
t_array_init(&range, 4);
for (i = 0; i < count; i++)
seq_range_array_add(&range, input[i]);
seqs = array_get(&range, &seqs_count);
test_assert(seqs_count == 2);
test_assert(seqs[0].seq1 == 0);
test_assert(seqs[0].seq2 == 1);
test_assert(seqs[1].seq1 == (uint32_t)-2);
test_assert(seqs[1].seq2 == (uint32_t)-1);
}
示例14: acl_rights_update_import
int acl_rights_update_import(struct acl_rights_update *update,
const char *id, const char *const *rights,
const char **error_r)
{
ARRAY_TYPE(const_string) dest_rights, dest_neg_rights, *dest;
unsigned int i, j;
if (acl_identifier_parse(id, &update->rights) < 0) {
*error_r = t_strdup_printf("Invalid ID: %s", id);
return -1;
}
if (rights == NULL) {
update->modify_mode = ACL_MODIFY_MODE_CLEAR;
update->neg_modify_mode = ACL_MODIFY_MODE_CLEAR;
return 0;
}
t_array_init(&dest_rights, 8);
t_array_init(&dest_neg_rights, 8);
for (i = 0; rights[i] != NULL; i++) {
const char *right = rights[i];
if (right[0] != '-')
dest = &dest_rights;
else {
right++;
dest = &dest_neg_rights;
}
if (strcmp(right, "all") != 0) {
if (*right == ':') {
/* non-standard right */
right++;
array_append(dest, &right, 1);
} else if (is_standard_right(right)) {
array_append(dest, &right, 1);
} else {
*error_r = t_strdup_printf("Invalid right '%s'",
right);
return -1;
}
} else {
for (j = 0; all_mailbox_rights[j] != NULL; j++)
array_append(dest, &all_mailbox_rights[j], 1);
}
}
if (array_count(&dest_rights) > 0) {
array_append_zero(&dest_rights);
update->rights.rights = array_idx(&dest_rights, 0);
} else if (update->modify_mode == ACL_MODIFY_MODE_REPLACE) {
update->modify_mode = ACL_MODIFY_MODE_CLEAR;
}
if (array_count(&dest_neg_rights) > 0) {
array_append_zero(&dest_neg_rights);
update->rights.neg_rights = array_idx(&dest_neg_rights, 0);
} else if (update->neg_modify_mode == ACL_MODIFY_MODE_REPLACE) {
update->neg_modify_mode = ACL_MODIFY_MODE_CLEAR;
}
return 0;
}
示例15: write_IP
/**
* Callback for Modbus write register function
* for setting a new IP address.
*
* High-Byte of value is always the left most IP segment!
* How to set a new IP:
* 1) Write higher 2 segments at num IP_HIGH.
* 2) Write lower 2 segments at num IP_LOW.
* New IP is stored in EEPROM.
* New IP address will be activated after Modbus transmission has
* been confirmed with old IP address.
*
* Example:
* write_IP(IP_HIGH, 0xC0A8); // 192.168
* write_IP(IP_LOW, 0x00A8); // 0.111
*
* @param num Register number
* @param value Two 8-bit values for IPv4 segments
* @return True if value was written successfully
**/
uint8_t write_IP(uint8_t num, uint16_t value) {
switch (num) {
case IP_HIGH:
config.ip[0] = (ARRAY_TYPE(config.ip))(value >> 8);
config.ip[1] = (ARRAY_TYPE(config.ip))value;
break;
case IP_LOW:
config.ip[2] = (ARRAY_TYPE(config.ip))(value >> 8);
config.ip[3] = (ARRAY_TYPE(config.ip))value;
eeprom_update_block(config.ip, eeConfig.ip, sizeof(config.ip));
renewIP = 1;
break;
default:
return 0;
}
return 1;
}