File: export-priv.h

package info (click to toggle)
zapping 0.10~cvs6-2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 9,856 kB
  • ctags: 11,841
  • sloc: ansic: 111,154; asm: 11,770; sh: 9,812; xml: 2,742; makefile: 1,283; perl: 488
file content (273 lines) | stat: -rw-r--r-- 8,128 bytes parent folder | download | duplicates (6)
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
/*
 *  libzvbi - Export modules
 *
 *  Copyright (C) 2001, 2002, 2003, 2004 Michael H. Schimek
 *
 *  Based on code from AleVT 1.5.1
 *  Copyright (C) 1998, 1999 Edgar Toernig <froese@gmx.de>
 *
 *  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 the Free Software
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

/* $Id: export-priv.h,v 1.3 2005/09/01 01:36:41 mschimek Exp $ */

#ifndef EXPORT_PRIV_H
#define EXPORT_PRIV_H

#include "export.h"

typedef struct _vbi3_export_module _vbi3_export_module;

/**
 * @ingroup Exmod
 *
 * Structure representing an export module instance, part of the private
 * export module interface.
 *
 * Export modules can read, but do not normally write its fields, as
 * they are maintained by the public libzvbi export functions.
 */
struct _vbi3_export {
	/**
	 * Points back to export module description.
	 */
	const _vbi3_export_module *module;

	/**
	 * Use _vbi3_export_write_error(),
	 * _vbi3_export_unknown_option(),
	 * _vbi3_export_invalid_option(),
	 * _vbi3_export_error_printf().
	 */
	char *			errstr;

	/** Name of the file we are writing, @c NULL if anonymous. */
	const char *		name;

	/** File we are writing. */
	FILE *			fp;

	/** Generic option: Network name or @c NULL. */
	char *			network;
	/** Generic option: Creator name [by default "libzvbi"] or @c NULL. */
	char *			creator;
	/** Generic option: Reveal hidden characters. */
	vbi3_bool		reveal;
	/** Generic option: Add page header. */
	vbi3_bool		header;

	struct {
		/** Not implemented yet. */
		vbi3_pgno		pgno;
		vbi3_subno		subno;

		double			start_timestamp;
		double			timestamp;

		vbi3_bool		have_timestamp;
	}			stream;

	/** See vbi3_export_set_link_cb(). */
	vbi3_export_link_cb *	link_callback;
	void *			link_user_data;

	/** See vbi3_export_set_pdc_cb(). */
	vbi3_export_pdc_cb *	pdc_callback;
	void *			pdc_user_data;

	/** @internal */
	const vbi3_export_info *	local_export_info;
	vbi3_option_info *	local_option_info;
};

/**
 * @ingroup Exmod
 *
 * Structure describing an export module, part of the private
 * export module interface. One required for each module.
 */
struct _vbi3_export_module {
	const vbi3_export_info *	export_info;

	vbi3_export *		(* _new)(const _vbi3_export_module *em);
	void			(* _delete)(vbi3_export *e);

	const vbi3_option_info *	option_info;
	unsigned int		option_info_size;

	vbi3_bool		(* option_set)(vbi3_export *e,
					       const char *keyword,
					       va_list);
	vbi3_bool		(* option_get)(vbi3_export *e,
					       const char *keyword,
					       vbi3_option_value *value);
	vbi3_bool		(* export)(vbi3_export *e,
					   const vbi3_page *pg);
};

/**
 * @example exp-templ.c
 * @ingroup Exmod
 *
 * Template for internal export module.
 */

/*
	Helper functions
 */

/**
 * @addtogroup Exmod
 * @{
 */
extern void
_vbi3_export_write_error		(vbi3_export *		e);
extern void
_vbi3_export_malloc_error		(vbi3_export *		e);
extern void
_vbi3_export_unknown_option	(vbi3_export *		e,
				 const char *		keyword);
extern void
_vbi3_export_invalid_option	(vbi3_export *		e,
				 const char *		keyword,
				 ...);
extern void
_vbi3_export_error_printf	(vbi3_export *		e,
				 const char *		template,
				 ...);
extern char *
_vbi3_export_strdup		(vbi3_export *		e,
				 char **		d,
				 const char *		s);

/* Option info building */

/**
 * Helper macro for export modules to build option lists. Use like this:
 *
 * @code
 * vbi3_option_info myinfo = VBI3_OPTION_BOOL_INITIALIZER
 *   ("mute", N_("Switch sound on/off"), FALSE, N_("I am a tooltip"));
 * @endcode
 *
 * N_() marks the string for i18n, see info gettext for details.
 */
#define _VBI3_OPTION_BOOL_INITIALIZER(key_, label_, def_, tip_)		\
  { VBI3_OPTION_BOOL, key_, label_, { .num = def_ }, { .num = 0 },	\
  { .num = 1 }, { .num = 1 }, { .num = NULL }, tip_ }

/**
 * Helper macro for export modules to build option lists. Use like this:
 *
 * @code
 * vbi3_option_info myinfo = VBI3_OPTION_INT_RANGE_INITIALIZER
 *   ("sampling", N_("Sampling rate"), 44100, 8000, 48000, 100, NULL);
 * @endcode
 *
 * Here we have no tooltip (@c NULL).
 */
#define _VBI3_OPTION_INT_RANGE_INITIALIZER(key_, label_, def_, min_,	\
  max_,	step_, tip_) { VBI3_OPTION_INT, key_, label_,			\
  { .num = def_ }, { .num = min_ }, { .num = max_ }, { .num = step_ },	\
  { .num = NULL }, tip_ }

/**
 * Helper macro for export modules to build option lists. Use like this:
 *
 * @code
 * int mymenu[] = { 29, 30, 31 };
 *
 * vbi3_option_info myinfo = VBI3_OPTION_INT_MENU_INITIALIZER
 *   ("days", NULL, 1, mymenu, N_ELEMENTS (mymenu), NULL);
 * @endcode
 *
 * No label and tooltip (@c NULL), i. e. this option is not to be
 * listed in the user interface. Default is entry 1 ("30") of 3 entries. 
 */
#define _VBI3_OPTION_INT_MENU_INITIALIZER(key_, label_, def_,		\
  menu_, elements_, tip_) { VBI3_OPTION_INT, key_, label_,		\
  { .num = def_}, { .num = 0 }, { .num = (elements_) - 1 },		\
  { .num = 1 }, { .num = menu_ }, tip_ }

/**
 * Helper macro for export modules to build option lists. Use like
 * VBI3_OPTION_INT_RANGE_INITIALIZER(), just with doubles but ints.
 */
#define _VBI3_OPTION_REAL_RANGE_INITIALIZER(key_, label_, def_, min_,	\
  max_, step_, tip_) { VBI3_OPTION_REAL, key_, label_,			\
  { .dbl = def_ }, { .dbl = min_ }, { .dbl = max_ }, { .dbl = step_ },	\
  { .dbl = NULL }, tip_ }

/**
 * Helper macro for export modules to build option lists. Use like
 * VBI3_OPTION_INT_MENU_INITIALIZER(), just with an array of doubles but ints.
 */
#define _VBI3_OPTION_REAL_MENU_INITIALIZER(key_, label_, def_,		\
  menu_, elements_, tip_) { VBI3_OPTION_REAL, key_, label_,		\
  { .num = def_ }, { .num = 0 }, { .num = (elements_) - 1 },		\
  { .num = 1 }, { .dbl = menu_ }, tip_ }

/**
 * Helper macro for export modules to build option lists. Use like this:
 *
 * @code
 * vbi3_option_info myinfo = VBI3_OPTION_STRING_INITIALIZER
 *   ("comment", N_("Comment"), "bububaba", "Please enter a string");
 * @endcode
 */
#define _VBI3_OPTION_STRING_INITIALIZER(key_, label_, def_, tip_)	\
  { VBI3_OPTION_STRING, key_, label_, { .str = def_ }, { .num = 0 },	\
  { .num = 0 }, { .num = 0 }, { .str = 0 }, tip_ }

/**
 * Helper macro for export modules to build option lists. Use like this:
 *
 * @code
 * char *mymenu[] = { "txt", "html" };
 *
 * vbi3_option_info myinfo = VBI3_OPTION_STRING_MENU_INITIALIZER
 *   ("extension", "Ext", 0, mymenu, N_ELEMENTS (mymenu),
 *   N_("Select an extension"));
 * @endcode
 *
 * Remember this is like VBI3_OPTION_STRING_INITIALIZER() in the sense
 * that the vbi client can pass any string as option value, not just those
 * proposed in the menu. In contrast a plain menu option as with
 * VBI3_OPTION_MENU_INITIALIZER() expects menu indices as input.
 */
#define _VBI3_OPTION_STRING_MENU_INITIALIZER(key_, label_, def_,		\
  menu_, elements_, tip_) { VBI3_OPTION_STRING, key_, label_,		\
  { .str = def_ }, { .num = 0 }, { .num = (elements_) - 1 },		\
  { .num = 1 }, { .str = menu_ }, tip_ }

/**
 * Helper macro for export modules to build option lists. Use like this:
 *
 * @code
 * char *mymenu [] = { N_("Monday"), N_("Tuesday") };
 *
 * vbi3_option_info myinfo = VBI3_OPTION_MENU_INITIALIZER
 *   ("weekday", "Weekday", 0, mymenu, N_ELEMENTS (mymenu),
 *   N_("Select a weekday"));
 * @endcode
 */
#define _VBI3_OPTION_MENU_INITIALIZER(key_, label_, def_, menu_,		\
  elements_, tip_) { VBI3_OPTION_MENU, key_, label_, { .num = def_ },	\
  { .num = 0 }, { .num = (elements_) - 1 }, { .num = 1 },		\
  { .str = menu_ }, tip_ }

/** @} */

#endif /* EXPORT_PRIV_H */