I was trying to setup a simply webservice to reply to POST requests. Earlier this was being done in tomcat which seem a little overkill to me since I already had a webserver up and running. So, a quick c program to respond to request is all that I needed. And here is the result.
* Filename: Login.cpp
* Version: 1.0
* Revision: none
* Compiler: gcc
* Author: Amit Agarwal (),
* == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == =
#define MAXLEN 1024
#define DEBUG(a,b) fprintf(stderr, a, b);
#define HEAD "n"
#define TAIL ""
char * data;
"Content-Type:text/xml;charset=iso-8859-1", 13, 10);
// len = getenv("QUERY_STRING"); // This is for GET
lenstr = getenv("CONTENT_LENGTH");
DEBUG( "Length string is %sn", lenstr);
if(lenstr == NULL || sscanf(lenstr,"%ld",&len)!=1 || len > MAXLEN)
printf("Error in invocation - wrong FORM probably.");
DEBUG( "Length is %ldn", len);
while ( count < len )
input[count++] = getchar();
DEBUG ( "Read characters = %dn", count)
//fprintf(stderr, "VAlue is %sn", input);
///unencode(input + 5 , input + len, data);
data = input;
DEBUG("Data value is %sn", data);
printf("Everything else goes heren");
fprintf(stderr, "Sent resp: tid[%s], eaid[%s], tcode[%s]n", tid, eaid, tcode);
Additionally, the makefile:
gcc -o Login Login.c -Wall
gcc -o Login Login.c -Wall -DDBG=1
And finally, compile this with make command and put in the cgi-bin folder and that is all that you need 🙂
Now once that is done, you will need to ensure that the call to g++, gcc and others that you want to use, you will need to create a link in the “~/bin” directory, like so:
for i in g++ gcc c++ cc
ln -s $(which colorgcc) ~/bin/$i
The one liner above will create the links for colorgcc as your favourite compiler in your homedir. Don’t forget to add the bin diretory to your PATH variable:
And now finally the ~/.colorgccrc file taken from Ubuntu for your reference:
# colorgcc configuration file
# $Id: colorgccrc,v 22.214.171.124 1999/04/25 15:24:03 jamoyers Exp $
# This file should be named $HOME/.colorgccrc
# The following groups of attributes may be combined for a given color:
# clear black on_black
# reset red on_red
# bold green on_green
# underline yellow on_yellow
# underscore blue on_blue
# blink magenta on_magenta
# reverse cyan on_cyan
# concealed white on_white
# For example, srcColor: bold cyan on_yellow
# gccVersion: if defined, append "-" to the compiler paths
# defined hereunder. Otherwise, those paths remains as is set
# gccVersion: 4.1.1
# Define the paths to the actual location of the various compilers.
# (Currently, colorgcc only understands these: g++ gcc c++ cc g77 f77 gcj)
# Don't do color if our terminal type ($TERM) is one of these.
# (List all terminal types on one line, seperated by whitespace.)
nocolor: dumb emacs
# Text between ` and ' is usually source code.
srcColor: bold cyan
# Text other than a warning or error.
# Warnings and errors both have similar formats:
# Each field may be assigned a different color.
errorMessageColor: bold red
# Possible translations, if you use localized compiler.
# (List all translations on one line, seperated by whitespace.)