Link to home
Start Free TrialLog in
Avatar of andrewyu
andrewyu

asked on

Apache API

How can I call API of Apache from a CGI written by C ?

Andrew
Avatar of BigRat
BigRat
Flag of France image

What API? For what purpose?
Avatar of andrewyu
andrewyu

ASKER

Apache API ......

Andrew
ASKER CERTIFIED SOLUTION
Avatar of monas
monas
Flag of Lithuania image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
So, can CGI call the module I wrote ?

Andrew
Directly - NO.

Indirectly - maybe. It depends for what purpose you are writing this module.

THe principle is that apache consist of number of modules. When it accepts a request for some document it handles this request in "phases" - or steps. The main steps are:

- converting from URL to filesystem path
- authentication (or finding who requested the document)
- authorization (or finding is he/she allowed to get this document)
- producing of the document
[check apache docs for full explanation]

In every phase corresponding functions from EVERY module is called.

So if you write module you can affect environment where CGI script will be invoked. But CGI module sends cgi-script's output directly to the requestor - therefore there is no possibility to afect data that your script provides.

Of course, you can modify mod_cgi and introduce some kind of possibility to access API via this module. But then this won't be a CGI module anymore. ANd your scripts won't be able to be run on other servers anymore - so you will loose the whole point why the CGI was invented.

      Good Look

So, I must write a HANDLER, right ?

Andrew
You did not say me what you want to achieve, therefore I can not say for sure.

But most likely, you have to write module, and every function which is invoked to perform modules' actions in that phase is called HANDLER. THerefore if you will be writing module you will need to write handler. Most likely, several of them.

But before you start at creating new modules check very carefully present modules. Chanses are pretty good that existing modules already provide services to achieve your final result. Possible not in the way you expect them to do this. I wasted my time several times "reinventing wheel".