/*free given mailbox*/
void free_mb(mailbox* mb){
	if (mb == NULL)	return;
	free_mb(mb->next);
	free_mail(mb->msg);
	if (mb != NULL) {
		kmem_cache_free(mbCache, mb);
	}
}
/*free given mail*/
void free_mail(message* mail){
	if (mail == NULL) return;
	free_mail(mail->next);
	if (mail->content != NULL){
		kmem_cache_free(msgCache, mail->content);
	}
	if (mail != NULL) {
		kmem_cache_free(mailCache, mail);
	}
}
asmlinkage long sys_mb_exit_group(int error_code){
	pid_t mypid = current->pid;
	mailbox *mb = get_mailbox(mypid);
	if (mb != NULL){
		free_mail(mb->msg);
		if (mb != NULL)
			kmem_cache_free(mbCache, mb);
	}
	(*ref_sys_exit_group)(error_code);
	return 0;
}
Exemplo n.º 4
0
void mail_remove(USER_DATA *usr, MAIL_DATA *pMail, bool fSave) {
	if (!pMail) {
		send_to_user("ERROR: Null pMail.\n\r", usr);
		bbs_bug("Mail_remove: Null pMail");
		return;
	}

	UNLINK(pMail, usr->pMailFirst, usr->pMailLast);
	free_mail(pMail);
	if (fSave)
		save_mail(usr);
	return;
}
Exemplo n.º 5
0
static void free_ml(void)
{
  imc_mail *p, *p_next;

  for (p=imc_ml_head; p; p=p_next)
  {
    p_next=p->next;
    p->usage=0; /* suppress warnings */
    free_mail(p);
  }

  imc_ml_head=NULL;
}
Exemplo n.º 6
0
/**
 * Stores in a hashmap the tokens of an e-mail body.
 */
map_t tokenizebody(char *email){
    char *res;
    
    rfc2822eml ret= parser_mail(email);
    map_t tokenmap;
    
    //printf("before dump_text\n");
    res=dump_text(ret);
    //printf("after dum_text\n");
    
    (res!=NULL)?(tokenmap=tokenize(res)):(tokenmap=NULL);
    
    //free(res);
    free_mail(ret);
    //freeEMLParser();
    
    return tokenmap;
}
Exemplo n.º 7
0
static void delete_ml(imc_mail *node)
{
  imc_mail *last, *p;

  if (!node)
  {
    imc_logerror("BUG: delete_ml: NULL node");
    return;
  }

  for (last=imc_ml_head, p=last->next; p && p != node; p=p->next)
    ;

  if (p)
  {
    last->next = p->next;
    free_mail(p);
  }
  else
    imc_logerror("BUG: delete_ml: node at %p not on list", node);
}
Exemplo n.º 8
0
void edit_mail_free(USER_DATA *usr) {
	if (usr->pCurrentMail) {
		free_mail(usr->pCurrentMail);
		usr->pCurrentMail = NULL;
	}
}
Exemplo n.º 9
0
//Free data
void free_data(void *data){
    free_mail((rfc2822eml)data);
}
Exemplo n.º 10
0
/* imc_send_mail: called by the mud to add a piece of mail to the queue */
void imc_send_mail(const char *from, const char *to, const char *date,
		   const char *subject, const char *text)
{
  char temp[IMC_DATA_LENGTH];
  imc_mail *m;
  imc_qnode *qroot, *q;
  char arg[IMC_NAME_LENGTH];
  const char *mud;
  int when=10;

  /* set up the entry for the mail list */

  m=new_mail();

  mudtoaddr(to, temp);		/* qualify local addresses */
  m->to       = imc_strdup(temp);
  sprintf(temp, "%s@%s", from, imc_name);	/* qualify sender */
  m->from     = imc_strdup(temp);
  m->date     = imc_strdup(date);
  m->subject  = imc_strdup(subject);
  m->id       = imc_strdup(generate_mailid());
  m->text     = imc_strdup(text);
  m->received = imc_now;

  qroot=NULL;			/* initialise the local list */
  to=imc_getarg(to, arg, IMC_NAME_LENGTH);

  while (*arg)
  {
    /*  get a mudname and check if we've already added a queue entry for that
     *  mud. If not, add it
     */

    if (strchr(arg, '@') != NULL && (mud = imc_mudof(arg))[0] != 0 &&
	strcasecmp(mud, imc_name))
    {
      if (!strcmp(mud, "*"))
	q=NULL;	                /* catch the @* case - not yet implemented */
      else
	for (q=qroot; q; q=q->next)
	  if (!strcasecmp(q->tomud, mud))
	    break;

      if (!q)			/* not seen yet */
      {				/* add to the top of our mini-queue */
	q=new_qnode();
	q->tomud=imc_strdup(mud);
	q->data=m;
	q->next=qroot;
	m->usage++;
	qroot=q;

	imc_add_event(when, ev_qnode_send, q, 1);
	when += rand()%30+30;
      }
    }

    /* get the next address */

    to=imc_getarg(to, arg, IMC_NAME_LENGTH);
  }

  if (!qroot)			/* boggle, no foreign addresses?? */
  {
    free_mail(m);
    return;
  }

  /* add mail to mail list, add mini-queue to mail queue */

  add_ml(m);
  add_mq(qroot);
  save_ml();
  save_mq();
}