Takes print spooler functions out of win16drv.
[wine] / win32 / init.c
1 /*
2  * Win32 kernel functions
3  *
4  * Copyright 1995 Martin von Loewis and Cameron Heide
5  */
6
7 #include <string.h>
8 #include <unistd.h>
9 #include <stdlib.h>
10 #include "windows.h"
11 #include "winerror.h"
12 #include "except.h"
13 #include "heap.h"
14 #include "task.h"
15 #include "debug.h"
16   
17 /***********************************************************************
18  *              GetStartupInfoA         (KERNEL32.273)
19  */
20 VOID WINAPI GetStartupInfo32A(LPSTARTUPINFO32A lpStartupInfo)
21 {
22     lpStartupInfo->cb = sizeof(STARTUPINFO32A);
23     lpStartupInfo->lpReserved = "<Reserved>";
24     lpStartupInfo->lpDesktop = "Desktop";
25     lpStartupInfo->lpTitle = "Title";
26
27     lpStartupInfo->cbReserved2 = 0;
28     lpStartupInfo->lpReserved2 = NULL; /* must be NULL for VC runtime */
29     lpStartupInfo->dwFlags    = STARTF_USESTDHANDLES;
30     lpStartupInfo->hStdInput  = (HANDLE32)0;
31     lpStartupInfo->hStdOutput = (HANDLE32)1;
32     lpStartupInfo->hStdError  = (HANDLE32)2;
33 }
34
35 /***********************************************************************
36  *              GetStartupInfoW         (KERNEL32.274)
37  */
38 VOID WINAPI GetStartupInfo32W(LPSTARTUPINFO32W lpStartupInfo)
39 {
40     lpStartupInfo->cb = sizeof(STARTUPINFO32W);
41     lpStartupInfo->lpReserved = HEAP_strdupAtoW(GetProcessHeap(),0,"<Reserved>");
42     lpStartupInfo->lpDesktop = HEAP_strdupAtoW(GetProcessHeap(), 0, "Desktop");
43     lpStartupInfo->lpTitle = HEAP_strdupAtoW(GetProcessHeap(), 0, "Title");
44
45     lpStartupInfo->cbReserved2 = 0;
46     lpStartupInfo->lpReserved2 = NULL; /* must be NULL for VC runtime */
47     lpStartupInfo->hStdInput  = (HANDLE32)0;
48     lpStartupInfo->hStdOutput = (HANDLE32)1;
49     lpStartupInfo->hStdError  = (HANDLE32)2;
50 }
51
52 /***********************************************************************
53  *              GetComputerNameA         (KERNEL32.165)
54  */
55 BOOL32 WINAPI GetComputerName32A(LPSTR name,LPDWORD size)
56 {
57         if (-1==gethostname(name,*size))
58                 return FALSE;
59         *size = lstrlen32A(name);
60         return TRUE;
61 }
62
63 /***********************************************************************
64  *              GetComputerNameW         (KERNEL32.166)
65  */
66 BOOL32 WINAPI GetComputerName32W(LPWSTR name,LPDWORD size)
67 {
68     LPSTR nameA = (LPSTR)HeapAlloc( GetProcessHeap(), 0, *size);
69     BOOL32 ret = GetComputerName32A(nameA,size);
70     if (ret) lstrcpynAtoW(name,nameA,*size+1);
71     HeapFree( GetProcessHeap(), 0, nameA );
72     return ret;
73 }
74
75 /***********************************************************************
76  *           GetUserNameA   [ADVAPI32.67]
77  */
78 BOOL32 WINAPI GetUserName32A(LPSTR lpszName, LPDWORD lpSize)
79 {
80   size_t len;
81   char *name;
82
83   name=getlogin();
84 #if 0
85   /* FIXME: should use getpwuid() here */
86   if (!name) name=cuserid(NULL);
87 #endif
88   len = name ? strlen(name) : 0;
89   if (!len || !lpSize || len > *lpSize) {
90     if (lpszName) *lpszName = 0;
91     return 0;
92   }
93   *lpSize=len;
94   strcpy(lpszName, name);
95   return 1;
96 }
97
98 /***********************************************************************
99  *           GetUserNameW   [ADVAPI32.68]
100  */
101 BOOL32 WINAPI GetUserName32W(LPWSTR lpszName, LPDWORD lpSize)
102 {
103         LPSTR name = (LPSTR)HeapAlloc( GetProcessHeap(), 0, *lpSize );
104         DWORD   size = *lpSize;
105         BOOL32 res = GetUserName32A(name,lpSize);
106
107         lstrcpynAtoW(lpszName,name,size);
108         HeapFree( GetProcessHeap(), 0, name );
109         return res;
110 }