owntone-server/src/ll.h

73 lines
1.9 KiB
C
Raw Normal View History

2006-02-04 19:22:46 -05:00
/*
* $Id$
* Rock stupid char* indexed linked lists
*
* Copyright (C) 2006 Ron Pedde (rpedde@users.sourceforge.net)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _LL_H_
#define _LL_H_
#define LL_TYPE_INT 0
#define LL_TYPE_STRING 1
#define LL_TYPE_LL 2
#define LL_E_SUCCESS 0
#define LL_E_MALLOC 1
#define LL_E_NOKEY 2
#define LL_FLAG_HONORCASE 1 /** Make keys case sensitive */
#define LL_FLAG_HEADINSERT 2 /** Insert at head, rather than tail */
typedef struct _LLITEM {
int type;
char *key;
union {
int as_int;
char *as_string;
struct _LL *as_ll;
} value;
struct _LLITEM *next;
} LL_ITEM, *LL_ITEMHANDLE;
typedef struct _LL {
unsigned int flags;
struct _LLITEM *tailptr;
struct _LLITEM itemlist;
} LL, *LL_HANDLE;
extern int ll_create(LL **ppl);
extern int ll_destroy(LL *pl);
extern int ll_add_string(LL *pl, char *key, char *cval);
extern int ll_add_int(LL *pl, char *key, int ival);
extern int ll_add_ll(LL *pl, char *key, LL *pnew);
extern int ll_set_flags(LL *pl, unsigned int flags);
extern int ll_get_flags(LL *pl, unsigned int *flags);
extern LL_ITEM *ll_fetch_item(LL *pl, char *key);
extern void ll_dump(LL *pl);
#endif /* _LL_H_ */