Example #1
0
int mailimf_address_list_write(FILE * f, int * col,
    struct mailimf_address_list * addr_list)
{
  clistiter * cur;
  int r;
  int first;

  first = TRUE;

  for(cur = clist_begin(addr_list->ad_list) ; cur != NULL ;
      cur = clist_next(cur)) {
    struct mailimf_address * addr;

    addr = clist_content(cur);

    if (!first) {
      r = mailimf_string_write(f, col, ", ", 2);
      if (r != MAILIMF_NO_ERROR)
	return r;
    }
    else {
      first = FALSE;
    }

    r = mailimf_address_write(f, col, addr);
    if (r != MAILIMF_NO_ERROR)
      return r;
  }

  return MAILIMF_NO_ERROR;
}
Example #2
0
void mailprivacy_prepare_mime(struct mailmime * mime)
{
  clistiter * cur;
  
  switch (mime->mm_type) {
  case MAILMIME_SINGLE:
    if (mime->mm_data.mm_single != NULL) {
      prepare_mime_single(mime);
    }
    break;
    
  case MAILMIME_MULTIPLE:
    for(cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ;
        cur != NULL ; cur = clist_next(cur)) {
      struct mailmime * child;
      
      child = clist_content(cur);
      
      mailprivacy_prepare_mime(child);
    }
    break;
    
  case MAILMIME_MESSAGE:
    if (mime->mm_data.mm_message.mm_msg_mime) {
      mailprivacy_prepare_mime(mime->mm_data.mm_message.mm_msg_mime);
    }
    break;
  }
}
Example #3
0
static uint64_t get_mod_sequence_value(mailimap * session)
{
  uint64_t mod_sequence_value;
  clistiter * cur;
  
  mod_sequence_value = 0;
  for(cur = clist_begin(session->imap_response_info->rsp_extension_list) ; cur != NULL ; cur = clist_next(cur)) {
    struct mailimap_extension_data * ext_data;
    struct mailimap_condstore_resptextcode * resptextcode;
    
    ext_data = clist_content(cur);
    if (ext_data->ext_extension->ext_id != MAILIMAP_EXTENSION_CONDSTORE) {
      continue;
    }
    if (ext_data->ext_type != MAILIMAP_CONDSTORE_TYPE_RESP_TEXT_CODE) {
      continue;
    }
    
    resptextcode = ext_data->ext_data;
    switch (resptextcode->cs_type) {
      case MAILIMAP_CONDSTORE_RESPTEXTCODE_HIGHESTMODSEQ:
      mod_sequence_value = resptextcode->cs_data.cs_modseq_value;
      break;
      case MAILIMAP_CONDSTORE_RESPTEXTCODE_NOMODSEQ:
      mod_sequence_value = 0;
      break;
    }
  }
  
  return mod_sequence_value;
}
Example #4
0
int mailimf_mailbox_list_write(FILE * f, int * col,
    struct mailimf_mailbox_list * mb_list)
{
  clistiter * cur;
  int r;
  int first;

  first = TRUE;

  for(cur = clist_begin(mb_list->mb_list) ; cur != NULL ;
      cur = clist_next(cur)) {
    struct mailimf_mailbox * mb;

    mb = clist_content(cur);

    if (!first) {
      r = mailimf_string_write(f, col, ", ", 2);
      if (r != MAILIMF_NO_ERROR)
	return r;
    }
    else {
      first = FALSE;
    }

    r = mailimf_mailbox_write(f, col, mb);
    if (r != MAILIMF_NO_ERROR)
      return r;
  }

  return MAILIMF_NO_ERROR;
}
Example #5
0
int newsnntp_xover_single(newsnntp * f, uint32_t article,
			   struct newsnntp_xover_resp_item ** result)
{
  char command[NNTP_STRING_SIZE];
  int r;
  clist * list;
  clistiter * cur;
  struct newsnntp_xover_resp_item * item;

  snprintf(command, NNTP_STRING_SIZE, "XOVER %i\r\n", article);
  r = send_command(f, command);
  if (r == -1)
    return NEWSNNTP_ERROR_STREAM;

  r = newsnntp_xover_resp(f, &list);
  if (r != NEWSNNTP_NO_ERROR)
    return r;

  cur = clist_begin(list);
  item = clist_content(cur);
  clist_free(list);
  
  * result = item;

  return r;
}
void mailprivacy_smime_encryption_id_list_clear(struct mailprivacy * privacy,
    mailmessage * msg)
{
  clist * encryption_id_list;
  clistiter * iter;
  
  LOCK();
  encryption_id_list = get_list(privacy, msg);
  if (encryption_id_list != NULL) {
    chashdatum key;
    
    for(iter = clist_begin(encryption_id_list) ;
        iter != NULL ; iter = clist_next(iter)) {
      char * str;
      
      str = clist_content(iter);
      free(str);
    }
    clist_free(encryption_id_list);
    
    key.data = &msg;
    key.len = sizeof(msg);
    chash_delete(encryption_id_hash, &key, NULL);
    
    if (chash_count(encryption_id_hash) == 0) {
      chash_free(encryption_id_hash);
      encryption_id_hash = NULL;
    }
  }
  UNLOCK();
}
Example #7
0
static void display_recursive_part(struct mailmime * mime)
{
  clistiter * cur;
  
  fprintf(stderr, "part %p\n", mime->mm_body);
  switch (mime->mm_type) {
  case MAILMIME_SINGLE:
    fprintf(stderr, "single %p - %i\n", mime->mm_data.mm_single,
        mime->mm_data.mm_single->dt_type);
    if (mime->mm_data.mm_single->dt_type == MAILMIME_DATA_TEXT) {
      fprintf(stderr, "data : %p %i\n",
          mime->mm_data.mm_single->dt_data.dt_text.dt_data,
          mime->mm_data.mm_single->dt_data.dt_text.dt_length);
    }
    break;
  case MAILMIME_MESSAGE:
    fprintf(stderr, "message %p\n", mime->mm_data.mm_message.mm_msg_mime);
    display_recursive_part(mime->mm_data.mm_message.mm_msg_mime);
    break;
  case MAILMIME_MULTIPLE:
    for(cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ;
        cur = clist_next(cur)) {

      fprintf(stderr, "multipart\n");
      display_recursive_part(clist_content(cur));
    }
    break;
  }
}
Example #8
0
static void fetch_messages(struct mailimap * imap)
{
	struct mailimap_set * set;
	struct mailimap_fetch_type * fetch_type;
	struct mailimap_fetch_att * fetch_att;
	clist * fetch_result;
	clistiter * cur;
	int r;
	
	/* as improvement UIDVALIDITY should be read and the message cache should be cleaned
	   if the UIDVALIDITY is not the same */
	
	set = mailimap_set_new_interval(1, 0); /* fetch in interval 1:* */
	fetch_type = mailimap_fetch_type_new_fetch_att_list_empty();
	fetch_att = mailimap_fetch_att_new_uid();
	mailimap_fetch_type_new_fetch_att_list_add(fetch_type, fetch_att);

	r = mailimap_fetch(imap, set, fetch_type, &fetch_result);
	check_error(r, "could not fetch");
	
  /* for each message */
	for(cur = clist_begin(fetch_result) ; cur != NULL ; cur = clist_next(cur)) {
		struct mailimap_msg_att * msg_att;
		uint32_t uid;
		
		msg_att = clist_content(cur);
		uid = get_uid(msg_att);
		if (uid == 0)
			continue;

		fetch_msg(imap, uid);
	}

	mailimap_fetch_list_free(fetch_result);
}
Example #9
0
void mailprivacy_recursive_unregister_mime(struct mailprivacy * privacy,
    struct mailmime * mime)
{
  clistiter * cur;
  
  unregister_mime(privacy, mime);
  
  switch (mime->mm_type) {
  case MAILMIME_SINGLE:
    break;
    
  case MAILMIME_MULTIPLE:
    for(cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ;
        cur != NULL ; cur = clist_next(cur)) {
      struct mailmime * child;
      
      child = clist_content(cur);
      
      mailprivacy_recursive_unregister_mime(privacy, child);
    }
    break;
    
  case MAILMIME_MESSAGE:
    if (mime->mm_data.mm_message.mm_msg_mime)
      mailprivacy_recursive_unregister_mime(privacy,
          mime->mm_data.mm_message.mm_msg_mime);
    break;
  }
}
static void cleanup_mime(struct mailmime * mime)
{
  mime->mm_mime_start = NULL;
  mime->mm_length = 0;
  if (mime->mm_body != NULL) {
    mailmime_data_free(mime->mm_body);
    mime->mm_body = NULL;
  }
  switch (mime->mm_type) {
  case MAILMIME_SINGLE:
    mime->mm_data.mm_single = NULL;
    break;
  case MAILMIME_MULTIPLE:
    {
      clistiter * cur;
      
      for(cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ;
          cur != NULL ; cur = clist_next(cur)) {
        struct mailmime * submime;
        
        submime = clist_content(cur);
        cleanup_mime(submime);
      }
    }
    break;
  case MAILMIME_MESSAGE:
    if (mime->mm_data.mm_message.mm_msg_mime != NULL) 
      cleanup_mime(mime->mm_data.mm_message.mm_msg_mime);
    break;
  }
}
Example #11
0
LIBETPAN_EXPORT
int mailsmtp_send(mailsmtp * session,
		   const char * from,
		   clist * addresses,
		   const char * message, size_t size)
{
  int r;
  clistiter * l;

  r = mailsmtp_mail(session, from);
  if (r != MAILSMTP_NO_ERROR)
    return r;

  for(l = clist_begin(addresses) ; l != NULL; l = clist_next(l)) {
    struct esmtp_address * addr;
    
    addr = clist_content(l);
    
    r = mailsmtp_rcpt(session, addr->address);
    if (r != MAILSMTP_NO_ERROR)
      return r;
  }

  r = mailsmtp_data(session);
  if (r != MAILSMTP_NO_ERROR)
    return r;

  r = mailsmtp_data_message(session, message, size);
  if (r != MAILSMTP_NO_ERROR)
    return r;

  return MAILSMTP_NO_ERROR;
}
Example #12
0
static int mailimf_keywords_write(FILE * f, int * col,
				  struct mailimf_keywords * keywords)
{
  int r;
  clistiter * cur;
  int first;
  
  r = mailimf_string_write(f, col, "Keywords: ", 10);
  if (r != MAILIMF_NO_ERROR)
    return r;

  first = TRUE;

  for(cur = clist_begin(keywords->kw_list) ; cur != NULL ;
      cur = clist_next(cur)) {
    char * keyword;
    size_t len;

    keyword = clist_content(cur);
    len = strlen(keyword);

    if (!first) {
      r = mailimf_string_write(f, col, ", ", 2);
      if (r != MAILIMF_NO_ERROR)
	return r;
    }
    else {
      first = FALSE;
    }

#if 0
    if (* col > 1) {
      
      if (* col + len >= MAX_MAIL_COL) {
	r = mailimf_string_write(f, col, "\r\n ", 3);
	if (r != MAILIMF_NO_ERROR)
	  return r;
#if 0
	* col = 1;
#endif
      }
    }
#endif

    r = mailimf_header_string_write(f, col, keyword, len);
    if (r != MAILIMF_NO_ERROR)
      return r;
  }

  r = mailimf_string_write(f, col, "\r\n", 2);
  if (r != MAILIMF_NO_ERROR)
    return r;
#if 0
  * col = 0;
#endif

  return MAILIMF_NO_ERROR;
}
Example #13
0
static int mailimf_msg_id_list_write(FILE * f, int * col, clist * mid_list)
{
  clistiter * cur;
  int r;
  int first;

  first = TRUE;

  for(cur = clist_begin(mid_list) ; cur != NULL ; cur = clist_next(cur)) {
    char * msgid;
    size_t len;

    msgid = clist_content(cur);
    len = strlen(msgid);
    
    /*
      XXX - if this is the first message ID, don't fold.
      This is a workaround for a bug of old versions of INN.
    */
    if (!first) {
      if (* col > 1) {
        
        if (* col + len >= MAX_MAIL_COL) {
          r = mailimf_string_write(f, col, "\r\n ", 3);
          if (r != MAILIMF_NO_ERROR)
            return r;
#if 0
          * col = 1;
#endif
          first = TRUE;
        }
      }
    }
    
    if (!first) {
      r = mailimf_string_write(f, col, " ", 1);
      if (r != MAILIMF_NO_ERROR)
	return r;
    }
    else {
      first = FALSE;
    }

    r = mailimf_string_write(f, col, "<", 1);
    if (r != MAILIMF_NO_ERROR)
      return r;

    r = mailimf_string_write(f, col, msgid, len);
    if (r != MAILIMF_NO_ERROR)
      return r;

    r = mailimf_string_write(f, col, ">", 1);
    if (r != MAILIMF_NO_ERROR)
      return r;
  }

  return MAILIMF_NO_ERROR;
}
Example #14
0
int mailimap_fetch_rfc822(mailimap * session,
			  uint32_t msgid, char ** result)
{
  int r;
  clist * fetch_list;
  struct mailimap_fetch_att * fetch_att;
  struct mailimap_fetch_type * fetch_type;
  struct mailimap_set * set;
  struct mailimap_msg_att * msg_att;
  struct mailimap_msg_att_item * item;
  int res;
  clistiter * cur;
  
  fetch_att = mailimap_fetch_att_new_rfc822();
  fetch_type = mailimap_fetch_type_new_fetch_att(fetch_att);
  set = mailimap_set_new_single(msgid);

  r = mailimap_fetch(session, set, fetch_type, &fetch_list);

  mailimap_set_free(set);
  mailimap_fetch_type_free(fetch_type);

  if (r != MAILIMAP_NO_ERROR) {
    res = r;
    goto err;
  }
  
  if (clist_isempty(fetch_list)) {
    res = MAILIMAP_ERROR_FETCH;
    goto free;
  }
  
  msg_att = (struct mailimap_msg_att *) clist_begin(fetch_list)->data;
  
  for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) {
    item = (struct mailimap_msg_att_item *) clist_content(cur);
    
    if (item->att_type != MAILIMAP_MSG_ATT_ITEM_STATIC) {
      continue;
    }
    if (item->att_data.att_static->att_type != MAILIMAP_MSG_ATT_RFC822) {
      continue;
    }
    
    * result = item->att_data.att_static->att_data.att_rfc822.att_content;
    item->att_data.att_static->att_data.att_rfc822.att_content = NULL;
    mailimap_fetch_list_free(fetch_list);
    
    return MAILIMAP_NO_ERROR;
  }
  
  res = MAILIMAP_ERROR_FETCH;
	
free:
	mailimap_fetch_list_free(fetch_list);
err:
	return res;
}
Example #15
0
void mailmime_single_fields_init(struct mailmime_single_fields * single_fields,
    struct mailmime_fields * fld_fields,
    struct mailmime_content * fld_content)
{
  clistiter * cur;

  memset(single_fields, 0, sizeof(struct mailmime_single_fields));

  if (fld_content != NULL)
    mailmime_content_single_fields_init(single_fields, fld_content);
  
  if (fld_fields == NULL)
    return;
  
  for(cur = clist_begin(fld_fields->fld_list) ; cur != NULL ;
      cur = clist_next(cur)) {
    struct mailmime_field * field;

    field = clist_content(cur);

    switch (field->fld_type) {
    case MAILMIME_FIELD_TYPE:
      mailmime_content_single_fields_init(single_fields,
          field->fld_data.fld_content);
      break;

    case MAILMIME_FIELD_TRANSFER_ENCODING:
      single_fields->fld_encoding = field->fld_data.fld_encoding;
      break;

    case MAILMIME_FIELD_ID:
      single_fields->fld_id = field->fld_data.fld_id;
      break;

    case MAILMIME_FIELD_DESCRIPTION:
      single_fields->fld_description = field->fld_data.fld_description;
      break;

    case MAILMIME_FIELD_VERSION:
      single_fields->fld_version = field->fld_data.fld_version;
      break;

    case MAILMIME_FIELD_DISPOSITION:
      mailmime_disposition_single_fields_init(single_fields,
          field->fld_data.fld_disposition);
      break;

    case MAILMIME_FIELD_LANGUAGE:
      single_fields->fld_language = field->fld_data.fld_language;
      break;
      
    case MAILMIME_FIELD_LOCATION:
      single_fields->fld_location = field->fld_data.fld_location;
      break;
    }
  }
}
Example #16
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;
}
Example #17
0
static int match_header(struct mailimf_fields * fields,
    char * name, char * value)
{
  clistiter * cur;

  for(cur = clist_begin(fields->list) ; cur != NULL ;
      cur = clist_content(cur)) {
    struct mailimf_field * field;
    struct mailimf_optional_field * opt_field;

    field = clist_content(cur);
    opt_field = field->optional_field;
    if ((char) toupper((unsigned char) opt_field->name[0]) ==
        (char) toupper((unsigned char) name[0])) {
      if (strcasecmp(opt_field->name, name) == 0)
	if (strstr(opt_field->value, value) != NULL)
	  return TRUE;
    }
  }
  return FALSE;
}
Example #18
0
static int is_search_header_only(struct mail_search_key * key)
{
  clistiter * cur;
  int result;

  switch (key->type) {
  case MAIL_SEARCH_KEY_ANSWERED:
  case MAIL_SEARCH_KEY_BCC:
  case MAIL_SEARCH_KEY_BEFORE:
  case MAIL_SEARCH_KEY_CC:
  case MAIL_SEARCH_KEY_DELETED:
  case MAIL_SEARCH_KEY_FLAGGED:
  case MAIL_SEARCH_KEY_FROM:
  case MAIL_SEARCH_KEY_NEW:
  case MAIL_SEARCH_KEY_OLD:
  case MAIL_SEARCH_KEY_ON:
  case MAIL_SEARCH_KEY_RECENT:
  case MAIL_SEARCH_KEY_SEEN:
  case MAIL_SEARCH_KEY_SINCE:
  case MAIL_SEARCH_KEY_SUBJECT:
  case MAIL_SEARCH_KEY_TO:
  case MAIL_SEARCH_KEY_UNANSWERED:
  case MAIL_SEARCH_KEY_UNDELETED:
  case MAIL_SEARCH_KEY_UNFLAGGED:
  case MAIL_SEARCH_KEY_UNSEEN:
  case MAIL_SEARCH_KEY_HEADER:
  case MAIL_SEARCH_KEY_LARGER:
  case MAIL_SEARCH_KEY_NOT:
  case MAIL_SEARCH_KEY_SMALLER:
  case MAIL_SEARCH_KEY_ALL:
    return TRUE;

  case MAIL_SEARCH_KEY_BODY:
  case MAIL_SEARCH_KEY_TEXT:
    return FALSE;

  case MAIL_SEARCH_KEY_OR:
    return (is_search_header_only(key->or1) &&
	    is_search_header_only(key->or2));

  case MAIL_SEARCH_KEY_MULTIPLE:
    result = TRUE;
    for (cur = clist_begin(key->multiple) ; cur != NULL ;
         cur = clist_next(cur))
      result = result && is_search_header_only(clist_content(cur));
    return result;

  default:
    return TRUE;
  }
}
Example #19
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;
}
static int etpan_fetch_mime(FILE * f, mailmessage * msg_info,
    struct mailmime * mime)
{
  int r;
  clistiter * cur;
  struct mailmime_single_fields fields;
  int res;

  memset(&fields, 0, sizeof(struct mailmime_single_fields));
  if (mime->mm_mime_fields != NULL)
    mailmime_single_fields_init(&fields, mime->mm_mime_fields,
        mime->mm_content_type);

  switch(mime->mm_type) {
  case MAILMIME_SINGLE:
    save_mime_content(msg_info, mime);

    break;
    
  case MAILMIME_MULTIPLE:

    for(cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ;
        cur != NULL ; cur = clist_next(cur)) {
      
      r = etpan_fetch_mime(f, msg_info, clist_content(cur));
      if (r != NO_ERROR) {
        res = r;
        goto err;
      }
    }

    break;
      
  case MAILMIME_MESSAGE:

    if (mime->mm_data.mm_message.mm_msg_mime != NULL) {
      r = etpan_fetch_mime(f, msg_info, mime->mm_data.mm_message.mm_msg_mime);
      if (r != NO_ERROR) {
        res = r;
        goto err;
      }
    }

    break;
  }

  return NO_ERROR;

 err:
  return res;
}
Example #21
0
static int comp_date(struct mailimf_fields * fields,
    struct mailimf_date_time * ref_date)
{
  clistiter * cur;
  struct mailimf_date_time * date;
  int r;

  date = NULL;
  for(cur = clist_begin(fields->list) ; cur != NULL ;
      cur = clist_content(cur)) {
    struct mailimf_field * field;
    struct mailimf_optional_field * opt_field;

    field = clist_content(cur);
    opt_field = field->optional_field;
    if ((char) toupper((unsigned char) opt_field->name[0]) == 'D') {
      if (strcasecmp(opt_field->name, "Date") == 0) {
	size_t cur_token;

	cur_token = 0;
	r = mailimf_date_time_parse(opt_field->value, strlen(opt_field->value),
				    &cur_token, &date);
	if (r == MAILIMF_NO_ERROR)
	  break;
	else if (r == MAILIMF_ERROR_PARSE) {
	  /* do nothing */
	}
	else
	  break;
      }
    }
  }

  if (date == NULL)
    return 0;

  return mailimf_date_time_comp(date, ref_date);
}
Example #22
0
int mailmime_transfer_encoding_get(struct mailmime_fields * fields)
{
  clistiter * cur;

  for(cur = clist_begin(fields->fld_list) ;
      cur != NULL ; cur = clist_next(cur)) {
    struct mailmime_field * field;

    field = clist_content(cur);
    if (field->fld_type == MAILMIME_FIELD_TRANSFER_ENCODING)
      return field->fld_data.fld_encoding->enc_type;
  }

  return MAILMIME_MECHANISM_8BIT;
}
Example #23
0
static void recursive_clear_registered_mime(struct mailprivacy * privacy,
    struct mailmime * mime)
{
  clistiter * cur;
  struct mailmime_data * data;
  
  switch (mime->mm_type) {
  case MAILMIME_SINGLE:
    if (mime_is_registered(privacy, mime)) {
      data = mime->mm_data.mm_single;
      if (data != NULL) {
        if (data->dt_type == MAILMIME_DATA_FILE)
          unlink(data->dt_data.dt_filename);
      }
    }
    break;
    
  case MAILMIME_MULTIPLE:
    if (mime_is_registered(privacy, mime)) {
      data = mime->mm_data.mm_multipart.mm_preamble;
      if (data != NULL) {
        if (data->dt_type == MAILMIME_DATA_FILE)
          unlink(data->dt_data.dt_filename);
      }
      data = mime->mm_data.mm_multipart.mm_epilogue;
      if (data != NULL) {
        if (data->dt_type == MAILMIME_DATA_FILE)
          unlink(data->dt_data.dt_filename);
      }
    }
    for(cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ;
        cur != NULL ; cur = clist_next(cur)) {
      struct mailmime * child;
      
      child = clist_content(cur);
      
      recursive_clear_registered_mime(privacy, child);
    }
    break;
    
  case MAILMIME_MESSAGE:
    if (mime->mm_data.mm_message.mm_msg_mime)
      recursive_clear_registered_mime(privacy,
          mime->mm_data.mm_message.mm_msg_mime);
    break;
  }
  unregister_mime(privacy, mime);
}
Example #24
0
int mailimf_fields_write(FILE * f, int * col,
			 struct mailimf_fields * fields)
{
  clistiter * cur;

  for(cur = clist_begin(fields->fld_list) ; cur != NULL ;
      cur = clist_next(cur)) {
    int r;
    
    r = mailimf_field_write(f, col, clist_content(cur));
    if (r != MAILIMF_NO_ERROR)
      return r;
  }

  return MAILIMF_NO_ERROR;
}
int mail_flags_has_extension(struct mail_flags * flags,
			     char * ext_flag)
{
  clistiter * cur;

  for(cur = clist_begin(flags->fl_extension) ; cur != NULL ;
      cur = clist_next(cur)) {
    char * flag_name;

    flag_name = clist_content(cur);

    if (strcasecmp(flag_name, ext_flag) == 0)
      return TRUE;
  }

  return FALSE;
}
Example #26
0
LIBETPAN_EXPORT
int mailesmtp_send(mailsmtp * session,
		    const char * from,
		    int return_full,
		    const char * envid,
		    clist * addresses,
		    const char * message, size_t size)
{
  int r;
  clistiter * l;

  if (!session->esmtp)
    return mailsmtp_send(session, from, addresses, message, size);

  if ((session->esmtp & MAILSMTP_ESMTP_SIZE) != 0) {
    if (session->smtp_max_msg_size != 0) {
      if (size > session->smtp_max_msg_size) {
        return MAILSMTP_ERROR_EXCEED_STORAGE_ALLOCATION;
      }
    }
  }

  r = mailesmtp_mail_size(session, from, return_full, envid, size);
  if (r != MAILSMTP_NO_ERROR)
    return r;

  for(l = clist_begin(addresses) ; l != NULL; l = clist_next(l)) {
    struct esmtp_address * addr;
    
    addr = clist_content(l);

    r = mailesmtp_rcpt(session, addr->address, addr->notify, addr->orcpt);
    if (r != MAILSMTP_NO_ERROR)
      return r;
  }

  r = mailsmtp_data(session);
  if (r != MAILSMTP_NO_ERROR)
    return r;

  r = mailsmtp_data_message(session, message, size);
  if (r != MAILSMTP_NO_ERROR)
    return r;

  return MAILSMTP_NO_ERROR;
}
Example #27
0
void mailprivacy_mime_clear(struct mailmime * mime)
{
  struct mailmime_data * data;
  clistiter * cur;
  
  switch (mime->mm_type) {
  case MAILMIME_SINGLE:
    data = mime->mm_data.mm_single;
    if (data != NULL) {
      if (data->dt_type == MAILMIME_DATA_FILE)
        unlink(data->dt_data.dt_filename);
    }
    break;
    
  case MAILMIME_MULTIPLE:
    data = mime->mm_data.mm_multipart.mm_preamble;
    if (data != NULL) {
      if (data->dt_type == MAILMIME_DATA_FILE)
        unlink(data->dt_data.dt_filename);
    }
    data = mime->mm_data.mm_multipart.mm_epilogue;
    if (data != NULL) {
      if (data->dt_type == MAILMIME_DATA_FILE)
        unlink(data->dt_data.dt_filename);
    }
    
    for(cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ;
        cur != NULL ; cur = clist_next(cur)) {
      struct mailmime * submime;
      
      submime = clist_content(cur);
      
      mailprivacy_mime_clear(submime);
    }
    break;
    
  case MAILMIME_MESSAGE:
    if (mime->mm_data.mm_message.mm_msg_mime != NULL) {
      mailprivacy_mime_clear(mime->mm_data.mm_message.mm_msg_mime);
    }
    break;
  }
}
static int recipient_add_addr_list(char * recipient, size_t * len,
    struct mailimf_address_list * addr_list)
{
  clistiter * cur;
  int r;

  for(cur = clist_begin(addr_list->ad_list) ; cur != NULL ;
      cur = clist_next(cur)) {
    struct mailimf_address * addr;

    addr = clist_content(cur);

    r = recipient_add_addr(recipient, len, addr);
    if (r != MAIL_NO_ERROR)
      return r;
  }
  
  return MAIL_NO_ERROR;
}
static int recipient_add_mb_list(char * recipient, size_t * len,
    struct mailimf_mailbox_list * mb_list)
{
  clistiter * cur;
  int r;

  for(cur = clist_begin(mb_list->mb_list) ; cur != NULL ;
      cur = clist_next(cur)) {
    struct mailimf_mailbox * mb;

    mb = clist_content(cur);

    r = recipient_add_mb(recipient, len, mb);
    if (r != MAIL_NO_ERROR)
      return r;
  }

  return MAIL_NO_ERROR;
}
Example #30
0
static struct mail_flags * mail_flags_dup(struct mail_flags * flags)
{
  clist * list;
  struct mail_flags * new_flags;
  int r;
  clistiter * cur;

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

  for(cur = clist_begin(flags->fl_extension) ; cur != NULL ;
      cur = clist_next(cur)) {
    char * ext;
    char * original_ext;
    
    original_ext = clist_content(cur);
    ext = strdup(original_ext);
    if (ext == NULL) {
      goto free;
    }

    r = clist_append(list, ext);
    if (r < 0) {
      free(ext);
      goto free;
    }
  }

  new_flags = mail_flags_new(flags->fl_flags, list);
  if (new_flags == NULL) {
    goto free;
  }

  return new_flags;

 free:
  clist_foreach(list, (clist_func) free, NULL);
  clist_free(list);
 err:
  return NULL;
}