File: pipe.c

package info (click to toggle)
csound 1%3A4.23f12-3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 6,132 kB
  • ctags: 17,345
  • sloc: ansic: 101,063; cpp: 7,730; perl: 335; makefile: 318; tcl: 82
file content (36 lines) | stat: -rw-r--r-- 676 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
 * Executes a given program, converting all
 * output to upper case.
 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
FILE* popen(char*, char*);
void pclose(FILE*);
char   buffer[256];

void main( int argc, char **argv )
  {
    int  i;
    int  c;
    FILE *f;

    for( i = 1; i < argc; i++ ) {
      strcat( buffer, argv[i] );
      strcat( buffer, " " );

    }

    if( ( f = popen( buffer, "r" ) ) == NULL ) {
      perror( "_popen" );
      exit( 1 );
    }
    while( ( c = getc(f) ) != EOF ) {
      if( islower( c ) )
          c = toupper( c );
      putchar( c );
    }
    pclose( f );
  }