Beispiel #1
0
static struct mailimf_fields * build_fields(void)
{
  struct mailimf_fields * fields;
  struct mailimf_field * f;
  clist * list;
  struct mailimf_from * from;
	struct mailimf_to * to;
  struct mailimf_mailbox * mb;
  struct mailimf_address * addr;
  struct mailimf_mailbox_list * mb_list;
  struct mailimf_address_list * addr_list;
  clist * fields_list;

  /* build headers */

  fields_list = clist_new();
  
  /* build header 'From' */
  
  list = clist_new();
  mb = mailimf_mailbox_new(strdup("DINH =?iso-8859-1?Q?Vi=EAt_Ho=E0?="),
    strdup("*****@*****.**"));
  clist_append(list, mb);
  mb_list = mailimf_mailbox_list_new(list);
  
  from = mailimf_from_new(mb_list);
  
  f = mailimf_field_new(MAILIMF_FIELD_FROM,
    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
    from, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
    NULL, NULL, NULL, NULL);

  clist_append(fields_list, f);
  
  /* build header To */

  list = clist_new();
  mb = mailimf_mailbox_new(strdup("DINH =?iso-8859-1?Q?Vi=EAt_Ho=E0?="),
    strdup("*****@*****.**"));
  addr = mailimf_address_new(MAILIMF_ADDRESS_MAILBOX, mb, NULL);
  clist_append(list, addr);
  addr_list = mailimf_address_list_new(list);
  
  to = mailimf_to_new(addr_list);

  f = mailimf_field_new(MAILIMF_FIELD_TO,
    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
    NULL, NULL, NULL, to, NULL, NULL, NULL, NULL, NULL,
    NULL, NULL, NULL, NULL);
  
  clist_append(fields_list, f);
  
  fields = mailimf_fields_new(fields_list);
  
  return fields;
}
Beispiel #2
0
hand
hand_new (void) {
    hand h;
    h.bet = 0;
    h.cards = clist_new();
    return h;
}
Beispiel #3
0
LIBETPAN_EXPORT
struct mailstorage * mailstorage_new(const char * sto_id)
{
  struct mailstorage * storage;

  storage = malloc(sizeof(struct mailstorage));
  if (storage == NULL)
    goto err;

  if (sto_id != NULL) {
    storage->sto_id = strdup(sto_id);
    if (storage->sto_id == NULL)
      goto free;
  }
  else
    storage->sto_id = NULL;

  storage->sto_data = NULL;
  storage->sto_session = NULL;
  storage->sto_driver = NULL;
  storage->sto_shared_folders = clist_new();
  if (storage->sto_shared_folders == NULL)
    goto free_id;

  return storage;

 free_id:
  if (storage->sto_id != NULL)
    free(storage->sto_id);
 free:
  free(storage);
 err:
  return NULL;
}
Beispiel #4
0
int
mailimap_quota_quota_list_empty_parse(mailstream * fd, MMAPString *buffer,
    size_t * indx, clist ** result,
    size_t progr_rate, progress_function * progr_fun)
{
  size_t cur_token;
  int r;
  clist * quota_resource_list;

  cur_token = * indx;

  r = mailimap_oparenth_parse(fd, buffer, &cur_token);
  if (r != MAILIMAP_NO_ERROR) {
    return r;
  }

  r = mailimap_cparenth_parse(fd, buffer, &cur_token);
  if (r != MAILIMAP_NO_ERROR) {
    return r;
  }

  quota_resource_list = clist_new();
  if (!quota_resource_list) {
    return MAILIMAP_ERROR_MEMORY;
  }

  * result = quota_resource_list;
  * indx = cur_token;
  
  return MAILIMAP_NO_ERROR;
}
Beispiel #5
0
static int mhdriver_list_folders(mailsession * session, const char * mb,
				 struct mail_list ** result)
{
  clist * list;
  int r;
  struct mailmh * mh;
  struct mail_list * ml;

  mh = get_mh_session(session);

  if (mh == NULL)
    return MAIL_ERROR_BAD_STATE;

  list = clist_new();
  if (list == NULL)
    return MAIL_ERROR_MEMORY;

  r =  get_list_folders(mh->mh_main, &list);
  if (r != MAIL_NO_ERROR)
    return r;

  ml = mail_list_new(list);
  if (ml == NULL)
    goto free;

  * result = ml;

  return MAIL_NO_ERROR;

 free:
  clist_foreach(list, (clist_func) free, NULL);
  clist_free(list);
  return MAIL_ERROR_MEMORY;
}
LIBETPAN_EXPORT
struct mailimap_set *
mailimap_set_new_single_item(struct mailimap_set_item * item)
{
  struct mailimap_set * set;
  clist * list;
  int r;
  
  list = clist_new();
  if (list == NULL)
    return NULL;
  
  r = clist_append(list, item);
  if (r < 0) {
    clist_free(list);
    return NULL;
  }
	  
  set = mailimap_set_new(list);
  if (set == NULL) {
    clist_free(list);
    return NULL;
  }

  return set;
}
Beispiel #7
0
void test_case_cscore_004(const UINT32 cscore_md_id)
{
    void *csdoc_words_1;
    void *csdoc_words_2;
    void *csdoc_words_3;
    void *csdoc_words_list;
    void *csword_docs;
    void *csdoc;

    csdoc_words_list = clist_new(MM_CSDOC_WORDS, 0);
    ASSERT(NULL_PTR != csdoc_words_list);

    /*make csdoc_words_1 = {doc={1001,1002,1003}, words={pepople, republic, of, china}}*/
    csdoc_words_1 = cscore_csdoc_words_new(cscore_md_id);
    ASSERT(NULL_PTR != csdoc_words_1);
    csdoc = (void *)cscore_csdoc_words_get_doc(cscore_md_id, csdoc_words_1);
    __test_case_cscore_csdoc_set_doc(cscore_md_id, csdoc, 1001, 1002, 1003);
    __test_case_cscore_csdoc_words_add_words(cscore_md_id, csdoc_words_1, 4, (UINT8 *)"pepole", (UINT8 *)"republic", (UINT8 *)"of", (UINT8 *)"china");
    clist_push_back(csdoc_words_list, (void *)csdoc_words_1);

    /*make csdoc_words_2 = {doc={1101,1002,1003}, words={pepople, working, hard}}*/
    csdoc_words_2 = cscore_csdoc_words_new(cscore_md_id);
    ASSERT(NULL_PTR != csdoc_words_2);    
    csdoc = (void *)cscore_csdoc_words_get_doc(cscore_md_id, csdoc_words_2);
    __test_case_cscore_csdoc_set_doc(cscore_md_id, csdoc, 1101, 1002, 1003);
    __test_case_cscore_csdoc_words_add_words(cscore_md_id, csdoc_words_2, 3, (UINT8 *)"pepole", (UINT8 *)"working", (UINT8 *)"hard");
    clist_push_back(csdoc_words_list, (void *)csdoc_words_2);

    /*make csdoc_words_3 = {doc={1101,1002,1003}, words={pepople, living, happ}}*/
    csdoc_words_3 = cscore_csdoc_words_new(cscore_md_id);
    ASSERT(NULL_PTR != csdoc_words_3);    
    csdoc = (void *)cscore_csdoc_words_get_doc(cscore_md_id, csdoc_words_3);
    __test_case_cscore_csdoc_set_doc(cscore_md_id, csdoc, 1011, 1002, 1003);
    __test_case_cscore_csdoc_words_add_words(cscore_md_id, csdoc_words_3, 3, (UINT8 *)"pepole", (UINT8 *)"living", (UINT8 *)"happ");
    clist_push_back(csdoc_words_list, (void *)csdoc_words_3);

    /*import csdoc_words_1 into bigtable*/
    dbg_log(SEC_0137_DEMO, 9)(LOGSTDOUT, "[DEBUG] test_case_cscore_004: import beg\n");
    ASSERT(EC_TRUE == cscore_csdoc_words_list_import(cscore_md_id, csdoc_words_list));
    clist_free_with_modi(csdoc_words_list, cscore_md_id);
    dbg_log(SEC_0137_DEMO, 9)(LOGSTDOUT, "[DEBUG] test_case_cscore_004: import end\n");

    /*make csword_docs ready*/
    csword_docs = cscore_csword_docs_new(cscore_md_id);
    ASSERT(NULL_PTR != csword_docs);

    /*add cswords to csword_docs*/
    __test_case_cscore_csword_docs_set_word(cscore_md_id, csword_docs, (UINT8 *)"pepole");

    dbg_log(SEC_0137_DEMO, 9)(LOGSTDOUT, "[DEBUG] test_case_cscore_004: export beg\n");
    ASSERT(EC_TRUE == cscore_csword_docs_export(cscore_md_id, CBGT_SELECT_FROM_ALL_TABLE, csword_docs));
    dbg_log(SEC_0137_DEMO, 9)(LOGSTDOUT, "[DEBUG] test_case_cscore_004: export end\n");
    dbg_log(SEC_0137_DEMO, 9)(LOGSTDOUT, "[DEBUG] test_case_cscore_004: export result:\n");
    cscore_csword_docs_print(LOGSTDOUT, csword_docs);
    cscore_csword_docs_free(cscore_md_id, csword_docs);

    return;
}
Beispiel #8
0
static clist * read_group_time_list(newsnntp * f)
{
  char * line;
  char * group_name;
  time_t date;
  char * email;
  clist * group_time_list;
  struct newsnntp_group_time * n;
  int r;

  group_time_list = clist_new();
  if (group_time_list == NULL)
    goto err;

  while (1) {
    char * p;
    char * remaining;
    
    line = read_line(f);
    
    if (line == NULL)
      goto free_list;

    if (mailstream_is_end_multiline(line))
      break;
    
    p = cut_token(line);
    if (p == NULL)
      continue;
      
    date = strtoul(p, &remaining, 10);

    p = remaining;
    parse_space(&p);

    email = p;
    
    group_name = line;
    
    n = group_time_new(group_name, date, email);
    if (n == NULL)
      goto free_list;
    
    r = clist_append(group_time_list, n);
    if (r < 0) {
      group_time_free(n);
      goto free_list;
    }
  }
  
  return group_time_list;

 free_list:
  group_time_list_free(group_time_list);
 err:
  return NULL;
}
Beispiel #9
0
static clist * read_distrib_default_value_list(newsnntp * f)
{
  char * line;
  uint32_t weight;
  char * group_pattern;
  char * meaning;
  clist * distrib_default_value_list;
  struct newsnntp_distrib_default_value * n;
  int r;

  distrib_default_value_list = clist_new();
  if (distrib_default_value_list == NULL)
    goto err;

  while (1) {
    char * p;
    char * remaining;
      
    line = read_line(f);
    if (line == NULL)
      goto free_list;

    if (mailstream_is_end_multiline(line))
      break;

    p = line;

    weight = strtoul(p, &remaining, 10);
    p = remaining;
    parse_space(&p);
      
    p = cut_token(line);
    if (p == NULL)
      continue;

    meaning = p;
    group_pattern = line;

    n = distrib_default_value_new(weight, group_pattern, meaning);
    if (n == NULL)
      goto free_list;

    r = clist_append(distrib_default_value_list, n);
    if (r < 0) {
      distrib_default_value_free(n);
      goto free_list;
    }
  }

  return distrib_default_value_list;

 free_list:
  distrib_default_value_list_free(distrib_default_value_list);
 err:
  return NULL;
}
struct mailimap_section * mailimap_section_new_empty(void)
{
  clist * list;

  list = clist_new();
  if (list == NULL)
    return NULL;

  return mailimap_section_new(list);
}
struct mailimap_status_att_list * mailimap_status_att_list_new_empty(void)
{
  clist * list;

  list = clist_new();
  if (list == NULL)
    return NULL;

  return mailimap_status_att_list_new(list);
}
Beispiel #12
0
struct mailmime_content *
mailmime_content_dup(struct mailmime_content * content)
{
  clist * list;
  struct mailmime_type * type;
  int r;
  struct mailmime_content * dup_content;
  char * subtype;

  type = mailmime_type_dup(content->ct_type);
  if (type == NULL)
    goto err;
  
  subtype = strdup(content->ct_subtype);
  if (subtype == NULL)
    goto free_type;
  
  list = clist_new();
  if (list == NULL)
    goto free_subtype;
  
  if (content->ct_parameters != NULL) {
    clistiter * cur;
    
    for(cur = clist_begin(content->ct_parameters) ;
        cur != NULL ; cur = clist_next(cur)) {
      struct mailmime_parameter * param;
      
      param = mailmime_parameter_dup(clist_content(cur));
      if (param == NULL)
        goto free_list;
      
      r = clist_append(list, param);
      if (r < 0) {
        mailmime_parameter_free(param);
        goto free_list;
      }
    }
  }
  
  dup_content = mailmime_content_new(type, subtype, list);
  if (dup_content == NULL)
    goto free_list;

  return dup_content;
  
 free_list:
  clist_foreach(list, (clist_func) mailmime_parameter_free, NULL);
 free_subtype:
  free(subtype);
 free_type:
  mailmime_type_free(type);
 err:
  return NULL;
}
Beispiel #13
0
static int mailimap_enable_parse(mailstream * fd, MMAPString * buffer,
	size_t * indx,
	struct mailimap_capability_data ** result,
	size_t progr_rate,
	progress_function * progr_fun)
{
  size_t cur_token;
  int r;
  int res;
	struct mailimap_capability_data * capabilities;
  clist * cap_list;
  
  cur_token = * indx;
  
  r = mailimap_token_case_insensitive_parse(fd, buffer, &cur_token, "ENABLED");
  if (r != MAILIMAP_NO_ERROR) {
    res = r;
    goto err;
  }
  
  r = mailimap_capability_list_parse(fd, buffer, &cur_token,
                                     &cap_list,
                                     progr_rate, progr_fun);
  if (r == MAILIMAP_ERROR_PARSE) {
    cap_list = clist_new();
    if (cap_list == NULL) {
      res = MAILIMAP_ERROR_MEMORY;
      goto err;
    }
    r = MAILIMAP_NO_ERROR;
  }
  if (r != MAILIMAP_NO_ERROR) {
    res = r;
    goto err;
  }
  
  capabilities = mailimap_capability_data_new(cap_list);
  if (capabilities == NULL) {
    res = MAILIMAP_ERROR_MEMORY;
    goto free_list;
  }
  
  * result = capabilities;
  * indx = cur_token;
  
  return MAILIMAP_NO_ERROR;
  
free_list:
  if (cap_list) {
    clist_foreach(cap_list, (clist_func) mailimap_capability_free, NULL);
    clist_free(cap_list);
  }
err:
  return res;
}
LIBETPAN_EXPORT
struct mailimap_set * mailimap_set_new_empty(void)
{
  clist * list;

  list = clist_new();
  if (list == NULL)
    return NULL;

  return mailimap_set_new(list);
}
struct mailimap_search_key *
mailimap_search_key_new_multiple_empty(void)
{
  clist * list;

  list = clist_new();
  if (list == NULL)
    return NULL;

  return mailimap_search_key_new_multiple(list);
}
struct mailimap_fetch_type *
mailimap_fetch_type_new_fetch_att_list_empty(void)
{
  clist * list;

  list = clist_new();
  if (list == NULL)
    return NULL;

  return mailimap_fetch_type_new(MAILIMAP_FETCH_TYPE_FETCH_ATT_LIST,
				 NULL, list);
}
LIBETPAN_EXPORT
int
mailimap_extension_register(struct mailimap_extension_api * extension)
{
  if (mailimap_extension_list == NULL) {
    mailimap_extension_list = clist_new();
    if (mailimap_extension_list == NULL)
      return MAILIMAP_ERROR_MEMORY;
  }

  return clist_append(mailimap_extension_list, extension);
}
static int mailprivacy_smime_add_encryption_id(struct mailprivacy * privacy,
    mailmessage * msg, char * encryption_id)
{
  clist * encryption_id_list;
  int r;
  int res;
  
  LOCK();
  
  res = -1;
  
  encryption_id_list = get_list(privacy, msg);
  if (encryption_id_list == NULL) {
    if (encryption_id_hash == NULL)
      encryption_id_hash = chash_new(CHASH_DEFAULTSIZE, CHASH_COPYKEY);
    
    if (encryption_id_hash != NULL) {
      encryption_id_list = clist_new();
      if (encryption_id_list != NULL) {
        chashdatum key;
        chashdatum value;
        
        key.data = &msg;
        key.len = sizeof(msg);
        value.data = encryption_id_list;
        value.len = 0;
        r = chash_set(encryption_id_hash, &key, &value, NULL);
        if (r < 0)
          clist_free(encryption_id_list);
      }
    }
  }
  
  encryption_id_list = get_list(privacy, msg);
  if (encryption_id_list != NULL) {
    char * str;
    
    str = strdup(encryption_id);
    if (str != NULL) {
      r = clist_append(encryption_id_list, str);
      if (r < 0) {
        free(str);
      }
      else {
        res = 0;
      }
    }
  }
  
  UNLOCK();
  
  return res;
}
Beispiel #19
0
static int mailimap_xgmlabels_parse(mailstream * fd,
                                    MMAPString * buffer, size_t * indx,
                                    clist ** result)
{
    size_t cur_token;
    clist * list;
    int r;
    int res;
    
    cur_token = * indx;
    
    r = mailimap_oparenth_parse(fd, buffer, &cur_token);
    if (r != MAILIMAP_NO_ERROR) {
      res = r;
      goto err;
    }
    
    r = mailimap_struct_spaced_list_parse(fd, buffer,
                                          &cur_token, &list,
                                          (mailimap_struct_parser * ) mailimap_astring_parse,
                                          (mailimap_struct_destructor * ) mailimap_astring_free,
                                          0, NULL);
    if (r == MAILIMAP_ERROR_PARSE) {
      list = clist_new();
      if (list == NULL) {
        res = MAILIMAP_ERROR_MEMORY;
        goto err;
      }
    }
    else if (r != MAILIMAP_NO_ERROR) {
      res = r;
      goto err;
    }
    
    r = mailimap_cparenth_parse(fd, buffer, &cur_token);
    if (r != MAILIMAP_NO_ERROR) {
      res = r;
      goto free_list;
    }
    
    * indx = cur_token;
    * result = list;
    
    return MAILIMAP_NO_ERROR;
    
free_list:
    clist_foreach(list, (clist_func) mailimap_astring_free, NULL);
    clist_free(list);
err:
    return res;
}
Beispiel #20
0
static int mhdriver_lsub_folders(mailsession * session, const char * mb,
				 struct mail_list ** result)
{
  clist * subscribed;
  clist * lsub_result;
  clistiter * cur;
  struct mail_list * lsub;
  size_t length;
  int r;

  length = strlen(mb);

  subscribed = get_data(session)->mh_subscribed_list;

  lsub_result = clist_new();
  if (lsub_result == NULL)
    return MAIL_ERROR_MEMORY;

  for(cur = clist_begin(subscribed) ; cur != NULL ;
      cur = clist_next(cur)) {
    char * cur_mb;
    char * new_mb;
    
    cur_mb = clist_content(cur);

    if (strncmp(mb, cur_mb, length) == 0) {
      new_mb = strdup(cur_mb);
      if (new_mb == NULL)
	goto free_list;
      
      r = clist_append(lsub_result, new_mb);
      if (r < 0) {
	free(new_mb);
	goto free_list;
      }
    }
  }    
  
  lsub = mail_list_new(lsub_result);
  if (lsub == NULL)
    goto free_list;

  * result = lsub;

  return MAIL_NO_ERROR;

 free_list:
  clist_foreach(lsub_result, (clist_func) free, NULL);
  clist_free(lsub_result);
  return MAIL_ERROR_MEMORY;
}
Beispiel #21
0
int
maildriver_env_list_to_msg_list_no_flags(struct mailmessage_list * env_list,
    clist ** result)
{
  clist * msg_list;
  int r;
  int res;
  unsigned int i;

  msg_list = clist_new();
  if (msg_list == NULL) {
    res = MAIL_ERROR_MEMORY;
    goto err;
  }

  for(i = 0 ; i < carray_count(env_list->msg_tab) ; i ++) {
    mailmessage * msg;

    msg = carray_get(env_list->msg_tab, i);

    if (msg->msg_flags == NULL) {
      uint32_t * pindex;

      pindex = malloc(sizeof(* pindex));
      if (pindex == NULL) {
	res = MAIL_ERROR_MEMORY;
	goto free_msg_list;
      }

      * pindex = msg->msg_index;

      r = clist_append(msg_list, pindex);
      if (r < 0) {
	free(pindex);
	res = MAIL_ERROR_MEMORY;
	goto free_msg_list;
      }

    }
  }

  * result = msg_list;

  return MAIL_NO_ERROR;

 free_msg_list:
  clist_foreach(msg_list, (clist_func) free, NULL);
  clist_free(msg_list);
 err:
  return res;
}
static int get_flags(mailmessage * msg_info,
    struct mail_flags ** result)
{
  chashdatum key;
  chashdatum value;
  struct maildir * md;
  struct mail_flags * flags;
  struct maildir_session_state_data * data;
  struct maildir_msg * md_msg;
  int r;
  uint32_t driver_flags;
  clist * ext;
  
  if (msg_info->msg_flags != NULL) {
    * result = msg_info->msg_flags;
    return MAIL_NO_ERROR;
  }
  
  data = get_session_data(msg_info);
  flags = mail_flags_store_get(data->md_flags_store,
      msg_info->msg_index);
  if (flags != NULL) {
    msg_info->msg_flags = flags;
    * result = msg_info->msg_flags;
    return MAIL_NO_ERROR;
  }
  
  md = get_maildir_session(msg_info);
  if (md == NULL)
    return MAIL_ERROR_BAD_STATE;
  
  key.data = msg_info->msg_uid;
  key.len = strlen(msg_info->msg_uid);
  r = chash_get(md->mdir_msg_hash, &key, &value);
  if (r < 0)
    return MAIL_ERROR_MSG_NOT_FOUND;
  
  md_msg = value.data;
  
  driver_flags = maildirdriver_maildir_flags_to_flags(md_msg->msg_flags);
  
  ext = clist_new();
  if (ext == NULL)
    return MAIL_ERROR_MEMORY;
  
  msg_info->msg_flags = mail_flags_new(driver_flags, ext);
  
  * result = msg_info->msg_flags;
  
  return MAIL_NO_ERROR;
}
Beispiel #23
0
static clist * read_group_description_list(newsnntp * f)
{
  char * line;
  char * group_name;
  char * description;
  clist * group_description_list;
  struct newsnntp_group_description * n;
  int r;

  group_description_list = clist_new();
  if (group_description_list == NULL)
    goto err;

  while (1) {
    char * p;
      
    line = read_line(f);
    if (line == NULL)
      goto free_list;

    if (mailstream_is_end_multiline(line))
      break;

    p = cut_token(line);
    if (p == NULL)
      continue;

    description = p;

    group_name = line;

    n = group_description_new(group_name, description);
    if (n == NULL)
      goto free_list;

    r = clist_append(group_description_list, n);
    if (r < 0) {
      group_description_free(n);
      goto free_list;
    }
  }

  return group_description_list;

 free_list:
  group_description_list_free(group_description_list);
 err:
  return NULL;
}
Beispiel #24
0
static clist * read_distrib_value_meaning_list(newsnntp * f)
{
  char * line;
  char * value;
  char * meaning;
  clist * distrib_value_meaning_list;
  struct newsnntp_distrib_value_meaning * n;
  int r;

  distrib_value_meaning_list = clist_new();
  if (distrib_value_meaning_list == NULL)
    goto err;

  while (1) {
    char * p;
      
    line = read_line(f);
    if (line == NULL)
      goto free_list;

    if (mailstream_is_end_multiline(line))
      break;
      
    p = cut_token(line);
    if (p == NULL)
      continue;
      
    meaning = p;

    value = line;

    n = distrib_value_meaning_new(value, meaning);
    if (n == NULL)
      goto free_list;

    r = clist_append(distrib_value_meaning_list, n);
    if (r < 0) {
      distrib_value_meaning_free(n);
      goto free_list;
    }
  }

  return distrib_value_meaning_list;

 free_list:
  distrib_value_meaning_list_free(distrib_value_meaning_list);
 err:
  return NULL;
}
Beispiel #25
0
SpeechTrimmer * new_speech_trimmer(int frequency, double threshold) {
  SpeechTrimmer *self = malloc(sizeof(SpeechTrimmer));
  self->leader = 5;
  self->trailer = 5;
  self->speech_started = FALSE;
  self->bcm = bent_cent_marker_new(threshold, 0.003, 1.0, 100.0, 0.0, 0.0);
  self->false_count = 0;
  self->true_count = 0;
  self->queue = clist_new();
  self->eos_reached = FALSE;
  self->scs = 20;
  self->ecs = 50;
  self->seg = new_segmenter(frequency/100, frequency/100);
  return self;
}
Beispiel #26
0
static int flags_extension_read(MMAPString * mmapstr, size_t * indx,
				clist ** result)
{
  clist * list;
  int r;
  uint32_t count;
  uint32_t i;
  int res;

  r = mailimf_cache_int_read(mmapstr, indx, &count);
  if (r != MAIL_NO_ERROR) {
    res = r;
    goto err;
  }

  list = clist_new();
  if (list == NULL) {
    res = MAIL_ERROR_MEMORY;
    goto err;
  }

  for(i = 0 ; i < count ; i++) {
    char * str;

    r = mailimf_cache_string_read(mmapstr, indx, &str);
    if (r != MAIL_NO_ERROR) {
      res = r;
      goto free_list;
    }

    r = clist_append(list, str);
    if (r < 0) {
      free(str);
      res = MAIL_ERROR_MEMORY;
      goto free_list;
    }
  }

  * result = list;

  return MAIL_NO_ERROR;

 free_list:
  clist_foreach(list, (clist_func) free, NULL);
  clist_free(list);
 err:
  return res;
}
Beispiel #27
0
static clist * read_xhdr_resp_list(newsnntp * f)
{
  char * line;
  uint32_t article;
  char * value;
  clist * xhdr_resp_list;
  struct newsnntp_xhdr_resp_item * n;
  int r;

  xhdr_resp_list = clist_new();
  if (xhdr_resp_list == NULL)
    goto err;

  while (1) {
    line = read_line(f);
    
    if (line == NULL)
      goto free_list;
    
    if (mailstream_is_end_multiline(line))
      break;
    
    article = strtoul(line, &line, 10);
    if (!parse_space(&line))
      continue;
    
    value = line;
    
    n = xhdr_resp_item_new(article, value);
    if (n == NULL)
      goto free_list;
    
    r = clist_append(xhdr_resp_list, n);
    if (r < 0) {
      xhdr_resp_item_free(n);
      goto free_list;
    }
  }
  
  return xhdr_resp_list;

 free_list:
  xhdr_resp_list_free(xhdr_resp_list);
 err:
  return NULL;
}
struct mailmime_content * mailmime_get_content_message(void)
{
  clist * list;
  struct mailmime_composite_type * composite_type;
  struct mailmime_type * mime_type;
  struct mailmime_content * content;
  char * subtype;

  composite_type =
    mailmime_composite_type_new(MAILMIME_COMPOSITE_TYPE_MESSAGE,
				NULL);
  if (composite_type == NULL)
    goto err;
  
  mime_type = mailmime_type_new(MAILMIME_TYPE_COMPOSITE_TYPE,
				NULL, composite_type);
  if (mime_type == NULL)
    goto free_composite;
  composite_type = NULL;

  list = clist_new();
  if (list == NULL)
    goto free_mime_type;

  subtype = strdup("rfc822");
  if (subtype == NULL)
    goto free_list;

  content = mailmime_content_new(mime_type, subtype, list);
  if (content == NULL)
    goto free_subtype;

  return content;

 free_subtype:
  free(subtype);
 free_list:
  clist_free(list);
 free_mime_type:
  mailmime_type_free(mime_type);
 free_composite:
  if (composite_type != NULL)
    mailmime_composite_type_free(composite_type);
 err:
  return NULL;
}
struct mailimap_id_params_list * mailimap_id_params_list_new_empty(void)
{
  clist * items;
  struct mailimap_id_params_list * list;
  
  items = clist_new();
  if (items == NULL)
    return NULL;
  
  list = mailimap_id_params_list_new(items);
  if (list == NULL) {
    clist_free(items);
    return NULL;
  }
  
  return list;
}
struct mailmime_content * mailmime_get_content_text(void)
{
  clist * list;
  struct mailmime_discrete_type * discrete_type;
  struct mailmime_type * mime_type;
  struct mailmime_content * content;
  char * subtype;

  discrete_type = mailmime_discrete_type_new(MAILMIME_DISCRETE_TYPE_TEXT,
					     NULL);
  if (discrete_type == NULL)
    goto err;
  
  mime_type = mailmime_type_new(MAILMIME_TYPE_DISCRETE_TYPE,
				discrete_type, NULL);
  if (mime_type == NULL)
    goto free_discrete;
  discrete_type = NULL;
  
  list = clist_new();
  if (list == NULL)
    goto free_type;

  subtype = strdup("plain");
  if (subtype == NULL)
    goto free_list;
  
  content = mailmime_content_new(mime_type, subtype, list);
  if (content == NULL)
    goto free_subtype;

  return content;

 free_subtype:
  free(subtype);
 free_list:
  clist_free(list);
 free_type:
  mailmime_type_free(mime_type);
 free_discrete:
  if (discrete_type != NULL)
    mailmime_discrete_type_free(discrete_type);
 err:
  return NULL;
}