PDA

View Full Version : need a bit of help on this CGI problem please


mcnasa01
08-01-2007, 02:34 AM
Hi everyone, I apologize if this is the wrong forum since my problem doesn't pertain to PERL but CGI.

I'm having a hard time trying to figure out how to implement this.

Develop a program written in C that will handle encoding and decoding of
CGI data.

* Your program should run from a command-line interface in Linux (preferably)
or DOS. It should prompt the user to enter these items:
1. Name
2. Address
3. Phone number

* Once you collect this data, CGI encode it and display the encoded string.

* Decode the CGI data, and display a label and associated value (these should
match exactly what the user entered.)

* Do not link in or use any code except what can be found in the standard
libraries.

Now I can set up and make a program that will fulfill the data requirements with executable that a user runs, though I'm not sure how to convert it to CGI and display it from there. I can also make the CGI script so that if the user goes to a webpage, puts in the information in the requirements will be fulfilled. My problem is how do I encode and decode data as CGI from a command line or shell, and how can data from an executable be made into CGI data. Thanks.

KevinADC
08-01-2007, 06:28 AM
You might want to post your question in a C forum. But I suggest you post any existing code you have, many people will not help you with what appears to be a school/class assigment unless you have shown some effort.

Normally a CGI script is meant to be run in an http environment, not as a command line program. That is essentially what the CGI protocol was invented for: communication between server and client via web forms.

KevinADC
08-01-2007, 06:30 AM
something here might help get you started:

http://www.google.com/search?q=c+programming+and+CGI&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a

mcnasa01
08-01-2007, 08:25 AM
Did some other posts and I got some feedback, I think my problem was approaching the problem the wrong way.

I believe the purpose of the problem is that I need to take the input that the user types in and encodes it using the same technique CGI data is encoded that is to use URL encoding. Therefore, I don't actually need to make a CGI script.

My approach for the problem is this:

1. user executes program from command line
2. program asks the user for required data
3. program encodes the data using URL encoding
4. program decodes the data
5. program displays the data to the user with labels
6. program exits.

I firmly believe the notation of CGI encoding should have said URI or URL encoding instead, but this may have been intentional so that I dig up more research, but I can't get a hold of the person who gave me the assignment.

Anyhow does this seem like a reasonable approach to the problem, and if possibble does anyone have a good source for URL encoding? googling shows a bunch of stuff for PERL but having a bit of a hard time finding information on C for it.

KevinADC
08-01-2007, 09:37 AM
URI/URL encoding is the same regardless of the backend program that does it. But your question is now firmly a C programming question, and should be continued in a C forum.