Modifications for updated Windows Build.

1) mods to use miniupnpc v1.3
2) bugfix to use WriteFile instead of write under windows with gpgme.



git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1449 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2009-07-30 14:36:42 +00:00
parent 3394239297
commit 870a30eac5
2 changed files with 37 additions and 3 deletions

View File

@ -106,8 +106,15 @@ gpg_error_t pgp_pwd_callback(void *hook, const char *uid_hint, const char *passp
//fprintf(stderr, "pgp_pwd_callback() Set Password to:\"%s\"\n", passwd); //fprintf(stderr, "pgp_pwd_callback() Set Password to:\"%s\"\n", passwd);
fprintf(stderr, "pgp_pwd_callback() Set Password\n"); fprintf(stderr, "pgp_pwd_callback() Set Password\n");
#ifndef WINDOWS_SYS
write(fd, passwd, strlen(passwd)); write(fd, passwd, strlen(passwd));
write(fd, "\n", 1); /* needs a new line? */ write(fd, "\n", 1); /* needs a new line? */
#else
DWORD written = 0;
HANDLE winFd = (HANDLE) fd;
WriteFile(winFd, passwd, strlen(passwd), &written, NULL);
WriteFile(winFd, "\n", 1, &written, NULL);
#endif
return 0; return 0;
} }
@ -140,7 +147,7 @@ GPGAuthMgr::GPGAuthMgr()
gpgme_check_version(NULL); gpgme_check_version(NULL);
gpgme_set_locale(NULL, LC_CTYPE, setlocale (LC_CTYPE, NULL)); gpgme_set_locale(NULL, LC_CTYPE, setlocale (LC_CTYPE, NULL));
#ifndef HAVE_W32_SYSTEM #ifdef LC_MESSAGES
gpgme_set_locale(NULL, LC_MESSAGES, setlocale (LC_MESSAGES, NULL)); gpgme_set_locale(NULL, LC_MESSAGES, setlocale (LC_MESSAGES, NULL));
#endif #endif
@ -2233,9 +2240,18 @@ static gpg_error_t keySignCallback(void *opaque, gpgme_status_code_t status, \
if (result) if (result)
{ {
fprintf(stderr,"keySignCallback result:%s\n", result); fprintf(stderr,"keySignCallback result:%s\n", result);
#ifndef WINDOWS_SYS
if (*result) if (*result)
write (fd, result, strlen (result)); write (fd, result, strlen (result));
write (fd, "\n", 1); write (fd, "\n", 1);
#else
DWORD written = 0;
HANDLE winFd = (HANDLE) fd;
if (*result)
WriteFile(winFd, result, strlen(result), &written, NULL);
WriteFile(winFd, "\n", 1, &written, NULL);
#endif
} }
fprintf(stderr,"keySignCallback Error status\n"); fprintf(stderr,"keySignCallback Error status\n");
@ -2334,9 +2350,17 @@ static gpgme_error_t trustCallback(void *opaque, gpgme_status_code_t status, \
if (result) if (result)
{ {
#ifndef WINDOWS_SYS
if (*result) if (*result)
write (fd, result, strlen (result)); write (fd, result, strlen (result));
write (fd, "\n", 1); write (fd, "\n", 1);
#else
DWORD written = 0;
HANDLE winFd = (HANDLE) fd;
if (*result)
WriteFile(winFd, result, strlen (result), &written, NULL);
WriteFile(winFd, "\n", 1, &written, NULL);
#endif
} }
return params->err; return params->err;

View File

@ -141,6 +141,11 @@ bool SetRedirectAndTest(struct UPNPUrls * urls,
printf("GetExternalIPAddress failed.\n"); printf("GetExternalIPAddress failed.\n");
// Unix at the moment! // Unix at the moment!
#if MINIUPNPC_VERSION >= 13
/* Starting from miniupnpc version 1.2, lease duration parameter is gone */
r = UPNP_AddPortMapping(urls->controlURL, data->servicetype,
eport, iport, iaddr, 0, proto, NULL);
#else
#if MINIUPNPC_VERSION >= 12 #if MINIUPNPC_VERSION >= 12
/* Starting from miniupnpc version 1.2, lease duration parameter is gone */ /* Starting from miniupnpc version 1.2, lease duration parameter is gone */
r = UPNP_AddPortMapping(urls->controlURL, data->servicetype, r = UPNP_AddPortMapping(urls->controlURL, data->servicetype,
@ -150,6 +155,7 @@ bool SetRedirectAndTest(struct UPNPUrls * urls,
r = UPNP_AddPortMapping(urls->controlURL, data->servicetype, r = UPNP_AddPortMapping(urls->controlURL, data->servicetype,
eport, iport, iaddr, 0, proto); eport, iport, iaddr, 0, proto);
#endif #endif
#endif
// r = UPNP_AddPortMapping(urls->controlURL, data->servicetype, // r = UPNP_AddPortMapping(urls->controlURL, data->servicetype,
// eport, iport, iaddr, 0, leaseDuration, proto); // eport, iport, iaddr, 0, leaseDuration, proto);
@ -271,7 +277,11 @@ RemoveRedirect(struct UPNPUrls * urls,
fprintf(stderr, "protocol invalid\n"); fprintf(stderr, "protocol invalid\n");
return 0; return 0;
} }
#if MINIUPNPC_VERSION >= 13
UPNP_DeletePortMapping(urls->controlURL, data->servicetype, eport, proto, NULL);
#else
UPNP_DeletePortMapping(urls->controlURL, data->servicetype, eport, proto); UPNP_DeletePortMapping(urls->controlURL, data->servicetype, eport, proto);
#endif
return 1; return 1;
} }