OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. | 2 * Copyright (C) 2010 Google Inc. |
3 * | 3 * |
4 * This program is free software; you can redistribute it and/or | 4 * This program is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU General Public License | 5 * modify it under the terms of the GNU General Public License |
6 * as published by the Free Software Foundation; either version 2 | 6 * as published by the Free Software Foundation; either version 2 |
7 * of the License, or (at your option) any later version. | 7 * of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 19 matching lines...) Expand all Loading... |
30 enum { | 30 enum { |
31 VPD_TYPE_TERMINATOR = 0, | 31 VPD_TYPE_TERMINATOR = 0, |
32 VPD_TYPE_STRING, | 32 VPD_TYPE_STRING, |
33 VPD_TYPE_IMPLICIT_TERMINATOR = 0xff, | 33 VPD_TYPE_IMPLICIT_TERMINATOR = 0xff, |
34 }; | 34 }; |
35 | 35 |
36 enum { | 36 enum { |
37 VPD_AS_LONG_AS = -1, | 37 VPD_AS_LONG_AS = -1, |
38 }; | 38 }; |
39 | 39 |
40 enum { | 40 enum { /* export_type */ |
41 VPD_EXPORT_KEY_VALUE = 1, | 41 VPD_EXPORT_KEY_VALUE = 1, |
| 42 VPD_EXPORT_VALUE, |
42 VPD_EXPORT_AS_PARAMETER, | 43 VPD_EXPORT_AS_PARAMETER, |
43 }; | 44 }; |
44 | 45 |
45 | 46 |
46 struct StringPair { | 47 struct StringPair { |
47 unsigned char *key; | 48 unsigned char *key; |
48 unsigned char *value; | 49 unsigned char *value; |
49 int pad_len; | 50 int pad_len; |
| 51 int filter_out; /* TRUE means not exported. */ |
50 struct StringPair *next; | 52 struct StringPair *next; |
51 }; | 53 }; |
52 | 54 |
53 struct PairContainer { | 55 struct PairContainer { |
54 struct StringPair *first; | 56 struct StringPair *first; |
55 }; | 57 }; |
56 | 58 |
57 | 59 |
58 /* Encodes the len into multiple bytes with the following format. | 60 /* Encodes the len into multiple bytes with the following format. |
59 * | 61 * |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 void mergeContainer(struct PairContainer *dst, | 167 void mergeContainer(struct PairContainer *dst, |
166 const struct PairContainer *src); | 168 const struct PairContainer *src); |
167 | 169 |
168 /* Given a container, encode its all entries into the buffer. | 170 /* Given a container, encode its all entries into the buffer. |
169 */ | 171 */ |
170 int encodeContainer(const struct PairContainer *container, | 172 int encodeContainer(const struct PairContainer *container, |
171 const int max_buf_len, | 173 const int max_buf_len, |
172 unsigned char *buf, | 174 unsigned char *buf, |
173 int *generated); | 175 int *generated); |
174 | 176 |
| 177 /* Set filter for exporting functions. |
| 178 * If filter is NULL, resets the filter so that everything can be exported. |
| 179 */ |
| 180 int setContainerFilter(struct PairContainer *container, |
| 181 const uint8_t *filter); |
| 182 |
175 /* | 183 /* |
176 * Export the container content with human-readable text. | 184 * Export the container content with human-readable text. |
177 * | 185 * |
178 * The buf points to the first byte of buffer and *generated contains the number | 186 * The buf points to the first byte of buffer and *generated contains the number |
179 * of bytes already existed in buffer. | 187 * of bytes already existed in buffer. |
180 * | 188 * |
181 * Afterward, the *generated will be plused on exact bytes this function has | 189 * Afterward, the *generated will be plused on exact bytes this function has |
182 * generated. | 190 * generated. |
183 */ | 191 */ |
184 int exportContainer(const int export_type, | 192 int exportContainer(const int export_type, |
185 const struct PairContainer *container, | 193 const struct PairContainer *container, |
186 const int max_buf_len, | 194 const int max_buf_len, |
187 uint8_t *buf, | 195 uint8_t *buf, |
188 int *generated); | 196 int *generated); |
189 | 197 |
190 void destroyContainer(struct PairContainer *container); | 198 void destroyContainer(struct PairContainer *container); |
191 | 199 |
192 | 200 |
193 #endif /* __LIB_VPD__ */ | 201 #endif /* __LIB_VPD__ */ |
OLD | NEW |