detect pin mode possible?

Thank you. And sorry to open a new thread, I actually did some googling before posting but probably the search criteria was poorly chosen.

I want it for the same reason with that guy that asked that question on the other thread. I am building an API to remotely control the Arduino over http as a project for my school, and it has to be generic.

So I want to know if there's anyway to read the current pin mode for a given pin.

I know that I can initialize all pins to some specific mode in my setup(), then keep in an array all calls to pinMode() but I was more curious to know if that was possible.

For example, what if I don't want to initialize the pins to some arbitrary state at setup? What if I want to just leave them as they happened to be at a given moment.