Make WvStreams compile with gcc 4.4.
[wvstreams.git] / include / wvuid.h
blob6345507ee36a8e9d68518c0c13fde37a1be359e2
1 /* -*- Mode: C++ -*-
2 * Worldvisions Weaver Software:
3 * Copyright (C) 1997-2002 Net Integration Technologies, Inc.
4 *
5 * Portable standins for getuid() and friends.
6 */
7 #ifndef __WVUID_H
8 #define __WVUID_H
10 #include "wvstring.h"
12 #if WIN32
13 typedef WvString wvuid_t;
14 #define WVUID_INVALID (WvString::null)
15 #else // not WIN32
16 #include <pwd.h>
17 typedef uid_t wvuid_t;
18 #define WVUID_INVALID ((wvuid_t)(-1))
19 #endif
21 /**
22 * Convert a uid object into a human-readable username.
23 * Returns WvString::null if the uid isn't findable or doesn't exist.
25 WvString wv_username_from_uid(wvuid_t uid);
27 /**
28 * Convert a human-readable username into a machine-usable uid.
29 * Returns WVUID_INVALID if the username isn't findable or doesn't exist.
31 wvuid_t wv_uid_from_username(WvString username);
33 /**
34 * Return the machine-usable uid corresponding to the current session user.
36 * Corresponds to getuid() in Unix; parallels for functions
37 * like getgid() and geteuid() are not currently available.
39 * In Unix, this should never fail. In Windows, there is no guarantee that
40 * it will work. It returns WVUID_INVALID on failure.
42 wvuid_t wvgetuid();
45 #endif // __WVUID_H