diff options
author | 2013-01-01 16:11:32 +0000 | |
---|---|---|
committer | 2013-01-01 16:11:32 +0000 | |
commit | ad80ff6c3f58529f95ca71d4ec397df6cb7eb25d (patch) | |
tree | 965b7d6f81b42ce36d685246ea1d067b88067111 /src/lib/portmidi/readbinaryplist.h | |
parent | e000eedfbbc6c8b5edd9f9e738e2ef12c9f326dc (diff) |
portmidi: Initial commit. [R. Belmont]
(nw: this isn't enabled to compile yet, this is just to make it easier to run the final tests on my Mac and my Windows laptop)
Diffstat (limited to 'src/lib/portmidi/readbinaryplist.h')
-rw-r--r-- | src/lib/portmidi/readbinaryplist.h | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/src/lib/portmidi/readbinaryplist.h b/src/lib/portmidi/readbinaryplist.h new file mode 100644 index 00000000000..e82056a0b79 --- /dev/null +++ b/src/lib/portmidi/readbinaryplist.h @@ -0,0 +1,88 @@ +/* readbinaryplist.h -- header to read preference files + + Roger B. Dannenberg, Jun 2008 +*/ + +#include <stdint.h> /* for uint8_t ... */ + +#ifndef TRUE + #define TRUE 1 + #define FALSE 0 +#endif + +#define MAX_KEY_SIZE 256 + +enum +{ + // Object tags (high nybble) + kTAG_SIMPLE = 0x00, // Null, true, false, filler, or invalid + kTAG_INT = 0x10, + kTAG_REAL = 0x20, + kTAG_DATE = 0x30, + kTAG_DATA = 0x40, + kTAG_ASCIISTRING = 0x50, + kTAG_UNICODESTRING = 0x60, + kTAG_UID = 0x80, + kTAG_ARRAY = 0xA0, + kTAG_DICTIONARY = 0xD0, + + // "simple" object values + kVALUE_NULL = 0x00, + kVALUE_FALSE = 0x08, + kVALUE_TRUE = 0x09, + kVALUE_FILLER = 0x0F, + + kVALUE_FULLDATETAG = 0x33 // Dates are tagged with a whole byte. +}; + + +typedef struct pldata_struct { + uint8_t *data; + size_t len; +} pldata_node, *pldata_ptr; + + +typedef struct array_struct { + struct value_struct **array; + uint64_t length; +} array_node, *array_ptr; + + +// a dict_node is a list of <key, value> pairs +typedef struct dict_struct { + struct value_struct *key; + struct value_struct *value; + struct dict_struct *next; +} dict_node, *dict_ptr; + + +// an value_node is a value with a tag telling the type +typedef struct value_struct { + int tag; + union { + int64_t integer; + uint64_t uinteger; + double real; + char *string; + pldata_ptr data; + array_ptr array; + struct dict_struct *dict; + }; +} value_node, *value_ptr; + + +value_ptr bplist_read_file(char *filename); +value_ptr bplist_read_user_pref(char *filename); +value_ptr bplist_read_system_pref(char *filename); +void bplist_free_data(void); + +/*************** functions for accessing values ****************/ + +char *value_get_asciistring(value_ptr v); +value_ptr value_dict_lookup_using_string(value_ptr v, char *key); +value_ptr value_dict_lookup_using_path(value_ptr v, char *path); + +/*************** functions for debugging ***************/ + +void plist_print(value_ptr v); + |