Forum Moderators: phranque
This is outside my real understanding, but the program must be treated as a cgi program ie it must run on the server and read/write STDIN and STDOUT and output HTTP headers as well as the keycode, etc.
If you ensure it outputs a minimal HTTP header and install it in the cgi bin, it should work, I think. (I am, of course, assuming that you are using a Windows server since a C++ program compiled for Windows won't run on any other platform.)
Kaled.
Basically, hide the program behind a Web page, have the Web page call the program to produce the required (key) output, and lock down the program so that it only accepts requests from that page on your server. Kaled's reply says essentially the same thing in different words.
Jim
Kaled.
Essentially, a cgi program works just like a console program except that no interaction with the user is possible. In other words, you must supply all the required data when the program starts. In addition, you must begin the output with an HTTP header. This consists of simple text and is terminated by a blank line.
The query part of an url (the text following a '?') is supplied to the program as an environment variable QUERY_STRING. This is how form data sent by the GET method is delivered.
Data sent by the form POST method is made available through the STDIN file (i.e. it is read as though it were entered by keyboard).
The HTTP header must, as a minimum contain a MIME type. I often use a cache instruction too.
Content-type: text/html
Cache-Control: no-cache Remember it must be terminated by a blank line.
I am not certain, but line-termination may require simply an LF char rather than the CRLF used by Windows. (ie It may require ascii #10 only rather than ascii #13 #10.)
If you set the content-type to text/html, you should output a valid html page i.e. <HEAD><BODY> etc.
When testing & developing, you will need to create a batch file. It should look something like this:-
set SERVER_NAME=www.yourdomain.com
set HTTP_REFERER=http://www.yourdomain.com/form-page.html
set QUERY_STRING=param1=value1^¶m2=value2^¶m3=value3
cgiprog.exe <testin.txt >testout.html
i.e. you must set up the required environment vars (note the use of the ^ char). You must also arrange to pipe input and output to files.
For initial testing, ignore the output pipe and simply view the output.
For final testing, pipe the output to a file, view it with a browser and then validate it. (You may need to edit out the HTTP headers before viewing with a browser).
So, in theory, it's straightforward. However, I suggest that you confirm with your host that you can install a cgi program written in C++ before you proceed.
Kaled.