1 /******************************************************************************
2 * Copyright (c) 2000-2016 Ericsson Telecom AB
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
11 * Szabo, Janos Zoltan – initial implementation
13 ******************************************************************************/
26 char *get_user_info(void)
30 const char *current_time
;
32 TCHAR user_name
[UNLEN
+ 1], computer_name
[MAX_COMPUTERNAME_LENGTH
+ 1];
33 DWORD buffer_size
= sizeof(user_name
);
34 if (GetUserName(user_name
, &buffer_size
)) ret_val
= mcopystr(user_name
);
35 else ret_val
= mcopystr("unknown");
36 ret_val
= mputc(ret_val
, '@');
37 buffer_size
= sizeof(computer_name
);
38 if (GetComputerName(computer_name
, &buffer_size
))
39 ret_val
= mputstr(ret_val
, computer_name
);
40 else ret_val
= mputstr(ret_val
, "unknown");
45 p
= getpwuid(getuid());
48 for (i
= 0; p
->pw_gecos
[i
] != '\0'; i
++) {
49 if (p
->pw_gecos
[i
] == ',') {
50 /* Truncating additional info (e.g. phone number) after the full name */
51 p
->pw_gecos
[i
] = '\0';
55 ret_val
= mprintf("%s (%s", p
->pw_gecos
, p
->pw_name
);
56 } else ret_val
= mcopystr("Unknown User (unknown");
58 if (gethostname(host_name
, sizeof(host_name
)))
59 ret_val
= mputstr(ret_val
, "@unknown)");
61 host_name
[sizeof(host_name
) - 1] = '\0';
62 ret_val
= mputprintf(ret_val
, "@%s)", host_name
);
66 current_time
= ctime(&t
);
67 ret_val
= mputprintf(ret_val
, " on %s", current_time
);
This page took 0.031084 seconds and 5 git commands to generate.