Article View: news.software.nntp
Article #63156Re: NNTP and YENC
From: George Ruof
Date: Wed, 15 Jan 2003 04:59
Date: Wed, 15 Jan 2003 04:59
115 lines
4853 bytes
4853 bytes
"Bart Crane" <bcrane@iready.com> wrote:
>My grep has a special option to write matching lines to one
>file, and non-matching lines to another file, as well as other
>options, and they use a special regexp package I wrote
>many years ago, that is especially compatible with how DOS
>expands wildcards. Scripts are built using these programs.
>A simple drop-in replacement of a new sed-workalike is not
>necessarily a simple, no-coding-required, option.
>
>I can not install a binary-to-text filter at the front of the
>pipeline without including the decoder logic, so that the
>proper context is known so as to escape 1Ah properly,
>so the rest of the pipeline works. But, then the decoder
>has to be kept up-to-date for every new protocol, else the
>same problem results.
>
>Alternatively, YENC could include 1Ah as a Critical
>Character, then everything is restored to normal.
>
>I could also run my existing software such that each article
>is redirected to a separate file. Then, if an article contained
>the End Of File character, only that file would be affected.
>The process-startup costs would be in the background, so
>that would not affect processing much. I worry about the
>nntp-server, though... that is a lot of socket connect/disconnects.
Did you even try to solve this problem on your own? I assume you can
still compile your tools since you said you wrote them initially.
Here's an example of how to put stdin into binary mode and still detect
EOF when the end of the physical file is reached. Works on Windows XP
and although I didn't test it on Unix I don't see any reason it wouldn't
work there too.
>//spew.cpp
>#include <stdio.h>
>#include <string.h>
>#include <fcntl.h>
>#include <io.h>
>
>const char* line1 = "This is a test of reading binary data from stdin.\n";
>const char* line2 = "This line contains an embedded CTRL-Z (0x1a) character here >";
>const char* line3 = "<\nIf you're reading this line it read past the EOF character.\n";
>const char eofchar = 0x1a;
>
>int main(int argc, char* argv[])
>{
> if(argc == 1)
> {
> printf("usage: 'spew f' to create test.txt file containing an embedded ctrl-z.\n");
> printf(" 'spew t < test.txt' to read test.txt in text mode.\n");
> printf(" 'spew b < test.txt' to read test.txt in binary mode.\n");
> return 0;
> }
>
> if(argc > 1 && argv[1][0] == 'f')
> {
> FILE* f = fopen("test.txt", "wb" );
> if(f)
> {
> fprintf(f, "%s%s%c%s", line1, line2, eofchar, line3 );
> fclose(f);
> }
> return 0;
> }
>
> if(argc > 1 && argv[1][0] == 'b')
> {
> int result = _setmode(_fileno( stdin ), _O_BINARY);
> if(result == -1)
> {
> perror("Cannot set mode");
> }
> else
> {
> printf("'stdin' successfully changed to binary mode\n");
> }
> }
> else if(argc > 1 && argv[1][0] == 't')
> {
> int result = _setmode(_fileno( stdin ), _O_TEXT);
> if(result == -1)
> {
> perror("Cannot set mode");
> }
> else
> {
> printf("'stdin' successfully changed to text mode\n");
> }
> }
> char buffer[1024];
> while(!feof(stdin))
> {
> memset(buffer, 0, sizeof buffer );
> fgets(buffer, sizeof buffer, stdin);
> if( buffer )
> {
> fputs(buffer, stdout);
> }
> }
> return 0;
>}
Have fun.
--
George Ruof
gruof@pacificnet.net
Technical Details
Message-ID:
<uvp92vcu16vti9itvf9pcoiegqrqm7g5mp@4ax.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!nycmny1-snh1.gtei.net!news.gtei.net!news-out.visi.com!hermes.visi.com!feed1.newsreader.com!newsreader.com!news2.newsreader.com!troll.newsreader.com!not-for-mailReferences:
<BXLR9.432835$pN3.48082@sccrnsc03> <1042007522.340079@ok-corral.gunslinger.net><8d$Rtvs3cDD@3247.org> <aOIU9.101$qk2.63728@news.uswest.net><1042509487.957651@ok-corral.gunslinger.net><sq1V9.77$2r2.63639@news.uswest.net> <ylvg0r9ssr.fsf@windlord.stanford.edu> <Sy2V9.86$2r2.72162@news.uswest.net>Show Full Headers
Complete Article Headers
Message-ID: <uvp92vcu16vti9itvf9pcoiegqrqm7g5mp@4ax.com> Subject: Re: NNTP and YENC Date: Tue, 14 Jan 2003 20:59:19 -0800 From: George Ruof <gruof@pacificnet.net> References: <BXLR9.432835$pN3.48082@sccrnsc03> <1042007522.340079@ok-corral.gunslinger.net><8d$Rtvs3cDD@3247.org> <aOIU9.101$qk2.63728@news.uswest.net><1042509487.957651@ok-corral.gunslinger.net><sq1V9.77$2r2.63639@news.uswest.net> <ylvg0r9ssr.fsf@windlord.stanford.edu> <Sy2V9.86$2r2.72162@news.uswest.net> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!nycmny1-snh1.gtei.net!news.gtei.net!news-out.visi.com!hermes.visi.com!feed1.newsreader.com!newsreader.com!news2.newsreader.com!troll.newsreader.com!not-for-mail Newsgroups: news.software.nntp X-Newsreader: Forte Agent 1.93/32.576 English (American) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: troll.newsreader.com w180cP,oAjTDuLlitHEvPZ@Dyyp/tyLoVrxftmyMC94m_AiM9 Lines: 114