I am working on a cgi program that pipes a designated file through the standard out. This is so that I can send a file to a browser that is not under my doc root. Trouble is that when I send a file that is not just plain ASCII things get screwed up.
My test uses the following code:
fp = fopen(lFilename, "rb");
if (fp == NULL)
printf("File failed to open\n");
while((c = getc(fp)) != EOF)
Now, by rights this should just read a byte from the file and wwrite it to the standard out. I do get a file written but it is not exactly the same as the source. Does the standard out modify certin ascii values somehow?
I suspect that there may be some problem with either null, CRLF or EOF characters. Any ideas?