aboutsummaryrefslogtreecommitdiff
path: root/tests/libtest/lib506.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2003-12-16 09:49:36 +0000
committerDaniel Stenberg <daniel@haxx.se>2003-12-16 09:49:36 +0000
commit989ec98ebdc1c73b70b957f9eeacb4de7882970a (patch)
treec251b8971fd20b0f0bb8496cdbc1a3750a20c95b /tests/libtest/lib506.c
parentd262d0a62a5a32ee2bd279ef66bdd973621db4fe (diff)
modified and corrected test 506
Diffstat (limited to 'tests/libtest/lib506.c')
-rw-r--r--tests/libtest/lib506.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/tests/libtest/lib506.c b/tests/libtest/lib506.c
index 52f6a38e7..998c1370c 100644
--- a/tests/libtest/lib506.c
+++ b/tests/libtest/lib506.c
@@ -14,20 +14,27 @@ struct Tdata {
char *url;
};
+struct userdata {
+ char *text;
+ int counter;
+};
/* lock callback */
void lock(CURL *handle, curl_lock_data data, curl_lock_access access,
void *useptr )
{
const char *what;
+ struct userdata *user = (struct userdata *)useptr;
+
(void)handle;
(void)access;
+
switch ( data ) {
case CURL_LOCK_DATA_SHARE:
- what = "share ";
+ what = "share";
break;
case CURL_LOCK_DATA_DNS:
- what = "dns ";
+ what = "dns";
break;
case CURL_LOCK_DATA_COOKIE:
what = "cookie";
@@ -36,20 +43,22 @@ void lock(CURL *handle, curl_lock_data data, curl_lock_access access,
fprintf(stderr, "lock: no such data: %d\n",data);
return;
}
- printf("lock: %s <%s>\n", what, (char *)useptr);
+ printf("lock: %-6s <%s>: %d\n", what, user->text, user->counter);
+ user->counter++;
}
/* unlock callback */
void unlock(CURL *handle, curl_lock_data data, void *useptr )
{
const char *what;
+ struct userdata *user = (struct userdata *)useptr;
(void)handle;
switch ( data ) {
case CURL_LOCK_DATA_SHARE:
- what = "share ";
+ what = "share";
break;
case CURL_LOCK_DATA_DNS:
- what = "dns ";
+ what = "dns";
break;
case CURL_LOCK_DATA_COOKIE:
what = "cookie";
@@ -58,7 +67,8 @@ void unlock(CURL *handle, curl_lock_data data, void *useptr )
fprintf(stderr, "unlock: no such data: %d\n",data);
return;
}
- printf("unlock: %s <%s>\n", what, (char *)useptr);
+ printf("unlock: %-6s <%s>: %d\n", what, user->text, user->counter);
+ user->counter++;
}
@@ -127,6 +137,10 @@ CURLcode test(char *URL)
CURLSH *share;
struct curl_slist *headers;
int i;
+ struct userdata user;
+
+ user.text = (char *)"Pigs in space";
+ user.counter = 0;
printf( "GLOBAL_INIT\n" );
curl_global_init( CURL_GLOBAL_ALL );
@@ -136,7 +150,7 @@ CURLcode test(char *URL)
share = curl_share_init();
curl_share_setopt( share, CURLSHOPT_LOCKFUNC, lock);
curl_share_setopt( share, CURLSHOPT_UNLOCKFUNC, unlock);
- curl_share_setopt( share, CURLSHOPT_USERDATA, "Pigs in space");
+ curl_share_setopt( share, CURLSHOPT_USERDATA, &user);
printf( "CURL_LOCK_DATA_COOKIE\n" );
curl_share_setopt( share, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE);
printf( "CURL_LOCK_DATA_DNS\n" );