🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #8550

Re: writing an app that can accept a pipe

#8550
From: JF Jolin
Date: Thu, 14 Oct 2004 16:46
51 lines
2012 bytes
14 Oct 2004 09:34:00 -0400, Jeff Kish <jeff.kish@mro.com> wrote:

> Hi.
>
> If I wanted to write an app that accepted output from another program,
> say, stdou and was able to read the input stream, how would I go about
> that?
>
>
> For example, say I frequently do this at the command line:
>
> grep -di "<tag" *.xml
>
> and wanted to pipe all the matches to an app that would be able then
> to parse the input, what would be the general approach, and if
> possible the call's I'd need to make to either the VCL or API to have
> this occur?
>
> Thanks
>
> Jeff Kish
>


Simple basic instructions in a console application would do the work.

Upper.c
-------
#include <stdio.h>
#include <string.h>
void main(void)  {
   char LineRead[255];
   while (fgets(LineRead, sizeof(LineRead), stdin))
     fputs(strupr(LineRead), stdout);
}

followed by:   grep -di "<tag" *.xml | Upper.exe

In a non-console application you can use dedicated API among:

GetStdHandle
CreateFile
CreateConsoleScreenBuffer
ReadFile
WriteFile
DuplicateHandle
CloseHandle


JF Jolin
[Montreal, Canada]
Technical Details
Message-ID: <opsfvcwd0wz6rw7b@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!peernews-us.colt.net!colt.net!peernews3.colt.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <quvsm0llngc543ujq31ksi8c29acs65g5l@4ax.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,d751b074fabd6dfb,start
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: writing an app that can accept a pipe
References: <quvsm0llngc543ujq31ksi8c29acs65g5l@4ax.com>
Message-ID: <opsfvcwd0wz6rw7b@newsgroups.borland.com>
Content-Type: text/plain; charset=iso-8859-15; format=flowed
From: JF Jolin <jfj@nospam.com>
MIME-Version: 1.0
Date: Thu, 14 Oct 2004 12:46:51 -0400
User-Agent: Opera7.11/Win32 M2 build 2887
NNTP-Posting-Host: 66.158.141.182
X-Trace: newsgroups.borland.com 1097772421 66.158.141.182 (14 Oct 2004 09:47:01 -0700)
Lines: 57
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!peernews-us.colt.net!colt.net!peernews3.colt.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail