/*
	**
	** summary-sort.h
	**
	** Sorts hosts and peers tables into linked list
	**
	** Copyright 1998 Damien Miller <dmiller@ilogic.com.au>
	**
	** This software is licensed under the terms of the GNU General 
	** Public License (GPL). Please see the file COPYING for details.
	** 
	** $Id: summary-sort.h,v 1.2 1998/12/02 01:11:18 dmiller Exp $
	**
 */

#ifndef _SUMMARY_SORT_H
#define _SUMMARY_SORT_H

#define SORT_NONE 					0
#define SORT_BYTES					1
#define SORT_BYTES_SENT 			2
#define SORT_BYTES_RECEIVED		3
#define SORT_PACKETS 				4
#define SORT_PACKETS_SENT  		5
#define SORT_PACKETS_RECEIVED 	6
#define SORT_CONNECTS				7
#define SORT_CONNECTS_SENT 		8
#define SORT_CONNECTS_RECEIVED	9
#define SORT_PEERS					10
#define SORT_HOSTNAME				11
#define SORT_IP_ADDR					12
#define SORT_FIRST_SEEN				13
#define SORT_LAST_SEEN				14
#define SORT_RANDOM					15

#define SORT_HOST_DEFAULT  		SORT_BYTES
#define SORT_PEER_DEFAULT  		SORT_BYTES

#include <glib.h>
#include "summary-structures.h"

/* Linked list of hosts */
typedef struct HOST_LIST
{
	host_t				*host;
	struct HOST_LIST	*next;
} host_list_t;

/* Linked list of peers */
typedef struct PEER_LIST
{
	peer_t				*peer;
	struct PEER_LIST	*next;
} peer_list_t;

/* Sorts hosts table into linked list */
host_list_t	*sort_hosts(GHashTable *hosts, unsigned int max_hosts, int host_sort_mode, int host_reverse);

/* Re-sort host list */
host_list_t	*resort_host_list(host_list_t *hl, int host_sort_mode, int host_reverse);

/* Sort peers list into linked list */
peer_list_t	*sort_peers(u_int64_t *peer_keys, unsigned int n_peers, GHashTable *peers, unsigned int max_peers, int peer_sort_mode, int peer_reverse);

/* Parses textual host sort key into numeric identifier */
int parse_host_sort_mode(const char *sort_mode);

/* Parses textual peer sort key into numeric identifier */
int parse_peer_sort_mode(const char *sort_mode);

#endif /* _SUMMARY_SORT_H */
