Ejemplo n.º 1
0
static char * get_first_from_addr(struct mailmime * mime)
{
  clistiter * cur;
  struct mailimf_single_fields single_fields;
  struct mailimf_fields * fields;
  struct mailimf_mailbox * mb;
  
  while (mime->mm_parent != NULL)
    mime = mime->mm_parent;
  
  if (mime->mm_type != MAILMIME_MESSAGE)
    return NULL;
  
  fields = mime->mm_data.mm_message.mm_fields;
  if (fields == NULL)
    return NULL;
  
  mailimf_single_fields_init(&single_fields, fields);
  
  if (single_fields.fld_from == NULL)
    return NULL;
  
  cur = clist_begin(single_fields.fld_from->frm_mb_list->mb_list);
  if (cur == NULL)
    return NULL;
  
  mb = clist_content(cur);
  
  return mb->mb_addr_spec;
}
Ejemplo n.º 2
0
LIBETPAN_EXPORT
void mailmessage_resolve_single_fields(mailmessage * msg_info)
{
  if (!msg_info->msg_resolved) {
    if (msg_info->msg_fields != NULL) {
      mailimf_single_fields_init(&msg_info->msg_single_fields,
          msg_info->msg_fields);
      msg_info->msg_resolved = TRUE;
    }
  }
}
Ejemplo n.º 3
0
static int collect_smime_cert(char * recipient, size_t size,
    struct mailimf_fields * fields)
{
  struct mailimf_single_fields single_fields;
  int r;
  size_t remaining;
  int res;
  
  * recipient = '\0';
  remaining = size;
  
	mailimf_single_fields_init(&single_fields, fields);
  
  if (single_fields.fld_to != NULL) {
    r = recipient_add_addr_list(recipient, &remaining,
        single_fields.fld_to->to_addr_list);
    if (r != MAIL_NO_ERROR) {
      res = r;
      goto err;
    }
  }
  
  if (single_fields.fld_cc != NULL) {
    r = recipient_add_addr_list(recipient, &remaining,
        single_fields.fld_cc->cc_addr_list);
    if (r != MAIL_NO_ERROR) {
      res = r;
      goto err;
    }
  }
  
  if (single_fields.fld_bcc != NULL) {
    if (single_fields.fld_bcc->bcc_addr_list != NULL) {
      r = recipient_add_addr_list(recipient, &remaining,
          single_fields.fld_bcc->bcc_addr_list);
      if (r < 0) {
        res = r;
        goto err;
      }
    }
  }
  
  return MAIL_NO_ERROR;
  
 err:
  return res;
}
Ejemplo n.º 4
0
static void simple_print_mail_info(mailmessage * msg)
{
  char * from;
  char * subject;
  int is_addr;
  char * dsp_from;
  char * dsp_subject;
  char output[MAX_OUTPUT];
  struct mailimf_single_fields single_fields;
  
  is_addr = 0;
  from = NULL;
  subject = NULL;
  
  if (msg->msg_fields != NULL)
    mailimf_single_fields_init(&single_fields, msg->msg_fields);
  else
    memset(&single_fields, 0, sizeof(single_fields));
  
  /* from field */
 
  get_from_value(&single_fields, &from, &is_addr);

  if (from == NULL)
    dsp_from = strdup("");
  else
    dsp_from = strdup(from);
  if (dsp_from == NULL)
    goto err;

  strip_crlf(dsp_from);

  /* subject */
  
  if (single_fields.fld_subject != NULL)
    subject = single_fields.fld_subject->sbj_value;
    
  if (subject == NULL)
    dsp_subject = strdup("");
  else
    dsp_subject = strdup(subject);
  
  if (dsp_subject == NULL)
    goto free_from;

  strip_crlf(dsp_subject);

  snprintf(output, MAX_OUTPUT, "%3i: %-21.21s %-53.53s\n",
      msg->msg_index % 1000, dsp_from, dsp_subject);
  
  printf("%s\n", output);

  free(dsp_subject);
  free(dsp_from);

  return;

 free_from:
  free(dsp_from);
 err:
  {}
}