diff options
Diffstat (limited to 'src/w32-ce.c')
-rw-r--r-- | src/w32-ce.c | 72 |
1 files changed, 66 insertions, 6 deletions
diff --git a/src/w32-ce.c b/src/w32-ce.c index e6c512ce..88a8f316 100644 --- a/src/w32-ce.c +++ b/src/w32-ce.c @@ -1,5 +1,6 @@ /* w32-ce.h Copyright (C) 2010 g10 Code GmbH + Copyright (C) 1991,92,97,2000,02 Free Software Foundation, Inc. This file is part of GPGME. @@ -14,9 +15,8 @@ Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. */ + License along with this program; if not, see <http://www.gnu.org/licenses/>. + */ #ifdef HAVE_CONFIG_H #include <config.h> @@ -290,7 +290,7 @@ RegQueryValueExA (HKEY hKey, LPCSTR lpValueName, LPDWORD lpReserved, { wchar_t *name; LONG err; - BYTE *data; + void *data; DWORD data_len; DWORD type; @@ -335,8 +335,8 @@ RegQueryValueExA (HKEY hKey, LPCSTR lpValueName, LPDWORD lpReserved, int data_c_len; /* This is valid since we allocated one more above. */ - data[data_len] = '\0'; - data[data_len + 1] = '\0'; + ((char*)data)[data_len] = '\0'; + ((char*)data)[data_len + 1] = '\0'; data_c = wchar_to_utf8 ((wchar_t*) data); if (!data_c) @@ -445,3 +445,63 @@ SHGetSpecialFolderPathA (HWND hwndOwner, LPSTR lpszPath, int nFolder, lpszPath[MAX_PATH - 1] = '\0'; return result; } + +/* Replacement for the access function. Note that we can't use fopen + here because wince might now allow to have a shared read for an + executable; it is better to to read the file attributes. + + Limitation: Only F_OK is supported. +*/ +int +_gpgme_wince_access (const char *fname, int mode) +{ + DWORD attr; + wchar_t *wfname; + + (void)mode; + + wfname = utf8_to_wchar (fname); + if (!wfname) + return -1; + + attr = GetFileAttributes (wfname); + free (wfname); + if (attr == (DWORD)(-1)) + { + gpg_err_set_errno (ENOENT); + return -1; + } + return 0; +} + + +/* Perform a binary search for KEY in BASE which has NMEMB elements + of SIZE bytes each. The comparisons are done by (*COMPAR)(). + Code taken from glibc-2.6. */ +void * +_gpgme_wince_bsearch (const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *)) +{ + size_t l, u, idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p); + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} + |