Solved

WinNT and C++ cgi

Posted on 1998-08-31
1
165 Views
Last Modified: 2013-12-25
Hi, can anyone tell me why my cgi script written in C runs perfectly fine in Unix and fails under windows nt?

The cgi prints out an image to the stdio!
0
Comment
Question by:sidefoo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 7

Accepted Solution

by:
jconde earned 200 total points
ID: 1828390
Sidefoo, the problems you have is normal!

What happens is that in Unix, the stdio is binary, and in Windows its text.
i.e.  Try the following in Unix and Windows and see what happens:

1)  type picture.gif > picture2.gif (windows)
2)  cat picutre.gif > picture2.gif (Unix)

..see the difference?

to correct that you must convert the std output of windows to binary.

you can accomplish that by simply putting the following line in your code:

setmode (fileio(stdio), O_BINARY);
cout << "Content-type:  image/gif" << endl << endl;

Make sure to check the setmode function out, since I dont have a compiler with me at this time, and I don't remember the exact way to call it.

--jconde
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial will discuss the log-in process using WhizBase. In this article I assume you already know HTML. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you might look at some of my other articles abo…
It is becoming increasingly popular to have a front-page slider on a web site. Nearly every TV website,  magazine or online news has one on their site, and even some e-commerce sites have one. Today you can use sliders with Joomla, WordPress or …
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question