int pop3c_sync_get_sizes(struct pop3c_mailbox *mbox) { struct istream *input; const char *error; char *line, *p; unsigned int seq, line_seq; i_assert(mbox->msg_sizes == NULL); if (mbox->msg_uidls == NULL) { if (pop3c_sync_get_uidls(mbox) < 0) return -1; } if (mbox->msg_count == 0) { mbox->msg_sizes = i_new(uoff_t, 1); return 0; } if (pop3c_client_cmd_stream(mbox->client, "LIST\r\n", &input, &error) < 0) { mail_storage_set_critical(mbox->box.storage, "LIST failed: %s", error); return -1; } mbox->msg_sizes = i_new(uoff_t, mbox->msg_count); seq = 0; while ((line = i_stream_read_next_line(input)) != NULL) { if (++seq > mbox->msg_count) { mail_storage_set_critical(mbox->box.storage, "Too much data in LIST: %s", line); break; } p = strchr(line, ' '); if (p == NULL) { mail_storage_set_critical(mbox->box.storage, "Invalid LIST line: %s", line); break; } *p++ = '\0'; if (str_to_uint(line, &line_seq) < 0 || line_seq != seq) { mail_storage_set_critical(mbox->box.storage, "Unexpected LIST seq: %s != %u", line, seq); break; } if (str_to_uoff(p, &mbox->msg_sizes[seq-1]) < 0) { mail_storage_set_critical(mbox->box.storage, "Invalid LIST size: %s", p); break; } } i_stream_destroy(&input); if (line != NULL) { i_free_and_null(mbox->msg_sizes); return -1; } return 0; }
static void tower_init(void) { int i, first = newarena; item_type *it_demonseye = it_find("demonseye"); item_type *it_griphonwing = it_find("griphonwing"); assert(it_griphonwing && it_demonseye); for (i = 0; i != 6; ++i) { region *r = tower_region[i] = findregion(arena_center->x + delta_x[i] * 3, arena_center->y + delta_y[i] * 3); if (r) { start_region[i] = findregion(arena_center->x + delta_x[i] * 2, arena_center->y + delta_y[i] * 2); if (rterrain(r) != T_DESERT) terraform(r, T_DESERT); if (!r->buildings) { building *b = new_building(bt_find("castle"), r, NULL); b->size = 10; if (i != 0) { sprintf(buf, "Turm des %s", LOC(default_locale, mkname("school", magic_school[i]))); } else sprintf(buf, "Turm der Ahnungslosen"); set_string(&b->name, buf); } } } if (first && !arena_center->buildings) { building *b = new_building(bt_find("castle"), arena_center, NULL); attrib *a; item *items; i_add(&items, i_new(it_griphonwing, 1)); i_add(&items, i_new(it_demonseye, 1)); a = a_add(&b->attribs, make_giveitem(b, items)); b->size = 10; set_string(&b->name, "Höhle des Greifen"); } }
uint32_t seq, seq1, seq2, iseq, uid; unsigned int cache_idx = ibox->cache_fields[MAIL_CACHE_POP3_UIDL].idx; i_assert(mbox->msg_uids == NULL); /* set our uidvalidity */ hdr = mail_index_get_header(sync_view); if (hdr->uid_validity == 0) { uint32_t uid_validity = ioloop_time; mail_index_update_header(sync_trans, offsetof(struct mail_index_header, uid_validity), &uid_validity, sizeof(uid_validity), TRUE); } /* skip over existing messages with matching UIDLs */ mbox->msg_uids = i_new(uint32_t, mbox->msg_count + 1); str = t_str_new(128); for (seq = 1; seq <= hdr->messages_count && seq <= mbox->msg_count; seq++) { str_truncate(str, 0); if (mail_cache_lookup_field(cache_view, str, seq, cache_idx) > 0 && strcmp(str_c(str), mbox->msg_uidls[seq-1]) == 0) { /* UIDL matched */ mail_index_lookup_uid(sync_view, seq, &mbox->msg_uids[seq-1]); } else { break; } } seq2 = seq; /* remove the rest of the messages from index */