From: Kevin Day Date: Sat, 10 Mar 2012 20:59:38 +0000 (-0600) Subject: Add Project: pipe X-Git-Tag: 0.3.0~101 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=dddeb62d268245bc2ff7911b94be917a5456397e;p=fll Add Project: pipe This adds the level 0 implementation of project pipe. At this time, all it does is provide a way to tell if the current instance of some program has piped data being passed to it. --- diff --git a/level_0/f_pipe/c/pipe.c b/level_0/f_pipe/c/pipe.c new file mode 100644 index 0000000..771a0af --- /dev/null +++ b/level_0/f_pipe/c/pipe.c @@ -0,0 +1,35 @@ +/* FLL - Level 0 + * Project: Pipe + * Version: 0.3.x + * Licenses: lgplv2.1 + * Programmers: Kevin Day + * Documentation: + * + * Provides pipe functionality. + */ +#include + +#ifdef __cplusplus +extern "C"{ +#endif + +#ifndef _di_f_pipe_exists_ + // returns f_true if the standard input contains piped data. + f_return_status f_pipe_exists(){ + struct stat st_info; + + if (fstat(fileno(f_pipe), &st_info) != 0) { + return f_file_stat_error; + } + + if (S_ISFIFO(st_info.st_mode)) { + return f_true; + } + + return f_false; + } +#endif // _di_f_pipe_exists_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_pipe/c/pipe.h b/level_0/f_pipe/c/pipe.h new file mode 100644 index 0000000..3d481cc --- /dev/null +++ b/level_0/f_pipe/c/pipe.h @@ -0,0 +1,39 @@ +/* FLL - Level 0 + * Project: Pipe + * Version: 0.3.x + * Licenses: lgplv2.1 + * Programmers: Kevin Day + * Documentation: + * + * Provides pipe functionality. + * + */ +#ifndef _F_pipe_h +#define _F_pipe_h + +// libc includes +#include +#include + +// fll includes +#include +#include + +#ifdef __cplusplus +extern "C"{ +#endif + +#ifndef _di_f_pipe_ + #define f_pipe f_standard_input +#endif // _di_f_pipe_ + +#ifndef _di_f_pipe_exists_ + // returns f_true if the standard input contains piped data. + extern f_return_status f_pipe_exists(); +#endif // _di_f_pipe_exists_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _F_pipe_h diff --git a/level_0/f_pipe/data/build/settings b/level_0/f_pipe/data/build/settings new file mode 100644 index 0000000..25af48d --- /dev/null +++ b/level_0/f_pipe/data/build/settings @@ -0,0 +1,21 @@ +# fss-0000 + +project_name f_pipe +project_level 0 + +version_major 0 +version_minor 3 +version_micro 0 + +build_compiler gcc +build_libraries -lc +build_sources_library pipe.c +build_sources_program +build_sources_headers pipe.h +build_shared yes + +flags_all -z now +flags_shared +flags_static +flags_library -fPIC +flags_program -fPIE