Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #6356

Re: filters

From Nobody <nobody@nowhere.com>
Subject Re: filters
Date 2011-06-18 15:25 +0100
Message-Id <pan.2011.06.18.14.24.28.703000@nowhere.com>
Newsgroups comp.lang.c
References <87d3ibxx7e.fsf@yun.yagibdah.de>
Organization Zen Internet

Show all headers | View raw


On Sat, 18 Jun 2011 12:15:01 +0200, lee wrote:

> it´s probably a FAQ, though I haven´t found any good info on it: How do
> you go about writing a filter, i. e. a program that reads data from
> stdin and processes it?
> 
> Since indefinte amounts of data could be read from stdin, they can´t
> just be put into some (ever increasing) buffer. Using a buffer of
> limited size can make it difficult to process the data because the
> buffer could be too small.
> 
> What´s the solution for this?

Read line, process line, write line. Replace "line" with whatever unit of
data is appropriate, but for a typical Unix filter, data is processed line
by line.

Many of the original Unix tools used fixed-size buffers; if an input line
was too large, the program would just terminate with an error. This wasn't
such a problem when creating a file with lines longer than 80 characters
was a feat in itself. Nowadays, such programs are more likely to realloc()
the buffer as required.

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

filters lee <lee@yun.yagibdah.de> - 2011-06-18 12:15 +0200
  Re: filters Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-06-18 11:37 +0100
    Re: filters cri@tiac.net (Richard Harter) - 2011-06-18 18:42 +0000
      Re: filters Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-06-18 23:13 +0100
        Re: filters cri@tiac.net (Richard Harter) - 2011-06-19 19:02 +0000
          Re: filters Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-06-19 21:16 +0100
            Re: filters lee <lee@yun.yagibdah.de> - 2011-06-20 16:06 +0200
              Re: filters Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-06-20 15:53 +0100
                Re: filters lee <lee@yun.yagibdah.de> - 2011-06-27 22:20 +0200
  Re: filters Francois Grieu <fgrieu@gmail.com> - 2011-06-18 13:56 +0200
    Re: filters "Bill Cunningham" <nospam@nspam.invalid> - 2011-06-18 14:24 -0400
      Re: filters Angel <angel+news@spamcop.net> - 2011-06-18 18:51 +0000
        Re: filters Keith Thompson <kst-u@mib.org> - 2011-06-18 11:55 -0700
          Re: filters Angel <angel+news@spamcop.net> - 2011-06-18 19:46 +0000
            Re: filters Keith Thompson <kst-u@mib.org> - 2011-06-18 13:18 -0700
      Re: filters Lew Pitcher <lpitcher@teksavvy.com> - 2011-06-18 14:55 -0400
  Re: filters James Kuyper <jameskuyper@verizon.net> - 2011-06-18 10:14 -0400
    Re: filters cri@tiac.net (Richard Harter) - 2011-06-18 19:58 +0000
    Re: filters Tim Rentsch <txr@alumni.caltech.edu> - 2011-06-19 16:09 -0700
      Re: filters Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-06-20 07:51 +0000
        Re: filters Tim Rentsch <txr@alumni.caltech.edu> - 2011-06-20 12:33 -0700
  Re: filters Nobody <nobody@nowhere.com> - 2011-06-18 15:25 +0100
  Re: filters gordonb.f4hvo@burditt.org (Gordon Burditt) - 2011-06-18 15:17 -0500

csiph-web