| 1 |
/* dctrl-tools - Debian control file inspection tools |
| 2 |
Copyright © 2004, 2010 Antti-Juhani Kaijanaho |
| 3 |
|
| 4 |
This program is free software; you can redistribute it and/or modify |
| 5 |
it under the terms of the GNU General Public License as published by |
| 6 |
the Free Software Foundation; either version 2 of the License, or |
| 7 |
(at your option) any later version. |
| 8 |
|
| 9 |
This program is distributed in the hope that it will be useful, |
| 10 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
GNU General Public License for more details. |
| 13 |
|
| 14 |
You should have received a copy of the GNU General Public License along |
| 15 |
with this program; if not, write to the Free Software Foundation, Inc., |
| 16 |
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 17 |
*/ |
| 18 |
|
| 19 |
#ifndef PARA_BUNDLE_H |
| 20 |
#define PARA_BUNDLE_H |
| 21 |
|
| 22 |
#include "fieldtrie.h" |
| 23 |
#include "fsaf.h" |
| 24 |
#include "ifile.h" |
| 25 |
#include "paragraph.h" |
| 26 |
#include "para_pool.h" |
| 27 |
|
| 28 |
struct srcfile { |
| 29 |
struct ifile ifi; |
| 30 |
int fd; |
| 31 |
FSAF * fs; |
| 32 |
para_parser_t pp; |
| 33 |
struct srcfile * next; |
| 34 |
}; |
| 35 |
|
| 36 |
struct para_bundle { |
| 37 |
para_pool_t pool; |
| 38 |
size_t num_paras; |
| 39 |
size_t max_num; |
| 40 |
para_t ** paras; |
| 41 |
struct srcfile * files; |
| 42 |
}; |
| 43 |
|
| 44 |
static inline |
| 45 |
void bundle_init(struct para_bundle * pb) |
| 46 |
{ |
| 47 |
para_pool_init(&pb->pool); |
| 48 |
pb->num_paras = 0; |
| 49 |
pb->max_num = 0; |
| 50 |
pb->paras = 0; |
| 51 |
pb->files = 0; |
| 52 |
} |
| 53 |
|
| 54 |
void bundle_slurp(struct para_bundle *, struct ifile, |
| 55 |
_Bool register_unknown_fields); |
| 56 |
|
| 57 |
static inline |
| 58 |
size_t bundle_size(struct para_bundle * pb) |
| 59 |
{ |
| 60 |
assert(pb != 0); |
| 61 |
return pb->num_paras; |
| 62 |
} |
| 63 |
|
| 64 |
static inline |
| 65 |
para_t ** bundle_vec(struct para_bundle * pb) |
| 66 |
{ |
| 67 |
assert(pb != 0); |
| 68 |
return pb->paras; |
| 69 |
} |
| 70 |
|
| 71 |
#endif /* PARA_BUNDLE_H */ |