From a746b826f42754684e3ed2556fc89e1ca38308dc Mon Sep 17 00:00:00 2001 From: Hans Leidekker Date: Tue, 12 Nov 2013 09:59:42 +0100 Subject: [PATCH] netapi32: Merge apibuf.c into netapi32.c. --- dlls/netapi32/Makefile.in | 1 - dlls/netapi32/apibuf.c | 99 --------------------------------------- dlls/netapi32/netapi32.c | 69 +++++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 100 deletions(-) delete mode 100644 dlls/netapi32/apibuf.c diff --git a/dlls/netapi32/Makefile.in b/dlls/netapi32/Makefile.in index fd4e531101..1b6b33c84a 100644 --- a/dlls/netapi32/Makefile.in +++ b/dlls/netapi32/Makefile.in @@ -5,7 +5,6 @@ IMPORTS = iphlpapi ws2_32 advapi32 C_SRCS = \ access.c \ - apibuf.c \ browsr.c \ ds.c \ local_group.c \ diff --git a/dlls/netapi32/apibuf.c b/dlls/netapi32/apibuf.c deleted file mode 100644 index a88c6f4c31..0000000000 --- a/dlls/netapi32/apibuf.c +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright 2002 Andriy Palamarchuk - * - * Net API buffer calls - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include - -#include "windef.h" -#include "winbase.h" -#include "lmcons.h" -#include "lmapibuf.h" -#include "lmerr.h" -#include "winerror.h" -#include "wine/debug.h" - -WINE_DEFAULT_DEBUG_CHANNEL(netapi32); - -/************************************************************ - * NetApiBufferAllocate (NETAPI32.@) - */ -NET_API_STATUS WINAPI NetApiBufferAllocate(DWORD ByteCount, LPVOID* Buffer) -{ - TRACE("(%d, %p)\n", ByteCount, Buffer); - - if (Buffer == NULL) return ERROR_INVALID_PARAMETER; - *Buffer = HeapAlloc(GetProcessHeap(), 0, ByteCount); - if (*Buffer) - return NERR_Success; - else - return GetLastError(); -} - -/************************************************************ - * NetApiBufferFree (NETAPI32.@) - */ -NET_API_STATUS WINAPI NetApiBufferFree(LPVOID Buffer) -{ - TRACE("(%p)\n", Buffer); - HeapFree(GetProcessHeap(), 0, Buffer); - return NERR_Success; -} - -/************************************************************ - * NetApiBufferReallocate (NETAPI32.@) - */ -NET_API_STATUS WINAPI NetApiBufferReallocate(LPVOID OldBuffer, DWORD NewByteCount, - LPVOID* NewBuffer) -{ - TRACE("(%p, %d, %p)\n", OldBuffer, NewByteCount, NewBuffer); - if (NewByteCount) - { - if (OldBuffer) - *NewBuffer = HeapReAlloc(GetProcessHeap(), 0, OldBuffer, NewByteCount); - else - *NewBuffer = HeapAlloc(GetProcessHeap(), 0, NewByteCount); - return *NewBuffer ? NERR_Success : GetLastError(); - } - else - { - if (!HeapFree(GetProcessHeap(), 0, OldBuffer)) return GetLastError(); - *NewBuffer = 0; - return NERR_Success; - } -} - -/************************************************************ - * NetApiBufferSize (NETAPI32.@) - */ -NET_API_STATUS WINAPI NetApiBufferSize(LPVOID Buffer, LPDWORD ByteCount) -{ - DWORD dw; - - TRACE("(%p, %p)\n", Buffer, ByteCount); - if (Buffer == NULL) - return ERROR_INVALID_PARAMETER; - dw = HeapSize(GetProcessHeap(), 0, Buffer); - TRACE("size: %d\n", dw); - if (dw != 0xFFFFFFFF) - *ByteCount = dw; - else - *ByteCount = 0; - - return NERR_Success; -} diff --git a/dlls/netapi32/netapi32.c b/dlls/netapi32/netapi32.c index 6d3e913a9f..6aa1e39dc5 100644 --- a/dlls/netapi32/netapi32.c +++ b/dlls/netapi32/netapi32.c @@ -1,4 +1,5 @@ /* Copyright 2001 Mike McCormack + * Copyright 2002 Andriy Palamarchuk * Copyright 2003 Juan Lang * * This library is free software; you can redistribute it and/or @@ -208,3 +209,71 @@ NET_API_STATUS WINAPI NetUseGetInfo(LMSTR server, LMSTR name, DWORD level, LPBYT return ERROR_NOT_SUPPORTED; } + +/************************************************************ + * NetApiBufferAllocate (NETAPI32.@) + */ +NET_API_STATUS WINAPI NetApiBufferAllocate(DWORD ByteCount, LPVOID* Buffer) +{ + TRACE("(%d, %p)\n", ByteCount, Buffer); + + if (Buffer == NULL) return ERROR_INVALID_PARAMETER; + *Buffer = HeapAlloc(GetProcessHeap(), 0, ByteCount); + if (*Buffer) + return NERR_Success; + else + return GetLastError(); +} + +/************************************************************ + * NetApiBufferFree (NETAPI32.@) + */ +NET_API_STATUS WINAPI NetApiBufferFree(LPVOID Buffer) +{ + TRACE("(%p)\n", Buffer); + HeapFree(GetProcessHeap(), 0, Buffer); + return NERR_Success; +} + +/************************************************************ + * NetApiBufferReallocate (NETAPI32.@) + */ +NET_API_STATUS WINAPI NetApiBufferReallocate(LPVOID OldBuffer, DWORD NewByteCount, + LPVOID* NewBuffer) +{ + TRACE("(%p, %d, %p)\n", OldBuffer, NewByteCount, NewBuffer); + if (NewByteCount) + { + if (OldBuffer) + *NewBuffer = HeapReAlloc(GetProcessHeap(), 0, OldBuffer, NewByteCount); + else + *NewBuffer = HeapAlloc(GetProcessHeap(), 0, NewByteCount); + return *NewBuffer ? NERR_Success : GetLastError(); + } + else + { + if (!HeapFree(GetProcessHeap(), 0, OldBuffer)) return GetLastError(); + *NewBuffer = 0; + return NERR_Success; + } +} + +/************************************************************ + * NetApiBufferSize (NETAPI32.@) + */ +NET_API_STATUS WINAPI NetApiBufferSize(LPVOID Buffer, LPDWORD ByteCount) +{ + DWORD dw; + + TRACE("(%p, %p)\n", Buffer, ByteCount); + if (Buffer == NULL) + return ERROR_INVALID_PARAMETER; + dw = HeapSize(GetProcessHeap(), 0, Buffer); + TRACE("size: %d\n", dw); + if (dw != 0xFFFFFFFF) + *ByteCount = dw; + else + *ByteCount = 0; + + return NERR_Success; +}