aboutsummaryrefslogtreecommitdiff
path: root/src/tuberia.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/tuberia.h')
-rw-r--r--src/tuberia.h74
1 files changed, 68 insertions, 6 deletions
diff --git a/src/tuberia.h b/src/tuberia.h
index f9746b2..2a25287 100644
--- a/src/tuberia.h
+++ b/src/tuberia.h
@@ -22,19 +22,26 @@
* @section building Building
*
* If you don't have a ./configure file, run:
- * - autoreconf -fi
+ * - `autoreconf -fi`
*
* When you have the ./configure file, run:
- * - ./configure
- * - make
- * - make install
+ * - `./configure`
+ * - `make`
+ * - `make install`
*
* You can see some configure options with
- * - ./configure --help
+ * - `./configure --help`
+ *
+ * @section using Using this library
+ *
+ * Include tuberia.h, and link libtuberia.a and pthread: `-ltuberia -lpthread`
+ *
+ * You can use: `pkg-config --cflags --libs --static tuberia`
*
* @section quick_guide Quick Guide
*
- * See the example/decode_resize_encode.c and the function do_tuberia()
+ * See the files example/simple.c and example/decode_resize_encode.c (function
+ * do_tuberia() in particular)
*
* Create a source with @ref tube_source_alloc().
* If you set fetch to something, there will be a thread running fetch to inject
@@ -58,6 +65,61 @@
* Free the pipeline with @ref tube_free().
*
* @subsection quick_example Example
+ *
+ * See example/simple.c
+ *
+ * Compile with: `gcc -o simple simple.c -ltuberia -lpthread`
+ *
+ * Or with: ``gcc -o simple simple.c `pkg-config --cflags --libs --static tuberia```
+ *
+@code {.c}
+#include <stdio.h>
+#include <stdlib.h>
+#include <tuberia.h>
+
+void *stage_one(void *element, void *opaque)
+{
+ int *i = element;
+ *i += 5;
+ return i;
+}
+
+void *stage_two(void *element, void *opaque)
+{
+ int *i = element;
+ *i *= 10;
+ return i;
+}
+
+void sink(void *element, void *opaque)
+{
+ int *i = element;
+ printf("sink: %d\n", *i);
+ free(i);
+}
+
+int main(void)
+{
+ tube *ctx;
+ tube_source *source;
+ int *element, n;
+
+ source = tube_source_alloc(2, NULL, NULL, free);
+ tube_stage_append(source, tube_stage_alloc(2, stage_one, NULL, free));
+ tube_stage_append(source, tube_stage_alloc(2, stage_two, NULL, free));
+ ctx = tube_alloc(source, sink, NULL);
+ tube_source_and_stages_free(&source);
+ tube_start(ctx);
+ while (scanf("%d", &n) == 1) {
+ element = malloc(sizeof(*element));
+ *element = n;
+ tube_inject(ctx, 1000, element);
+ }
+ tube_free(&ctx);
+
+ return 0;
+}
+@endcode
*/
/**