File: proplist.h

package info (click to toggle)
libproplist 0.7.1-4
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 684 kB
  • ctags: 452
  • sloc: ansic: 3,684; sh: 1,856; lex: 181; yacc: 118; makefile: 106; tcl: 40
file content (165 lines) | stat: -rw-r--r-- 4,995 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
/* proplist.h: This is -*- c -*-

   Copyright (c) 1997 Bjoern Giesler <giesler@ira.uka.de>
   libPropList and this file are subject to the GNU Library Public License
   (LPL). You should have received a copy of that license; it's in the 
   file COPYING.LIB.
   
   Interface declaration for the property-list handling library. This
   library allows plain C programs to use (read and write)
   GNUstep-style property lists. It defines the opaque data type
   proplist_t. An element of type proplist_t can be a string, an
   array, a dictionary or a data object.

   */

#ifndef PROPLIST_H
#define PROPLIST_H

#ifndef BOOL
#define BOOL int
#endif /* !def BOOL */
#ifndef YES
#define YES 1
#define NO 0
#endif /* !def YES */

typedef void *proplist_t;

typedef void (*plcallback_t)(void);

/*
 * Vanilla file-handling stuff
 */

/* Return a pointer to a proplist structure if successful, NULL otherwise */
proplist_t PLGetProplistWithDescription(const char *description);

/* Return a pointer to a proplist structure if successful, NULL otherwise */
proplist_t PLGetProplistWithPath(const char *filename);

/* Synchronize the proplist with the file: Returns NO on error */
BOOL PLSynchronize(proplist_t pl);

/* Write out to a file. Uses temporary file if atomically==YES. Returns
   NO on error */ 
BOOL PLSave(proplist_t pl, BOOL atomically);

/* Get the file name for the property list */
proplist_t PLSetFilename(proplist_t pl, proplist_t filename);

/* Get the file name, or NULL if there isn't any */
proplist_t PLGetFilename(proplist_t pl);

/*
 * Talking to the daemon
 */

/* Get an array containing all registered domain names. */
proplist_t PLGetDomainNames();

/* Get the named domain from the daemon. If callback is non-NULL, it
   specifies a function to be called whenever the domain is changed. */
proplist_t PLGetDomain(proplist_t name);

/* Set the specified domain. If kickme is NO, a callback function the
   program has registered for this domain will not be called. */
proplist_t PLSetDomain(proplist_t name, proplist_t value,
		 BOOL kickme);

/* See above. */
proplist_t PLDeleteDomain(proplist_t name, BOOL kickme);

/* Returns the specified domain, and registers callback to be called
   whenever domain is changed. Returns name. */
proplist_t PLRegister(proplist_t name, plcallback_t callback);

/* Unregisters callback entries for name, or all callback entries if
   name is NULL. Returns name. */
proplist_t PLUnregister(proplist_t name);

/*
 * Test if the proplist is of a certain type
 */
BOOL PLIsString(proplist_t pl);
BOOL PLIsData(proplist_t pl);
BOOL PLIsArray(proplist_t pl);
BOOL PLIsDictionary(proplist_t pl);
BOOL PLIsSimple(proplist_t pl); /* YES if pl is string or data */
BOOL PLIsCompound(proplist_t pl); /* YES if pl is array or dictionary */

/*
 * Values of simple types. Note that all these return copies; free the
 * return value after you're done.
 */
char *PLGetStringDescription(proplist_t pl);
char *PLGetString(proplist_t pl); 
char *PLGetDataDescription(proplist_t pl);
unsigned int PLGetDataLength(proplist_t pl);
unsigned char *PLGetDataBytes(proplist_t pl);

/*
 * The description in proplist format. Free the return value.
 */
char *PLGetDescriptionIndent(proplist_t pl, unsigned int level);
char *PLGetDescription(proplist_t pl);


/*
 * Descending into compound types. None of these return copies.
 */
unsigned int PLGetNumberOfElements(proplist_t pl);
proplist_t PLGetArrayElement(proplist_t pl, unsigned int index);
proplist_t PLGetAllDictionaryKeys(proplist_t pl); /* returns an array */
proplist_t PLGetDictionaryEntry(proplist_t pl, proplist_t key);
 
/*
 * Getting the container
 */
proplist_t PLGetContainer(proplist_t pl);

/*
 * Creating simple types
 */
proplist_t PLMakeString(char *bytes);
proplist_t PLMakeData(unsigned char *data, unsigned int length);

/*
 * Creating/Changing compound types
 */
/* Make an array from the given elements. List must be NULL-terminated. */
proplist_t PLMakeArrayFromElements(proplist_t pl, ...);
/* returns NULL if index out of bounds */
proplist_t PLInsertArrayElement(proplist_t array, proplist_t pl,
				unsigned int index);
proplist_t PLRemoveArrayElement(proplist_t array,
				unsigned int index);
proplist_t PLAppendArrayElement(proplist_t array, proplist_t pl);

proplist_t PLMakeDictionaryFromEntries(proplist_t key, proplist_t value,
				       ...);
proplist_t PLInsertDictionaryEntry(proplist_t dict, proplist_t key,
				   proplist_t value);
proplist_t PLRemoveDictionaryEntry(proplist_t dict, proplist_t key);
/* Changes only dest. Copies entries from source. */
proplist_t PLMergeDictionaries(proplist_t dest, proplist_t source);

/*
 * Destroying and Copying
 */

proplist_t PLShallowCopy(proplist_t pl);
proplist_t PLDeepCopy(proplist_t pl);
void PLRelease(proplist_t pl);
proplist_t PLRetain(proplist_t pl);

/*
 * Comparing
 */

BOOL PLIsEqual(proplist_t pl1, proplist_t pl2);
void PLSetStringCmpHook(BOOL(*fn)(proplist_t, proplist_t));

#endif /* !def PROPLIST_H */