/** * dvbcfg_source configuration file support. * * Copyright (c) 2005 by Andrew de Quincey * * Credits go to Klaus Schmidinger's VDR for coming up with this really * great idea. * * This library is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef DVBCFG_SOURCE_BACKEND_H #define DVBCFG_SOURCE_BACKEND_H #include #include /** * Backend parser API. */ struct dvbcfg_source_backend { /** * Loads a single source from the backend and add to the supplied list. * * @param backend Pointer to the backend structure concerned. * @param sources Pointer to the list of sources. * @return 0 on success, <0 on error, or 1 on end of file. */ int get_source(struct dvbcfg_source_backend* backend, struct dvbcfg_source** sources); /** * Stores a single source to the backend. * * @param backend Pointer to the backend structure concerned. * @param source Source to store. * @return 0 on success, <0 on error. */ int put_source(struct dvbcfg_source_backend* backend, struct dvbcfg_source* source); }; /** * Convenience method to load all sources from a backend. * * @param config_file Config filename to load. * @param sources Where to put the pointer to the start of the loaded sources. * If NULL, a new list will be created, if it points to an already initialised * list, the loaded sources will be appended to it. * @return 0 on success, or nonzero error code on failure. */ extern int dvbcfg_source_load(struct dvbcfg_source_backend *backend, struct dvbcfg_source **sources); /** * Convenience method to store all sources to a backend. * * @param config_file Config filename to save. * @param sources Pointer to the list of sources to save. * @return 0 on success, or nonzero error code on failure. */ extern int dvbcfg_source_save(struct dvbcfg_source_backend *backend, struct dvbcfg_source *sources); /******************************* DEFAULT BACKEND ******************************/ /** * The default backend stores sources in a file on disk as follows: * * * * Comments begin with '#' - any characters after this will be ignored to the * end of the line. * * Examples: * S5E Sirius 2/3 * S13E Hotbird 1-(5)-6 * Tau-au-Adelaide A DVB-T transmitter in Australia serving the Adelaide area. * Tuk-scottish-BlackHill A DVB-T transmitter in the UK serving the central belt of scotland. */ /** * Create an instance of the default backend. This stores the source in a file * on disk. * * @param filename Pathname to store as. Pass NULL to use the default pathname * @param backend Pointer to the backend structure to initialise. * @return 0 on success, nonzero on error. */ extern int dvbcfg_source_backend_default_create(char* filename, struct dvbcfg_source_backend* backend); /** * Tidy up a default backend. * * @param backend Pointer to the backend structure to destroy. */ extern void dvbcfg_source_backend_default_destroy(struct dvbcfg_source_backend* backend); #endif