GRASS Programmer's Manual
6.5.svn(2014)-r66266
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
gis/whoami.c
Go to the documentation of this file.
1
17
#include <unistd.h>
18
#include <stdlib.h>
19
20
#ifndef __MINGW32__
21
#include <pwd.h>
22
#endif
23
24
#include <grass/gis.h>
25
26
40
char
*
G_whoami
(
void
)
41
{
42
#ifdef __MINGW32__
43
char
*
name
=
getenv
(
"USERNAME"
);
44
45
if
(name ==
NULL
) {
46
name =
"user_name"
;
47
}
48
#else
49
static
char
*name =
NULL
;
50
51
#ifdef COMMENTED_OUT
52
char
*getlogin();
53
char
*ttyname();
54
55
if
(name ==
NULL
) {
56
char
*x;
57
58
x = ttyname(0);
59
if
(x && *x) {
60
x = getlogin();
61
if
(x && *x)
62
name =
G_store
(x);
63
}
64
}
65
#endif
/* COMMENTED_OUT */
66
67
if
(name ==
NULL
) {
68
struct
passwd *p;
69
70
if
((p = getpwuid(getuid())))
71
name =
G_store
(p->pw_name);
72
}
73
if
(name ==
NULL
)
74
name =
G_store
(
"?"
);
75
76
#endif
77
78
return
name
;
79
}
G_store
char * G_store(const char *s)
Copy string to allocated memory.
Definition:
store.c:32
render.name
string name
Definition:
render.py:1314
getenv
char * getenv()
G_whoami
char * G_whoami(void)
Gets user's name.
Definition:
gis/whoami.c:40
NULL
return NULL
Definition:
dbfopen.c:1394
lib
gis
whoami.c
Generated on Sat Jan 2 2016 01:46:50 for GRASS Programmer's Manual by
1.8.5