2001-02-19 21:15:25 +00:00
|
|
|
/*
|
|
|
|
qfplist.h
|
|
|
|
|
|
|
|
Property list management types and prototypes
|
|
|
|
|
2001-06-19 02:10:47 +00:00
|
|
|
Copyright (C) 2000 Jeff Teunissen <deek@d2dc.net>
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
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:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
$Id$
|
|
|
|
*/
|
|
|
|
|
2001-06-19 02:10:47 +00:00
|
|
|
#ifndef __QF_qfplist_h_
|
|
|
|
#define __QF_qfplist_h_
|
|
|
|
|
2001-03-27 23:36:02 +00:00
|
|
|
#include "QF/qtypes.h"
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// Ugly defines for fast checking and conversion from char to number
|
|
|
|
#define inrange(ch,min,max) ((ch) >= (min) && (ch) <= (max))
|
|
|
|
#define char2num(ch) \
|
2001-06-19 02:10:47 +00:00
|
|
|
inrange((ch), '0', '9') ? ((ch) - 0x30) \
|
|
|
|
: (inrange((ch), 'a', 'f') ? ((ch) - 0x57) : ((ch) - 0x37))
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// Maximum number of items in an array
|
|
|
|
#define MAX_ARRAY_INDEX 128
|
|
|
|
|
|
|
|
typedef enum {QFDictionary, QFArray, QFBinary, QFString} pltype_t; // possible types
|
|
|
|
|
2001-06-19 02:10:47 +00:00
|
|
|
/*
|
|
|
|
Generic property list item
|
|
|
|
*/
|
2001-02-19 21:15:25 +00:00
|
|
|
struct plitem_s {
|
2001-06-19 02:10:47 +00:00
|
|
|
pltype_t type; // Type
|
|
|
|
void *data;
|
2001-02-19 21:15:25 +00:00
|
|
|
};
|
2001-06-19 02:10:47 +00:00
|
|
|
typedef struct plitem_s plitem_t;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
Dictionaries
|
|
|
|
*/
|
|
|
|
struct dictkey_s {
|
2001-06-19 02:10:47 +00:00
|
|
|
char *key;
|
|
|
|
plitem_t *value;
|
2001-02-19 21:15:25 +00:00
|
|
|
};
|
2001-06-19 02:10:47 +00:00
|
|
|
typedef struct dictkey_s dictkey_t;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
Arrays
|
|
|
|
*/
|
2001-06-19 02:10:47 +00:00
|
|
|
struct plarray_s {
|
|
|
|
int numvals; // Number of items in array
|
2001-02-19 21:15:25 +00:00
|
|
|
struct plitem_s *values[MAX_ARRAY_INDEX+1]; // Array data
|
|
|
|
};
|
2001-06-19 02:10:47 +00:00
|
|
|
typedef struct plarray_s plarray_t;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-06-19 02:10:47 +00:00
|
|
|
/*
|
|
|
|
Typeless, unformatted binary data (not supported yet)
|
|
|
|
*/
|
|
|
|
struct plbinary_s {
|
|
|
|
size_t size;
|
|
|
|
void *data;
|
|
|
|
};
|
|
|
|
typedef struct plbinary_s plbinary_t;
|
|
|
|
|
|
|
|
plitem_t *PL_GetPropertyList (const char *);
|
|
|
|
plitem_t *PL_ObjectForKey (struct hashtab_s *, const char *);
|
|
|
|
void PL_FreeItem (struct plitem_s *);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
typedef struct pldata_s { // Unparsed property list string
|
|
|
|
const char *ptr;
|
|
|
|
unsigned int end;
|
|
|
|
unsigned int pos;
|
|
|
|
unsigned int line;
|
|
|
|
char *error;
|
|
|
|
} pldata_t;
|
|
|
|
|
|
|
|
/*
|
|
|
|
Internal prototypes
|
|
|
|
|
|
|
|
static plist_t *PL_ParsePropertyList (pldata_t *);
|
|
|
|
static qboolean PL_SkipSpace (pldata_t *);
|
|
|
|
static char *PL_ParseQuotedString (pldata_t *);
|
|
|
|
static char *PL_ParseUnquotedString (pldata_t *);
|
|
|
|
*/
|
2001-06-19 02:10:47 +00:00
|
|
|
#endif // __QF_qfplist_h_
|