summaryrefslogtreecommitdiff
path: root/src/modules/netlib
diff options
context:
space:
mode:
authorVadim Dashevskiy <watcherhd@gmail.com>2012-06-15 14:13:45 +0000
committerVadim Dashevskiy <watcherhd@gmail.com>2012-06-15 14:13:45 +0000
commit4aa6229698b946e52ce19018aaf13f8b92fb168e (patch)
tree29334e8c5ee492a80f11a97fedab2373b8fbb392 /src/modules/netlib
parent5e8e561a80d1ac9ca1c2f1c3d388105733ed4e4e (diff)
another portion of "#ifsef Unicode" removal
git-svn-id: http://svn.miranda-ng.org/main/trunk@426 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/modules/netlib')
-rw-r--r--src/modules/netlib/netlib.h2
-rw-r--r--src/modules/netlib/netlibsecurity.cpp46
2 files changed, 9 insertions, 39 deletions
diff --git a/src/modules/netlib/netlib.h b/src/modules/netlib/netlib.h
index 88a1db2284..f152eafe10 100644
--- a/src/modules/netlib/netlib.h
+++ b/src/modules/netlib/netlib.h
@@ -204,9 +204,7 @@ void NetlibSecurityInit(void);
void NetlibSecurityDestroy(void);
void NetlibDestroySecurityProvider(HANDLE hSecurity);
HANDLE NetlibInitSecurityProvider(const TCHAR* szProvider, const TCHAR* szPrincipal);
-#ifdef UNICODE
HANDLE NetlibInitSecurityProvider(const char* szProvider, const char* szPrincipal);
-#endif
char* NtlmCreateResponseFromChallenge(HANDLE hSecurity, const char *szChallenge, const TCHAR* login, const TCHAR* psw,
bool http, unsigned& complete);
diff --git a/src/modules/netlib/netlibsecurity.cpp b/src/modules/netlib/netlibsecurity.cpp
index c97ee97c30..46756ff3cc 100644
--- a/src/modules/netlib/netlibsecurity.cpp
+++ b/src/modules/netlib/netlibsecurity.cpp
@@ -156,12 +156,10 @@ HANDLE NetlibInitSecurityProvider(const TCHAR* szProvider, const TCHAR* szPrinci
return hSecurity;
}
-#ifdef UNICODE
HANDLE NetlibInitSecurityProvider(const char* szProvider, const char* szPrincipal)
{
return NetlibInitSecurityProvider(StrConvT(szProvider), StrConvT(szPrincipal));
}
-#endif
void NetlibDestroySecurityProvider(HANDLE hSecurity)
{
@@ -307,7 +305,7 @@ char* NtlmCreateResponseFromChallenge(HANDLE hSecurity, const char *szChallenge,
NtlmType2packet* pkt = ( NtlmType2packet* )nlb64.pbDecoded;
if (!strncmp(pkt->sign, "NTLMSSP", 8) && pkt->type == 2)
{
-#ifdef UNICODE
+
wchar_t* domainName = (wchar_t*)&nlb64.pbDecoded[pkt->targetName.offset];
int domainLen = pkt->targetName.len;
@@ -321,19 +319,6 @@ char* NtlmCreateResponseFromChallenge(HANDLE hSecurity, const char *szChallenge,
}
else
domainLen /= sizeof(wchar_t);
-#else
- char* domainName = (char*)&nlb64.pbDecoded[pkt->targetName.offset];
- int domainLen = pkt->targetName.len;
-
- // Negotiate Unicode? if yes, convert the unicode name to ANSI
- if (pkt->flags & 1)
- {
- int bufsz = WideCharToMultiByte(CP_ACP, 0, (WCHAR*)domainName, domainLen, NULL, 0, NULL, NULL);
- char* buf = (char*)alloca(bufsz);
- domainLen = WideCharToMultiByte(CP_ACP, 0, (WCHAR*)domainName, domainLen, buf, bufsz, NULL, NULL) - 1;
- domainName = buf;
- }
-#endif
if (domainLen)
{
@@ -360,11 +345,9 @@ char* NtlmCreateResponseFromChallenge(HANDLE hSecurity, const char *szChallenge,
if (login != NULL && login[0] != '\0')
{
memset(&auth, 0, sizeof(auth));
-#ifdef _UNICODE
+
NetlibLogf(NULL, "Security login requested, user: %S pssw: %s", login, psw ? "(exist)" : "(no psw)");
-#else
- NetlibLogf(NULL, "Security login requested, user: %s pssw: %s", login, psw ? "(exist)" : "(no psw)");
-#endif
+
const TCHAR* loginName = login;
const TCHAR* domainName = _tcschr(login, '\\');
@@ -384,7 +367,7 @@ char* NtlmCreateResponseFromChallenge(HANDLE hSecurity, const char *szChallenge,
domainLen = lstrlen(++domainName);
}
-#ifdef UNICODE
+
auth.User = (PWORD)loginName;
auth.UserLength = loginLen;
auth.Password = (PWORD)psw;
@@ -392,15 +375,7 @@ char* NtlmCreateResponseFromChallenge(HANDLE hSecurity, const char *szChallenge,
auth.Domain = (PWORD)domainName;
auth.DomainLength = domainLen;
auth.Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE;
-#else
- auth.User = (PBYTE)loginName;
- auth.UserLength = loginLen;
- auth.Password = (PBYTE)psw;
- auth.PasswordLength = lstrlen(psw);
- auth.Domain = (PBYTE)domainName;
- auth.DomainLength = domainLen;
- auth.Flags = SEC_WINNT_AUTH_IDENTITY_ANSI;
-#endif
+
hNtlm->hasDomain = domainLen != 0;
}
@@ -496,11 +471,11 @@ static INT_PTR InitSecurityProviderService2(WPARAM, LPARAM lParam)
HANDLE hSecurity;
-#ifdef UNICODE
+
if (req->flags & NNR_UNICODE)
hSecurity = NetlibInitSecurityProvider(req->szProviderName, req->szPrincipal);
else
-#endif
+
hSecurity = NetlibInitSecurityProvider((char*)req->szProviderName, (char*)req->szPrincipal);
return (INT_PTR)hSecurity;
@@ -530,7 +505,7 @@ static INT_PTR NtlmCreateResponseService2( WPARAM wParam, LPARAM lParam )
char* response;
-#ifdef UNICODE
+
if (req->flags & NNR_UNICODE)
{
response = NtlmCreateResponseFromChallenge(( HANDLE )wParam, req->szChallenge,
@@ -545,10 +520,7 @@ static INT_PTR NtlmCreateResponseService2( WPARAM wParam, LPARAM lParam )
mir_free(szLogin);
mir_free(szPassw);
}
-#else
- response = NtlmCreateResponseFromChallenge(( HANDLE )wParam, req->szChallenge,
- req->szUserName, req->szPassword, false, req->complete );
-#endif
+
return (INT_PTR)response;
}