repo_name string | dataset string | owner string | lang string | func_name string | code string | docstring string | url string | sha string |
|---|---|---|---|---|---|---|---|---|
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | test | int test(char *URL)
{
CURL *c = NULL;
CURLM *m = NULL;
int res = 0;
int running;
start_test_timing();
global_init(CURL_GLOBAL_ALL);
easy_init(c);
easy_setopt(c, CURLOPT_PROXY, libtest_arg2); /* set in first.c */
easy_setopt(c, CURLOPT_URL, URL);
easy_setopt(c, CURLOPT_USERPWD, "test:ing");
easy_setopt(c, CURLOPT_PROXYUSERPWD, "test:ing");
easy_setopt(c, CURLOPT_HTTPPROXYTUNNEL, 1L);
easy_setopt(c, CURLOPT_HEADER, 1L);
easy_setopt(c, CURLOPT_VERBOSE, 1L);
multi_init(m);
multi_add_handle(m, c);
for(;;) {
struct timeval interval;
fd_set rd, wr, exc;
int maxfd = -99;
interval.tv_sec = 1;
interval.tv_usec = 0;
multi_perform(m, &running);
abort_on_test_timeout();
if(!running)
break; /* done */
FD_ZERO(&rd);
FD_ZERO(&wr);
FD_ZERO(&exc);
multi_fdset(m, &rd, &wr, &exc, &maxfd);
/* At this point, maxfd is guaranteed to be greater or equal than -1. */
select_test(maxfd+1, &rd, &wr, &exc, &interval);
abort_on_test_timeout();
}
test_cleanup:
/* proper cleanup sequence - type PA */
curl_multi_remove_handle(m, c);
curl_multi_cleanup(m);
curl_easy_cleanup(c);
curl_global_cleanup();
return res;
} | /*
* Source code in here hugely as reported in bug report 651460 by
* Christopher R. Palmer.
*
* Use multi interface to get HTTPS document over proxy, and provide
* auth info.
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/libtest/lib503.c#L38-L101 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | test | int test(char *URL)
{
CURL *c = NULL;
int res = 0;
CURLM *m = NULL;
fd_set rd, wr, exc;
int running;
start_test_timing();
global_init(CURL_GLOBAL_ALL);
easy_init(c);
/* The point here is that there must not be anything running on the given
proxy port */
if (libtest_arg2)
easy_setopt(c, CURLOPT_PROXY, libtest_arg2);
easy_setopt(c, CURLOPT_URL, URL);
easy_setopt(c, CURLOPT_VERBOSE, 1L);
multi_init(m);
multi_add_handle(m, c);
for(;;) {
struct timeval interval;
int maxfd = -99;
interval.tv_sec = 1;
interval.tv_usec = 0;
fprintf(stderr, "curl_multi_perform()\n");
multi_perform(m, &running);
abort_on_test_timeout();
if(!running) {
/* This is where this code is expected to reach */
int numleft;
CURLMsg *msg = curl_multi_info_read(m, &numleft);
fprintf(stderr, "Expected: not running\n");
if(msg && !numleft)
res = TEST_ERR_SUCCESS; /* this is where we should be */
else
res = TEST_ERR_FAILURE; /* not correct */
break; /* done */
}
fprintf(stderr, "running == %d\n", running);
FD_ZERO(&rd);
FD_ZERO(&wr);
FD_ZERO(&exc);
fprintf(stderr, "curl_multi_fdset()\n");
multi_fdset(m, &rd, &wr, &exc, &maxfd);
/* At this point, maxfd is guaranteed to be greater or equal than -1. */
select_test(maxfd+1, &rd, &wr, &exc, &interval);
abort_on_test_timeout();
}
test_cleanup:
/* proper cleanup sequence - type PA */
curl_multi_remove_handle(m, c);
curl_multi_cleanup(m);
curl_easy_cleanup(c);
curl_global_cleanup();
return res;
} | /*
* Source code in here hugely as reported in bug report 651464 by
* Christopher R. Palmer.
*
* Use multi interface to get document over proxy with bad port number.
* This caused the interface to "hang" in libcurl 7.10.2.
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/libtest/lib504.c#L37-L113 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | test | int test(char *URL)
{
CURL *curl;
CURLcode res = CURLE_OK;
FILE *hd_src ;
int hd ;
struct_stat file_info;
struct curl_slist *hl;
int error;
struct curl_slist *headerlist=NULL;
const char *buf_1 = "RNFR 505";
const char *buf_2 = "RNTO 505-forreal";
if (!libtest_arg2) {
fprintf(stderr, "Usage: <url> <file-to-upload>\n");
return -1;
}
hd_src = fopen(libtest_arg2, "rb");
if(NULL == hd_src) {
error = ERRNO;
fprintf(stderr, "fopen() failed with error: %d %s\n",
error, strerror(error));
fprintf(stderr, "Error opening file: %s\n", libtest_arg2);
return -2; /* if this happens things are major weird */
}
/* get the file size of the local file */
hd = fstat(fileno(hd_src), &file_info);
if(hd == -1) {
/* can't open file, bail out */
error = ERRNO;
fprintf(stderr, "fstat() failed with error: %d %s\n",
error, strerror(error));
fprintf(stderr, "ERROR: cannot open file %s\n", libtest_arg2);
fclose(hd_src);
return -1;
}
if(! file_info.st_size) {
fprintf(stderr, "ERROR: file %s has zero size!\n", libtest_arg2);
fclose(hd_src);
return -4;
}
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
fclose(hd_src);
return TEST_ERR_MAJOR_BAD;
}
/* get a curl handle */
if ((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
fclose(hd_src);
return TEST_ERR_MAJOR_BAD;
}
/* build a list of commands to pass to libcurl */
if ((hl = curl_slist_append(headerlist, buf_1)) == NULL) {
fprintf(stderr, "curl_slist_append() failed\n");
curl_easy_cleanup(curl);
curl_global_cleanup();
fclose(hd_src);
return TEST_ERR_MAJOR_BAD;
}
if ((headerlist = curl_slist_append(hl, buf_2)) == NULL) {
fprintf(stderr, "curl_slist_append() failed\n");
curl_slist_free_all(hl);
curl_easy_cleanup(curl);
curl_global_cleanup();
fclose(hd_src);
return TEST_ERR_MAJOR_BAD;
}
headerlist = hl;
/* enable uploading */
test_setopt(curl, CURLOPT_UPLOAD, 1L);
/* enable verbose */
test_setopt(curl, CURLOPT_VERBOSE, 1L);
/* specify target */
test_setopt(curl,CURLOPT_URL, URL);
/* pass in that last of FTP commands to run after the transfer */
test_setopt(curl, CURLOPT_POSTQUOTE, headerlist);
/* now specify which file to upload */
test_setopt(curl, CURLOPT_INFILE, hd_src);
/* and give the size of the upload (optional) */
test_setopt(curl, CURLOPT_INFILESIZE_LARGE,
(curl_off_t)file_info.st_size);
/* Now run off and do what you've been told! */
res = curl_easy_perform(curl);
test_cleanup:
/* clean up the FTP commands list */
curl_slist_free_all(headerlist);
/* close the local file */
fclose(hd_src);
curl_easy_cleanup(curl);
curl_global_cleanup();
return res;
} | /*
* This example shows an FTP upload, with a rename of the file just after
* a successful upload.
*
* Example based on source code provided by Erick Nuwendam. Thanks!
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/libtest/lib505.c#L37-L150 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | my_lock | static void my_lock(CURL *handle, curl_lock_data data, curl_lock_access laccess,
void *useptr )
{
const char *what;
struct userdata *user = (struct userdata *)useptr;
(void)handle;
(void)laccess;
switch ( data ) {
case CURL_LOCK_DATA_SHARE:
what = "share";
break;
case CURL_LOCK_DATA_DNS:
what = "dns";
break;
case CURL_LOCK_DATA_COOKIE:
what = "cookie";
break;
default:
fprintf(stderr, "lock: no such data: %d\n", (int)data);
return;
}
printf("lock: %-6s [%s]: %d\n", what, user->text, user->counter);
user->counter++;
} | /* lock callback */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/libtest/lib506.c#L44-L69 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | my_unlock | static void my_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";
break;
case CURL_LOCK_DATA_DNS:
what = "dns";
break;
case CURL_LOCK_DATA_COOKIE:
what = "cookie";
break;
default:
fprintf(stderr, "unlock: no such data: %d\n", (int)data);
return;
}
printf("unlock: %-6s [%s]: %d\n", what, user->text, user->counter);
user->counter++;
} | /* unlock callback */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/libtest/lib506.c#L72-L93 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | test | int test(char *URL)
{
int res;
CURLSHcode scode = CURLSHE_OK;
char *url;
struct Tdata tdata;
CURL *curl;
CURLSH *share;
struct curl_slist *headers;
int i;
struct userdata user;
user.text = (char *)"Pigs in space";
user.counter = 0;
printf( "GLOBAL_INIT\n" );
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
/* prepare share */
printf( "SHARE_INIT\n" );
if ((share = curl_share_init()) == NULL) {
fprintf(stderr, "curl_share_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
if ( CURLSHE_OK == scode ) {
printf( "CURLSHOPT_LOCKFUNC\n" );
scode = curl_share_setopt( share, CURLSHOPT_LOCKFUNC, my_lock);
}
if ( CURLSHE_OK == scode ) {
printf( "CURLSHOPT_UNLOCKFUNC\n" );
scode = curl_share_setopt( share, CURLSHOPT_UNLOCKFUNC, my_unlock);
}
if ( CURLSHE_OK == scode ) {
printf( "CURLSHOPT_USERDATA\n" );
scode = curl_share_setopt( share, CURLSHOPT_USERDATA, &user);
}
if ( CURLSHE_OK == scode ) {
printf( "CURL_LOCK_DATA_COOKIE\n" );
scode = curl_share_setopt( share, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE);
}
if ( CURLSHE_OK == scode ) {
printf( "CURL_LOCK_DATA_DNS\n" );
scode = curl_share_setopt( share, CURLSHOPT_SHARE, CURL_LOCK_DATA_DNS);
}
if ( CURLSHE_OK != scode ) {
fprintf(stderr, "curl_share_setopt() failed\n");
curl_share_cleanup(share);
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
res = 0;
/* start treads */
for (i=1; i<=THREADS; i++ ) {
/* set thread data */
tdata.url = suburl( URL, i ); /* must be curl_free()d */
tdata.share = share;
/* simulate thread, direct call of "thread" function */
printf( "*** run %d\n",i );
fire( &tdata );
curl_free( tdata.url );
}
/* fetch a another one and save cookies */
printf( "*** run %d\n", i );
if ((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_share_cleanup(share);
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
url = suburl( URL, i );
headers = sethost( NULL );
test_setopt( curl, CURLOPT_HTTPHEADER, headers );
test_setopt( curl, CURLOPT_URL, url );
printf( "CURLOPT_SHARE\n" );
test_setopt( curl, CURLOPT_SHARE, share );
printf( "CURLOPT_COOKIEJAR\n" );
test_setopt( curl, CURLOPT_COOKIEJAR, JAR );
printf( "PERFORM\n" );
curl_easy_perform( curl );
/* try to free share, expect to fail because share is in use*/
printf( "try SHARE_CLEANUP...\n" );
scode = curl_share_cleanup( share );
if ( scode==CURLSHE_OK )
{
fprintf(stderr, "curl_share_cleanup succeed but error expected\n");
share = NULL;
} else {
printf( "SHARE_CLEANUP failed, correct\n" );
}
test_cleanup:
/* clean up last handle */
printf( "CLEANUP\n" );
curl_easy_cleanup( curl );
curl_slist_free_all( headers );
curl_free(url);
/* free share */
printf( "SHARE_CLEANUP\n" );
scode = curl_share_cleanup( share );
if ( scode!=CURLSHE_OK )
fprintf(stderr, "curl_share_cleanup failed, code errno %d\n",
(int)scode);
printf( "GLOBAL_CLEANUP\n" );
curl_global_cleanup();
return res;
} | /* test function */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/libtest/lib506.c#L148-L276 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | test | int test(char *URL)
{
CURLcode code;
CURL *curl;
CURL *curl2;
int rc = 99;
code = curl_global_init(CURL_GLOBAL_ALL);
if(code == CURLE_OK) {
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_HEADER, 1L);
curl2 = curl_easy_duphandle(curl);
if(curl2) {
code = curl_easy_setopt(curl2, CURLOPT_URL, URL);
if(code == CURLE_OK) {
code = curl_easy_perform(curl2);
if(code == CURLE_OK)
rc = 0;
else
rc = 1;
}
else
rc = 2;
curl_easy_cleanup(curl2);
}
else
rc = 3;
curl_easy_cleanup(curl);
}
else
rc = 4;
curl_global_cleanup();
}
else
rc = 5;
return rc;
} | /* Test case code based on source in a bug report filed by James Bursa on
28 Apr 2004 */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/libtest/lib512.c#L29-L76 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | test | int test(char *URL)
{
(void)URL;
printf("system lacks necessary system function(s)");
return 1; /* skip test */
} | /* defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT) */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/libtest/lib518.c#L509-L514 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | test | int test(char *URL)
{
(void)URL;
printf("system lacks necessary system function(s)");
return 1; /* skip test */
} | /* defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT) */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/libtest/lib537.c#L512-L517 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | test | int test(char *URL)
{
CURL *curl;
CURLcode res = CURLE_OK;
FILE *hd_src ;
int hd ;
struct_stat file_info;
int error;
if (!libtest_arg2) {
fprintf(stderr, "Usage: <url> <file-to-upload>\n");
return -1;
}
hd_src = fopen(libtest_arg2, "rb");
if(NULL == hd_src) {
error = ERRNO;
fprintf(stderr, "fopen() failed with error: %d %s\n",
error, strerror(error));
fprintf(stderr, "Error opening file: %s\n", libtest_arg2);
return -2; /* if this happens things are major weird */
}
/* get the file size of the local file */
hd = fstat(fileno(hd_src), &file_info);
if(hd == -1) {
/* can't open file, bail out */
error = ERRNO;
fprintf(stderr, "fstat() failed with error: %d %s\n",
error, strerror(error));
fprintf(stderr, "ERROR: cannot open file %s\n", libtest_arg2);
fclose(hd_src);
return -1;
}
if(! file_info.st_size) {
fprintf(stderr, "ERROR: file %s has zero size!\n", libtest_arg2);
fclose(hd_src);
return -4;
}
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
fclose(hd_src);
return TEST_ERR_MAJOR_BAD;
}
/* get a curl handle */
if ((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
fclose(hd_src);
return TEST_ERR_MAJOR_BAD;
}
/* enable uploading */
test_setopt(curl, CURLOPT_UPLOAD, 1L);
/* enable verbose */
test_setopt(curl, CURLOPT_VERBOSE, 1L);
/* specify target */
test_setopt(curl,CURLOPT_URL, URL);
/* now specify which file to upload */
test_setopt(curl, CURLOPT_INFILE, hd_src);
/* Now run off and do what you've been told! */
res = curl_easy_perform(curl);
/* and now upload the exact same again, but without rewinding so it already
is at end of file */
res = curl_easy_perform(curl);
test_cleanup:
/* close the local file */
fclose(hd_src);
curl_easy_cleanup(curl);
curl_global_cleanup();
return res;
} | /*
* Two FTP uploads, the second with no content sent.
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/libtest/lib541.c#L34-L117 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | test | int test(char *URL)
{
CURL *curl;
CURLcode res = CURLE_OK;
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
/* get a curl handle */
if ((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
/* enable verbose */
test_setopt(curl, CURLOPT_VERBOSE, 1L);
/* enable NOBODY */
test_setopt(curl, CURLOPT_NOBODY, 1L);
/* disable HEADER */
test_setopt(curl, CURLOPT_HEADER, 0L);
/* specify target */
test_setopt(curl,CURLOPT_URL, URL);
/* Now run off and do what you've been told! */
res = curl_easy_perform(curl);
test_cleanup:
curl_easy_cleanup(curl);
curl_global_cleanup();
return res;
} | /*
* FTP get with NOBODY but no HEADER
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/libtest/lib542.c#L34-L72 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | read_callback | static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *stream)
{
size_t amount = nmemb * size; /* Total bytes curl wants */
size_t available = sizeof(databuf) - current_offset; /* What we have to give */
size_t given = amount < available ? amount : available; /* What is given */
(void)stream;
memcpy(ptr, databuf + current_offset, given);
current_offset += given;
return given;
} | /* MUST be more than 64k OR MAX_INITIAL_POST_SIZE */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/libtest/lib552.c#L126-L135 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | test | int test(char *URL)
{
CURL *http_handle = NULL;
CURLM *multi_handle = NULL;
int res = 0;
int still_running; /* keep number of running handles */
start_test_timing();
/*
** curl_global_init called indirectly from curl_easy_init.
*/
easy_init(http_handle);
/* set options */
easy_setopt(http_handle, CURLOPT_URL, URL);
easy_setopt(http_handle, CURLOPT_HEADER, 1L);
easy_setopt(http_handle, CURLOPT_SSL_VERIFYPEER, 0L);
easy_setopt(http_handle, CURLOPT_SSL_VERIFYHOST, 0L);
/* init a multi stack */
multi_init(multi_handle);
/* add the individual transfers */
multi_add_handle(multi_handle, http_handle);
/* we start some action by calling perform right away */
multi_perform(multi_handle, &still_running);
abort_on_test_timeout();
while(still_running) {
struct timeval timeout;
fd_set fdread;
fd_set fdwrite;
fd_set fdexcep;
int maxfd = -99;
FD_ZERO(&fdread);
FD_ZERO(&fdwrite);
FD_ZERO(&fdexcep);
/* set a suitable timeout to play around with */
timeout.tv_sec = 1;
timeout.tv_usec = 0;
/* get file descriptors from the transfers */
multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd);
/* At this point, maxfd is guaranteed to be greater or equal than -1. */
select_test(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
abort_on_test_timeout();
/* timeout or readable/writable sockets */
multi_perform(multi_handle, &still_running);
abort_on_test_timeout();
}
test_cleanup:
/* undocumented cleanup sequence - type UA */
curl_multi_cleanup(multi_handle);
curl_easy_cleanup(http_handle);
curl_global_cleanup();
return res;
} | /*
* Simply download a HTTPS file!
*
* This test was added after the HTTPS-using-multi-interface with OpenSSL
* regression of 7.19.1 to hopefully prevent this embarassing mistake from
* appearing again... Unfortunately the bug wasn't triggered by this test,
* which presumably is because the connect to a local server is too
* fast/different compared to the real/distant servers we saw the bug happen
* with.
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/libtest/lib560.c#L40-L113 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | test | int test(char *URL)
{
CURL *curl;
CURLcode res = CURLE_OK;
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
/* get a curl handle */
if ((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
/* enable verbose */
test_setopt(curl, CURLOPT_VERBOSE, 1L);
/* set port number */
test_setopt(curl, CURLOPT_PORT, strtol(libtest_arg2, NULL, 10));
/* specify target */
test_setopt(curl,CURLOPT_URL, URL);
/* Now run off and do what you've been told! */
res = curl_easy_perform(curl);
test_cleanup:
curl_easy_cleanup(curl);
curl_global_cleanup();
return res;
} | /*
* From "KNOWN_BUGS" April 2009:
59. If the CURLOPT_PORT option is used on an FTP URL like
"ftp://example.com/file;type=A" the ";type=A" is stripped off.
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/libtest/lib562.c#L38-L73 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | test | int test(char *URL)
{
CURLcode res;
CURL *curl;
struct curl_slist *custom_headers=NULL;
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
if ((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
/* Dump data to stdout for protocol verification */
test_setopt(curl, CURLOPT_HEADERDATA, stdout);
test_setopt(curl, CURLOPT_WRITEDATA, stdout);
test_setopt(curl, CURLOPT_URL, URL);
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, URL);
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS);
test_setopt(curl, CURLOPT_USERAGENT, "test567");
custom_headers = curl_slist_append(custom_headers, "Test-Number: 567");
test_setopt(curl, CURLOPT_RTSPHEADER, custom_headers);
res = curl_easy_perform(curl);
test_cleanup:
if(custom_headers)
curl_slist_free_all(custom_headers);
curl_easy_cleanup(curl);
curl_global_cleanup();
return (int)res;
} | /*
* Test a simple OPTIONS request with a custom header
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/libtest/lib567.c#L29-L68 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | test | int test(char *URL)
{
int res;
CURL *curl;
int sdp;
FILE *sdpf = NULL;
struct_stat file_info;
char *stream_uri = NULL;
int request=1;
struct curl_slist *custom_headers=NULL;
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
if ((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
test_setopt(curl, CURLOPT_HEADERDATA, stdout);
test_setopt(curl, CURLOPT_WRITEDATA, stdout);
test_setopt(curl, CURLOPT_URL, URL);
if((stream_uri = suburl(URL, request++)) == NULL) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
free(stream_uri);
stream_uri = NULL;
sdp = open("log/file568.txt", O_RDONLY);
fstat(sdp, &file_info);
close(sdp);
sdpf = fopen("log/file568.txt", "rb");
if(sdpf == NULL) {
fprintf(stderr, "can't open log/file568.txt\n");
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_ANNOUNCE);
test_setopt(curl, CURLOPT_READDATA, sdpf);
test_setopt(curl, CURLOPT_UPLOAD, 1L);
test_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t) file_info.st_size);
/* Do the ANNOUNCE */
res = curl_easy_perform(curl);
if(res)
goto test_cleanup;
test_setopt(curl, CURLOPT_UPLOAD, 0L);
fclose(sdpf);
sdpf = NULL;
/* Make sure we can do a normal request now */
if((stream_uri = suburl(URL, request++)) == NULL) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
free(stream_uri);
stream_uri = NULL;
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_DESCRIBE);
res = curl_easy_perform(curl);
if(res)
goto test_cleanup;
/* Now do a POST style one */
if((stream_uri = suburl(URL, request++)) == NULL) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
free(stream_uri);
stream_uri = NULL;
custom_headers = curl_slist_append(custom_headers,
"Content-Type: posty goodness");
if(!custom_headers) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
test_setopt(curl, CURLOPT_RTSPHEADER, custom_headers);
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_ANNOUNCE);
test_setopt(curl, CURLOPT_POSTFIELDS, "postyfield=postystuff&project=curl\n");
res = curl_easy_perform(curl);
if(res)
goto test_cleanup;
test_setopt(curl, CURLOPT_POSTFIELDS, NULL);
test_setopt(curl, CURLOPT_RTSPHEADER, NULL);
curl_slist_free_all(custom_headers);
custom_headers = NULL;
/* Make sure we can do a normal request now */
if((stream_uri = suburl(URL, request++)) == NULL) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
free(stream_uri);
stream_uri = NULL;
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS);
res = curl_easy_perform(curl);
test_cleanup:
if(sdpf)
fclose(sdpf);
if(stream_uri)
free(stream_uri);
if(custom_headers)
curl_slist_free_all(custom_headers);
curl_easy_cleanup(curl);
curl_global_cleanup();
return res;
} | /*
* Test the Client->Server ANNOUNCE functionality (PUT style)
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/libtest/lib568.c#L44-L174 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | test | int test(char *URL)
{
int res;
CURL *curl;
char *stream_uri = NULL;
char *rtsp_session_id;
int request=1;
int i;
FILE *idfile = NULL;
idfile = fopen(libtest_arg2, "wb");
if(idfile == NULL) {
fprintf(stderr, "couldn't open the Session ID File\n");
return TEST_ERR_MAJOR_BAD;
}
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
fclose(idfile);
return TEST_ERR_MAJOR_BAD;
}
if ((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
fclose(idfile);
return TEST_ERR_MAJOR_BAD;
}
test_setopt(curl, CURLOPT_HEADERDATA, stdout);
test_setopt(curl, CURLOPT_WRITEDATA, stdout);
test_setopt(curl, CURLOPT_VERBOSE, 1L);
test_setopt(curl, CURLOPT_URL, URL);
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP);
res = curl_easy_perform(curl);
if(res != (int)CURLE_BAD_FUNCTION_ARGUMENT) {
fprintf(stderr, "This should have failed. "
"Cannot setup without a Transport: header");
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
/* Go through the various Session IDs */
for(i = 0; i < 3; i++) {
if((stream_uri = suburl(URL, request++)) == NULL) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
free(stream_uri);
stream_uri = NULL;
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP);
test_setopt(curl, CURLOPT_RTSP_TRANSPORT, "Fake/NotReal/JustATest;foo=baz");
res = curl_easy_perform(curl);
if(res)
goto test_cleanup;
curl_easy_getinfo(curl, CURLINFO_RTSP_SESSION_ID, &rtsp_session_id);
fprintf(idfile, "Got Session ID: [%s]\n", rtsp_session_id);
rtsp_session_id = NULL;
if((stream_uri = suburl(URL, request++)) == NULL) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
free(stream_uri);
stream_uri = NULL;
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_TEARDOWN);
res = curl_easy_perform(curl);
/* Clear for the next go-round */
test_setopt(curl, CURLOPT_RTSP_SESSION_ID, NULL);
}
test_cleanup:
if(idfile)
fclose(idfile);
if(stream_uri)
free(stream_uri);
curl_easy_cleanup(curl);
curl_global_cleanup();
return res;
} | /*
* Test Session ID capture
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/libtest/lib569.c#L37-L128 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | test | int test(char *URL)
{
int res;
CURL *curl;
int params;
FILE *paramsf = NULL;
struct_stat file_info;
char *stream_uri = NULL;
int request=1;
struct curl_slist *custom_headers=NULL;
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
if ((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
test_setopt(curl, CURLOPT_HEADERDATA, stdout);
test_setopt(curl, CURLOPT_WRITEDATA, stdout);
test_setopt(curl, CURLOPT_VERBOSE, 1L);
test_setopt(curl, CURLOPT_URL, URL);
/* SETUP */
if((stream_uri = suburl(URL, request++)) == NULL) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
free(stream_uri);
stream_uri = NULL;
test_setopt(curl, CURLOPT_RTSP_TRANSPORT, "Planes/Trains/Automobiles");
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP);
res = curl_easy_perform(curl);
if(res)
goto test_cleanup;
if((stream_uri = suburl(URL, request++)) == NULL) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
free(stream_uri);
stream_uri = NULL;
/* PUT style GET_PARAMETERS */
params = open("log/file572.txt", O_RDONLY);
fstat(params, &file_info);
close(params);
paramsf = fopen("log/file572.txt", "rb");
if(paramsf == NULL) {
fprintf(stderr, "can't open log/file572.txt\n");
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_GET_PARAMETER);
test_setopt(curl, CURLOPT_READDATA, paramsf);
test_setopt(curl, CURLOPT_UPLOAD, 1L);
test_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t) file_info.st_size);
res = curl_easy_perform(curl);
if(res)
goto test_cleanup;
test_setopt(curl, CURLOPT_UPLOAD, 0L);
fclose(paramsf);
paramsf = NULL;
/* Heartbeat GET_PARAMETERS */
if((stream_uri = suburl(URL, request++)) == NULL) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
free(stream_uri);
stream_uri = NULL;
res = curl_easy_perform(curl);
if(res)
goto test_cleanup;
/* POST GET_PARAMETERS */
if((stream_uri = suburl(URL, request++)) == NULL) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
free(stream_uri);
stream_uri = NULL;
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_GET_PARAMETER);
test_setopt(curl, CURLOPT_POSTFIELDS, "packets_received\njitter\n");
res = curl_easy_perform(curl);
if(res)
goto test_cleanup;
test_setopt(curl, CURLOPT_POSTFIELDS, NULL);
/* Make sure we can do a normal request now */
if((stream_uri = suburl(URL, request++)) == NULL) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
free(stream_uri);
stream_uri = NULL;
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS);
res = curl_easy_perform(curl);
test_cleanup:
if(paramsf)
fclose(paramsf);
if(stream_uri)
free(stream_uri);
if(custom_headers)
curl_slist_free_all(custom_headers);
curl_easy_cleanup(curl);
curl_global_cleanup();
return res;
} | /*
* Test GET_PARAMETER: PUT, HEARTBEAT, and POST
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/libtest/lib572.c#L44-L180 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | test | int test(char *URL)
{
CURL *c = NULL;
CURLM *m = NULL;
int res = 0;
int running = 1;
double connect_time = 0.0;
double dbl_epsilon;
dbl_epsilon = 1.0;
do {
dbl_epsilon /= 2.0;
} while ((double)(1.0 + (dbl_epsilon/2.0)) > (double)1.0);
start_test_timing();
global_init(CURL_GLOBAL_ALL);
easy_init(c);
easy_setopt(c, CURLOPT_HEADER, 1L);
easy_setopt(c, CURLOPT_URL, URL);
libtest_debug_config.nohex = 1;
libtest_debug_config.tracetime = 1;
easy_setopt(c, CURLOPT_DEBUGDATA, &libtest_debug_config);
easy_setopt(c, CURLOPT_DEBUGFUNCTION, libtest_debug_cb);
easy_setopt(c, CURLOPT_VERBOSE, 1L);
multi_init(m);
multi_add_handle(m, c);
while (running) {
struct timeval timeout;
fd_set fdread, fdwrite, fdexcep;
int maxfd = -99;
timeout.tv_sec = 0;
timeout.tv_usec = 100000L; /* 100 ms */
multi_perform(m, &running);
abort_on_test_timeout();
if(!running)
break; /* done */
FD_ZERO(&fdread);
FD_ZERO(&fdwrite);
FD_ZERO(&fdexcep);
multi_fdset(m, &fdread, &fdwrite, &fdexcep, &maxfd);
/* At this point, maxfd is guaranteed to be greater or equal than -1. */
select_test(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
abort_on_test_timeout();
}
curl_easy_getinfo(c, CURLINFO_CONNECT_TIME, &connect_time);
if (connect_time < dbl_epsilon) {
fprintf(stderr, "connect time is < epsilon\n");
res = TEST_ERR_MAJOR_BAD;
}
test_cleanup:
/* proper cleanup sequence - type PA */
curl_multi_remove_handle(m, c);
curl_multi_cleanup(m);
curl_easy_cleanup(c);
curl_global_cleanup();
return res;
} | /*
* Get a single URL without select().
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/libtest/lib573.c#L35-L112 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | test | int test(char *URL)
{
CURL *handle = NULL;
CURL *duphandle = NULL;
CURLM *mhandle = NULL;
int res = 0;
int still_running = 0;
start_test_timing();
global_init(CURL_GLOBAL_ALL);
easy_init(handle);
easy_setopt(handle, CURLOPT_URL, URL);
easy_setopt(handle, CURLOPT_WILDCARDMATCH, 1L);
easy_setopt(handle, CURLOPT_VERBOSE, 1L);
res = curl_easy_perform(handle);
if(res)
goto test_cleanup;
res = curl_easy_perform(handle);
if(res)
goto test_cleanup;
duphandle = curl_easy_duphandle(handle);
if(!duphandle)
goto test_cleanup;
curl_easy_cleanup(handle);
handle = duphandle;
multi_init(mhandle);
multi_add_handle(mhandle, handle);
multi_perform(mhandle, &still_running);
abort_on_test_timeout();
while(still_running) {
struct timeval timeout;
fd_set fdread;
fd_set fdwrite;
fd_set fdexcep;
int maxfd = -99;
timeout.tv_sec = 0;
timeout.tv_usec = 100000L; /* 100 ms */
FD_ZERO(&fdread);
FD_ZERO(&fdwrite);
FD_ZERO(&fdexcep);
multi_fdset(mhandle, &fdread, &fdwrite, &fdexcep, &maxfd);
/* At this point, maxfd is guaranteed to be greater or equal than -1. */
select_test(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
abort_on_test_timeout();
multi_perform(mhandle, &still_running);
abort_on_test_timeout();
}
test_cleanup:
/* undocumented cleanup sequence - type UA */
curl_multi_cleanup(mhandle);
curl_easy_cleanup(handle);
curl_global_cleanup();
return res;
} | /* 3x download!
* 1. normal
* 2. dup handle
* 3. with multi interface
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/libtest/lib575.c#L38-L114 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | removeFd | static void removeFd(struct Sockets* sockets, curl_socket_t fd, int mention)
{
int i;
if(mention)
fprintf(stderr, "Remove socket fd %d\n", (int) fd);
for (i = 0; i < sockets->count; ++i) {
if (sockets->sockets[i] == fd) {
if (i < sockets->count - 1)
memmove(&sockets->sockets[i], &sockets->sockets[i + 1],
sizeof(curl_socket_t) * (sockets->count - (i + 1)));
--sockets->count;
}
}
} | /**
* Remove a file descriptor from a sockets array.
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/libtest/lib582.c#L47-L62 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | addFd | static void addFd(struct Sockets* sockets, curl_socket_t fd, const char *what)
{
/**
* To ensure we only have each file descriptor once, we remove it then add
* it again.
*/
fprintf(stderr, "Add socket fd %d for %s\n", (int) fd, what);
removeFd(sockets, fd, 0);
/*
* Allocate array storage when required.
*/
if(!sockets->sockets) {
sockets->sockets = malloc(sizeof(curl_socket_t) * 20U);
if(!sockets->sockets)
return;
sockets->max_count = 20;
}
else if(sockets->count + 1 > sockets->max_count) {
curl_socket_t *oldptr = sockets->sockets;
sockets->sockets = realloc(oldptr, sizeof(curl_socket_t) *
(sockets->max_count + 20));
if(!sockets->sockets) {
/* cleanup in test_cleanup */
sockets->sockets = oldptr;
return;
}
sockets->max_count += 20;
}
/*
* Add file descriptor to array.
*/
sockets->sockets[sockets->count] = fd;
++sockets->count;
} | /**
* Add a file descriptor to a sockets array.
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/libtest/lib582.c#L67-L100 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | curlSocketCallback | static int curlSocketCallback(CURL *easy, curl_socket_t s, int action,
void *userp, void *socketp)
{
struct ReadWriteSockets* sockets = userp;
(void)easy; /* unused */
(void)socketp; /* unused */
if (action == CURL_POLL_IN || action == CURL_POLL_INOUT)
addFd(&sockets->read, s, "read");
if (action == CURL_POLL_OUT || action == CURL_POLL_INOUT)
addFd(&sockets->write, s, "write");
if(action == CURL_POLL_REMOVE) {
removeFd(&sockets->read, s, 1);
removeFd(&sockets->write, s, 0);
}
return 0;
} | /**
* Callback invoked by curl to poll reading / writing of a socket.
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/libtest/lib582.c#L105-L125 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | curlTimerCallback | static int curlTimerCallback(CURLM *multi, long timeout_ms, void *userp)
{
struct timeval* timeout = userp;
(void)multi; /* unused */
if (timeout_ms != -1) {
*timeout = tutil_tvnow();
timeout->tv_usec += timeout_ms * 1000;
}
else {
timeout->tv_sec = -1;
}
return 0;
} | /**
* Callback invoked by curl to set a timeout.
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/libtest/lib582.c#L130-L143 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | checkForCompletion | static int checkForCompletion(CURLM* curl, int* success)
{
int numMessages;
CURLMsg* message;
int result = 0;
*success = 0;
while ((message = curl_multi_info_read(curl, &numMessages)) != NULL) {
if (message->msg == CURLMSG_DONE) {
result = 1;
if (message->data.result == CURLE_OK)
*success = 1;
else
*success = 0;
}
else {
fprintf(stderr, "Got an unexpected message from curl: %i\n",
(int)message->msg);
result = 1;
*success = 0;
}
}
return result;
} | /**
* Check for curl completion.
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/libtest/lib582.c#L148-L170 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | updateFdSet | static void updateFdSet(struct Sockets* sockets, fd_set* fdset,
curl_socket_t *maxFd)
{
int i;
for (i = 0; i < sockets->count; ++i) {
FD_SET(sockets->sockets[i], fdset);
if (*maxFd < sockets->sockets[i] + 1) {
*maxFd = sockets->sockets[i] + 1;
}
}
} | /**
* Update a fd_set with all of the sockets in use.
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/libtest/lib582.c#L188-L198 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | checkFdSet | static void checkFdSet(CURLM *curl, struct Sockets *sockets, fd_set *fdset,
int evBitmask, const char *name)
{
int i;
for (i = 0; i < sockets->count; ++i) {
if (FD_ISSET(sockets->sockets[i], fdset)) {
notifyCurl(curl, sockets->sockets[i], evBitmask, name);
}
}
} | /**
* Invoke curl when a file descriptor is set.
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/libtest/lib582.c#L214-L223 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | my_lock | static void my_lock(CURL *handle, curl_lock_data data, curl_lock_access laccess,
void *useptr )
{
const char *what;
struct userdata *user = (struct userdata *)useptr;
(void)handle;
(void)laccess;
switch ( data ) {
case CURL_LOCK_DATA_SHARE:
what = "share";
break;
case CURL_LOCK_DATA_DNS:
what = "dns";
break;
case CURL_LOCK_DATA_COOKIE:
what = "cookie";
break;
case CURL_LOCK_DATA_SSL_SESSION:
what = "ssl_session";
break;
default:
fprintf(stderr, "lock: no such data: %d\n", (int)data);
return;
}
printf("lock: %-6s [%s]: %d\n", what, user->text, user->counter);
user->counter++;
} | /* lock callback */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/libtest/lib586.c#L42-L70 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | my_unlock | static void my_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";
break;
case CURL_LOCK_DATA_DNS:
what = "dns";
break;
case CURL_LOCK_DATA_COOKIE:
what = "cookie";
break;
case CURL_LOCK_DATA_SSL_SESSION:
what = "ssl_session";
break;
default:
fprintf(stderr, "unlock: no such data: %d\n", (int)data);
return;
}
printf("unlock: %-6s [%s]: %d\n", what, user->text, user->counter);
user->counter++;
} | /* unlock callback */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/libtest/lib586.c#L73-L97 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | test | int test(char *URL)
{
int res;
CURLSHcode scode = CURLSHE_OK;
char *url;
struct Tdata tdata;
CURL *curl;
CURLSH *share;
int i;
struct userdata user;
user.text = (char *)"Pigs in space";
user.counter = 0;
printf( "GLOBAL_INIT\n" );
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
/* prepare share */
printf( "SHARE_INIT\n" );
if ((share = curl_share_init()) == NULL) {
fprintf(stderr, "curl_share_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
if ( CURLSHE_OK == scode ) {
printf( "CURLSHOPT_LOCKFUNC\n" );
scode = curl_share_setopt( share, CURLSHOPT_LOCKFUNC, my_lock);
}
if ( CURLSHE_OK == scode ) {
printf( "CURLSHOPT_UNLOCKFUNC\n" );
scode = curl_share_setopt( share, CURLSHOPT_UNLOCKFUNC, my_unlock);
}
if ( CURLSHE_OK == scode ) {
printf( "CURLSHOPT_USERDATA\n" );
scode = curl_share_setopt( share, CURLSHOPT_USERDATA, &user);
}
if ( CURLSHE_OK == scode ) {
printf( "CURL_LOCK_DATA_SSL_SESSION\n" );
scode = curl_share_setopt( share, CURLSHOPT_SHARE, CURL_LOCK_DATA_SSL_SESSION);
}
if ( CURLSHE_OK != scode ) {
fprintf(stderr, "curl_share_setopt() failed\n");
curl_share_cleanup(share);
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
res = 0;
/* start treads */
for (i=1; i<=THREADS; i++ ) {
/* set thread data */
tdata.url = URL;
tdata.share = share;
/* simulate thread, direct call of "thread" function */
printf( "*** run %d\n",i );
fire( &tdata );
}
/* fetch a another one */
printf( "*** run %d\n", i );
if ((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_share_cleanup(share);
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
url = URL;
test_setopt( curl, CURLOPT_URL, url );
printf( "CURLOPT_SHARE\n" );
test_setopt( curl, CURLOPT_SHARE, share );
printf( "PERFORM\n" );
curl_easy_perform( curl );
/* try to free share, expect to fail because share is in use*/
printf( "try SHARE_CLEANUP...\n" );
scode = curl_share_cleanup( share );
if ( scode==CURLSHE_OK )
{
fprintf(stderr, "curl_share_cleanup succeed but error expected\n");
share = NULL;
} else {
printf( "SHARE_CLEANUP failed, correct\n" );
}
test_cleanup:
/* clean up last handle */
printf( "CLEANUP\n" );
curl_easy_cleanup( curl );
/* free share */
printf( "SHARE_CLEANUP\n" );
scode = curl_share_cleanup( share );
if ( scode!=CURLSHE_OK )
fprintf(stderr, "curl_share_cleanup failed, code errno %d\n",
(int)scode);
printf( "GLOBAL_CLEANUP\n" );
curl_global_cleanup();
return res;
} | /* test function */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/libtest/lib586.c#L132-L245 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | gethostname | int gethostname(char *name, GETHOSTNAME_TYPE_ARG2 namelen)
{
const char *force_hostname = getenv("CURL_GETHOSTNAME");
if(force_hostname) {
strncpy(name, force_hostname, namelen);
name[namelen-1] = '\0';
return 0;
}
/* LD_PRELOAD used, but no hostname set, we'll just return a failure */
return -1;
} | /*
* we force our own host name, in order to make some tests machine independent
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/libtest/sethostname.c#L30-L41 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | libtest_debug_dump | static
void libtest_debug_dump(const char *timebuf, const char *text, FILE *stream,
const unsigned char *ptr, size_t size, int nohex)
{
size_t i;
size_t c;
unsigned int width = 0x10;
if(nohex)
/* without the hex output, we can fit more on screen */
width = 0x40;
fprintf(stream, "%s%s, %d bytes (0x%x)\n", timebuf, text,
(int)size, (int)size);
for(i = 0; i < size; i += width) {
fprintf(stream, "%04x: ", (int)i);
if(!nohex) {
/* hex not disabled, show it */
for(c = 0; c < width; c++)
if(i+c < size)
fprintf(stream, "%02x ", ptr[i+c]);
else
fputs(" ", stream);
}
for(c = 0; (c < width) && (i+c < size); c++) {
/* check for 0D0A; if found, skip past and start a new line of output */
if(nohex &&
(i+c+1 < size) && (ptr[i+c] == 0x0D) && (ptr[i+c+1] == 0x0A)) {
i += (c+2-width);
break;
}
fprintf(stream, "%c", ((ptr[i+c] >= 0x20) && (ptr[i+c] < 0x80)) ?
ptr[i+c] : '.');
/* check again for 0D0A, to avoid an extra \n if it's at width */
if(nohex &&
(i+c+2 < size) && (ptr[i+c+1] == 0x0D) && (ptr[i+c+2] == 0x0A)) {
i += (c+3-width);
break;
}
}
fputc('\n', stream); /* newline */
}
fflush(stream);
} | /* for test time tracing */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/libtest/testtrace.c#L37-L85 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | tutil_tvdiff | long tutil_tvdiff(struct timeval newer, struct timeval older)
{
return (newer.tv_sec-older.tv_sec)*1000+
(newer.tv_usec-older.tv_usec)/1000;
} | /*
* Make sure that the first argument is the more recent time, as otherwise
* we'll get a weird negative time-diff back...
*
* Returns: the time difference in number of milliseconds.
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/libtest/testutil.c#L112-L116 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | tutil_tvdiff_secs | double tutil_tvdiff_secs(struct timeval newer, struct timeval older)
{
if(newer.tv_sec != older.tv_sec)
return (double)(newer.tv_sec-older.tv_sec)+
(double)(newer.tv_usec-older.tv_usec)/1000000.0;
else
return (double)(newer.tv_usec-older.tv_usec)/1000000.0;
} | /*
* Same as tutil_tvdiff but with full usec resolution.
*
* Returns: the time difference in seconds with subsecond resolution.
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/libtest/testutil.c#L123-L130 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | tutil_tvlong | long tutil_tvlong(struct timeval t1)
{
return t1.tv_sec;
} | /* return the number of seconds in the given input timeval struct */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/libtest/testutil.c#L133-L136 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | readline | static int readline(char **buffer, size_t *bufsize, FILE *stream)
{
size_t offset = 0;
size_t length;
char *newptr;
if(!*buffer) {
*buffer = malloc(128);
if(!*buffer)
return GPE_OUT_OF_MEMORY;
*bufsize = 128;
}
for(;;) {
int bytestoread = curlx_uztosi(*bufsize - offset);
if(!fgets(*buffer + offset, bytestoread, stream))
return (offset != 0) ? GPE_OK : GPE_END_OF_FILE ;
length = offset + strlen(*buffer + offset);
if(*(*buffer + length - 1) == '\n')
break;
offset = length;
if(length < *bufsize - 1)
continue;
newptr = realloc(*buffer, *bufsize * 2);
if(!newptr)
return GPE_OUT_OF_MEMORY;
*buffer = newptr;
*bufsize *= 2;
}
return GPE_OK;
} | /*
* readline()
*
* Reads a complete line from a file into a dynamically allocated buffer.
*
* Calling function may call this multiple times with same 'buffer'
* and 'bufsize' pointers to avoid multiple buffer allocations. Buffer
* will be reallocated and 'bufsize' increased until whole line fits in
* buffer before returning it.
*
* Calling function is responsible to free allocated buffer.
*
* This function may return:
* GPE_OUT_OF_MEMORY
* GPE_END_OF_FILE
* GPE_OK
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/server/getpart.c#L84-L118 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | appenddata | static int appenddata(char **dst_buf, /* dest buffer */
size_t *dst_len, /* dest buffer data length */
size_t *dst_alloc, /* dest buffer allocated size */
char *src_buf, /* source buffer */
int src_b64) /* != 0 if source is base64 encoded */
{
size_t need_alloc, src_len;
union {
unsigned char *as_uchar;
char *as_char;
} buf64;
src_len = strlen(src_buf);
if(!src_len)
return GPE_OK;
buf64.as_char = NULL;
if(src_b64) {
/* base64 decode the given buffer */
int error = (int) Curl_base64_decode(src_buf, &buf64.as_uchar, &src_len);
if(error)
return GPE_OUT_OF_MEMORY;
src_buf = buf64.as_char;
if(!src_len || !src_buf) {
/*
** currently there is no way to tell apart an OOM condition in
** Curl_base64_decode() from zero length decoded data. For now,
** let's just assume it is an OOM condition, currently we have
** no input for this function that decodes to zero length data.
*/
if(buf64.as_char)
free(buf64.as_char);
return GPE_OUT_OF_MEMORY;
}
}
need_alloc = src_len + *dst_len + 1;
/* enlarge destination buffer if required */
if(need_alloc > *dst_alloc) {
size_t newsize = need_alloc * 2;
char *newptr = realloc(*dst_buf, newsize);
if(!newptr) {
if(buf64.as_char)
free(buf64.as_char);
return GPE_OUT_OF_MEMORY;
}
*dst_alloc = newsize;
*dst_buf = newptr;
}
/* memcpy to support binary blobs */
memcpy(*dst_buf + *dst_len, src_buf, src_len);
*dst_len += src_len;
*(*dst_buf + *dst_len) = '\0';
if(buf64.as_char)
free(buf64.as_char);
return GPE_OK;
} | /*
* appenddata()
*
* This appends data from a given source buffer to the end of the used part of
* a destination buffer. Arguments relative to the destination buffer are, the
* address of a pointer to the destination buffer 'dst_buf', the length of data
* in destination buffer excluding potential null string termination 'dst_len',
* the allocated size of destination buffer 'dst_alloc'. All three destination
* buffer arguments may be modified by this function. Arguments relative to the
* source buffer are, a pointer to the source buffer 'src_buf' and indication
* whether the source buffer is base64 encoded or not 'src_b64'.
*
* If the source buffer is indicated to be base64 encoded, this appends the
* decoded data, binary or whatever, to the destination. The source buffer
* may not hold binary data, only a null terminated string is valid content.
*
* Destination buffer will be enlarged and relocated as needed.
*
* Calling function is responsible to provide preallocated destination
* buffer and also to deallocate it when no longer needed.
*
* This function may return:
* GPE_OUT_OF_MEMORY
* GPE_OK
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/server/getpart.c#L146-L207 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | getpart | int getpart(char **outbuf, size_t *outlen,
const char *main, const char *sub, FILE *stream)
{
# define MAX_TAG_LEN 79
char couter[MAX_TAG_LEN+1]; /* current outermost section */
char cmain[MAX_TAG_LEN+1]; /* current main section */
char csub[MAX_TAG_LEN+1]; /* current sub section */
char ptag[MAX_TAG_LEN+1]; /* potential tag */
char patt[MAX_TAG_LEN+1]; /* potential attributes */
char *buffer = NULL;
char *ptr;
char *end;
union {
ssize_t sig;
size_t uns;
} len;
size_t bufsize = 0;
size_t outalloc = 256;
int in_wanted_part = 0;
int base64 = 0;
int error;
enum {
STATE_OUTSIDE = 0,
STATE_OUTER = 1,
STATE_INMAIN = 2,
STATE_INSUB = 3,
STATE_ILLEGAL = 4
} state = STATE_OUTSIDE;
*outlen = 0;
*outbuf = malloc(outalloc);
if(!*outbuf)
return GPE_OUT_OF_MEMORY;
*(*outbuf) = '\0';
couter[0] = cmain[0] = csub[0] = ptag[0] = patt[0] = '\0';
while((error = readline(&buffer, &bufsize, stream)) == GPE_OK) {
ptr = buffer;
EAT_SPACE(ptr);
if('<' != *ptr) {
if(in_wanted_part) {
show(("=> %s", buffer));
error = appenddata(outbuf, outlen, &outalloc, buffer, base64);
if(error)
break;
}
continue;
}
ptr++;
if('/' == *ptr) {
/*
** closing section tag
*/
ptr++;
end = ptr;
EAT_WORD(end);
if((len.sig = end - ptr) > MAX_TAG_LEN) {
error = GPE_NO_BUFFER_SPACE;
break;
}
memcpy(ptag, ptr, len.uns);
ptag[len.uns] = '\0';
if((STATE_INSUB == state) && !strcmp(csub, ptag)) {
/* end of current sub section */
state = STATE_INMAIN;
csub[0] = '\0';
if(in_wanted_part) {
/* end of wanted part */
in_wanted_part = 0;
break;
}
}
else if((STATE_INMAIN == state) && !strcmp(cmain, ptag)) {
/* end of current main section */
state = STATE_OUTER;
cmain[0] = '\0';
if(in_wanted_part) {
/* end of wanted part */
in_wanted_part = 0;
break;
}
}
else if((STATE_OUTER == state) && !strcmp(couter, ptag)) {
/* end of outermost file section */
state = STATE_OUTSIDE;
couter[0] = '\0';
if(in_wanted_part) {
/* end of wanted part */
in_wanted_part = 0;
break;
}
}
}
else if(!in_wanted_part) {
/*
** opening section tag
*/
/* get potential tag */
end = ptr;
EAT_WORD(end);
if((len.sig = end - ptr) > MAX_TAG_LEN) {
error = GPE_NO_BUFFER_SPACE;
break;
}
memcpy(ptag, ptr, len.uns);
ptag[len.uns] = '\0';
/* ignore comments, doctypes and xml declarations */
if(('!' == ptag[0]) || ('?' == ptag[0])) {
show(("* ignoring (%s)", buffer));
continue;
}
/* get all potential attributes */
ptr = end;
EAT_SPACE(ptr);
end = ptr;
while(*end && ('>' != *end))
end++;
if((len.sig = end - ptr) > MAX_TAG_LEN) {
error = GPE_NO_BUFFER_SPACE;
break;
}
memcpy(patt, ptr, len.uns);
patt[len.uns] = '\0';
if(STATE_OUTSIDE == state) {
/* outermost element (<testcase>) */
strcpy(couter, ptag);
state = STATE_OUTER;
continue;
}
else if(STATE_OUTER == state) {
/* start of a main section */
strcpy(cmain, ptag);
state = STATE_INMAIN;
continue;
}
else if(STATE_INMAIN == state) {
/* start of a sub section */
strcpy(csub, ptag);
state = STATE_INSUB;
if(!strcmp(cmain, main) && !strcmp(csub, sub)) {
/* start of wanted part */
in_wanted_part = 1;
if(strstr(patt, "base64="))
/* bit rough test, but "mostly" functional, */
/* treat wanted part data as base64 encoded */
base64 = 1;
}
continue;
}
}
if(in_wanted_part) {
show(("=> %s", buffer));
error = appenddata(outbuf, outlen, &outalloc, buffer, base64);
if(error)
break;
}
} /* while */
if(buffer)
free(buffer);
if(error != GPE_OK) {
if(error == GPE_END_OF_FILE)
error = GPE_OK;
else {
if(*outbuf)
free(*outbuf);
*outbuf = NULL;
*outlen = 0;
}
}
return error;
} | /*
* getpart()
*
* This returns whole contents of specified XML-like section and subsection
* from the given file. This is mostly used to retrieve a specific part from
* a test definition file for consumption by test suite servers.
*
* Data is returned in a dynamically allocated buffer, a pointer to this data
* and the size of the data is stored at the addresses that caller specifies.
*
* If the returned data is a string the returned size will be the length of
* the string excluding null termination. Otherwise it will just be the size
* of the returned binary data.
*
* Calling function is responsible to free returned buffer.
*
* This function may return:
* GPE_NO_BUFFER_SPACE
* GPE_OUT_OF_MEMORY
* GPE_OK
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/server/getpart.c#L231-L420 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | main | int main(int argc, char *argv[])
{
int arg=1;
const char *host = NULL;
int rc = 0;
while(argc>arg) {
if(!strcmp("--version", argv[arg])) {
printf("resolve IPv4%s\n",
#ifdef ENABLE_IPV6
"/IPv6"
#else
""
#endif
);
return 0;
}
else if(!strcmp("--ipv6", argv[arg])) {
ipv_inuse = "IPv6";
use_ipv6 = TRUE;
arg++;
}
else if(!strcmp("--ipv4", argv[arg])) {
/* for completeness, we support this option as well */
ipv_inuse = "IPv4";
use_ipv6 = FALSE;
arg++;
}
else {
host = argv[arg++];
}
}
if(!host) {
puts("Usage: resolve [option] <host>\n"
" --version\n"
" --ipv4"
#ifdef ENABLE_IPV6
"\n --ipv6"
#endif
);
return 1;
}
#ifdef WIN32
win32_init();
atexit(win32_cleanup);
#endif
if(!use_ipv6) {
/* gethostbyname() resolve */
struct hostent *he;
he = gethostbyname(host);
rc = !he;
}
else {
#ifdef ENABLE_IPV6
/* Check that the system has IPv6 enabled before checking the resolver */
curl_socket_t s = socket(PF_INET6, SOCK_DGRAM, 0);
if(s == CURL_SOCKET_BAD)
/* an ipv6 address was requested and we can't get/use one */
rc = -1;
else {
sclose(s);
}
if (rc == 0) {
/* getaddrinfo() resolve */
struct addrinfo *ai;
struct addrinfo hints;
memset(&hints, 0, sizeof(hints));
hints.ai_family = PF_INET6;
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_CANONNAME;
/* Use parenthesis around function to stop it from being replaced by
the macro in memdebug.h */
rc = (getaddrinfo)(host, "80", &hints, &ai);
}
#else
puts("IPv6 support has been disabled in this program");
return 1;
#endif
}
if(rc)
printf("Resolving %s '%s' didn't work\n", ipv_inuse, host);
return !!rc;
} | /* for a util.c function we don't use */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/server/resolve.c#L62-L152 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | exit_signal_handler | static RETSIGTYPE exit_signal_handler(int signum)
{
int old_errno = errno;
if(got_exit_signal == 0) {
got_exit_signal = 1;
exit_signal = signum;
}
(void)signal(signum, exit_signal_handler);
errno = old_errno;
} | /* signal handler that will be triggered to indicate that the program
should finish its execution in a controlled manner as soon as possible.
The first time this is called it will set got_exit_signal to one and
store in exit_signal the signal that triggered its execution. */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/server/rtspd.c#L248-L257 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | storerequest | static void storerequest(char *reqbuf, size_t totalsize)
{
int res;
int error = 0;
size_t written;
size_t writeleft;
FILE *dump;
if (reqbuf == NULL)
return;
if (totalsize == 0)
return;
do {
dump = fopen(REQUEST_DUMP, "ab");
} while ((dump == NULL) && ((error = errno) == EINTR));
if (dump == NULL) {
logmsg("Error opening file %s error: %d %s",
REQUEST_DUMP, error, strerror(error));
logmsg("Failed to write request input to " REQUEST_DUMP);
return;
}
writeleft = totalsize;
do {
written = fwrite(&reqbuf[totalsize-writeleft],
1, writeleft, dump);
if(got_exit_signal)
goto storerequest_cleanup;
if(written > 0)
writeleft -= written;
} while ((writeleft > 0) && ((error = errno) == EINTR));
if(writeleft == 0)
logmsg("Wrote request (%zu bytes) input to " REQUEST_DUMP, totalsize);
else if(writeleft > 0) {
logmsg("Error writing file %s error: %d %s",
REQUEST_DUMP, error, strerror(error));
logmsg("Wrote only (%zu bytes) of (%zu bytes) request input to %s",
totalsize-writeleft, totalsize, REQUEST_DUMP);
}
storerequest_cleanup:
do {
res = fclose(dump);
} while(res && ((error = errno) == EINTR));
if(res)
logmsg("Error closing file %s error: %d %s",
REQUEST_DUMP, error, strerror(error));
} | /* store the entire request in a file */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/server/rtspd.c#L719-L769 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | get_request | static int get_request(curl_socket_t sock, struct httprequest *req)
{
int error;
int fail = 0;
int done_processing = 0;
char *reqbuf = req->reqbuf;
ssize_t got = 0;
char *pipereq = NULL;
size_t pipereq_length = 0;
if(req->pipelining) {
pipereq = reqbuf + req->checkindex;
pipereq_length = req->offset - req->checkindex;
}
/*** Init the httprequest structure properly for the upcoming request ***/
req->checkindex = 0;
req->offset = 0;
req->testno = DOCNUMBER_NOTHING;
req->partno = 0;
req->open = TRUE;
req->auth_req = FALSE;
req->auth = FALSE;
req->cl = 0;
req->digest = FALSE;
req->ntlm = FALSE;
req->pipe = 0;
req->skip = 0;
req->rcmd = RCMD_NORMALREQ;
req->protocol = RPROT_NONE;
req->prot_version = 0;
req->pipelining = FALSE;
req->rtp_buffer = NULL;
req->rtp_buffersize = 0;
/*** end of httprequest init ***/
while(!done_processing && (req->offset < REQBUFSIZ-1)) {
if(pipereq_length && pipereq) {
memmove(reqbuf, pipereq, pipereq_length);
got = curlx_uztosz(pipereq_length);
pipereq_length = 0;
}
else {
if(req->skip)
/* we are instructed to not read the entire thing, so we make sure to only
read what we're supposed to and NOT read the enire thing the client
wants to send! */
got = sread(sock, reqbuf + req->offset, req->cl);
else
got = sread(sock, reqbuf + req->offset, REQBUFSIZ-1 - req->offset);
}
if(got_exit_signal)
return 1;
if(got == 0) {
logmsg("Connection closed by client");
fail = 1;
}
else if(got < 0) {
error = SOCKERRNO;
logmsg("recv() returned error: (%d) %s", error, strerror(error));
fail = 1;
}
if(fail) {
/* dump the request received so far to the external file */
reqbuf[req->offset] = '\0';
storerequest(reqbuf, req->offset);
return 1;
}
logmsg("Read %zd bytes", got);
req->offset += (size_t)got;
reqbuf[req->offset] = '\0';
done_processing = ProcessRequest(req);
if(got_exit_signal)
return 1;
if(done_processing && req->pipe) {
logmsg("Waiting for another piped request");
done_processing = 0;
req->pipe--;
}
}
if((req->offset == REQBUFSIZ-1) && (got > 0)) {
logmsg("Request would overflow buffer, closing connection");
/* dump request received so far to external file anyway */
reqbuf[REQBUFSIZ-1] = '\0';
fail = 1;
}
else if(req->offset > REQBUFSIZ-1) {
logmsg("Request buffer overflow, closing connection");
/* dump request received so far to external file anyway */
reqbuf[REQBUFSIZ-1] = '\0';
fail = 1;
}
else
reqbuf[req->offset] = '\0';
/* dump the request to an external file */
storerequest(reqbuf, req->pipelining ? req->checkindex : req->offset);
if(got_exit_signal)
return 1;
return fail; /* return 0 on success */
} | /* return 0 on success, non-zero on failure */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/server/rtspd.c#L772-L880 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | send_doc | static int send_doc(curl_socket_t sock, struct httprequest *req)
{
ssize_t written;
size_t count;
const char *buffer;
char *ptr=NULL;
FILE *stream;
char *cmd=NULL;
size_t cmdsize=0;
FILE *dump;
bool persistant = TRUE;
bool sendfailure = FALSE;
size_t responsesize;
int error = 0;
int res;
static char weare[256];
char partbuf[80]="data";
logmsg("Send response number %ld part %ld", req->testno, req->partno);
switch(req->rcmd) {
default:
case RCMD_NORMALREQ:
break; /* continue with business as usual */
case RCMD_STREAM:
#define STREAMTHIS "a string to stream 01234567890\n"
count = strlen(STREAMTHIS);
for (;;) {
written = swrite(sock, STREAMTHIS, count);
if(got_exit_signal)
return -1;
if(written != (ssize_t)count) {
logmsg("Stopped streaming");
break;
}
}
return -1;
case RCMD_IDLE:
/* Do nothing. Sit idle. Pretend it rains. */
return 0;
}
req->open = FALSE;
if(req->testno < 0) {
size_t msglen;
char msgbuf[64];
switch(req->testno) {
case DOCNUMBER_QUIT:
logmsg("Replying to QUIT");
buffer = docquit;
break;
case DOCNUMBER_WERULEZ:
/* we got a "friends?" question, reply back that we sure are */
logmsg("Identifying ourselves as friends");
sprintf(msgbuf, "RTSP_SERVER WE ROOLZ: %ld\r\n", (long)getpid());
msglen = strlen(msgbuf);
sprintf(weare, "HTTP/1.1 200 OK\r\nContent-Length: %zu\r\n\r\n%s",
msglen, msgbuf);
buffer = weare;
break;
case DOCNUMBER_INTERNAL:
logmsg("Bailing out due to internal error");
return -1;
case DOCNUMBER_CONNECT:
logmsg("Replying to CONNECT");
buffer = docconnect;
break;
case DOCNUMBER_BADCONNECT:
logmsg("Replying to a bad CONNECT");
buffer = docbadconnect;
break;
case DOCNUMBER_404:
default:
logmsg("Replying to with a 404");
if(req->protocol == RPROT_HTTP) {
buffer = doc404_HTTP;
} else {
buffer = doc404_RTSP;
}
break;
}
count = strlen(buffer);
}
else {
char *filename = test2file(req->testno);
if(0 != req->partno)
sprintf(partbuf, "data%ld", req->partno);
stream=fopen(filename, "rb");
if(!stream) {
error = errno;
logmsg("fopen() failed with error: %d %s", error, strerror(error));
logmsg("Error opening file: %s", filename);
logmsg("Couldn't open test file");
return 0;
}
else {
error = getpart(&ptr, &count, "reply", partbuf, stream);
fclose(stream);
if(error) {
logmsg("getpart() failed with error: %d", error);
return 0;
}
buffer = ptr;
}
if(got_exit_signal) {
if(ptr)
free(ptr);
return -1;
}
/* re-open the same file again */
stream=fopen(filename, "rb");
if(!stream) {
error = errno;
logmsg("fopen() failed with error: %d %s", error, strerror(error));
logmsg("Error opening file: %s", filename);
logmsg("Couldn't open test file");
if(ptr)
free(ptr);
return 0;
}
else {
/* get the custom server control "commands" */
error = getpart(&cmd, &cmdsize, "reply", "postcmd", stream);
fclose(stream);
if(error) {
logmsg("getpart() failed with error: %d", error);
if(ptr)
free(ptr);
return 0;
}
}
}
if(got_exit_signal) {
if(ptr)
free(ptr);
if(cmd)
free(cmd);
return -1;
}
/* If the word 'swsclose' is present anywhere in the reply chunk, the
connection will be closed after the data has been sent to the requesting
client... */
if(strstr(buffer, "swsclose") || !count) {
persistant = FALSE;
logmsg("connection close instruction \"swsclose\" found in response");
}
if(strstr(buffer, "swsbounce")) {
prevbounce = TRUE;
logmsg("enable \"swsbounce\" in the next request");
}
else
prevbounce = FALSE;
dump = fopen(RESPONSE_DUMP, "ab");
if(!dump) {
error = errno;
logmsg("fopen() failed with error: %d %s", error, strerror(error));
logmsg("Error opening file: %s", RESPONSE_DUMP);
logmsg("couldn't create logfile: " RESPONSE_DUMP);
if(ptr)
free(ptr);
if(cmd)
free(cmd);
return -1;
}
responsesize = count;
do {
/* Ok, we send no more than 200 bytes at a time, just to make sure that
larger chunks are split up so that the client will need to do multiple
recv() calls to get it and thus we exercise that code better */
size_t num = count;
if(num > 200)
num = 200;
written = swrite(sock, buffer, num);
if (written < 0) {
sendfailure = TRUE;
break;
}
else {
logmsg("Sent off %zd bytes", written);
}
/* write to file as well */
fwrite(buffer, 1, (size_t)written, dump);
if(got_exit_signal)
break;
count -= written;
buffer += written;
} while(count>0);
/* Send out any RTP data */
if(req->rtp_buffer) {
logmsg("About to write %zu RTP bytes", req->rtp_buffersize);
count = req->rtp_buffersize;
do {
size_t num = count;
if(num > 200)
num = 200;
written = swrite(sock, req->rtp_buffer + (req->rtp_buffersize - count), num);
if(written < 0) {
sendfailure = TRUE;
break;
}
count -= written;
} while(count > 0);
free(req->rtp_buffer);
req->rtp_buffersize = 0;
}
do {
res = fclose(dump);
} while(res && ((error = errno) == EINTR));
if(res)
logmsg("Error closing file %s error: %d %s",
RESPONSE_DUMP, error, strerror(error));
if(got_exit_signal) {
if(ptr)
free(ptr);
if(cmd)
free(cmd);
return -1;
}
if(sendfailure) {
logmsg("Sending response failed. Only (%zu bytes) of (%zu bytes) were sent",
responsesize-count, responsesize);
if(ptr)
free(ptr);
if(cmd)
free(cmd);
return -1;
}
logmsg("Response sent (%zu bytes) and written to " RESPONSE_DUMP,
responsesize);
if(ptr)
free(ptr);
if(cmdsize > 0 ) {
char command[32];
int quarters;
int num;
ptr=cmd;
do {
if(2 == sscanf(ptr, "%31s %d", command, &num)) {
if(!strcmp("wait", command)) {
logmsg("Told to sleep for %d seconds", num);
quarters = num * 4;
while(quarters > 0) {
quarters--;
res = wait_ms(250);
if(got_exit_signal)
break;
if(res) {
/* should not happen */
error = errno;
logmsg("wait_ms() failed with error: (%d) %s",
error, strerror(error));
break;
}
}
if(!quarters)
logmsg("Continuing after sleeping %d seconds", num);
}
else
logmsg("Unknown command in reply command section");
}
ptr = strchr(ptr, '\n');
if(ptr)
ptr++;
else
ptr = NULL;
} while(ptr && *ptr);
}
if(cmd)
free(cmd);
req->open = persistant;
prevtestno = req->testno;
prevpartno = req->partno;
return 0;
} | /* returns -1 on failure */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/server/rtspd.c#L883-L1181 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | exit_signal_handler | static RETSIGTYPE exit_signal_handler(int signum)
{
int old_errno = errno;
if(got_exit_signal == 0) {
got_exit_signal = 1;
exit_signal = signum;
}
(void)signal(signum, exit_signal_handler);
errno = old_errno;
} | /* signal handler that will be triggered to indicate that the program
should finish its execution in a controlled manner as soon as possible.
The first time this is called it will set got_exit_signal to one and
store in exit_signal the signal that triggered its execution. */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/server/sockfilt.c#L194-L203 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | fullread | static ssize_t fullread(int filedes, void *buffer, size_t nbytes)
{
int error;
ssize_t rc;
ssize_t nread = 0;
do {
rc = read(filedes, (unsigned char *)buffer + nread, nbytes - nread);
if(got_exit_signal) {
logmsg("signalled to die");
return -1;
}
if(rc < 0) {
error = errno;
if((error == EINTR) || (error == EAGAIN))
continue;
logmsg("reading from file descriptor: %d,", filedes);
logmsg("unrecoverable read() failure: (%d) %s",
error, strerror(error));
return -1;
}
if(rc == 0) {
logmsg("got 0 reading from stdin");
return 0;
}
nread += rc;
} while((size_t)nread < nbytes);
if(verbose)
logmsg("read %zd bytes", nread);
return nread;
} | /*
* fullread is a wrapper around the read() function. This will repeat the call
* to read() until it actually has read the complete number of bytes indicated
* in nbytes or it fails with a condition that cannot be handled with a simple
* retry of the read call.
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/server/sockfilt.c#L280-L317 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | fullwrite | static ssize_t fullwrite(int filedes, const void *buffer, size_t nbytes)
{
int error;
ssize_t wc;
ssize_t nwrite = 0;
do {
wc = write(filedes, (unsigned char *)buffer + nwrite, nbytes - nwrite);
if(got_exit_signal) {
logmsg("signalled to die");
return -1;
}
if(wc < 0) {
error = errno;
if((error == EINTR) || (error == EAGAIN))
continue;
logmsg("writing to file descriptor: %d,", filedes);
logmsg("unrecoverable write() failure: (%d) %s",
error, strerror(error));
return -1;
}
if(wc == 0) {
logmsg("put 0 writing to stdout");
return 0;
}
nwrite += wc;
} while((size_t)nwrite < nbytes);
if(verbose)
logmsg("wrote %zd bytes", nwrite);
return nwrite;
} | /*
* fullwrite is a wrapper around the write() function. This will repeat the
* call to write() until it actually has written the complete number of bytes
* indicated in nbytes or it fails with a condition that cannot be handled
* with a simple retry of the write call.
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/server/sockfilt.c#L326-L363 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | read_stdin | static bool read_stdin(void *buffer, size_t nbytes)
{
ssize_t nread = fullread(fileno(stdin), buffer, nbytes);
if(nread != (ssize_t)nbytes) {
logmsg("exiting...");
return FALSE;
}
return TRUE;
} | /*
* read_stdin tries to read from stdin nbytes into the given buffer. This is a
* blocking function that will only return TRUE when nbytes have actually been
* read or FALSE when an unrecoverable error has been detected. Failure of this
* function is an indication that the sockfilt process should terminate.
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/server/sockfilt.c#L372-L380 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | write_stdout | static bool write_stdout(const void *buffer, size_t nbytes)
{
ssize_t nwrite = fullwrite(fileno(stdout), buffer, nbytes);
if(nwrite != (ssize_t)nbytes) {
logmsg("exiting...");
return FALSE;
}
return TRUE;
} | /*
* write_stdout tries to write to stdio nbytes from the given buffer. This is a
* blocking function that will only return TRUE when nbytes have actually been
* written or FALSE when an unrecoverable error has been detected. Failure of
* this function is an indication that the sockfilt process should terminate.
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/server/sockfilt.c#L389-L397 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | select_ws | static int select_ws(int nfds, fd_set *readfds, fd_set *writefds,
fd_set *exceptfds, struct timeval *timeout)
{
long networkevents;
DWORD milliseconds, wait, idx, avail, events, inputs;
WSAEVENT wsaevent, *wsaevents;
WSANETWORKEVENTS wsanetevents;
INPUT_RECORD *inputrecords;
HANDLE handle, *handles;
curl_socket_t sock, *fdarr, *wsasocks;
int error, fds;
DWORD nfd = 0, wsa = 0;
int ret = 0;
/* check if the input value is valid */
if(nfds < 0) {
errno = EINVAL;
return -1;
}
/* check if we got descriptors, sleep in case we got none */
if(!nfds) {
Sleep((timeout->tv_sec * 1000) + (timeout->tv_usec / 1000));
return 0;
}
/* allocate internal array for the original input handles */
fdarr = malloc(nfds * sizeof(curl_socket_t));
if(fdarr == NULL) {
errno = ENOMEM;
return -1;
}
/* allocate internal array for the internal event handles */
handles = malloc(nfds * sizeof(HANDLE));
if(handles == NULL) {
errno = ENOMEM;
return -1;
}
/* allocate internal array for the internal socket handles */
wsasocks = malloc(nfds * sizeof(curl_socket_t));
if(wsasocks == NULL) {
errno = ENOMEM;
return -1;
}
/* allocate internal array for the internal WINSOCK2 events */
wsaevents = malloc(nfds * sizeof(WSAEVENT));
if(wsaevents == NULL) {
errno = ENOMEM;
return -1;
}
/* loop over the handles in the input descriptor sets */
for(fds = 0; fds < nfds; fds++) {
networkevents = 0;
handles[nfd] = 0;
if(FD_ISSET(fds, readfds))
networkevents |= FD_READ|FD_ACCEPT|FD_CLOSE;
if(FD_ISSET(fds, writefds))
networkevents |= FD_WRITE|FD_CONNECT;
if(FD_ISSET(fds, exceptfds))
networkevents |= FD_OOB;
/* only wait for events for which we actually care */
if(networkevents) {
fdarr[nfd] = curlx_sitosk(fds);
if(fds == fileno(stdin)) {
handles[nfd] = GetStdHandle(STD_INPUT_HANDLE);
}
else if(fds == fileno(stdout)) {
handles[nfd] = GetStdHandle(STD_OUTPUT_HANDLE);
}
else if(fds == fileno(stderr)) {
handles[nfd] = GetStdHandle(STD_ERROR_HANDLE);
}
else {
wsaevent = WSACreateEvent();
if(wsaevent != WSA_INVALID_EVENT) {
error = WSAEventSelect(fds, wsaevent, networkevents);
if(error != SOCKET_ERROR) {
handles[nfd] = wsaevent;
wsasocks[wsa] = curlx_sitosk(fds);
wsaevents[wsa] = wsaevent;
wsa++;
}
else {
handles[nfd] = (HANDLE) curlx_sitosk(fds);
WSACloseEvent(wsaevent);
}
}
}
nfd++;
}
}
/* convert struct timeval to milliseconds */
if(timeout) {
milliseconds = ((timeout->tv_sec * 1000) + (timeout->tv_usec / 1000));
}
else {
milliseconds = INFINITE;
}
/* wait for one of the internal handles to trigger */
wait = WaitForMultipleObjectsEx(nfd, handles, FALSE, milliseconds, FALSE);
/* loop over the internal handles returned in the descriptors */
for(idx = 0; idx < nfd; idx++) {
handle = handles[idx];
sock = fdarr[idx];
fds = curlx_sktosi(sock);
/* check if the current internal handle was triggered */
if(wait != WAIT_FAILED && (wait - WAIT_OBJECT_0) >= idx &&
WaitForSingleObjectEx(handle, 0, FALSE) == WAIT_OBJECT_0) {
/* try to handle the event with STD* handle functions */
if(fds == fileno(stdin)) {
/* check if there is no data in the input buffer */
if(!stdin->_cnt) {
/* check if we are getting data from a PIPE */
if(!GetConsoleMode(handle, &avail)) {
/* check if there is no data from PIPE input */
if(!PeekNamedPipe(handle, NULL, 0, NULL, &avail, NULL))
avail = 0;
if(!avail)
FD_CLR(sock, readfds);
} /* check if there is no data from keyboard input */
else if (!_kbhit()) {
/* check if there are INPUT_RECORDs in the input buffer */
if(GetNumberOfConsoleInputEvents(handle, &events)) {
if(events > 0) {
/* remove INPUT_RECORDs from the input buffer */
inputrecords = (INPUT_RECORD*)malloc(events *
sizeof(INPUT_RECORD));
if(inputrecords) {
if(!ReadConsoleInput(handle, inputrecords,
events, &inputs))
inputs = 0;
free(inputrecords);
}
/* check if we got all inputs, otherwise clear buffer */
if(events != inputs)
FlushConsoleInputBuffer(handle);
}
}
/* remove from descriptor set since there is no real data */
FD_CLR(sock, readfds);
}
}
/* stdin is never ready for write or exceptional */
FD_CLR(sock, writefds);
FD_CLR(sock, exceptfds);
}
else if(fds == fileno(stdout) || fds == fileno(stderr)) {
/* stdout and stderr are never ready for read or exceptional */
FD_CLR(sock, readfds);
FD_CLR(sock, exceptfds);
}
else {
/* try to handle the event with the WINSOCK2 functions */
error = WSAEnumNetworkEvents(fds, NULL, &wsanetevents);
if(error != SOCKET_ERROR) {
/* remove from descriptor set if not ready for read/accept/close */
if(!(wsanetevents.lNetworkEvents & (FD_READ|FD_ACCEPT|FD_CLOSE)))
FD_CLR(sock, readfds);
/* remove from descriptor set if not ready for write/connect */
if(!(wsanetevents.lNetworkEvents & (FD_WRITE|FD_CONNECT)))
FD_CLR(sock, writefds);
/* remove from descriptor set if not exceptional */
if(!(wsanetevents.lNetworkEvents & FD_OOB))
FD_CLR(sock, exceptfds);
}
}
/* check if the event has not been filtered using specific tests */
if(FD_ISSET(sock, readfds) || FD_ISSET(sock, writefds) ||
FD_ISSET(sock, exceptfds)) {
ret++;
}
}
else {
/* remove from all descriptor sets since this handle did not trigger */
FD_CLR(sock, readfds);
FD_CLR(sock, writefds);
FD_CLR(sock, exceptfds);
}
}
for(idx = 0; idx < wsa; idx++) {
WSAEventSelect(wsasocks[idx], NULL, 0);
WSACloseEvent(wsaevents[idx]);
}
free(wsaevents);
free(wsasocks);
free(handles);
free(fdarr);
return ret;
} | /*
* WinSock select() does not support standard file descriptors,
* it can only check SOCKETs. The following function is an attempt
* to re-create a select() function with support for other handle types.
*
* select() function with support for WINSOCK2 sockets and all
* other handle types supported by WaitForMultipleObjectsEx().
*
* TODO: Differentiate between read/write/except for non-SOCKET handles.
*
* http://msdn.microsoft.com/en-us/library/windows/desktop/ms687028.aspx
* http://msdn.microsoft.com/en-us/library/windows/desktop/ms741572.aspx
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/server/sockfilt.c#L450-L659 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | juggle | static bool juggle(curl_socket_t *sockfdp,
curl_socket_t listenfd,
enum sockmode *mode)
{
struct timeval timeout;
fd_set fds_read;
fd_set fds_write;
fd_set fds_err;
curl_socket_t sockfd = CURL_SOCKET_BAD;
int maxfd = -99;
ssize_t rc;
ssize_t nread_socket;
ssize_t bytes_written;
ssize_t buffer_len;
int error = 0;
/* 'buffer' is this excessively large only to be able to support things like
test 1003 which tests exceedingly large server response lines */
unsigned char buffer[17010];
char data[16];
if(got_exit_signal) {
logmsg("signalled to die, exiting...");
return FALSE;
}
#ifdef HAVE_GETPPID
/* As a last resort, quit if sockfilt process becomes orphan. Just in case
parent ftpserver process has died without killing its sockfilt children */
if(getppid() <= 1) {
logmsg("process becomes orphan, exiting");
return FALSE;
}
#endif
timeout.tv_sec = 120;
timeout.tv_usec = 0;
FD_ZERO(&fds_read);
FD_ZERO(&fds_write);
FD_ZERO(&fds_err);
FD_SET((curl_socket_t)fileno(stdin), &fds_read);
switch(*mode) {
case PASSIVE_LISTEN:
/* server mode */
sockfd = listenfd;
/* there's always a socket to wait for */
FD_SET(sockfd, &fds_read);
maxfd = (int)sockfd;
break;
case PASSIVE_CONNECT:
sockfd = *sockfdp;
if(CURL_SOCKET_BAD == sockfd) {
/* eeek, we are supposedly connected and then this cannot be -1 ! */
logmsg("socket is -1! on %s:%d", __FILE__, __LINE__);
maxfd = 0; /* stdin */
}
else {
/* there's always a socket to wait for */
FD_SET(sockfd, &fds_read);
maxfd = (int)sockfd;
}
break;
case ACTIVE:
sockfd = *sockfdp;
/* sockfd turns CURL_SOCKET_BAD when our connection has been closed */
if(CURL_SOCKET_BAD != sockfd) {
FD_SET(sockfd, &fds_read);
maxfd = (int)sockfd;
}
else {
logmsg("No socket to read on");
maxfd = 0;
}
break;
case ACTIVE_DISCONNECT:
logmsg("disconnected, no socket to read on");
maxfd = 0;
sockfd = CURL_SOCKET_BAD;
break;
} /* switch(*mode) */
do {
/* select() blocking behavior call on blocking descriptors please */
rc = select(maxfd + 1, &fds_read, &fds_write, &fds_err, &timeout);
if(got_exit_signal) {
logmsg("signalled to die, exiting...");
return FALSE;
}
} while((rc == -1) && ((error = errno) == EINTR));
if(rc < 0) {
logmsg("select() failed with error: (%d) %s",
error, strerror(error));
return FALSE;
}
if(rc == 0)
/* timeout */
return TRUE;
if(FD_ISSET(fileno(stdin), &fds_read)) {
/* read from stdin, commands/data to be dealt with and possibly passed on
to the socket
protocol:
4 letter command + LF [mandatory]
4-digit hexadecimal data length + LF [if the command takes data]
data [the data being as long as set above]
Commands:
DATA - plain pass-thru data
*/
if(!read_stdin(buffer, 5))
return FALSE;
logmsg("Received %c%c%c%c (on stdin)",
buffer[0], buffer[1], buffer[2], buffer[3] );
if(!memcmp("PING", buffer, 4)) {
/* send reply on stdout, just proving we are alive */
if(!write_stdout("PONG\n", 5))
return FALSE;
}
else if(!memcmp("PORT", buffer, 4)) {
/* Question asking us what PORT number we are listening to.
Replies to PORT with "IPv[num]/[port]" */
sprintf((char *)buffer, "%s/%hu\n", ipv_inuse, port);
buffer_len = (ssize_t)strlen((char *)buffer);
snprintf(data, sizeof(data), "PORT\n%04zx\n", buffer_len);
if(!write_stdout(data, 10))
return FALSE;
if(!write_stdout(buffer, buffer_len))
return FALSE;
}
else if(!memcmp("QUIT", buffer, 4)) {
/* just die */
logmsg("quits");
return FALSE;
}
else if(!memcmp("DATA", buffer, 4)) {
/* data IN => data OUT */
if(!read_stdin(buffer, 5))
return FALSE;
buffer[5] = '\0';
buffer_len = (ssize_t)strtol((char *)buffer, NULL, 16);
if (buffer_len > (ssize_t)sizeof(buffer)) {
logmsg("ERROR: Buffer size (%zu bytes) too small for data size "
"(%zd bytes)", sizeof(buffer), buffer_len);
return FALSE;
}
logmsg("> %zd bytes data, server => client", buffer_len);
if(!read_stdin(buffer, buffer_len))
return FALSE;
lograw(buffer, buffer_len);
if(*mode == PASSIVE_LISTEN) {
logmsg("*** We are disconnected!");
if(!write_stdout("DISC\n", 5))
return FALSE;
}
else {
/* send away on the socket */
bytes_written = swrite(sockfd, buffer, buffer_len);
if(bytes_written != buffer_len) {
logmsg("Not all data was sent. Bytes to send: %zd sent: %zd",
buffer_len, bytes_written);
}
}
}
else if(!memcmp("DISC", buffer, 4)) {
/* disconnect! */
if(!write_stdout("DISC\n", 5))
return FALSE;
if(sockfd != CURL_SOCKET_BAD) {
logmsg("====> Client forcibly disconnected");
sclose(sockfd);
*sockfdp = CURL_SOCKET_BAD;
if(*mode == PASSIVE_CONNECT)
*mode = PASSIVE_LISTEN;
else
*mode = ACTIVE_DISCONNECT;
}
else
logmsg("attempt to close already dead connection");
return TRUE;
}
}
if((sockfd != CURL_SOCKET_BAD) && (FD_ISSET(sockfd, &fds_read)) ) {
curl_socket_t newfd = CURL_SOCKET_BAD; /* newly accepted socket */
if(*mode == PASSIVE_LISTEN) {
/* there's no stream set up yet, this is an indication that there's a
client connecting. */
newfd = accept(sockfd, NULL, NULL);
if(CURL_SOCKET_BAD == newfd) {
error = SOCKERRNO;
logmsg("accept(%d, NULL, NULL) failed with error: (%d) %s",
sockfd, error, strerror(error));
}
else {
logmsg("====> Client connect");
if(!write_stdout("CNCT\n", 5))
return FALSE;
*sockfdp = newfd; /* store the new socket */
*mode = PASSIVE_CONNECT; /* we have connected */
}
return TRUE;
}
/* read from socket, pass on data to stdout */
nread_socket = sread(sockfd, buffer, sizeof(buffer));
if(nread_socket <= 0) {
logmsg("====> Client disconnect");
if(!write_stdout("DISC\n", 5))
return FALSE;
sclose(sockfd);
*sockfdp = CURL_SOCKET_BAD;
if(*mode == PASSIVE_CONNECT)
*mode = PASSIVE_LISTEN;
else
*mode = ACTIVE_DISCONNECT;
return TRUE;
}
snprintf(data, sizeof(data), "DATA\n%04zx\n", nread_socket);
if(!write_stdout(data, 10))
return FALSE;
if(!write_stdout(buffer, nread_socket))
return FALSE;
logmsg("< %zd bytes data, client => server", nread_socket);
lograw(buffer, nread_socket);
}
return TRUE;
} | /* USE_WINSOCK */
/*
sockfdp is a pointer to an established stream or CURL_SOCKET_BAD
if sockfd is CURL_SOCKET_BAD, listendfd is a listening socket we must
accept()
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/server/sockfilt.c#L669-L936 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | exit_signal_handler | static RETSIGTYPE exit_signal_handler(int signum)
{
int old_errno = errno;
if(got_exit_signal == 0) {
got_exit_signal = 1;
exit_signal = signum;
}
(void)signal(signum, exit_signal_handler);
errno = old_errno;
} | /* signal handler that will be triggered to indicate that the program
should finish its execution in a controlled manner as soon as possible.
The first time this is called it will set got_exit_signal to one and
store in exit_signal the signal that triggered its execution. */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/server/sws.c#L253-L262 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | parse_servercmd | static int parse_servercmd(struct httprequest *req)
{
FILE *stream;
char *filename;
int error;
filename = test2file(req->testno);
stream=fopen(filename, "rb");
if(!stream) {
error = errno;
logmsg("fopen() failed with error: %d %s", error, strerror(error));
logmsg("Error opening file: %s", filename);
logmsg("Couldn't open test file %ld", req->testno);
req->open = FALSE; /* closes connection */
return 1; /* done */
}
else {
char *orgcmd = NULL;
char *cmd = NULL;
size_t cmdsize = 0;
int num=0;
/* get the custom server control "commands" */
error = getpart(&orgcmd, &cmdsize, "reply", "servercmd", stream);
fclose(stream);
if(error) {
logmsg("getpart() failed with error: %d", error);
req->open = FALSE; /* closes connection */
return 1; /* done */
}
req->connmon = FALSE;
cmd = orgcmd;
while(cmd && cmdsize) {
char *check;
if(!strncmp(CMD_AUTH_REQUIRED, cmd, strlen(CMD_AUTH_REQUIRED))) {
logmsg("instructed to require authorization header");
req->auth_req = TRUE;
}
else if(!strncmp(CMD_IDLE, cmd, strlen(CMD_IDLE))) {
logmsg("instructed to idle");
req->rcmd = RCMD_IDLE;
req->open = TRUE;
}
else if(!strncmp(CMD_STREAM, cmd, strlen(CMD_STREAM))) {
logmsg("instructed to stream");
req->rcmd = RCMD_STREAM;
}
else if(!strncmp(CMD_CONNECTIONMONITOR, cmd,
strlen(CMD_CONNECTIONMONITOR))) {
logmsg("enabled connection monitoring");
req->connmon = TRUE;
}
else if(1 == sscanf(cmd, "pipe: %d", &num)) {
logmsg("instructed to allow a pipe size of %d", num);
if(num < 0)
logmsg("negative pipe size ignored");
else if(num > 0)
req->pipe = num-1; /* decrease by one since we don't count the
first request in this number */
}
else if(1 == sscanf(cmd, "skip: %d", &num)) {
logmsg("instructed to skip this number of bytes %d", num);
req->skip = num;
}
else if(1 == sscanf(cmd, "writedelay: %d", &num)) {
logmsg("instructed to delay %d secs between packets", num);
req->writedelay = num;
}
else {
logmsg("Unknown <servercmd> instruction found: %s", cmd);
}
/* try to deal with CRLF or just LF */
check = strchr(cmd, '\r');
if(!check)
check = strchr(cmd, '\n');
if(check) {
/* get to the letter following the newline */
while((*check == '\r') || (*check == '\n'))
check++;
if(!*check)
/* if we reached a zero, get out */
break;
cmd = check;
}
else
break;
}
if(orgcmd)
free(orgcmd);
}
return 0; /* OK! */
} | /* based on the testno, parse the correct server commands */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/server/sws.c#L333-L431 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | storerequest | static void storerequest(char *reqbuf, size_t totalsize)
{
int res;
int error = 0;
size_t written;
size_t writeleft;
FILE *dump;
const char *dumpfile=is_proxy?REQUEST_PROXY_DUMP:REQUEST_DUMP;
if (reqbuf == NULL)
return;
if (totalsize == 0)
return;
do {
dump = fopen(dumpfile, "ab");
} while ((dump == NULL) && ((error = errno) == EINTR));
if (dump == NULL) {
logmsg("Error opening file %s error: %d %s",
dumpfile, error, strerror(error));
logmsg("Failed to write request input ");
return;
}
writeleft = totalsize;
do {
written = fwrite(&reqbuf[totalsize-writeleft],
1, writeleft, dump);
if(got_exit_signal)
goto storerequest_cleanup;
if(written > 0)
writeleft -= written;
} while ((writeleft > 0) && ((error = errno) == EINTR));
if(writeleft == 0)
logmsg("Wrote request (%zu bytes) input to %s", totalsize, dumpfile);
else if(writeleft > 0) {
logmsg("Error writing file %s error: %d %s",
dumpfile, error, strerror(error));
logmsg("Wrote only (%zu bytes) of (%zu bytes) request input to %s",
totalsize-writeleft, totalsize, dumpfile);
}
storerequest_cleanup:
do {
res = fclose(dump);
} while(res && ((error = errno) == EINTR));
if(res)
logmsg("Error closing file %s error: %d %s",
dumpfile, error, strerror(error));
} | /* store the entire request in a file */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/server/sws.c#L767-L818 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | get_request | static int get_request(curl_socket_t sock, struct httprequest *req)
{
int error;
int fail = 0;
char *reqbuf = req->reqbuf;
ssize_t got = 0;
int overflow = 0;
char *pipereq = NULL;
size_t pipereq_length = 0;
if(req->pipelining) {
pipereq = reqbuf + req->checkindex;
pipereq_length = req->offset - req->checkindex;
/* Now that we've got the pipelining info we can reset the
pipelining-related vars which were skipped in init_httprequest */
req->pipelining = FALSE;
req->checkindex = 0;
req->offset = 0;
}
if(req->offset >= REQBUFSIZ-1) {
/* buffer is already full; do nothing */
overflow = 1;
}
else {
if(pipereq_length && pipereq) {
memmove(reqbuf, pipereq, pipereq_length);
got = curlx_uztosz(pipereq_length);
pipereq_length = 0;
}
else {
if(req->skip)
/* we are instructed to not read the entire thing, so we make sure to
only read what we're supposed to and NOT read the enire thing the
client wants to send! */
got = sread(sock, reqbuf + req->offset, req->cl);
else
got = sread(sock, reqbuf + req->offset, REQBUFSIZ-1 - req->offset);
}
if(got_exit_signal)
return -1;
if(got == 0) {
logmsg("Connection closed by client");
fail = 1;
}
else if(got < 0) {
error = SOCKERRNO;
if (EAGAIN == error || EWOULDBLOCK == error) {
/* nothing to read at the moment */
return 0;
}
logmsg("recv() returned error: (%d) %s", error, strerror(error));
fail = 1;
}
if(fail) {
/* dump the request received so far to the external file */
reqbuf[req->offset] = '\0';
storerequest(reqbuf, req->offset);
return -1;
}
logmsg("Read %zd bytes", got);
req->offset += (size_t)got;
reqbuf[req->offset] = '\0';
req->done_processing = ProcessRequest(req);
if(got_exit_signal)
return -1;
if(req->done_processing && req->pipe) {
logmsg("Waiting for another piped request");
req->done_processing = 0;
req->pipe--;
}
}
if(overflow || (req->offset == REQBUFSIZ-1 && got > 0)) {
logmsg("Request would overflow buffer, closing connection");
/* dump request received so far to external file anyway */
reqbuf[REQBUFSIZ-1] = '\0';
fail = 1;
}
else if(req->offset > REQBUFSIZ-1) {
logmsg("Request buffer overflow, closing connection");
/* dump request received so far to external file anyway */
reqbuf[REQBUFSIZ-1] = '\0';
fail = 1;
}
else
reqbuf[req->offset] = '\0';
/* at the end of a request dump it to an external file */
if (fail || req->done_processing)
storerequest(reqbuf, req->pipelining ? req->checkindex : req->offset);
if(got_exit_signal)
return -1;
return fail ? -1 : 1;
} | /* returns 1 if the connection should be serviced again immediately, 0 if there
is no data waiting, or < 0 if it should be closed */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/server/sws.c#L849-L949 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | send_doc | static int send_doc(curl_socket_t sock, struct httprequest *req)
{
ssize_t written;
size_t count;
const char *buffer;
char *ptr=NULL;
FILE *stream;
char *cmd=NULL;
size_t cmdsize=0;
FILE *dump;
bool persistant = TRUE;
bool sendfailure = FALSE;
size_t responsesize;
int error = 0;
int res;
const char *responsedump = is_proxy?RESPONSE_PROXY_DUMP:RESPONSE_DUMP;
static char weare[256];
char partbuf[80]="data";
logmsg("Send response test%ld section <data%ld>", req->testno, req->partno);
switch(req->rcmd) {
default:
case RCMD_NORMALREQ:
break; /* continue with business as usual */
case RCMD_STREAM:
#define STREAMTHIS "a string to stream 01234567890\n"
count = strlen(STREAMTHIS);
for (;;) {
written = swrite(sock, STREAMTHIS, count);
if(got_exit_signal)
return -1;
if(written != (ssize_t)count) {
logmsg("Stopped streaming");
break;
}
}
return -1;
case RCMD_IDLE:
/* Do nothing. Sit idle. Pretend it rains. */
return 0;
}
req->open = FALSE;
if(req->testno < 0) {
size_t msglen;
char msgbuf[64];
switch(req->testno) {
case DOCNUMBER_QUIT:
logmsg("Replying to QUIT");
buffer = docquit;
break;
case DOCNUMBER_WERULEZ:
/* we got a "friends?" question, reply back that we sure are */
logmsg("Identifying ourselves as friends");
sprintf(msgbuf, "WE ROOLZ: %ld\r\n", (long)getpid());
msglen = strlen(msgbuf);
if(use_gopher)
sprintf(weare, "%s", msgbuf);
else
sprintf(weare, "HTTP/1.1 200 OK\r\nContent-Length: %zu\r\n\r\n%s",
msglen, msgbuf);
buffer = weare;
break;
case DOCNUMBER_INTERNAL:
logmsg("Bailing out due to internal error");
return -1;
case DOCNUMBER_CONNECT:
logmsg("Replying to CONNECT");
buffer = docconnect;
break;
case DOCNUMBER_BADCONNECT:
logmsg("Replying to a bad CONNECT");
buffer = docbadconnect;
break;
case DOCNUMBER_404:
default:
logmsg("Replying to with a 404");
buffer = doc404;
break;
}
count = strlen(buffer);
}
else {
char *filename = test2file(req->testno);
if(0 != req->partno)
sprintf(partbuf, "data%ld", req->partno);
stream=fopen(filename, "rb");
if(!stream) {
error = errno;
logmsg("fopen() failed with error: %d %s", error, strerror(error));
logmsg("Error opening file: %s", filename);
logmsg("Couldn't open test file");
return 0;
}
else {
error = getpart(&ptr, &count, "reply", partbuf, stream);
fclose(stream);
if(error) {
logmsg("getpart() failed with error: %d", error);
return 0;
}
buffer = ptr;
}
if(got_exit_signal) {
if(ptr)
free(ptr);
return -1;
}
/* re-open the same file again */
stream=fopen(filename, "rb");
if(!stream) {
error = errno;
logmsg("fopen() failed with error: %d %s", error, strerror(error));
logmsg("Error opening file: %s", filename);
logmsg("Couldn't open test file");
if(ptr)
free(ptr);
return 0;
}
else {
/* get the custom server control "commands" */
error = getpart(&cmd, &cmdsize, "reply", "postcmd", stream);
fclose(stream);
if(error) {
logmsg("getpart() failed with error: %d", error);
if(ptr)
free(ptr);
return 0;
}
}
}
if(got_exit_signal) {
if(ptr)
free(ptr);
if(cmd)
free(cmd);
return -1;
}
/* If the word 'swsclose' is present anywhere in the reply chunk, the
connection will be closed after the data has been sent to the requesting
client... */
if(strstr(buffer, "swsclose") || !count) {
persistant = FALSE;
logmsg("connection close instruction \"swsclose\" found in response");
}
if(strstr(buffer, "swsbounce")) {
prevbounce = TRUE;
logmsg("enable \"swsbounce\" in the next request");
}
else
prevbounce = FALSE;
dump = fopen(responsedump, "ab");
if(!dump) {
error = errno;
logmsg("fopen() failed with error: %d %s", error, strerror(error));
logmsg("Error opening file: %s", responsedump);
if(ptr)
free(ptr);
if(cmd)
free(cmd);
return -1;
}
responsesize = count;
do {
/* Ok, we send no more than 200 bytes at a time, just to make sure that
larger chunks are split up so that the client will need to do multiple
recv() calls to get it and thus we exercise that code better */
size_t num = count;
if(num > 200)
num = 200;
written = swrite(sock, buffer, num);
if (written < 0) {
sendfailure = TRUE;
break;
}
else {
logmsg("Sent off %zd bytes", written);
}
/* write to file as well */
fwrite(buffer, 1, (size_t)written, dump);
count -= written;
buffer += written;
if(req->writedelay) {
int quarters = req->writedelay * 4;
logmsg("Pausing %d seconds", req->writedelay);
while((quarters > 0) && !got_exit_signal) {
quarters--;
wait_ms(250);
}
}
} while((count > 0) && !got_exit_signal);
do {
res = fclose(dump);
} while(res && ((error = errno) == EINTR));
if(res)
logmsg("Error closing file %s error: %d %s",
responsedump, error, strerror(error));
if(got_exit_signal) {
if(ptr)
free(ptr);
if(cmd)
free(cmd);
return -1;
}
if(sendfailure) {
logmsg("Sending response failed. Only (%zu bytes) of (%zu bytes) were sent",
responsesize-count, responsesize);
if(ptr)
free(ptr);
if(cmd)
free(cmd);
return -1;
}
logmsg("Response sent (%zu bytes) and written to %s",
responsesize, responsedump);
if(ptr)
free(ptr);
if(cmdsize > 0 ) {
char command[32];
int quarters;
int num;
ptr=cmd;
do {
if(2 == sscanf(ptr, "%31s %d", command, &num)) {
if(!strcmp("wait", command)) {
logmsg("Told to sleep for %d seconds", num);
quarters = num * 4;
while((quarters > 0) && !got_exit_signal) {
quarters--;
res = wait_ms(250);
if(res) {
/* should not happen */
error = errno;
logmsg("wait_ms() failed with error: (%d) %s",
error, strerror(error));
break;
}
}
if(!quarters)
logmsg("Continuing after sleeping %d seconds", num);
}
else
logmsg("Unknown command in reply command section");
}
ptr = strchr(ptr, '\n');
if(ptr)
ptr++;
else
ptr = NULL;
} while(ptr && *ptr);
}
if(cmd)
free(cmd);
req->open = use_gopher?FALSE:persistant;
prevtestno = req->testno;
prevpartno = req->partno;
return 0;
} | /* returns -1 on failure */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/server/sws.c#L952-L1233 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | accept_connection | static curl_socket_t accept_connection(curl_socket_t sock)
{
curl_socket_t msgsock = CURL_SOCKET_BAD;
int error;
int flag = 1;
if(MAX_SOCKETS == num_sockets) {
logmsg("Too many open sockets!");
return CURL_SOCKET_BAD;
}
msgsock = accept(sock, NULL, NULL);
if(got_exit_signal) {
if(CURL_SOCKET_BAD != msgsock)
sclose(msgsock);
return CURL_SOCKET_BAD;
}
if(CURL_SOCKET_BAD == msgsock) {
error = SOCKERRNO;
if(EAGAIN == error || EWOULDBLOCK == error) {
/* nothing to accept */
return 0;
}
logmsg("MAJOR ERROR: accept() failed with error: (%d) %s",
error, strerror(error));
return CURL_SOCKET_BAD;
}
if(0 != curlx_nonblock(msgsock, TRUE)) {
error = SOCKERRNO;
logmsg("curlx_nonblock failed with error: (%d) %s",
error, strerror(error));
sclose(msgsock);
return CURL_SOCKET_BAD;
}
if(0 != setsockopt(msgsock, SOL_SOCKET, SO_KEEPALIVE,
(void *)&flag, sizeof(flag))) {
error = SOCKERRNO;
logmsg("setsockopt(SO_KEEPALIVE) failed with error: (%d) %s",
error, strerror(error));
sclose(msgsock);
return CURL_SOCKET_BAD;
}
/*
** As soon as this server accepts a connection from the test harness it
** must set the server logs advisor read lock to indicate that server
** logs should not be read until this lock is removed by this server.
*/
if(!serverlogslocked)
set_advisor_read_lock(SERVERLOGS_LOCK);
serverlogslocked += 1;
logmsg("====> Client connect");
all_sockets[num_sockets] = msgsock;
num_sockets += 1;
#ifdef TCP_NODELAY
/*
* Disable the Nagle algorithm to make it easier to send out a large
* response in many small segments to torture the clients more.
*/
if(0 != setsockopt(msgsock, IPPROTO_TCP, TCP_NODELAY,
(void *)&flag, sizeof(flag)))
logmsg("====> TCP_NODELAY failed");
else
logmsg("TCP_NODELAY set");
#endif
return msgsock;
} | /* returns a socket handle, or 0 if there are no more waiting sockets,
or < 0 if there was an error */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/server/sws.c#L1730-L1805 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | service_connection | static int service_connection(curl_socket_t msgsock, struct httprequest *req,
curl_socket_t listensock, const char *hostport)
{
if(got_exit_signal)
return -1;
while(!req->done_processing) {
int rc = get_request(msgsock, req);
if (rc <= 0) {
/* Nothing further to read now (possibly because the socket was closed */
return rc;
}
}
if(prevbounce) {
/* bounce treatment requested */
if((req->testno == prevtestno) &&
(req->partno == prevpartno)) {
req->partno++;
logmsg("BOUNCE part number to %ld", req->partno);
}
else {
prevbounce = FALSE;
prevtestno = -1;
prevpartno = -1;
}
}
send_doc(msgsock, req);
if(got_exit_signal)
return -1;
if(DOCNUMBER_CONNECT == req->testno) {
/* a CONNECT request, setup and talk the tunnel */
if(!is_proxy) {
logmsg("received CONNECT but isn't running as proxy! EXIT");
}
else
http_connect(&msgsock, listensock, req, hostport);
return -1;
}
if((req->testno < 0) && (req->testno != DOCNUMBER_CONNECT)) {
logmsg("special request received, no persistency");
return -1;
}
if(!req->open) {
logmsg("instructed to close connection after server-reply");
return -1;
}
/* if we got a CONNECT, loop and get another request as well! */
if(req->open) {
logmsg("=> persistant connection request ended, awaits new request\n");
return 1;
}
if(req->testno == DOCNUMBER_CONNECT)
return 1;
return -1;
} | /* returns 1 if the connection should be serviced again immediately, 0 if there
is no data waiting, or < 0 if it should be closed */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/server/sws.c#L1809-L1871 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | mysignal | static void mysignal(int sig, void (*handler)(int))
{
struct sigaction sa;
memset(&sa, 0, sizeof(sa));
sa.sa_handler = handler;
sigaction(sig, &sa, NULL);
} | /*
* Like signal(), but with well-defined semantics.
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/server/tftpd.c#L327-L333 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | exit_signal_handler | static RETSIGTYPE exit_signal_handler(int signum)
{
int old_errno = errno;
if(got_exit_signal == 0) {
got_exit_signal = 1;
exit_signal = signum;
}
(void)signal(signum, exit_signal_handler);
errno = old_errno;
} | /* HAVE_ALARM && SIGALRM */
/* signal handler that will be triggered to indicate that the program
should finish its execution in a controlled manner as soon as possible.
The first time this is called it will set got_exit_signal to one and
store in exit_signal the signal that triggered its execution. */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/server/tftpd.c#L370-L379 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | readit | static int readit(struct testcase *test, struct tftphdr **dpp,
int convert /* if true, convert to ascii */)
{
struct bf *b;
bfs[current].counter = BF_FREE; /* free old one */
current = !current; /* "incr" current */
b = &bfs[current]; /* look at new buffer */
if (b->counter == BF_FREE) /* if it's empty */
read_ahead(test, convert); /* fill it */
*dpp = &b->buf.hdr; /* set caller's ptr */
return b->counter;
} | /* Have emptied current buffer by sending to net and getting ack.
Free it and return next buffer filled with data.
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/server/tftpd.c#L468-L482 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | read_ahead | static void read_ahead(struct testcase *test,
int convert /* if true, convert to ascii */)
{
int i;
char *p;
int c;
struct bf *b;
struct tftphdr *dp;
b = &bfs[nextone]; /* look at "next" buffer */
if (b->counter != BF_FREE) /* nop if not free */
return;
nextone = !nextone; /* "incr" next buffer ptr */
dp = &b->buf.hdr;
if (convert == 0) {
/* The former file reading code did this:
b->counter = read(fileno(file), dp->th_data, SEGSIZE); */
size_t copy_n = MIN(SEGSIZE, test->rcount);
memcpy(dp->th_data, test->rptr, copy_n);
/* decrease amount, advance pointer */
test->rcount -= copy_n;
test->rptr += copy_n;
b->counter = (int)copy_n;
return;
}
p = dp->th_data;
for (i = 0 ; i < SEGSIZE; i++) {
if (newline) {
if (prevchar == '\n')
c = '\n'; /* lf to cr,lf */
else
c = '\0'; /* cr to cr,nul */
newline = 0;
}
else {
if(test->rcount) {
c=test->rptr[0];
test->rptr++;
test->rcount--;
}
else
break;
if (c == '\n' || c == '\r') {
prevchar = c;
c = '\r';
newline = 1;
}
}
*p++ = (char)c;
}
b->counter = (int)(p - dp->th_data);
} | /*
* fill the input buffer, doing ascii conversions if requested
* conversions are lf -> cr,lf and cr -> cr, nul
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/server/tftpd.c#L488-L543 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | writeit | static int writeit(struct testcase *test, struct tftphdr **dpp,
int ct, int convert)
{
bfs[current].counter = ct; /* set size of data to write */
current = !current; /* switch to other buffer */
if (bfs[current].counter != BF_FREE) /* if not free */
write_behind(test, convert); /* flush it */
bfs[current].counter = BF_ALLOC; /* mark as alloc'd */
*dpp = &bfs[current].buf.hdr;
return ct; /* this is a lie of course */
} | /* Update count associated with the buffer, get new buffer from the queue.
Calls write_behind only if next buffer not available.
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/server/tftpd.c#L548-L558 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | write_behind | static ssize_t write_behind(struct testcase *test, int convert)
{
char *writebuf;
int count;
int ct;
char *p;
int c; /* current character */
struct bf *b;
struct tftphdr *dp;
b = &bfs[nextone];
if (b->counter < -1) /* anything to flush? */
return 0; /* just nop if nothing to do */
if(!test->ofile) {
char outfile[256];
snprintf(outfile, sizeof(outfile), "log/upload.%ld", test->num);
test->ofile=open(outfile, O_CREAT|O_RDWR, 0777);
if(test->ofile == -1) {
logmsg("Couldn't create and/or open file %s for upload!", outfile);
return -1; /* failure! */
}
}
count = b->counter; /* remember byte count */
b->counter = BF_FREE; /* reset flag */
dp = &b->buf.hdr;
nextone = !nextone; /* incr for next time */
writebuf = dp->th_data;
if (count <= 0)
return -1; /* nak logic? */
if (convert == 0)
return write(test->ofile, writebuf, count);
p = writebuf;
ct = count;
while (ct--) { /* loop over the buffer */
c = *p++; /* pick up a character */
if (prevchar == '\r') { /* if prev char was cr */
if (c == '\n') /* if have cr,lf then just */
lseek(test->ofile, -1, SEEK_CUR); /* smash lf on top of the cr */
else
if (c == '\0') /* if have cr,nul then */
goto skipit; /* just skip over the putc */
/* else just fall through and allow it */
}
/* formerly
putc(c, file); */
if(1 != write(test->ofile, &c, 1))
break;
skipit:
prevchar = c;
}
return count;
} | /*
* Output a buffer to a file, converting from netascii if requested.
* CR,NUL -> CR and CR,LF => LF.
* Note spec is undefined if we get CR as last byte of file or a
* CR followed by anything else. In this case we leave it alone.
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/server/tftpd.c#L566-L622 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | synchnet | static int synchnet(curl_socket_t f /* socket to flush */)
{
#if defined(HAVE_IOCTLSOCKET)
unsigned long i;
#else
int i;
#endif
int j = 0;
char rbuf[PKTSIZE];
srvr_sockaddr_union_t fromaddr;
curl_socklen_t fromaddrlen;
for (;;) {
#if defined(HAVE_IOCTLSOCKET)
(void) ioctlsocket(f, FIONREAD, &i);
#else
(void) ioctl(f, FIONREAD, &i);
#endif
if (i) {
j++;
#ifdef ENABLE_IPV6
if(!use_ipv6)
#endif
fromaddrlen = sizeof(fromaddr.sa4);
#ifdef ENABLE_IPV6
else
fromaddrlen = sizeof(fromaddr.sa6);
#endif
(void) recvfrom(f, rbuf, sizeof(rbuf), 0,
&fromaddr.sa, &fromaddrlen);
}
else
break;
}
return j;
} | /* When an error has occurred, it is possible that the two sides are out of
* synch. Ie: that what I think is the other side's response to packet N is
* really their response to packet N-1.
*
* So, to try to prevent that, we flush all the input queued up for us on the
* network connection on our host.
*
* We return the number of packets we flushed (mostly for reporting when trace
* is active).
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/server/tftpd.c#L635-L671 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | win32_perror | void win32_perror (const char *msg)
{
char buf[512];
DWORD err = SOCKERRNO;
if (!FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err,
LANG_NEUTRAL, buf, sizeof(buf), NULL))
snprintf(buf, sizeof(buf), "Unknown error %lu (%#lx)", err, err);
if (msg)
fprintf(stderr, "%s: ", msg);
fprintf(stderr, "%s\n", buf);
} | /* use instead of perror() on generic windows */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/server/util.c#L138-L149 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | wait_ms | int wait_ms(int timeout_ms)
{
#if !defined(MSDOS) && !defined(USE_WINSOCK)
#ifndef HAVE_POLL_FINE
struct timeval pending_tv;
#endif
struct timeval initial_tv;
int pending_ms;
int error;
#endif
int r = 0;
if(!timeout_ms)
return 0;
if(timeout_ms < 0) {
errno = EINVAL;
return -1;
}
#if defined(MSDOS)
delay(timeout_ms);
#elif defined(USE_WINSOCK)
Sleep(timeout_ms);
#else
pending_ms = timeout_ms;
initial_tv = curlx_tvnow();
do {
#if defined(HAVE_POLL_FINE)
r = poll(NULL, 0, pending_ms);
#else
pending_tv.tv_sec = pending_ms / 1000;
pending_tv.tv_usec = (pending_ms % 1000) * 1000;
r = select(0, NULL, NULL, NULL, &pending_tv);
#endif /* HAVE_POLL_FINE */
if(r != -1)
break;
error = errno;
if(error && (error != EINTR))
break;
pending_ms = timeout_ms - (int)curlx_tvdiff(curlx_tvnow(), initial_tv);
if(pending_ms <= 0)
break;
} while(r == -1);
#endif /* USE_WINSOCK */
if(r)
r = -1;
return r;
} | /*
* Portable function used for waiting a specific amount of ms.
* Waiting indefinitely with this function is not allowed, a
* zero or negative timeout value will return immediately.
*
* Return values:
* -1 = system call error, or invalid timeout value
* 0 = specified timeout has elapsed
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/server/util.c#L203-L249 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | s_testBigEndian | static
int
s_testBigEndian( void )
{
union
{
posh_byte_t c[ 4 ];
posh_u32_t i;
} u;
u.i= 1;
if ( u.c[ 0 ] == 1 )
{
return 0;
}
return 1;
} | /* POSH_LITTLE_ENDIAN */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/nvtt/src/nvcore/poshlib/posh.c#L84-L101 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | POSH_SwapU16 | posh_u16_t
POSH_SwapU16( posh_u16_t v )
{
posh_u16_t swapped;
swapped = v << 8;
swapped |= v >> 8;
return swapped;
} | /* ---------------------------------------------------------------------------*/
/* BYTE SWAPPING SUPPORT */
/* ---------------------------------------------------------------------------*/
/**
* Byte swaps a 16-bit unsigned value
*
@ingroup ByteSwapFunctions
@param v [in] unsigned 16-bit input value to swap
@returns a byte swapped version of v
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/nvtt/src/nvcore/poshlib/posh.c#L288-L297 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | POSH_SwapI16 | posh_i16_t
POSH_SwapI16( posh_i16_t v )
{
return ( posh_i16_t ) POSH_SwapU16( v );
} | /**
* Byte swaps a 16-bit signed value
*
@ingroup ByteSwapFunctions
@param v [in] signed 16-bit input value to swap
@returns a byte swapped version of v
@remarks This just calls back to the unsigned version, since byte swapping
is independent of sign. However, we still provide this function to
avoid signed/unsigned mismatch compiler warnings.
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/nvtt/src/nvcore/poshlib/posh.c#L309-L313 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | POSH_SwapU32 | posh_u32_t
POSH_SwapU32( posh_u32_t v )
{
posh_u32_t swapped;
swapped = ( v & 0xFF ) << 24;
swapped |= ( v & 0xFF00 ) << 8;
swapped |= ( v >> 8 ) & 0xFF00;
swapped |= ( v >> 24 );
return swapped;
} | /**
* Byte swaps a 32-bit unsigned value
*
@ingroup ByteSwapFunctions
@param v [in] unsigned 32-bit input value to swap
@returns a byte swapped version of v
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/nvtt/src/nvcore/poshlib/posh.c#L322-L333 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | POSH_SwapI32 | posh_i32_t
POSH_SwapI32( posh_i32_t v )
{
return ( posh_i32_t ) POSH_SwapU32( ( posh_u32_t ) v );
} | /**
* Byte swaps a 32-bit signed value
*
@ingroup ByteSwapFunctions
@param v [in] signed 32-bit input value to swap
@returns a byte swapped version of v
@remarks This just calls back to the unsigned version, since byte swapping
is independent of sign. However, we still provide this function to
avoid signed/unsigned mismatch compiler warnings.
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/nvtt/src/nvcore/poshlib/posh.c#L345-L349 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | POSH_SwapU64 | posh_u64_t
POSH_SwapU64( posh_u64_t v )
{
posh_byte_t tmp;
union {
posh_byte_t bytes[ 8 ];
posh_u64_t u64;
} u;
u.u64 = v;
tmp = u.bytes[ 0 ]; u.bytes[ 0 ] = u.bytes[ 7 ]; u.bytes[ 7 ] = tmp;
tmp = u.bytes[ 1 ]; u.bytes[ 1 ] = u.bytes[ 6 ]; u.bytes[ 6 ] = tmp;
tmp = u.bytes[ 2 ]; u.bytes[ 2 ] = u.bytes[ 5 ]; u.bytes[ 5 ] = tmp;
tmp = u.bytes[ 3 ]; u.bytes[ 3 ] = u.bytes[ 4 ]; u.bytes[ 4 ] = tmp;
return u.u64;
} | /**
* Byte swaps a 64-bit unsigned value
@param v [in] a 64-bit input value to swap
@ingroup SixtyFourBit
@returns a byte swapped version of v
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/nvtt/src/nvcore/poshlib/posh.c#L359-L376 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | POSH_SwapI64 | posh_i64_t
POSH_SwapI64( posh_i64_t v )
{
return ( posh_i64_t ) POSH_SwapU64( ( posh_u64_t ) v );
} | /**
* Byte swaps a 64-bit signed value
@param v [in] a 64-bit input value to swap
@ingroup SixtyFourBit
@returns a byte swapped version of v
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/nvtt/src/nvcore/poshlib/posh.c#L385-L389 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | POSH_ReadU16FromLittle | posh_u16_t
POSH_ReadU16FromLittle( const void *src )
{
posh_u16_t v = 0;
posh_byte_t *p = ( posh_byte_t * ) src;
v |= p[ 0 ];
v |= ( ( posh_u16_t ) p[ 1 ] ) << 8;
return v;
} | /* POSH_64BIT_INTEGER */
/* ---------------------------------------------------------------------------*/
/* IN-MEMORY DESERIALIZATION */
/* ---------------------------------------------------------------------------*/
/**
* Reads an unsigned 16-bit value from a little-endian buffer
@ingroup MemoryBuffer
@param src [in] source buffer
@returns host-endian unsigned 16-bit value
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/nvtt/src/nvcore/poshlib/posh.c#L640-L650 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | POSH_ReadI16FromLittle | posh_i16_t
POSH_ReadI16FromLittle( const void *src )
{
return ( posh_i16_t ) POSH_ReadU16FromLittle( src );
} | /**
* Reads a signed 16-bit value from a little-endian buffer
@ingroup MemoryBuffer
@param src [in] source buffer
@returns host-endian signed 16-bit value
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/nvtt/src/nvcore/poshlib/posh.c#L658-L662 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | POSH_ReadU32FromLittle | posh_u32_t
POSH_ReadU32FromLittle( const void *src )
{
posh_u32_t v = 0;
posh_byte_t *p = ( posh_byte_t * ) src;
v |= p[ 0 ];
v |= ( ( posh_u32_t ) p[ 1 ] ) << 8;
v |= ( ( posh_u32_t ) p[ 2 ] ) << 16;
v |= ( ( posh_u32_t ) p[ 3 ] ) << 24;
return v;
} | /**
* Reads an unsigned 32-bit value from a little-endian buffer
@ingroup MemoryBuffer
@param src [in] source buffer
@returns host-endian unsigned 32-bit value
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/nvtt/src/nvcore/poshlib/posh.c#L670-L682 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | POSH_ReadI32FromLittle | posh_i32_t
POSH_ReadI32FromLittle( const void *src )
{
return ( posh_i32_t ) POSH_ReadU32FromLittle( src );
} | /**
* Reads a signed 32-bit value from a little-endian buffer
@ingroup MemoryBuffer
@param src [in] source buffer
@returns host-endian signed 32-bit value
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/nvtt/src/nvcore/poshlib/posh.c#L690-L694 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | POSH_ReadU16FromBig | posh_u16_t
POSH_ReadU16FromBig( const void *src )
{
posh_u16_t v = 0;
posh_byte_t *p = ( posh_byte_t * ) src;
v |= p[ 1 ];
v |= ( ( posh_u16_t ) p[ 0 ] ) << 8;
return v;
} | /**
* Reads an unsigned 16-bit value from a big-endian buffer
@ingroup MemoryBuffer
@param src [in] source buffer
@returns host-endian unsigned 16-bit value
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/nvtt/src/nvcore/poshlib/posh.c#L703-L713 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | POSH_ReadI16FromBig | posh_i16_t
POSH_ReadI16FromBig( const void *src )
{
return ( posh_i16_t ) POSH_ReadU16FromBig( src );
} | /**
* Reads a signed 16-bit value from a big-endian buffer
@ingroup MemoryBuffer
@param src [in] source buffer
@returns host-endian signed 16-bit value
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/nvtt/src/nvcore/poshlib/posh.c#L721-L725 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | POSH_ReadU32FromBig | posh_u32_t
POSH_ReadU32FromBig( const void *src )
{
posh_u32_t v = 0;
posh_byte_t *p = ( posh_byte_t * ) src;
v |= p[ 3 ];
v |= ( ( posh_u32_t ) p[ 2 ] ) << 8;
v |= ( ( posh_u32_t ) p[ 1 ] ) << 16;
v |= ( ( posh_u32_t ) p[ 0 ] ) << 24;
return v;
} | /**
* Reads an unsigned 32-bit value from a big-endian buffer
@ingroup MemoryBuffer
@param src [in] source buffer
@returns host-endian unsigned 32-bit value
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/nvtt/src/nvcore/poshlib/posh.c#L733-L745 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | POSH_ReadI32FromBig | posh_i32_t
POSH_ReadI32FromBig( const void *src )
{
return POSH_BigI32( (*(const posh_i32_t*)src ) );
} | /**
* Reads a signed 32-bit value from a big-endian buffer
@ingroup MemoryBuffer
@param src [in] source buffer
@returns host-endian signed 32-bit value
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/nvtt/src/nvcore/poshlib/posh.c#L753-L757 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | POSH_ReadU64FromLittle | posh_u64_t
POSH_ReadU64FromLittle( const void *src )
{
posh_u64_t v = 0;
posh_byte_t *p = ( posh_byte_t * ) src;
int i;
for ( i = 0; i < 8; i++ )
{
v |= ( ( posh_u64_t ) p[ i ] ) << (i*8);
}
return v;
} | /**
* Reads an unsigned 64-bit value from a little-endian buffer
@param src [in] source buffer
@returns host-endian unsigned 32-bit value
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/nvtt/src/nvcore/poshlib/posh.c#L766-L779 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | POSH_ReadI64FromLittle | posh_i64_t
POSH_ReadI64FromLittle( const void *src )
{
return ( posh_i64_t ) POSH_ReadU64FromLittle( src );
} | /**
* Reads a signed 64-bit value from a little-endian buffer
@param src [in] source buffer
@returns host-endian signed 32-bit value
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/nvtt/src/nvcore/poshlib/posh.c#L786-L790 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | POSH_ReadU64FromBig | posh_u64_t
POSH_ReadU64FromBig( const void *src )
{
posh_u64_t v = 0;
posh_byte_t *p = ( posh_byte_t * ) src;
int i;
for ( i = 0; i < 8; i++ )
{
v |= ( ( posh_u64_t ) p[ 7-i ] ) << (i*8);
}
return v;
} | /**
* Reads an unsigned 64-bit value from a big-endian buffer
@param src [in] source buffer
@returns host-endian unsigned 32-bit value
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/nvtt/src/nvcore/poshlib/posh.c#L797-L810 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | POSH_ReadI64FromBig | posh_i64_t
POSH_ReadI64FromBig( const void *src )
{
return ( posh_i64_t ) POSH_ReadU64FromBig( src );
} | /**
* Reads an signed 64-bit value from a big-endian buffer
@param src [in] source buffer
@returns host-endian signed 32-bit value
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/nvtt/src/nvcore/poshlib/posh.c#L817-L821 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | POSH_LittleFloatBits | posh_u32_t
POSH_LittleFloatBits( float f )
{
union
{
float f32;
posh_u32_t u32;
} u;
u.f32 = f;
return POSH_LittleU32( u.u32 );
} | /** @ingroup FloatingPoint
@param[in] f floating point value
@returns a little-endian bit representation of f
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/nvtt/src/nvcore/poshlib/posh.c#L835-L847 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | POSH_BigFloatBits | posh_u32_t
POSH_BigFloatBits( float f )
{
union
{
float f32;
posh_u32_t u32;
} u;
u.f32 = f;
return POSH_BigU32( u.u32 );
} | /**
* Extracts raw big-endian bits from a 32-bit floating point value
*
@ingroup FloatingPoint
@param f [in] floating point value
@returns a big-endian bit representation of f
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/nvtt/src/nvcore/poshlib/posh.c#L856-L868 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | POSH_DoubleBits | void
POSH_DoubleBits( double d, posh_byte_t dst[ 8 ] )
{
union
{
double d64;
posh_byte_t bytes[ 8 ];
} u;
u.d64 = d;
#if defined POSH_LITTLE_ENDIAN
dst[ 0 ] = u.bytes[ 0 ];
dst[ 1 ] = u.bytes[ 1 ];
dst[ 2 ] = u.bytes[ 2 ];
dst[ 3 ] = u.bytes[ 3 ];
dst[ 4 ] = u.bytes[ 4 ];
dst[ 5 ] = u.bytes[ 5 ];
dst[ 6 ] = u.bytes[ 6 ];
dst[ 7 ] = u.bytes[ 7 ];
#else
dst[ 0 ] = u.bytes[ 7 ];
dst[ 1 ] = u.bytes[ 6 ];
dst[ 2 ] = u.bytes[ 5 ];
dst[ 3 ] = u.bytes[ 4 ];
dst[ 4 ] = u.bytes[ 3 ];
dst[ 5 ] = u.bytes[ 2 ];
dst[ 6 ] = u.bytes[ 1 ];
dst[ 7 ] = u.bytes[ 0 ];
#endif
} | /**
* Extracts raw, little-endian bit representation from a 64-bit double.
*
@param d [in] 64-bit double precision value
@param dst [out] 8-byte storage buffer
@ingroup FloatingPoint
@returns the raw bits used to represent the value 'd', in the form dst[0]=LSB
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/nvtt/src/nvcore/poshlib/posh.c#L878-L908 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | POSH_DoubleFromBits | double
POSH_DoubleFromBits( const posh_byte_t src[ 8 ] )
{
union
{
double d64;
posh_byte_t bytes[ 8 ];
} u;
#if defined POSH_LITTLE_ENDIAN
u.bytes[ 0 ] = src[ 0 ];
u.bytes[ 1 ] = src[ 1 ];
u.bytes[ 2 ] = src[ 2 ];
u.bytes[ 3 ] = src[ 3 ];
u.bytes[ 4 ] = src[ 4 ];
u.bytes[ 5 ] = src[ 5 ];
u.bytes[ 6 ] = src[ 6 ];
u.bytes[ 7 ] = src[ 7 ];
#else
u.bytes[ 0 ] = src[ 7 ];
u.bytes[ 1 ] = src[ 6 ];
u.bytes[ 2 ] = src[ 5 ];
u.bytes[ 3 ] = src[ 4 ];
u.bytes[ 4 ] = src[ 3 ];
u.bytes[ 5 ] = src[ 2 ];
u.bytes[ 6 ] = src[ 1 ];
u.bytes[ 7 ] = src[ 0 ];
#endif
return u.d64;
} | /**
* Creates a double-precision, 64-bit floating point value from a set of raw,
* little-endian bits
@ingroup FloatingPoint
@param src [in] little-endian byte representation of 64-bit double precision
floating point value
@returns double precision floating point representation of the raw bits
@remarks No error checking is performed, so there are no guarantees that the
result is a valid number, nor is there any check to ensure that src is
non-NULL. BE CAREFUL USING THIS.
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/nvtt/src/nvcore/poshlib/posh.c#L922-L952 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | POSH_FloatFromLittleBits | float
POSH_FloatFromLittleBits( posh_u32_t bits )
{
union
{
float f32;
posh_u32_t u32;
} u;
u.u32 = bits;
#if defined POSH_BIG_ENDIAN
u.u32 = POSH_SwapU32( u.u32 );
#endif
return u.f32;
} | /**
* Creates a floating point number from little endian bits
*
@ingroup FloatingPoint
@param bits [in] raw floating point bits in little-endian form
@returns a floating point number based on the given bit representation
@remarks No error checking is performed, so there are no guarantees that the
result is a valid number. BE CAREFUL USING THIS.
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/nvtt/src/nvcore/poshlib/posh.c#L963-L978 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | POSH_FloatFromBigBits | float
POSH_FloatFromBigBits( posh_u32_t bits )
{
union
{
float f32;
posh_u32_t u32;
} u;
u.u32 = bits;
#if defined POSH_LITTLE_ENDIAN
u.u32 = POSH_SwapU32( u.u32 );
#endif
return u.f32;
} | /**
* Creates a floating point number from big-endian bits
*
@ingroup FloatingPoint
@param bits [in] raw floating point bits in big-endian form
@returns a floating point number based on the given bit representation
@remarks No error checking is performed, so there are no guarantees that the
result is a valid number. BE CAREFUL USING THIS.
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/nvtt/src/nvcore/poshlib/posh.c#L989-L1004 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | args_from_file | int args_from_file(char *file, int *argc, char **argv[])
{
FILE *fp;
int num,i;
unsigned int len;
static char *buf=NULL;
static char **arg=NULL;
char *p;
fp=fopen(file,"r");
if (fp == NULL)
return(0);
if (fseek(fp,0,SEEK_END)==0)
len=ftell(fp), rewind(fp);
else len=-1;
if (len<=0)
{
fclose(fp);
return(0);
}
*argc=0;
*argv=NULL;
if (buf != NULL) OPENSSL_free(buf);
buf=(char *)OPENSSL_malloc(len+1);
if (buf == NULL) return(0);
len=fread(buf,1,len,fp);
if (len <= 1) return(0);
buf[len]='\0';
i=0;
for (p=buf; *p; p++)
if (*p == '\n') i++;
if (arg != NULL) OPENSSL_free(arg);
arg=(char **)OPENSSL_malloc(sizeof(char *)*(i*2));
*argv=arg;
num=0;
p=buf;
for (;;)
{
if (!*p) break;
if (*p == '#') /* comment line */
{
while (*p && (*p != '\n')) p++;
continue;
}
/* else we have a line */
*(arg++)=p;
num++;
while (*p && ((*p != ' ') && (*p != '\t') && (*p != '\n')))
p++;
if (!*p) break;
if (*p == '\n')
{
*(p++)='\0';
continue;
}
/* else it is a tab or space */
p++;
while (*p && ((*p == ' ') || (*p == '\t') || (*p == '\n')))
p++;
if (!*p) break;
if (*p == '\n')
{
p++;
continue;
}
*(arg++)=p++;
num++;
while (*p && (*p != '\n')) p++;
if (!*p) break;
/* else *p == '\n' */
*(p++)='\0';
}
*argc=num;
return(1);
} | /* never finished - probably never will be :-) */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/openssl/apps/apps.c#L175-L255 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | make_revoked | int make_revoked(X509_REVOKED *rev, const char *str)
{
char *tmp = NULL;
int reason_code = -1;
int i, ret = 0;
ASN1_OBJECT *hold = NULL;
ASN1_GENERALIZEDTIME *comp_time = NULL;
ASN1_ENUMERATED *rtmp = NULL;
ASN1_TIME *revDate = NULL;
i = unpack_revinfo(&revDate, &reason_code, &hold, &comp_time, str);
if (i == 0)
goto err;
if (rev && !X509_REVOKED_set_revocationDate(rev, revDate))
goto err;
if (rev && (reason_code != OCSP_REVOKED_STATUS_NOSTATUS))
{
rtmp = ASN1_ENUMERATED_new();
if (!rtmp || !ASN1_ENUMERATED_set(rtmp, reason_code))
goto err;
if (!X509_REVOKED_add1_ext_i2d(rev, NID_crl_reason, rtmp, 0, 0))
goto err;
}
if (rev && comp_time)
{
if (!X509_REVOKED_add1_ext_i2d(rev, NID_invalidity_date, comp_time, 0, 0))
goto err;
}
if (rev && hold)
{
if (!X509_REVOKED_add1_ext_i2d(rev, NID_hold_instruction_code, hold, 0, 0))
goto err;
}
if (reason_code != OCSP_REVOKED_STATUS_NOSTATUS)
ret = 2;
else ret = 1;
err:
if (tmp) OPENSSL_free(tmp);
ASN1_OBJECT_free(hold);
ASN1_GENERALIZEDTIME_free(comp_time);
ASN1_ENUMERATED_free(rtmp);
ASN1_TIME_free(revDate);
return ret;
} | /* Convert revocation field to X509_REVOKED entry
* return code:
* 0 error
* 1 OK
* 2 OK and some extensions added (i.e. V2 CRL)
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/openssl/apps/ca.c#L2787-L2839 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | cms_cb | static int cms_cb(int ok, X509_STORE_CTX *ctx)
{
int error;
error = X509_STORE_CTX_get_error(ctx);
verify_err = error;
if ((error != X509_V_ERR_NO_EXPLICIT_POLICY)
&& ((error != X509_V_OK) || (ok != 2)))
return ok;
policies_print(NULL, ctx);
return ok;
} | /* Minimal callback just to output policy info (if any) */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/openssl/apps/cms.c#L1210-L1226 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | add_certs_from_file | static int add_certs_from_file(STACK_OF(X509) *stack, char *certfile)
{
BIO *in=NULL;
int count=0;
int ret= -1;
STACK_OF(X509_INFO) *sk=NULL;
X509_INFO *xi;
in=BIO_new(BIO_s_file());
if ((in == NULL) || (BIO_read_filename(in,certfile) <= 0))
{
BIO_printf(bio_err,"error opening the file, %s\n",certfile);
goto end;
}
/* This loads from a file, a stack of x509/crl/pkey sets */
sk=PEM_X509_INFO_read_bio(in,NULL,NULL,NULL);
if (sk == NULL) {
BIO_printf(bio_err,"error reading the file, %s\n",certfile);
goto end;
}
/* scan over it and pull out the CRL's */
while (sk_X509_INFO_num(sk))
{
xi=sk_X509_INFO_shift(sk);
if (xi->x509 != NULL)
{
sk_X509_push(stack,xi->x509);
xi->x509=NULL;
count++;
}
X509_INFO_free(xi);
}
ret=count;
end:
/* never need to OPENSSL_free x */
if (in != NULL) BIO_free(in);
if (sk != NULL) sk_X509_INFO_free(sk);
return(ret);
} | /*
*----------------------------------------------------------------------
* int add_certs_from_file
*
* Read a list of certificates to be checked from a file.
*
* Results:
* number of certs added if successful, -1 if not.
*----------------------------------------------------------------------
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/openssl/apps/crl2p7.c#L295-L336 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | dh_cb | static int MS_CALLBACK dh_cb(int p, int n, BN_GENCB *cb)
{
char c='*';
if (p == 0) c='.';
if (p == 1) c='+';
if (p == 2) c='*';
if (p == 3) c='\n';
BIO_write(cb->arg,&c,1);
(void)BIO_flush(cb->arg);
#ifdef LINT
p=n;
#endif
return 1;
} | /* dh_cb is identical to dsa_cb in apps/dsaparam.c */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/openssl/apps/dhparam.c#L538-L552 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | get_cert_chain | int get_cert_chain (X509 *cert, X509_STORE *store, STACK_OF(X509) **chain)
{
X509_STORE_CTX store_ctx;
STACK_OF(X509) *chn;
int i = 0;
/* FIXME: Should really check the return status of X509_STORE_CTX_init
* for an error, but how that fits into the return value of this
* function is less obvious. */
X509_STORE_CTX_init(&store_ctx, store, cert, NULL);
if (X509_verify_cert(&store_ctx) <= 0) {
i = X509_STORE_CTX_get_error (&store_ctx);
if (i == 0)
/* avoid returning 0 if X509_verify_cert() did not
* set an appropriate error value in the context */
i = -1;
chn = NULL;
goto err;
} else
chn = X509_STORE_CTX_get1_chain(&store_ctx);
err:
X509_STORE_CTX_cleanup(&store_ctx);
*chain = chn;
return i;
} | /* Given a single certificate return a verified chain or NULL if error */
/* Hope this is OK .... */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/openssl/apps/pkcs12.c#L827-L852 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | cert_load | int cert_load(BIO *in, STACK_OF(X509) *sk)
{
int ret;
X509 *cert;
ret = 0;
#ifdef CRYPTO_MDEBUG
CRYPTO_push_info("cert_load(): reading one cert");
#endif
while((cert = PEM_read_bio_X509(in, NULL, NULL, NULL))) {
#ifdef CRYPTO_MDEBUG
CRYPTO_pop_info();
#endif
ret = 1;
sk_X509_push(sk, cert);
#ifdef CRYPTO_MDEBUG
CRYPTO_push_info("cert_load(): reading one cert");
#endif
}
#ifdef CRYPTO_MDEBUG
CRYPTO_pop_info();
#endif
if(ret) ERR_clear_error();
return ret;
} | /* Load all certificates from a given file */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/openssl/apps/pkcs12.c#L871-L894 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | print_attribs | int print_attribs (BIO *out, STACK_OF(X509_ATTRIBUTE) *attrlst,const char *name)
{
X509_ATTRIBUTE *attr;
ASN1_TYPE *av;
char *value;
int i, attr_nid;
if(!attrlst) {
BIO_printf(out, "%s: <No Attributes>\n", name);
return 1;
}
if(!sk_X509_ATTRIBUTE_num(attrlst)) {
BIO_printf(out, "%s: <Empty Attributes>\n", name);
return 1;
}
BIO_printf(out, "%s\n", name);
for(i = 0; i < sk_X509_ATTRIBUTE_num(attrlst); i++) {
attr = sk_X509_ATTRIBUTE_value(attrlst, i);
attr_nid = OBJ_obj2nid(attr->object);
BIO_printf(out, " ");
if(attr_nid == NID_undef) {
i2a_ASN1_OBJECT (out, attr->object);
BIO_printf(out, ": ");
} else BIO_printf(out, "%s: ", OBJ_nid2ln(attr_nid));
if(sk_ASN1_TYPE_num(attr->value.set)) {
av = sk_ASN1_TYPE_value(attr->value.set, 0);
switch(av->type) {
case V_ASN1_BMPSTRING:
value = OPENSSL_uni2asc(av->value.bmpstring->data,
av->value.bmpstring->length);
BIO_printf(out, "%s\n", value);
OPENSSL_free(value);
break;
case V_ASN1_OCTET_STRING:
hex_prin(out, av->value.octet_string->data,
av->value.octet_string->length);
BIO_printf(out, "\n");
break;
case V_ASN1_BIT_STRING:
hex_prin(out, av->value.bit_string->data,
av->value.bit_string->length);
BIO_printf(out, "\n");
break;
default:
BIO_printf(out, "<Unsupported tag %d>\n", av->type);
break;
}
} else BIO_printf(out, "<No Values>\n");
}
return 1;
} | /* Generalised attribute print: handle PKCS#8 and bag attributes */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/openssl/apps/pkcs12.c#L898-L951 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | build_subject | static int build_subject(X509_REQ *req, char *subject, unsigned long chtype, int multirdn)
{
X509_NAME *n;
if (!(n = parse_name(subject, chtype, multirdn)))
return 0;
if (!X509_REQ_set_subject_name(req, n))
{
X509_NAME_free(n);
return 0;
}
X509_NAME_free(n);
return 1;
} | /*
* subject is expected to be in the format /type0=value0/type1=value1/type2=...
* where characters may be escaped by \
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/openssl/apps/req.c#L1171-L1185 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.