Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
9a741bf3
Commit
9a741bf3
authored
May 19, 2011
by
Jacek Caban
Committed by
Alexandre Julliard
May 19, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wininet: Moved getting cookie from known host to separated function.
parent
aca2385d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
78 additions
and
82 deletions
+78
-82
cookie.c
dlls/wininet/cookie.c
+78
-82
No files found.
dlls/wininet/cookie.c
View file @
9a741bf3
...
...
@@ -260,114 +260,110 @@ static void COOKIE_deleteDomain(cookie_domain *deadDomain)
HeapFree
(
GetProcessHeap
(),
0
,
deadDomain
);
}
/***********************************************************************
* InternetGetCookieW (WININET.@)
*
* Retrieve cookie from the specified url
*
* It should be noted that on windows the lpszCookieName parameter is "not implemented".
* So it won't be implemented here.
*
* RETURNS
* TRUE on success
* FALSE on failure
*
*/
BOOL
WINAPI
InternetGetCookieW
(
LPCWSTR
lpszUrl
,
LPCWSTR
lpszCookieName
,
LPWSTR
lpCookieData
,
LPDWORD
lpdwSize
)
static
BOOL
get_cookie
(
const
WCHAR
*
host
,
const
WCHAR
*
path
,
WCHAR
*
cookie_data
,
DWORD
*
size
)
{
BOOL
ret
;
struct
list
*
cursor
;
unsigned
int
cnt
=
0
,
domain_count
=
0
,
cookie_count
=
0
;
WCHAR
hostName
[
2048
],
path
[
2048
];
unsigned
cnt
=
0
,
len
,
domain_count
=
0
,
cookie_count
=
0
;
cookie_domain
*
domain
;
FILETIME
tm
;
TRACE
(
"(%s, %s, %p, %p)
\n
"
,
debugstr_w
(
lpszUrl
),
debugstr_w
(
lpszCookieName
),
lpCookieData
,
lpdwSize
);
GetSystemTimeAsFileTime
(
&
tm
);
if
(
!
lpszUrl
)
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
}
LIST_FOR_EACH_ENTRY
(
domain
,
&
domain_list
,
cookie_domain
,
entry
)
{
struct
list
*
cursor
,
*
cursor2
;
hostName
[
0
]
=
0
;
ret
=
COOKIE_crackUrlSimple
(
lpszUrl
,
hostName
,
sizeof
(
hostName
)
/
sizeof
(
hostName
[
0
]),
path
,
sizeof
(
path
)
/
sizeof
(
path
[
0
]));
if
(
!
ret
||
!
hostName
[
0
])
return
FALSE
;
GetSystemTimeAsFileTime
(
&
tm
);
if
(
!
COOKIE_matchDomain
(
host
,
path
,
domain
,
TRUE
))
continue
;
LIST_FOR_EACH
(
cursor
,
&
domain_list
)
{
cookie_domain
*
cookiesDomain
=
LIST_ENTRY
(
cursor
,
cookie_domain
,
entry
);
if
(
COOKIE_matchDomain
(
hostName
,
path
,
cookiesDomain
,
TRUE
))
{
struct
list
*
cursor
,
*
cursor2
;
domain_count
++
;
TRACE
(
"found domain %p
\n
"
,
cookiesDomain
);
domain_count
++
;
TRACE
(
"found domain %p
\n
"
,
domain
);
LIST_FOR_EACH_SAFE
(
cursor
,
cursor2
,
&
cookiesDomain
->
cookie_list
)
LIST_FOR_EACH_SAFE
(
cursor
,
cursor2
,
&
domain
->
cookie_list
)
{
cookie
*
cookie_iter
=
LIST_ENTRY
(
cursor
,
cookie
,
entry
);
/* check for expiry */
if
((
cookie_iter
->
expiry
.
dwLowDateTime
!=
0
||
cookie_iter
->
expiry
.
dwHighDateTime
!=
0
)
&&
CompareFileTime
(
&
tm
,
&
cookie_iter
->
expiry
)
>
0
)
{
cookie
*
thisCookie
=
LIST_ENTRY
(
cursor
,
cookie
,
entry
);
/* check for expiry */
if
((
thisCookie
->
expiry
.
dwLowDateTime
!=
0
||
thisCookie
->
expiry
.
dwHighDateTime
!=
0
)
&&
CompareFileTime
(
&
tm
,
&
thisCookie
->
expiry
)
>
0
)
{
TRACE
(
"Found expired cookie. deleting
\n
"
);
COOKIE_deleteCookie
(
thisCookie
,
FALSE
);
continue
;
}
TRACE
(
"Found expired cookie. deleting
\n
"
);
COOKIE_deleteCookie
(
cookie_iter
,
FALSE
);
continue
;
}
if
(
lpCookieData
==
NULL
)
/* return the size of the buffer required to lpdwSize */
{
unsigned
int
len
;
if
(
cookie_count
)
cnt
+=
2
;
/* '; ' */
cnt
+=
strlenW
(
thisCookie
->
lpCookieName
);
if
((
len
=
strlenW
(
thisCookie
->
lpCookieData
)))
{
cnt
+=
1
;
/* = */
cnt
+=
len
;
}
if
(
!
cookie_data
)
{
/* return the size of the buffer required to lpdwSize */
if
(
cookie_count
)
cnt
+=
2
;
/* '; ' */
cnt
+=
strlenW
(
cookie_iter
->
lpCookieName
);
if
((
len
=
strlenW
(
cookie_iter
->
lpCookieData
)))
{
cnt
+=
1
;
/* = */
cnt
+=
len
;
}
else
{
static
const
WCHAR
szsc
[]
=
{
';'
,
' '
,
0
};
static
const
WCHAR
szname
[]
=
{
'%'
,
's'
,
0
};
static
const
WCHAR
szdata
[]
=
{
'='
,
'%'
,
's'
,
0
};
}
else
{
static
const
WCHAR
szsc
[]
=
{
';'
,
' '
,
0
};
static
const
WCHAR
szname
[]
=
{
'%'
,
's'
,
0
};
static
const
WCHAR
szdata
[]
=
{
'='
,
'%'
,
's'
,
0
};
if
(
cookie_count
)
cnt
+=
snprintfW
(
lpCookieData
+
cnt
,
*
lpdwS
ize
-
cnt
,
szsc
);
cnt
+=
snprintfW
(
lpCookieData
+
cnt
,
*
lpdwSize
-
cnt
,
szname
,
thisCookie
->
lpCookieName
);
if
(
cookie_count
)
cnt
+=
snprintfW
(
cookie_data
+
cnt
,
*
s
ize
-
cnt
,
szsc
);
cnt
+=
snprintfW
(
cookie_data
+
cnt
,
*
size
-
cnt
,
szname
,
cookie_iter
->
lpCookieName
);
if
(
thisCookie
->
lpCookieData
[
0
])
cnt
+=
snprintfW
(
lpCookieData
+
cnt
,
*
lpdwSize
-
cnt
,
szdata
,
thisCookie
->
lpCookieData
);
if
(
cookie_iter
->
lpCookieData
[
0
])
cnt
+=
snprintfW
(
cookie_data
+
cnt
,
*
size
-
cnt
,
szdata
,
cookie_iter
->
lpCookieData
);
TRACE
(
"Cookie: %s
\n
"
,
debugstr_w
(
lpCookieData
));
}
cookie_count
++
;
TRACE
(
"Cookie: %s
\n
"
,
debugstr_w
(
cookie_data
));
}
cookie_count
++
;
}
}
if
(
!
domain_count
)
{
TRACE
(
"no cookies found for %s
\n
"
,
debugstr_w
(
hostName
));
if
(
!
domain_count
)
{
TRACE
(
"no cookies found for %s
\n
"
,
debugstr_w
(
host
));
SetLastError
(
ERROR_NO_MORE_ITEMS
);
return
FALSE
;
}
if
(
lpCookieData
==
NULL
)
{
*
lpdwSize
=
(
cnt
+
1
)
*
sizeof
(
WCHAR
);
TRACE
(
"returning %u
\n
"
,
*
lpdwSize
);
if
(
!
cookie_data
)
{
*
size
=
(
cnt
+
1
)
*
sizeof
(
WCHAR
);
TRACE
(
"returning %u
\n
"
,
*
size
);
return
TRUE
;
}
*
lpdwSize
=
cnt
+
1
;
*
size
=
cnt
+
1
;
TRACE
(
"Returning %u (from %u domains): %s
\n
"
,
cnt
,
domain_count
,
debugstr_w
(
cookie_data
));
return
cnt
!=
0
;
}
/***********************************************************************
* InternetGetCookieW (WININET.@)
*
* Retrieve cookie from the specified url
*
* It should be noted that on windows the lpszCookieName parameter is "not implemented".
* So it won't be implemented here.
*
* RETURNS
* TRUE on success
* FALSE on failure
*
*/
BOOL
WINAPI
InternetGetCookieW
(
LPCWSTR
lpszUrl
,
LPCWSTR
lpszCookieName
,
LPWSTR
lpCookieData
,
LPDWORD
lpdwSize
)
{
WCHAR
host
[
INTERNET_MAX_HOST_NAME_LENGTH
],
path
[
INTERNET_MAX_PATH_LENGTH
];
BOOL
ret
;
TRACE
(
"(%s, %s, %p, %p)
\n
"
,
debugstr_w
(
lpszUrl
),
debugstr_w
(
lpszCookieName
),
lpCookieData
,
lpdwSize
);
if
(
!
lpszUrl
)
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
}
TRACE
(
"Returning %u (from %u domains): %s
\n
"
,
cnt
,
domain_count
,
debugstr_w
(
lpCookieData
));
host
[
0
]
=
0
;
ret
=
COOKIE_crackUrlSimple
(
lpszUrl
,
host
,
sizeof
(
host
)
/
sizeof
(
host
[
0
]),
path
,
sizeof
(
path
)
/
sizeof
(
path
[
0
]));
if
(
!
ret
||
!
host
[
0
])
return
FALSE
;
return
(
cnt
?
TRUE
:
FALSE
);
return
get_cookie
(
host
,
path
,
lpCookieData
,
lpdwSize
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment