Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.
I'm sure there's a few ways...

getenv("$HOSTNAME");

might be one way.

char myhost[20];
gethostname(&myhost, sizeof(myhost));

is another...

There may be some more Mac specific API calls to do this as well...
 
Are you sure these can be called from kernel level? When I try it they are not found.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.