Added preliminary Symbian support.
[silc.git] / lib / silcutil / symbian / silcsymbianutil.cpp
1 /*\r
2 \r
3   silcsymbianutil.cpp\r
4 \r
5   Author: Pekka Riikonen <priikone@silcnet.org>\r
6 \r
7   Copyright (C) 2006 Pekka Riikonen\r
8 \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
12 \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
17 \r
18 */\r
19 \r
20 #include "silc.h"\r
21 \r
22 /* Returns the username of the user. */\r
23 \r
24 char *silc_get_username()\r
25 {\r
26   char *logname = NULL;\r
27 \r
28   logname = getlogin();\r
29   if (!logname) {\r
30     struct passwd *pw;\r
31 \r
32     pw = getpwuid(getuid());\r
33     if (!pw)\r
34       return strdup("User");\r
35 \r
36     logname = pw->pw_name;\r
37   }\r
38 \r
39   return strdup(logname);\r
40 }\r
41 \r
42 /* Returns the real name of ther user. */\r
43 \r
44 char *silc_get_real_name()\r
45 {\r
46   char *realname = NULL;\r
47   struct passwd *pw;\r
48 \r
49   pw = getpwuid(getuid());\r
50   if (!pw)\r
51     return strdup("No Name");\r
52 \r
53   if (strchr(pw->pw_gecos, ','))\r
54     *strchr(pw->pw_gecos, ',') = 0;\r
55 \r
56   if (!strlen(pw->pw_gecos))\r
57     return strdup("No Name");\r
58 \r
59   realname = strdup(pw->pw_gecos);\r
60 \r
61   return realname;\r
62 }\r
63 \r
64 /* Return current time to struct timeval. */\r
65 \r
66 int silc_gettimeofday(struct timeval *p)\r
67 {\r
68   return gettimeofday(p, NULL);\r
69 }\r
70 \r
71 int silc_file_set_nonblock(int fd)\r
72 {\r
73   return 0;\r
74 }\r