Unix - getpwuid & getprpwuid

I need a c-program that will detect if the Unix System is trusted host or not and use the appropriate function
getpwuid - none trusted host
getprpwuid - trusted host

How do I do this?

If you know the answer and have sample code, please send it to me.

I'm creating a cgi script that will authenticate users on a Web Site using the System password DB. This includes encrypting the password using crypt & the SALT and then comparing it to the encrypted System User password. If they match, your logged in.
*** If you have already done this, please let me know and I'll reward you 500 points. ***