mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-21 10:09:57 +01:00
dirmngr: Clean up for not supporting WindowsCE.
* dirmngr/Makefile.am (dirmngr_SOURCES): Remove w32-ldap-help.h. * dirmngr/cdblib.c (cdb_init): Remove for __MINGW32CE__. * dirmngr/w32-ldap-help.h: Remove. -- Fixes-commit: 4c295646ba0e175743e6be13457308c1e6d21dd3 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
parent
2cebba7274
commit
d05221065f
@ -74,7 +74,7 @@ dirmngr_SOURCES += dns.c dns.h
|
||||
endif
|
||||
|
||||
if USE_LDAP
|
||||
dirmngr_SOURCES += ldapserver.h ldapserver.c ldap.c w32-ldap-help.h \
|
||||
dirmngr_SOURCES += ldapserver.h ldapserver.c ldap.c \
|
||||
ldap-wrapper.h ldap-parse-uri.c ldap-parse-uri.h \
|
||||
ldap-misc.c ldap-misc.h \
|
||||
ks-engine-ldap.c $(ldap_url) ldap-wrapper.c
|
||||
|
@ -131,11 +131,7 @@ cdb_init(struct cdb *cdbp, int fd)
|
||||
}
|
||||
/* memory-map file */
|
||||
#ifdef _WIN32
|
||||
# ifdef __MINGW32CE__
|
||||
hFile = fd;
|
||||
# else
|
||||
hFile = (HANDLE) _get_osfhandle(fd);
|
||||
# endif
|
||||
if (hFile == (HANDLE) -1)
|
||||
return -1;
|
||||
hMapping = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL);
|
||||
|
@ -1,169 +0,0 @@
|
||||
/* w32-ldap-help.h - Map utf8 based API into a wchar_t API.
|
||||
* Copyright (C) 2010 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GnuPG.
|
||||
*
|
||||
* GnuPG is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GnuPG 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef W32_LDAP_HELP_H
|
||||
#define W32_LDAP_HELP_H
|
||||
|
||||
#ifndef HAVE_W32CE_SYSTEM
|
||||
# error This is only required for W32CE.
|
||||
#endif
|
||||
|
||||
|
||||
static inline LDAP *
|
||||
_dirmngr_ldap_init (const char *host, unsigned short port)
|
||||
{
|
||||
LDAP *ld;
|
||||
wchar_t *whost = NULL;
|
||||
|
||||
if (host)
|
||||
{
|
||||
whost = utf8_to_wchar (host);
|
||||
if (!whost)
|
||||
return NULL;
|
||||
}
|
||||
ld = ldap_init (whost, port);
|
||||
xfree (whost);
|
||||
return ld;
|
||||
}
|
||||
|
||||
|
||||
static inline ULONG
|
||||
_dirmngr_ldap_simple_bind_s (LDAP *ld, const char *user, const char *pass)
|
||||
{
|
||||
ULONG ret;
|
||||
wchar_t *wuser, *wpass;
|
||||
|
||||
wuser = user? utf8_to_wchar (user) : NULL;
|
||||
wpass = pass? utf8_to_wchar (pass) : NULL;
|
||||
/* We can't easily map errnos to ldap_errno, thus we pass a NULL to
|
||||
the function in the hope that the server will throw an error. */
|
||||
ret = ldap_simple_bind_s (ld, wuser, wpass);
|
||||
xfree (wpass);
|
||||
xfree (wuser);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static inline ULONG
|
||||
_dirmngr_ldap_search_st (LDAP *ld, const char *base, ULONG scope,
|
||||
const char *filter, char **attrs,
|
||||
ULONG attrsonly, struct timeval *timeout,
|
||||
LDAPMessage **res)
|
||||
{
|
||||
ULONG ret = LDAP_NO_MEMORY;
|
||||
wchar_t *wbase = NULL;
|
||||
wchar_t *wfilter = NULL;
|
||||
wchar_t **wattrs = NULL;
|
||||
int i;
|
||||
|
||||
if (base)
|
||||
{
|
||||
wbase = utf8_to_wchar (base);
|
||||
if (!wbase)
|
||||
goto leave;
|
||||
}
|
||||
if (filter)
|
||||
{
|
||||
wfilter = utf8_to_wchar (filter);
|
||||
if (!wfilter)
|
||||
goto leave;
|
||||
}
|
||||
if (attrs)
|
||||
{
|
||||
for (i=0; attrs[i]; i++)
|
||||
;
|
||||
wattrs = xtrycalloc (i+1, sizeof *wattrs);
|
||||
if (!wattrs)
|
||||
goto leave;
|
||||
for (i=0; attrs[i]; i++)
|
||||
{
|
||||
wattrs[i] = utf8_to_wchar (attrs[i]);
|
||||
if (!wattrs[i])
|
||||
goto leave;
|
||||
}
|
||||
}
|
||||
|
||||
ret = ldap_search_st (ld, wbase, scope, wfilter, wattrs, attrsonly,
|
||||
(struct l_timeval *)timeout, res);
|
||||
|
||||
leave:
|
||||
if (wattrs)
|
||||
{
|
||||
for (i=0; wattrs[i]; i++)
|
||||
xfree (wattrs[i]);
|
||||
xfree (wattrs);
|
||||
}
|
||||
xfree (wfilter);
|
||||
xfree (wbase);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static inline char *
|
||||
_dirmngr_ldap_first_attribute (LDAP *ld, LDAPMessage *msg, BerElement **elem)
|
||||
{
|
||||
wchar_t *wattr;
|
||||
char *attr;
|
||||
|
||||
wattr = ldap_first_attribute (ld, msg, elem);
|
||||
if (!wattr)
|
||||
return NULL;
|
||||
attr = wchar_to_utf8 (wattr);
|
||||
ldap_memfree (wattr);
|
||||
return attr;
|
||||
}
|
||||
|
||||
|
||||
static inline char *
|
||||
_dirmngr_ldap_next_attribute (LDAP *ld, LDAPMessage *msg, BerElement *elem)
|
||||
{
|
||||
wchar_t *wattr;
|
||||
char *attr;
|
||||
|
||||
wattr = ldap_next_attribute (ld, msg, elem);
|
||||
if (!wattr)
|
||||
return NULL;
|
||||
attr = wchar_to_utf8 (wattr);
|
||||
ldap_memfree (wattr);
|
||||
return attr;
|
||||
}
|
||||
|
||||
static inline BerValue **
|
||||
_dirmngr_ldap_get_values_len (LDAP *ld, LDAPMessage *msg, const char *attr)
|
||||
{
|
||||
BerValue **ret;
|
||||
wchar_t *wattr;
|
||||
|
||||
if (attr)
|
||||
{
|
||||
wattr = utf8_to_wchar (attr);
|
||||
if (!wattr)
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
wattr = NULL;
|
||||
|
||||
ret = ldap_get_values_len (ld, msg, wattr);
|
||||
xfree (wattr);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
#endif /*W32_LDAP_HELP_H*/
|
Loading…
x
Reference in New Issue
Block a user