Q: problem: CGI-programming with C (writing files and sending picyures) 
Author Message
 Q: problem: CGI-programming with C (writing files and sending picyures)

Dear Sirs

I have two problems with C(++) CGI-programming, ment to run on a
WindowsNT-server.
My programs are compiled 32bit-console

My first problem:

I want to let a executealble return a image after the call:

<IMG SRC=" http://www.*-*-*.com/ ;>

in a html document.

This I tried with:

#include <stdio.h>

void main(int argc, char *argv[]){
   FILE *In; char Ch;
   fprintf(stdout, "Content-type: image/gif%c%c", 10, 10);
   In = fopen(argv[1], "rb");
   fread(&Ch, sizeof(char), 1, In);
   while(!feof(In)){
      fprintf(stdout, "%c", Ch);
      fread(&Ch, sizeof(char), 1, In);
      }
   fclose(In);
   }//End void main

I do recieve the image from the exe-file, but the image is corrupted, it
looks like it has been transported by
ftp without setting the mode to binary. ( bit 8 is set to 0???, just a
thought)

My second problem:

Executing files on the NT-server, making them return html-code works
fine. Making the exe-file read from the
servers harddrive does also work fine, but when I try to write to the
harddrive, the process hangs. The strange
thing is that the harddrive is written to, but just after that, the
process stops.

My code would typically look like this:

FILE *Out = fopen( Filename, "wb");
if(Out != NULL){
   fwrite(&Something, sizeof(Something), 1, Out);
      <---Here the process stops, I think, and the program hangs
   }
else
   error();
fclose(Out);

If anyone know the solution to one of my problems, I would be most
greatful.

Yours faithfully
Jorn Gabrielsen,




Sun, 05 Sep 1999 03:00:00 GMT  
 Q: problem: CGI-programming with C (writing files and sending picyures)

1) try:
   freopen( "CON", "wb", stdout );

2) try:
FILE *Out = fopen( Filename, "wb");
if(Out != NULL){
   fwrite(&Something, sizeof(Something), 1, Out);
   fclose(Out);

Quote:
}

else {
   error();
Quote:
}

>Dear Sirs
>I have two problems with C(++) CGI-programming, ment to run on a
>WindowsNT-server.
>My programs are compiled 32bit-console
>My first problem:
>I want to let a executealble return a image after the call:
><IMG SRC="http://some.server.no/pictureshow.exe?picture.gif">
>in a html document.
>This I tried with:
>#include <stdio.h>
>void main(int argc, char *argv[]){
>   FILE *In; char Ch;
>   fprintf(stdout, "Content-type: image/gif%c%c", 10, 10);
>   In = fopen(argv[1], "rb");
>   fread(&Ch, sizeof(char), 1, In);
>   while(!feof(In)){
>      fprintf(stdout, "%c", Ch);
>      fread(&Ch, sizeof(char), 1, In);
>      }
>   fclose(In);
>   }//End void main
>I do recieve the image from the exe-file, but the image is corrupted, it
>looks like it has been transported by
>ftp without setting the mode to binary. ( bit 8 is set to 0???, just a
>thought)
>My second problem:
>Executing files on the NT-server, making them return html-code works
>fine. Making the exe-file read from the
>servers harddrive does also work fine, but when I try to write to the
>harddrive, the process hangs. The strange
>thing is that the harddrive is written to, but just after that, the
>process stops.
>My code would typically look like this:
>FILE *Out = fopen( Filename, "wb");
>if(Out != NULL){
>   fwrite(&Something, sizeof(Something), 1, Out);
>      <---Here the process stops, I think, and the program hangs
>   }
>else
>   error();
>fclose(Out);
>If anyone know the solution to one of my problems, I would be most
>greatful.
>Yours faithfully
>Jorn Gabrielsen,




Sun, 05 Sep 1999 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Newbie: separate big .cs file into small .cs files

2. Problem #30 on http://cs.nmu.edu/programming/c/problems.htm

3. writing cgi program using C language

4. cgi program which is a daemon/starting daemon from cgi

5. resx files needed for cs - files ??

6. CS files display in VS6 like CPP files ?

7. Calling a CGI program from a C program

8. the program which transmits data to CGI program

9. Need to send CGI command

10. program to send files over TCP/IP

11. Getting Environment Variable in C++ written CGI script

12. Writing CGI using UNIX-C

 

 
Powered by phpBB® Forum Software