Solved

WinNT and C++ cgi

Posted on 1998-08-31
1
154 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
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Recently I have been answering a lot of questions like this in IT forums that I frequent. The question posed is usually something along the lines of "We have software X installed and need to uninstall it for reason Y" or some other variant of the sa…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
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…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

707 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now