httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Lozano, Javier" <>
Subject Web Programming with Apache API 1.3 Problem
Date Wed, 19 Jun 2002 20:59:03 GMT

 <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

My name is Javier Lozano and I'm an intern with the Principal Financial Group in Des Moines,
IA.  One of my projects this summer is to take our web site sign-on API from MFC (Apache Windows)
and port it to Standard Template Library (STL Apache Linux).

Currently the API compiles in Windows with one of two macros, -IIS -APACHE.  For -IIS, it
uses IIS specific libraries and with -APACHE it generates Apache Modules that mimic the IIS
functionality.  Whether the code is compiled with the -IIS or -APACHE macro, it still uses
some MFC classes, such as CString.

The conversion from CString to STL <string> is pretty simple and straightforward.  It
is when I get to Apache/IIS functionality conversion where it gets tricky.  

The MFC library has the following header file, <wininet.h>  That houses the InternetCanonicalizeUrl(...)
function.  This function takes in 4 parameters, a source buffer, an output buffer, length
of output buffer, and additional flags for configuration.  Right now the following code does
the following:


CString urlEncode(LPCTSTR szText)


  CString strText(szText);

  DWORD dwLen = _tcslen(szText) * 2;






  return strText;



Takes in a LPCTSTR (const char*) variable which contains an URL such as http://  <> and generates the CString object from it.  From here, it gets the length
of the LPCTSTR variable and stores it in a DWORD type (long) of twice the length.  

InternetCanonicalizeUrl then takes the source string, the new string, the length of it and
an optional flag (0- do nothing specific) and performs a canonicalization produce on szText
and stores the result into strText.  What it does to the url is the following:


If szText  =  <> login/main-page.html  it will make 

strText =  <>  Thus it converts,
spaces, ampersands, etc. to their %equivalent.


Now, when trying to convert to Linux, I found in the Apache API the function called, ap_unescape_url(...)
that takes in a (char * ) parameter.  This function claims to perform the same functionality
as its MFC equivalent.  However, when I try to compile the following conversion code, it compiles
but fails to link. 


string urlEncode(const char* szText)


  int length = strlen(szText) * 2;

  char* encodedURL = new char[length];




  int error = ap_unescaped_url(encodedURL);


  if(error != 0){

     string url(encodedURL);

     return url; 



     string badurl = "";

     return badurl;




When I try to compile, I get the following linker error:


g++ -I /usr/local/apache/include -O -o urlTest.exe urlTest.cpp

/tmp/cc2oAm7k.o: In function `main': urlEncode

/tmp/cc2oAm7k.o(.text+0x15d): undefined reference to `ap_unescape_url'

collect2: ld returned 1 exit status


My question is the following: Is this the correct function to use for this procedure?  Is
the ap_unescape_url function unreachable when outside Apache (not in a module)?


I also tried writing a simple Apache module that uses the same function and I get an error
in a different place.  The module links fine, but when I try to restart Apache with apachectl
restart it complains about the module containing ap_unescape_url prevents Apache to restart.
 I comment the line out, recompile and restart Apache and it works just fine.


If any of you can help me out with this issue, I would really appreciate it.


I thank you for your time.





-Javier G. Lozano

Principal Financial Group

IS - Web Infrastructure Team

View raw message