WvStreams
|
00001 /* -*- Mode: C++ -*- 00002 * Worldvisions Weaver Software: 00003 * Copyright (C) 1997-2002 Net Integration Technologies, Inc. 00004 * 00005 * Portable standins for getuid() and friends. See wvuid.h. 00006 */ 00007 #include "wvautoconf.h" 00008 #include "wvuid.h" 00009 00010 #if WIN32 00011 00012 00013 WvString wv_username_from_uid(wvuid_t uid) 00014 { 00015 // FIXME not implemented 00016 return WvString::null; 00017 } 00018 00019 00020 wvuid_t wv_uid_from_username(WvString username) 00021 { 00022 // FIXME not implemented 00023 return WVUID_INVALID; 00024 } 00025 00026 00027 wvuid_t wvgetuid() 00028 { 00029 // FIXME not implemented 00030 return WVUID_INVALID; 00031 } 00032 00033 00034 #else // not WIN32 00035 00036 00037 WvString wv_username_from_uid(wvuid_t uid) 00038 { 00039 char buf[1024]; 00040 struct passwd pwbuf, *userinfo; 00041 00042 if (getpwuid_r(uid, &pwbuf, buf, sizeof(buf), &userinfo) == 0) 00043 return userinfo->pw_name; 00044 else 00045 return WvString::null; 00046 } 00047 00048 00049 wvuid_t wv_uid_from_username(WvString username) 00050 { 00051 char buf[1024]; 00052 struct passwd pwbuf, *userinfo; 00053 00054 if (getpwnam_r(username, &pwbuf, buf, sizeof(buf), &userinfo) != 0) 00055 return userinfo->pw_uid; 00056 else 00057 return WVUID_INVALID; 00058 } 00059 00060 00061 wvuid_t wvgetuid() 00062 { 00063 return getuid(); 00064 } 00065 00066 00067 #endif