#include /* Make sure MSDOS is defined if you are using NT, MSDOS or OS/2! */ #ifdef MSDOS #include #endif /* MSDOS */ #define IMAGE_FILE "/CHANGE/THIS/PATH/test.gif" int main(int argc, char *argv) { int ch; FILE *in; /* The 'b' ensures that the file is opened in binary mode. This is very important on DOS and related systems such as NT and OS/2. It does no harm on other systems. */ in = fopen(IMAGE_FILE, "rb"); if (!in) { /* Uh-oh, no such image */ printf("Status: 404 Not Found\n\n"); printf("dimage could not find the image to send!\n"); exit(0); } /* Make sure MSDOS is defined if you are using NT, MSDOS or OS/2! */ #ifdef MSDOS _setmode(fileno(stdout), O_BINARY); #endif /* MSDOS */ printf("Content-type: image/gif\n\n"); /* Now write the contents of the file to standard output */ while (1) { ch = getc(in); if (ch == EOF) { break; } putc(ch, stdout); } fclose(in); return 0; }