Пример #1
0
static void nc_conn_written(struct nc_conn *conn, size_t bytes)
{
	while (bytes > 0) {
		clist *tmp;
		struct buffer *buf;
		unsigned int left;

		tmp = conn->write_q;
		buf = tmp->data;
		left = buf->len - conn->write_partial;

		/* buffer fully written; free */
		if (bytes >= left) {
			free(buf->p);
			free(buf);
			conn->write_partial = 0;
			conn->write_q = clist_delete(tmp, tmp);

			bytes -= left;
		}

		/* buffer partially written; store state */
		else {
			conn->write_partial += bytes;
			break;
		}
	}
}
Пример #2
0
void
session_delete(struct session *session)
{
    /* Delete the clist */
    if (session->own_clist) {
        clist_delete(session->clist);
    }

    /* Delete the session */
    iguana_session_delete(IGUANA_PAGER, session->ref, NULL);
    free(session);
}
Пример #3
0
struct peer *peerman_pop(struct peer_manager *peers)
{
	struct peer *peer;
	clist *tmp;

	tmp = peers->addrlist;
	if (!tmp)
		return NULL;

	peer = tmp->data;

	peers->addrlist = clist_delete(tmp, tmp);

	bp_hashtab_del(peers->map_addr, peer->addr.ip);

	return peer;
}
Пример #4
0
LIBETPAN_EXPORT
void mailfolder_disconnect(struct mailfolder * folder)
{
  if (folder->fld_session == NULL)
    return;

  if (folder->fld_shared_session) {
    clist_delete(folder->fld_storage->sto_shared_folders, folder->fld_pos);
    folder->fld_pos = NULL;
  }
  else {
    mailsession_logout(folder->fld_session);
    mailsession_free(folder->fld_session);
  }

  folder->fld_session = NULL;
}
Пример #5
0
void mailmime_remove_part(struct mailmime * mime)
{
  struct mailmime * parent;

  parent = mime->mm_parent;
  if (parent == NULL)
    return;

  switch (mime->mm_parent_type) {
  case MAILMIME_MESSAGE:
    mime->mm_parent = NULL;
    parent->mm_data.mm_message.mm_msg_mime = NULL;
    break;

  case MAILMIME_MULTIPLE:
    mime->mm_parent = NULL;
    clist_delete(parent->mm_data.mm_multipart.mm_mp_list,
        mime->mm_multipart_pos);
    break;
  }
}
Пример #6
0
int mail_flags_remove_extension(struct mail_flags * flags,
				char * ext_flag)
{
  clistiter * cur;
  
  cur = clist_begin(flags->fl_extension);
  while (cur != NULL) {
    char * flag_name;

    flag_name = clist_content(cur);

    if (strcasecmp(flag_name, ext_flag) == 0) {
      free(flag_name);
      cur = clist_delete(flags->fl_extension, cur);
    }
    else
      cur = clist_next(cur);
  }

  return MAIL_NO_ERROR;
}
Пример #7
0
static int remove_from_list(mailsession * session, const char * mb)
{
  clistiter * cur;
  struct nntp_session_state_data * data;

  data = get_data(session);

  for(cur = clist_begin(data->nntp_subscribed_list) ; cur != NULL ;
      cur = clist_next(cur)) {
    char * cur_name;

    cur_name = clist_content(cur);
    if (strcmp(cur_name, mb) == 0) {
      clist_delete(data->nntp_subscribed_list, cur);
      free(cur_name);
      return 0;
    }
  }

  return -1;
}
Пример #8
0
struct session *
session_create(objref_t object, L4_ThreadId_t *server_tid)
{
    clist_ref_t clist;
    struct session *session;

    clist = clist_create();
    if (clist == 0) {
        return 0;
    }
    session = session_create_with_clist(object, clist, server_tid);

    if (session == NULL) {
        clist_delete(clist);
        return NULL;
    }

    session->own_clist = 1;

    return session;
}
Пример #9
0
int main(void)
{
	link cursor = NULL;
	int i = 0;

	clist_print(cursor, print_int_data);

	for (i = 0; i < 100; i++)
	{
		int *p = make_data(i+1);
		link item = make_node(p);
		cursor = clist_insert_after(cursor, item);
	}

	cursor = cursor->next;
	clist_print(cursor, print_int_data);
	printf("ring list length = %d\n", clist_length(cursor));

	int step = 0;
	while (cursor != NULL)
	{
		print_int_data(cursor->data);
		step++;

		if (step == 3)	
		{
			printf("-> %d out\n", *(int *)(cursor->data));
			cursor = clist_delete(cursor, cursor);
			printf("length = %d\n", clist_length(cursor));
			step = 0;
		}
		else
			cursor = cursor->next;

		//getchar();
		//sleep(1);
	}

	return 0;
}
Пример #10
0
static void strip_mime_headers(struct mailmime * mime)
{
  struct mailmime_fields * fields;
  clistiter * cur;
  
  fields = mime->mm_mime_fields;
  
  if (fields == NULL)
    return;
  
  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_VERSION) {
      mailmime_field_free(field);
      clist_delete(fields->fld_list, cur);
      break;
    }
  }
}
Пример #11
0
LIBETPAN_EXPORT
int mailimap_acl_myrights(mailimap * session,
    const char * mailbox,
    struct mailimap_acl_myrights_data ** result)
{
  struct mailimap_response * response;
  struct mailimap_extension_data * ext_data;
  clistiter * cur;
  int r;
  int error_code;

  if (session->imap_state != MAILIMAP_STATE_AUTHENTICATED)
    return MAILIMAP_ERROR_BAD_STATE;

  r = mailimap_send_current_tag(session);
  if (r != MAILIMAP_NO_ERROR)
    return r;

  r = mailimap_acl_myrights_send(session->imap_stream, mailbox);
  if (r != MAILIMAP_NO_ERROR)
    return r;

  r = mailimap_crlf_send(session->imap_stream);
  if (r != MAILIMAP_NO_ERROR)
    return r;

  if (mailstream_flush(session->imap_stream) == -1)
    return MAILIMAP_ERROR_STREAM;

  if (mailimap_read_line(session) == NULL)
    return MAILIMAP_ERROR_STREAM;

  r = mailimap_parse_response(session, &response);
  if (r != MAILIMAP_NO_ERROR)
    return r;

  * result = NULL;

  /* in rsp_extension_list there is at most one myrights_data */
  for (cur = clist_begin(session->imap_response_info->rsp_extension_list);
    cur != NULL; cur = clist_next(cur)) {
      ext_data = (struct mailimap_extension_data *) clist_content(cur);
      if (
        ext_data->ext_extension->ext_id == MAILIMAP_EXTENSION_ACL &&
        ext_data->ext_type == MAILIMAP_ACL_TYPE_MYRIGHTS_DATA) {
          * result = (struct mailimap_acl_myrights_data *)ext_data->ext_data;
          ext_data->ext_data = NULL;
          /* remove the element from rsp_extension_list */
          clist_delete(session->imap_response_info->rsp_extension_list, cur);
          mailimap_extension_data_free(ext_data);

          break;
      }
  }

  clist_foreach(session->imap_response_info->rsp_extension_list,
        (clist_func) mailimap_extension_data_free, NULL);
  clist_free(session->imap_response_info->rsp_extension_list);
  session->imap_response_info->rsp_extension_list = NULL;

  error_code = response->rsp_resp_done->rsp_data.rsp_tagged->rsp_cond_state->rsp_type;

  mailimap_response_free(response);

  /* if there is no data to be returned, return MAILIMAP_ERROR_EXTENSION */
  if (* result == NULL)
    return MAILIMAP_ERROR_EXTENSION;

  switch (error_code) {
  case MAILIMAP_RESP_COND_STATE_OK:
    return MAILIMAP_NO_ERROR;

  default:
    return MAILIMAP_ERROR_EXTENSION;
  }
}