diff options
| author | svn svn@31f1291d-b8d6-0310-a050-a5561fc1590b <svn svn@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864> | 2004-03-28 21:59:56 +0000 |
|---|---|---|
| committer | svn svn@31f1291d-b8d6-0310-a050-a5561fc1590b <svn svn@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864> | 2004-03-28 21:59:56 +0000 |
| commit | 55bf4dbcabf378e9472b7d31d6edf87f6ac853e9 (patch) | |
| tree | 7a9454ea6b8750256e242cf6d5fba3ca7a4b5044 /slist.h | |
Initial Anope Import
git-svn-id: svn://svn.anope.org/anope/trunk@1 31f1291d-b8d6-0310-a050-a5561fc1590b
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'slist.h')
| -rw-r--r-- | slist.h | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/slist.h b/slist.h new file mode 100644 index 000000000..a4e3001e2 --- /dev/null +++ b/slist.h @@ -0,0 +1,63 @@ +/* Header for Services list handler. + * + * (C) 2003 Anope Team + * Contact us at info@anope.org + * + * Please read COPYING and README for furhter details. + * + * Based on the original code of Epona by Lara. + * Based on the original code of Services by Andy Church. + * + * $Id: slist.h,v 1.4 2003/07/20 01:15:50 dane Exp $ + * + */ + +#ifndef SLIST_H +#define SLIST_H + +typedef struct slist_ SList; +typedef struct slistopts_ SListOpts; + +struct slist_ { + void **list; + + int16 count; /* Total entries of the list */ + int16 capacity; /* Capacity of the list */ + int16 limit; /* Maximum possible entries on the list */ + + SListOpts *opts; +}; + +struct slistopts_ { + int32 flags; /* Flags for the list. See below. */ + + int (*compareitem) (SList *slist, void *item1, void *item2); /* Called to compare two items */ + int (*isequal) (SList *slist, void *item1, void *item2); /* Called by slist_indexof. item1 can be an arbitrary pointer. */ + void (*freeitem) (SList *slist, void *item); /* Called when an item is removed */ +}; + +#define SLIST_DEFAULT_LIMIT 32767 + +#define SLISTF_NODUP 0x00000001 /* No duplicates in the list. */ +#define SLISTF_SORT 0x00000002 /* Automatically sort the list. Used with compareitem member. */ + +/* Note that number is the index in the array + 1 */ +typedef int (*slist_enumcb_t) (SList *slist, int number, void *item, va_list args); +/* Callback to know whether we can delete the entry. */ +typedef int (*slist_delcheckcb_t) (SList *slist, void *item, va_list args); + +/* Functions for global use */ +extern int slist_add(SList *slist, void *item); +extern void slist_clear(SList *slist, int free); +extern int slist_delete(SList *slist, int index); +extern int slist_delete_range(SList *slist, char *range, slist_delcheckcb_t cb, ...); +extern int slist_enum(SList *slist, char *range, slist_enumcb_t cb, ...); +extern int slist_full(SList *slist); +extern int slist_indexof(SList *slist, void *item); +extern void slist_init(SList *slist); +extern void slist_pack(SList *slist); +extern int slist_remove(SList *slist, void *item); +extern int slist_setcapacity(SList *slist, int16 capacity); + +#endif /* SLIST_H */ + |
