Hi!
I'm using cpp code to generate .cgi files. The problem is that I tried to execute a file with .cgi extension and in error log file I have this:
[Sat Mar 21 21:04:02 2009] [error] [client 127.0.0.1] (8)Error de formato ejecutable: exec of '/opt/lampp/htdocs/Ejemplos_Proyecto/PFORM/parser.cgi' failed
[Sat Mar 21 21:04:02 2009] [error] [client 127.0.0.1] Premature end of script headers: parser.cgi
The code of parser.cpp is this:
#include <iostream>
#include <malloc.h>
#include <cstdlib>
#include "cgi.h"
using namespace std;
int main()
{
CCGI cgi;
CCGIItem item;
char* lpszOut;
char* lpszContentLength = getenv("CONTENT_LENGTH");
int i,nLength;
cout << "Content-type: text/html" << endl << endl;
cout<< "<html>" << endl;
cout << "<body>" << endl;
cout << "<p>You sent " << lpszContentLength;
cout << " bytes of data, which contained the following values: </p>" << endl;
cout << "<ul>" << endl;
cgi.Load();
for(i=0; i<cgi.GetItemCount(); i++)
{
cgi.GetItem(i,&item);
nLength = item.GetNameLength();
lpszOut = (char*) malloc(nLength);
item.GetName(lpszOut,nLength);
cout << "<li>" << lpszOut << " - ";
free(lpszOut);
nLength = item.GetLength();
lpszOut = (char*) malloc(nLength);
item.GetValue(lpszOut,nLength);
cout << lpszOut << endl;
free(lpszOut);
}
cout << "</ul>" << endl
<< "</body>" << endl
<< "</html>" << endl;
return 0;
}
I hope you could help me.
Thanks a lot.