+2009-04-20 Thomas Quinot <quinot@adacore.com>
+
+ * s-oscons-tmplt.c: Add support for generating a dummy version of
+ s-oscons.ads providing all possible constants.
+
+ * g-socthi-mingw.ads: Fix calling convention for __gnat_inet_pton.
+
+ * socket.c (__gnat_inet_pton): On Windows make sure we always use the
+ ANSI version (not the UNICODE version) of WSAStringToAddress.
+
+2009-04-20 Pascal Obry <obry@adacore.com>
+
+ * adaint.c (__gnat_set_OWNER_ACL): properly free memory
+ allocated for the security descriptor and make sure all
+ handles are closed before leaving this procedure.
+
2009-04-20 Javier Miranda <miranda@adacore.com>
* einfo.ads, einfo.adb (Is_Underlying_Record_View): New subprogram
PRIVILEGE_SET PrivilegeSet;
DWORD dwPrivSetSize = sizeof (PRIVILEGE_SET);
BOOL fAccessGranted = FALSE;
- HANDLE hToken;
- DWORD nLength;
+ HANDLE hToken = NULL;
+ DWORD nLength = 0;
SECURITY_DESCRIPTOR* pSD = NULL;
GetFileSecurity
(wname, OWNER_SECURITY_INFORMATION |
GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION,
pSD, nLength, &nLength))
- return 0;
+ goto error;
if (!ImpersonateSelf (SecurityImpersonation))
- return 0;
+ goto error;
if (!OpenThreadToken
(GetCurrentThread(), TOKEN_DUPLICATE | TOKEN_QUERY, FALSE, &hToken))
- return 0;
+ goto error;
/* Undoes the effect of ImpersonateSelf. */
&dwPrivSetSize, /* size of PrivilegeSet buffer */
&dwAccessAllowed, /* receives mask of allowed access rights */
&fAccessGranted))
- return 0;
+ goto error;
+ CloseHandle (hToken);
+ HeapFree (GetProcessHeap (), 0, pSD);
return fAccessGranted;
+
+ error:
+ if (hToken)
+ CloseHandle (hToken);
+ HeapFree (GetProcessHeap (), 0, pSD);
+ return 0;
}
static void
pragma Import (Stdcall, C_Getpeername, "getpeername");
pragma Import (Stdcall, C_Getsockname, "getsockname");
pragma Import (Stdcall, C_Getsockopt, "getsockopt");
- pragma Import (Stdcall, Inet_Pton, "__gnat_inet_pton");
+ pragma Import (C, Inet_Pton, "__gnat_inet_pton");
pragma Import (Stdcall, C_Ioctl, "ioctlsocket");
pragma Import (Stdcall, C_Listen, "listen");
pragma Import (Stdcall, C_Recv, "recv");
**
**/
-#ifndef TARGET
-# error Please define TARGET
-#endif
-
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include "gsocket.h"
+#ifdef DUMMY
+
+# if defined (TARGET)
+# error TARGET may not be defined when generating the dummy version
+# else
+# define TARGET "batch runtime compilation (dummy values)"
+# endif
+
+# if !(defined (HAVE_SOCKETS) && defined (HAVE_TERMIOS))
+# error Features missing on platform
+# endif
+
+# define NATIVE
+
+#endif
+
+#ifndef TARGET
+# error Please define TARGET
+#endif
+
#ifndef HAVE_SOCKETS
# include <errno.h>
#endif
#ifdef NATIVE
#include <stdio.h>
+
+#ifdef DUMMY
+int counter = 0;
+# define _VAL(x) counter++
+#else
+# define _VAL(x) x
+#endif
+
#define CND(name,comment) \
- printf ("\n->CND:$%d:" #name ":$%d:" comment, __LINE__, ((int) name));
+ printf ("\n->CND:$%d:" #name ":$%d:" comment, __LINE__, ((int) _VAL (name)));
#define CNS(name,comment) \
printf ("\n->CNS:$%d:" #name ":" name ":" comment, __LINE__);
/**
** System-specific constants follow
+ ** Each section should be activated if compiling for the corresponding
+ ** platform *or* generating the dummy version for runtime test compilation.
**/
-#ifdef __vxworks
+#if defined (__vxworks) || defined (DUMMY)
/*
#endif
-#ifdef __MINGW32__
+#if defined (__MINGW32__) || defined (DUMMY)
/*
------------------------------
putchar ('\n');
#endif
-#ifdef __APPLE__
+#if defined (__APPLE__) || defined (DUMMY)
/*
-------------------------------
int rc;
ss.ss_family = af;
- rc = WSAStringToAddress (src, af, NULL, (struct sockaddr *)&ss, &sslen);
+ rc = WSAStringToAddressA (src, af, NULL, (struct sockaddr *)&ss, &sslen);
if (rc > 0) {
switch (af) {
case AF_INET: