Apache API

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

Andrew
andrewyuAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

BigRatCommented:
What API? For what purpose?
0
andrewyuAuthor Commented:
Apache API ......

Andrew
0
monasCommented:
You CAN NOT!

To use apache API you should write apache module, not a cgi program. This means that you should compile your code into apache server.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

andrewyuAuthor Commented:
So, can CGI call the module I wrote ?

Andrew
0
monasCommented:
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

0
andrewyuAuthor Commented:
So, I must write a HANDLER, right ?

Andrew
0
monasCommented:
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".
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.