unix streams
lets say you see this command: cat /etc/hosts | grep "unidef"
basically this is what happens:
the cat command reads the file and outputs either the entire thing or line break line break at a time, not sure whcih but yeah
now the grep part, takes the inputed data (which is i think done by the STDIN macro, which allows you to read the standard output stream fed into the program, which normally i think is read by the sprintf() function in the stdlib, meaning the function opens the stream using the STDIN macro, which is a macro for data streamed directly into the macro from the operating system, and allows for programming in the program
so somewhere in the grep program, a function call is made to read the STDIN stream (you can also stream into STDIN and various other c macros used to communicate with unix streams.), and it reads the data used by the stream command (which is "|") and allows for programming done to the inputted data (or stream)
not all programs support STDIN and various macros, but can be added easily (ie of you want to do something like allow stdin with error checking bounds to the ping programs hostname function, your free to!)
again, to stream one commands data into another you need to use the | character in your shell, which is on every keyboard. that again is COMMAND -SWITCHES ARGUMENTS | PROGRAM_TO_STREAM -OPTIONS | PROGRAM2_TO_STREAM -OPTIONS
each streamed functions will be read from STDIN and data passed through variables, functions, pointers, etc, so each program doesnt need an argument pertaining to the original data sent through the stream
if wanting to write in streaming funcitonallity, all you really need to do is read the STDIN macro using sprintf(), and im not sure how to stream out, lol, i think you use the STDIN macro, i havent done it personally
but if you use a funciton to read STDIN, which is data inputted through the | character in shells and data outputted by STDOU, it should cream a chain (a stream) of data and commands, which can be super useful for making shell scripts! more on that in the next article
unidef