5 Author: Pekka Riikonen <priikone@silcnet.org>
\r
7 Copyright (C) 2006 Pekka Riikonen
\r
9 This program is free software; you can redistribute it and/or modify
\r
10 it under the terms of the GNU General Public License as published by
\r
11 the Free Software Foundation; version 2 of the License.
\r
13 This program is distributed in the hope that it will be useful,
\r
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
16 GNU General Public License for more details.
\r
22 /* Returns the username of the user. */
\r
24 char *silc_get_username()
\r
26 char *logname = NULL;
\r
28 logname = getlogin();
\r
32 pw = getpwuid(getuid());
\r
34 return strdup("User");
\r
36 logname = pw->pw_name;
\r
39 return strdup(logname);
\r
42 /* Returns the real name of ther user. */
\r
44 char *silc_get_real_name()
\r
46 char *realname = NULL;
\r
49 pw = getpwuid(getuid());
\r
51 return strdup("No Name");
\r
53 if (strchr(pw->pw_gecos, ','))
\r
54 *strchr(pw->pw_gecos, ',') = 0;
\r
56 if (!strlen(pw->pw_gecos))
\r
57 return strdup("No Name");
\r
59 realname = strdup(pw->pw_gecos);
\r
64 /* Return current time to struct timeval. */
\r
66 int silc_gettimeofday(struct timeval *p)
\r
68 return gettimeofday(p, NULL);
\r
71 int silc_file_set_nonblock(int fd)
\r