1 /*
2  * Replacement for the passwd related functions for micro ports.
3  * Copyright (c) 1996 Markku Rossi.
4  *
5  * Author: Markku Rossi <mtr@iki.fi>
6  */
7 
8 /*
9  * This file is part of GNU Enscript.
10  *
11  * Enscript is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation, either version 3 of the License, or
14  * (at your option) any later version.
15  *
16  * Enscript is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with Enscript.  If not, see <http://www.gnu.org/licenses/>.
23  */
24 
25 #include <stdio.h>
26 #include <stdlib.h>
27 
28 #if defined(WIN32)
29 #include <windows.h>
30 #endif
31 
32 #include "dummypwd.h"
33 
34 /*
35  * Static variables
36  */
37 
38 static struct passwd dummy_passwd =
39 {
40   "dos", "Dos User", "/home",
41 };
42 
43 
44 /*
45  * Global functions
46  */
47 
48 struct passwd *
getpwuid()49 getpwuid ()
50 {
51 #if defined(WIN32)
52 
53   static char userName[32];
54   DWORD userNameLen = sizeof (userName);
55 
56   if (GetUserName (userName, &userNameLen))
57     {
58       dummy_passwd.pw_name = userName;
59       dummy_passwd.pw_gecos = userName;
60     }
61 
62   return &dummy_passwd;
63 
64 #else /* not WIN32 */
65 
66   return &dummy_passwd;
67 
68 #endif /* not WIN32 */
69 }
70 
71 
72 struct passwd *
getpwnam(name)73 getpwnam (name)
74      char *name;
75 {
76   return getpwuid ();
77 }
78