X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=write_common.c;h=ac92bc1a1740d1eeefa50551d03744a6018fce41;hp=b1ab00cfa97ca9c991396a76a4fc4964eb169232;hb=9f487d2aaaa3462d9e4ecd76f22a75c9ae847e92;hpb=b2c352332d341e23580cb67b5ae2c6ff0a9224ae diff --git a/write_common.c b/write_common.c index b1ab00cf..ac92bc1a 100644 --- a/write_common.c +++ b/write_common.c @@ -25,7 +25,10 @@ #include "write.h" #include "error.h" +/** the array containing the names of all supported writers */ const char *writer_names[] ={WRITER_NAMES}; + +/** the array of supported writers */ struct writer writers[NUM_SUPPORTED_WRITERS] = {WRITER_ARRAY}; static void wng_pre_select(__a_unused struct sched *s, struct task *t) @@ -79,6 +82,16 @@ static void wng_post_select(struct sched *s, struct task *t) } } +/** + * call the open function of each writer in the group + * + * \param g the writer node group + * + * \return If at least one open function returned an error, all successful + * writer notes get closed and this error value is returned. Upon success, a + * task associated with \a g is registered to the scheduler and the function + * returnes a positive value. + * */ int wng_open(struct writer_node_group *g) { int i, ret = 1; @@ -108,12 +121,25 @@ err_out: return ret; } + +/** + * unregister a writer node group task + * + * \param g the group whose task is to be closed + */ void wng_unregister(struct writer_node_group *g) { unregister_task(&g->task); g->eof = 1; } +/** + * call the close function of each writer in the given group + * + * \param g the writer node group to close + * + * This function also frees all resources of the given group. + */ void wng_close(struct writer_node_group *g) { int i; @@ -129,6 +155,13 @@ void wng_close(struct writer_node_group *g) free(g); } +/** + * allocate and initialize a new writer_node_group struct + * + * \param num_writers the number of writer nodes for the new group + * + * \return Pointer to the new writer node group + */ struct writer_node_group *wng_new(unsigned num_writers) { struct writer_node_group *g = para_calloc(sizeof(struct writer_node_group)); @@ -141,6 +174,9 @@ struct writer_node_group *wng_new(unsigned num_writers) return g; } +/** + * call the init function of each supported paraslash writer + */ void init_supported_writers(void) { int i; @@ -148,7 +184,21 @@ void init_supported_writers(void) FOR_EACH_WRITER(i) writers[i].init(&writers[i]); } - +/** + * check if given string is a valid command line for any writer + * + * \param \wa string of the form writer_name:options + * \param writer_num contains the number of the writer upon success + * + * This function checks whether \a wa starts with the name of a supported + * paraslash writer, optinally followed by a colon and any options for that + * writer. If a valid writer name was found and further are present, the + * remaining part of \a wa is passed to that writer's config parser. + * + * \return On success, a pointer to the gengetopt args info struct is returned + * and \a writer_num contains the number of the writer. Otherwise this function + * returns \p NULL. + */ void *check_writer_arg(const char *wa, int *writer_num) { int i; @@ -175,6 +225,14 @@ void *check_writer_arg(const char *wa, int *writer_num) return NULL; } +/** + * setup a writer node group with only one writer, the default writer + * + * The writer which is set up depends on the OS. It defaults to alsa for Linux, + * osx_write for OS X, file writer if neither of these is supported. + * + * \return pointer to the allocated writer node group + */ struct writer_node_group *setup_default_wng(void) { struct writer_node_group *wng = wng_new(1);