File: nullgzip.cpp

package info (click to toggle)
rsyncrypto 1.14-1.2
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 1,552 kB
  • sloc: cpp: 3,459; sh: 1,221; makefile: 29
file content (30 lines) | stat: -rw-r--r-- 754 bytes parent folder | download | duplicates (5)
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
#include <windows.h>
#include <stdio.h>

int main(int argc, char *argv[] )
{
    unsigned char buffer[8192];
    HANDLE hInput, hOutput;

    hInput=GetStdHandle(STD_INPUT_HANDLE);
    hOutput=GetStdHandle(STD_OUTPUT_HANDLE);
    DWORD numread;
    BOOL success;

    while( (success=ReadFile(hInput, buffer, sizeof(buffer), &numread, NULL )) && numread>0 ) {
        DWORD written;
        if( !WriteFile(hOutput, buffer, numread, &written, NULL ) ) {
            fprintf(stderr, "Error in writing: %d\n", GetLastError() );
            return 1;
        }
    }

    DWORD error=GetLastError();

    if( !success && error!=ERROR_BROKEN_PIPE ) {
        fprintf(stderr, "Error in reading: %d\n", GetLastError() );
        return 1;
    }

    return 0;
}