Fixed header dependencies to be fully compatible with the Windows
[wine/multimedia.git] / dlls / netapi32 / netapi32.c
blob748d4978b752548d61a0b20cbb24abad270981b4
1 /*
2 * Copyright 2001 Mike McCormack
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #include "config.h"
21 #include <string.h>
22 #include <stdarg.h>
23 #include <stdio.h>
24 #include <stdlib.h>
25 #ifdef HAVE_UNISTD_H
26 # include <unistd.h>
27 #endif
29 #include "windef.h"
30 #include "winbase.h"
31 #include "winreg.h"
32 #include "wingdi.h"
33 #include "winuser.h"
34 #include "wine/debug.h"
35 #include "winerror.h"
36 #include "nb30.h"
37 #include "lmcons.h"
38 #include "iphlpapi.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(netbios);
42 HMODULE NETAPI32_hModule = 0;
44 static UCHAR NETBIOS_Enum(PNCB ncb)
46 int i;
47 LANA_ENUM *lanas = (PLANA_ENUM) ncb->ncb_buffer;
48 DWORD apiReturn, size = 0;
49 PMIB_IFTABLE table;
50 UCHAR ret;
52 TRACE("NCBENUM\n");
54 apiReturn = GetIfTable(NULL, &size, FALSE);
55 if (apiReturn != NO_ERROR)
57 table = (PMIB_IFTABLE)malloc(size);
58 if (table)
60 apiReturn = GetIfTable(table, &size, FALSE);
61 if (apiReturn == NO_ERROR)
63 lanas->length = 0;
64 for (i = 0; i < table->dwNumEntries && lanas->length < MAX_LANA;
65 i++)
67 if (table->table[i].dwType != MIB_IF_TYPE_LOOPBACK)
69 lanas->lana[lanas->length] = table->table[i].dwIndex;
70 lanas->length++;
73 ret = NRC_GOODRET;
75 else
76 ret = NRC_SYSTEM;
77 free(table);
79 else
80 ret = NRC_NORESOURCES;
82 else
83 ret = NRC_SYSTEM;
84 return ret;
88 static UCHAR NETBIOS_Astat(PNCB ncb)
90 PADAPTER_STATUS astat = (PADAPTER_STATUS) ncb->ncb_buffer;
91 MIB_IFROW row;
93 TRACE("NCBASTAT (Adapter %d)\n", ncb->ncb_lana_num);
95 memset(astat, 0, sizeof astat);
97 row.dwIndex = ncb->ncb_lana_num;
98 if (GetIfEntry(&row) != NO_ERROR)
99 return NRC_INVADDRESS;
100 /* doubt anyone cares, but why not.. */
101 if (row.dwType == MIB_IF_TYPE_TOKENRING)
102 astat->adapter_type = 0xff;
103 else
104 astat->adapter_type = 0xfe; /* for Ethernet */
105 return NRC_GOODRET;
108 BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
110 TRACE("%p,%lx,%p\n", hinstDLL, fdwReason, lpvReserved);
112 switch (fdwReason) {
113 case DLL_PROCESS_ATTACH:
114 DisableThreadLibraryCalls(hinstDLL);
115 NETAPI32_hModule = hinstDLL;
116 break;
117 case DLL_PROCESS_DETACH:
118 break;
121 return TRUE;
124 BOOL WINAPI Netbios(PNCB pncb)
126 UCHAR ret = NRC_ILLCMD;
128 TRACE("ncb = %p\n",pncb);
130 if(!pncb)
131 return NRC_INVADDRESS;
133 switch(pncb->ncb_command&0x7f)
135 case NCBRESET:
136 FIXME("NCBRESET adapter %d\n",pncb->ncb_lana_num);
137 if(pncb->ncb_lana_num < MAX_LANA )
139 MIB_IFROW row;
141 row.dwIndex = pncb->ncb_lana_num;
142 if (GetIfEntry(&row) != NO_ERROR)
143 ret = NRC_GOODRET;
144 else
145 ret = NRC_ILLCMD; /* NetBIOS emulator not found */
147 else
148 ret = NRC_ILLCMD; /* NetBIOS emulator not found */
149 break;
151 case NCBADDNAME:
152 FIXME("NCBADDNAME\n");
153 break;
155 case NCBADDGRNAME:
156 FIXME("NCBADDGRNAME\n");
157 break;
159 case NCBDELNAME:
160 FIXME("NCBDELNAME\n");
161 break;
163 case NCBSEND:
164 FIXME("NCBSEND\n");
165 break;
167 case NCBRECV:
168 FIXME("NCBRECV\n");
169 break;
171 case NCBHANGUP:
172 FIXME("NCBHANGUP\n");
173 break;
175 case NCBCANCEL:
176 FIXME("NCBCANCEL\n");
177 break;
179 case NCBLISTEN:
180 FIXME("NCBLISTEN\n");
181 break;
183 case NCBASTAT:
184 ret = NETBIOS_Astat(pncb);
185 break;
187 case NCBENUM:
188 ret = NETBIOS_Enum(pncb);
189 break;
191 default:
192 FIXME("(%p): command code %02x\n", pncb, pncb->ncb_command);
194 ret = NRC_ILLCMD; /* NetBIOS emulator not found */
196 pncb->ncb_retcode = ret;
197 return ret;
200 NET_API_STATUS WINAPI NetServerEnum(
201 LPCWSTR servername,
202 DWORD level,
203 LPBYTE* bufptr,
204 DWORD prefmaxlen,
205 LPDWORD entriesread,
206 LPDWORD totalentries,
207 DWORD servertype,
208 LPCWSTR domain,
209 LPDWORD resume_handle
212 FIXME("Stub (%p, %ld %p %ld %p %p %ld %s %p)\n",servername, level, bufptr,
213 prefmaxlen, entriesread, totalentries, servertype, debugstr_w(domain), resume_handle);
215 return ERROR_NO_BROWSER_SERVERS_FOUND;