2 * Copyright (C) 2006-2010 Andre Noll <maan@systemlinux.org>
4 * Licensed under the GPL v2. For licencing details see COPYING.
7 /** \file write.h Writer-related structures. */
9 /** The list of supported writers. */
10 enum writer_enum
{WRITER_ENUM
};
13 * Describes one running instance of a writer.
16 /** The number of this writer. */
18 /** Writer-specific data. */
20 /** The writer-specific configuration of this node. */
22 struct btr_node
*btrn
;
27 /** Describes one supported writer. */
30 * The init function of the writer.
32 * It must fill in all other function pointers of the given
35 void (*init
)(struct writer
*w
);
37 * The command line parser of the writer.
39 * It should check whether the command line options given by \a options are
40 * valid. On success, it should return a pointer to the writer-specific
41 * configuration data determined by \a options. Note that this might be called
42 * more than once with different values of \a options.
44 void *(*parse_config
)(const char *options
);
45 void (*free_config
)(void *conf
);
47 * Open one instance of this writer.
49 * This function should perform any work necessary to write the incoming
50 * stream. To this aim, it may allocate its private data structure and store
51 * a pointer to that structure via the given writer_node parameter.
53 int (*open
)(struct writer_node
*);
55 * Prepare the fd sets for select.
57 * This is called from scheduler. It may use the sched pointer to add
58 * any file descriptors or to decrease the select timeout.
60 void (*pre_select
)(struct sched
*s
, struct task
*t
);
64 * Called from the post_select function of the writer node's task.
66 void (*post_select
)(struct sched
*s
, struct task
*t
);
68 * Close one instance of the writer.
70 * This function is assumed to succeed.
72 void (*close
)(struct writer_node
*);
76 * This is a optional function pointer used for cleaning up.
78 void (*shutdown
)(struct writer_node
*);
80 btr_command_handler execute
;
83 /** Loop over each supported writer. */
84 #define FOR_EACH_WRITER(i) for (i = 0; i < NUM_SUPPORTED_WRITERS; i++)
86 /** Declare the init functions of all supported writers. */
89 /** Array containing the name of each writer. */
90 extern const char *writer_names
[];
92 /** The writer structure for each supported writer. */
93 extern struct writer writers
[NUM_SUPPORTED_WRITERS
];