Anope IRC Services  Version 1.8
Functions | Variables
slist.c File Reference
#include "services.h"
#include "slist.h"
Include dependency graph for slist.c:

Go to the source code of this file.

Functions

int slist_add (SList *slist, void *item)
 
void slist_clear (SList *slist, int mustfree)
 
int slist_delete (SList *slist, int index)
 
int slist_delete_range (SList *slist, char *range, slist_delcheckcb_t cb,...)
 
int slist_enum (SList *slist, char *range, slist_enumcb_t cb,...)
 
int slist_full (SList *slist)
 
void slist_init (SList *slist)
 
int slist_indexof (SList *slist, void *item)
 
void slist_pack (SList *slist)
 
int slist_remove (SList *slist, void *item)
 
int slist_setcapacity (SList *slist, int16 capacity)
 

Variables

static SListOpts slist_defopts = { 0, NULL, NULL, NULL }
 

Function Documentation

int slist_add ( SList slist,
void *  item 
)

Adds a pointer to the list. Returns the index of the new item. Returns -2 if there are too many items in the list, -3 if the item already exists when the flags of the list contain SLISTF_NODUP.

Parameters
slistSlist Struct
itemItem being added
Returns
int

Definition at line 29 of file slist.c.

References slist_::capacity, slistopts_::compareitem, slist_::count, slistopts_::flags, slist_::limit, slist_::list, slist_::opts, slist_indexof(), slist_setcapacity(), SLISTF_NODUP, and SLISTF_SORT.

Referenced by add_akill(), add_sgline(), add_sqline(), add_szline(), db_mysql_load_ns_dbase(), db_mysql_load_os_dbase(), do_admin(), do_oper(), load_ns_dbase(), load_old_akill(), load_old_ns_dbase(), load_os_dbase(), makealias(), and makenick().

void slist_clear ( SList slist,
int  mustfree 
)

Clears the list. If free is 1, the freeitem function will be called for each item before clearing.

Parameters
slistSlist Struct
mustfreeWhat is being freed
Returns
void

Definition at line 70 of file slist.c.

References slist_::capacity, slist_::count, slistopts_::freeitem, slist_::list, and slist_::opts.

Referenced by do_admin(), do_akill(), do_oper(), do_sgline(), do_sqline(), and do_szline().

int slist_delete ( SList slist,
int  index 
)

Deletes an item from the list, by index. Returns 1 if successful, 0 otherwise.

Parameters
slistSlist Struct
indexbeign deleted
Returns
int Returns 1 if successful, 0 otherwise.

Definition at line 97 of file slist.c.

References slist_::capacity, slist_::count, slistopts_::freeitem, slist_::list, slist_::opts, and slist_setcapacity().

Referenced by add_akill(), add_sgline(), add_sqline(), add_szline(), do_admin(), do_akill(), do_oper(), do_sgline(), do_sqline(), do_szline(), expire_akills(), expire_sglines(), expire_sqlines(), expire_szlines(), load_old_akill(), slist_pack(), and slist_remove().

int slist_delete_range ( SList slist,
char *  range,
slist_delcheckcb_t  cb,
  ... 
)

Deletes a range of entries. Return -1 if the permission was denied, 0 if no records were deleted, or the number of records deleted

Parameters
slistSlist Struct
rangeRange to delete
cbCall back function
...various args
Returns
int

Definition at line 129 of file slist.c.

References slist_::count, slistopts_::freeitem, slist_::list, slist_::opts, slist_pack(), and VA_COPY.

Referenced by do_admin(), do_akill(), do_oper(), do_sgline(), do_sqline(), and do_szline().

int slist_enum ( SList slist,
char *  range,
slist_enumcb_t  cb,
  ... 
)

Enumerates all entries of the list. If range is not NULL, will only enumerate entries that are in the range. Returns the total number of entries enumerated.

Parameters
slitSlist struct
rangeRange to enum
cbCall back function
...various args
Returns
int

Definition at line 203 of file slist.c.

References alog(), slist_::count, slist_::list, and VA_COPY.

Referenced by do_admin(), do_akill(), do_oper(), do_sgline(), do_sqline(), do_staff(), and do_szline().

int slist_full ( SList slist)

Determines whether the list is full.

Parameters
slistSlist Struct
Returns
int

Definition at line 287 of file slist.c.

References slist_::count, and slist_::limit.

Referenced by add_akill(), add_sgline(), add_sqline(), and add_szline().

int slist_indexof ( SList slist,
void *  item 
)

Returns the index of an item in the list, -1 if inexistant.

Parameters
slistSlist Struct
itemItem index
Returns
int

Definition at line 317 of file slist.c.

References slist_::count, slistopts_::isequal, slist_::list, and slist_::opts.

Referenced by do_admin(), do_akill(), do_oper(), do_sgline(), do_sqline(), do_szline(), load_old_akill(), load_os_dbase(), slist_add(), and slist_remove().

void slist_init ( SList slist)

Initialization of the list.

Parameters
slistSlist Struct
Returns
int

Definition at line 302 of file slist.c.

References slist_::limit, slist_::opts, SLIST_DEFAULT_LIMIT, and slist_defopts.

Referenced by load_ns_dbase(), load_old_ns_dbase(), makenick(), and os_init().

void slist_pack ( SList slist)

Removes all NULL pointers from the list.

Parameters
slistSlist Struct
Returns
void

Definition at line 344 of file slist.c.

References slist_::count, slist_::list, and slist_delete().

Referenced by slist_delete_range().

int slist_remove ( SList slist,
void *  item 
)

Removes a specific item from the list. Returns the old index of the deleted item, or -1 if the item was not found.

Parameters
slistSlist Struct
itemto remove
Returns
int

Definition at line 362 of file slist.c.

References slist_delete(), and slist_indexof().

Referenced by delnick(), and os_remove_nick().

int slist_setcapacity ( SList slist,
int16  capacity 
)

Sets the maximum capacity of the list

Parameters
slistSlist Struct
capacityHow large the list can be
Returns
int

Definition at line 379 of file slist.c.

References slist_::capacity, slist_::count, slist_::list, and srealloc().

Referenced by db_mysql_load_os_dbase(), load_old_akill(), load_os_dbase(), slist_add(), and slist_delete().

Variable Documentation

SListOpts slist_defopts = { 0, NULL, NULL, NULL }
static

Definition at line 17 of file slist.c.

Referenced by slist_init().