mailbox-attribute.c revision 0206ab42ade102a3170b3a536d1c8e9f2c1340c8
/* Copyright (c) 2003-2017 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "str.h"
#include "istream.h"
#include "mail-storage-private.h"
#include "bsearch-insert-pos.h"
#include "mailbox-attribute-internal.h"
static pool_t mailbox_attribute_pool;
void mailbox_attributes_init(void)
{
/* internal mailbox attributes */
}
void mailbox_attributes_deinit(void)
{
}
/*
* Internal attributes
*/
static int
const struct mailbox_attribute_internal *reg1,
const struct mailbox_attribute_internal *reg2)
{
}
const struct mailbox_attribute_internal *iattr)
{
struct mailbox_attribute_internal ireg;
unsigned int insert_idx;
}
{
unsigned int i;
for (i = 0; i < count; i++)
}
const struct mailbox_attribute_internal *iattr)
{
unsigned int idx;
i_panic("mailbox_attribute_unregister_internal(%s): "
}
}
{
unsigned int i;
for (i = 0; i < count; i++)
}
static const struct mailbox_attribute_internal *
const char *key)
{
const struct mailbox_attribute_internal *iattr;
struct mailbox_attribute_internal dreg;
unsigned int insert_idx;
&insert_idx)) {
/* exact match */
}
if (insert_idx == 0) {
/* not found at all */
return NULL;
}
/* iattr isn't a prefix of key */
return NULL;
/* iattr is a prefix of key and it wants to handle the key */
return iattr;
} else {
return NULL;
}
}
static void
{
const struct mailbox_attribute_internal *regs;
struct mailbox_attribute_internal dreg;
char *bare_prefix;
unsigned int count, i;
plen--;
}
&dreg, mailbox_attribute_internal_cmp, &i);
for (; i < count; i++) {
return;
if (plen > 0) {
return;
/* remove prefix */
/* list the key itself, so this becomes an
empty key string. it's the same as how the
dict backend works too. */
} else {
return;
}
}
}
}
/*
* Attribute API
*/
static int
const struct mail_attribute_value *value)
{
const struct mailbox_attribute_internal *iattr;
int ret;
/* allow internal server attribute only for inbox */
/* handle internal attribute */
/* notify about assignment */
return -1;
break;
"The /%s/%s attribute cannot be changed",
return -1;
}
/* assign internal attribute */
default:
i_unreached();
}
}
return ret;
}
int mailbox_attribute_set(struct mailbox_transaction_context *t,
const struct mail_attribute_value *value)
{
}
int mailbox_attribute_unset(struct mailbox_transaction_context *t,
{
struct mail_attribute_value value;
}
const struct mail_attribute_value *value,
const char **str_r)
{
const unsigned char *data;
return 0;
}
"Attribute string value has NULs");
return -1;
}
}
return -1;
}
return 0;
}
static int
struct mail_attribute_value *value_r)
{
const struct mailbox_attribute_internal *iattr;
int ret;
/* allow internal server attributes only for the inbox */
/* internal attribute */
if (ret < 0)
return -1;
return 1;
}
break;
break;
return ret;
return 1;
default:
i_unreached();
}
}
if (ret != 0)
return ret;
/* default entries */
ret = 0;
else {
return ret;
}
if (ret > 0) {
return 1;
}
break;
break;
default:
i_unreached();
}
}
return 0;
}
struct mail_attribute_value *value_r)
{
int ret;
value_r)) <= 0)
return ret;
return 1;
}
struct mail_attribute_value *value_r)
{
int ret;
value_r)) <= 0)
return ret;
return 1;
}
struct mailbox_attribute_internal_iter {
struct mailbox_attribute_iter iter;
unsigned int extra_attr_idx;
struct mailbox_attribute_iter *real_iter;
};
struct mailbox_attribute_iter *
{
struct mailbox_attribute_internal_iter *intiter;
struct mailbox_attribute_iter *iter;
const char *const *attr;
bool have_dict;
/* check which internal attributes may apply */
/* any extra internal attributes to add? */
if (array_count(&extra_attrs) == 0) {
/* no */
return iter;
}
/* yes */
/* copy relevant attributes */
/* skip internal server attributes unless we're interating inbox */
continue;
}
}
{
struct mailbox_attribute_internal_iter *intiter;
const char *const *attrs;
unsigned int count, i;
const char *result;
/* no internal attributes to add */
}
/* filter out duplicate results */
for (i = 0; i < count; i++) {
break;
}
if (i == count) {
/* return normally */
return result;
}
/* this attribute name is also to be returned as extra;
skip now */
}
/* return extra attributes at the end */
return NULL;
}
{
struct mailbox_attribute_internal_iter *intiter;
int ret;
/* not wrapped */
}
/* wrapped */
return ret;
}