int main(int argc, char** argv) { if (argc != 2) { fprintf(stderr, "Usage: ./test_parse_robotstxt robots.txt\n"); return -1; } coda_strt s; if (coda_mmap_file(&s, argv[1]) < 0) { fprintf(stderr, "Can't mmap %s: (%d) %s\n", argv[1], errno, strerror(errno)); return -1; } std::string src(s.data, s.size); multcher::domain_robotstxt_t rtxt; rtxt.parse_from_source(src.c_str(), "bla"); while (!feof(stdin)) { char buf[1024]; if (!fgets(buf, 1024, stdin)) break; char* nl = strpbrk(buf, "\r\n"); if (nl) *nl = 0; test_url(rtxt, buf); } return 0; }
int main() { axutil_env_t *env = cut_setup_env("Url"); CUT_ASSERT(env != NULL); if (env) { test_url(env); axutil_env_free(env); } CUT_RETURN_ON_FAILURE(-1); return 0; }
void Server::loadObject (ObjectRequest const &request, Object *object) const { namespace fs = boost::filesystem; //fs::path path; bool is_url = false; if (request.url.size()) { if (request.content.size()) { throw RequestError("both url and content set"); } if (test_url(request.url)) { is_url = true; } } if (request.raw) { if (request.content.size()) { xtor.extract(request.content, request.type, object); } else if (is_url) { xtor.extract_url(request.url, request.type, object); } else { xtor.extract_path(request.url, request.type, object); } } else { if (request.content.size()) { std::istringstream is(request.content); object->read(is); } else { fs::path path; if (is_url) { // url path = fs::unique_path(); int r = wget(request.url, path.native()); if (r != 0) { throw ExternalError(request.url); } } else { path = fs::path(request.url); } ifstream is(path.native(), ios::binary); object->read(is); if (is_url) { fs::remove(path); } } } }
void Server::loadObject (ObjectRequest const &request, Object *object) const { namespace fs = boost::filesystem; fs::path path; bool is_url = false; if (request.url.size()) { if (request.content.size()) { throw RequestError("both url and content set"); } if (test_url(request.url)) { is_url = true; path = fs::unique_path(); string cmd = (boost::format("wget -O '%s' '%s'") % path.native() % request.url).str(); int r = ::system(cmd.c_str()); if (r != 0) { throw ExternalError(cmd); } } else { path = fs::path(request.url); } } if (request.raw) { if (request.content.size()) { xtor.extract(request.content, request.type, object); } else { // url std::cout<<"Inside Server::loadObject, request.raw = true"<<std::endl; xtor.extract_path(path.native(), request.type, object); } } else { if (request.content.size()) { std::istringstream is(request.content); object->read(is); } else { // url ifstream is(path.native(), ios::binary); object->read(is); } } if (is_url) { fs::remove(path); } }
int main(void) { char *url_str[] = { "https://foo.bar.com:512/foo/bar/baz?a=bbb&c=ddddd#boom", "http://foo.com", "http:// foo bar/", "http://foo.com}", "http//", "sftp:/|", "http://my.domain:badport", "http://my.domain:", "://my.domain", "https://foo.bar.com:512/foo/bar/baz ?a=bbb&c=ddddd#boom", "https://foo.bar.com:512/foo/bar/baz?abbb&c=ddddd#boom", "https://foo.bar.com:512/foo/bar/baz|a=bbb&c=ddddd#boom", "https://foo.bar.com:512/foo/bar/baz a=bbb&c=ddddd#boom", "https://foo.bar.com:512/foo/bar/baz?a=!bbb&c=ddddd#boom", "https://foo.bar.com:512/foo/bar/baz?a=bbb&c=ddddd#bo om", " http://foo.com", "https://foo.bar.com:512/?u=1234", "https://foo.bar.com:512?u=1234", "https://foo.bar.com:hi", }; size_t len = sizeof(url_str)/sizeof(char *); for (size_t i = 0; i < len; i++) { printf("---------------------------------------\n"); printf("%s\n",url_str[i]); int parsed_url = test_url(url_str[i]); if (EXIT_SUCCESS != parsed_url) { fprintf(stderr,"failure on %s\n",url_str[i]); } } }
static void run_test (int i, gboolean sync) { char *http_url, *https_url; debug_printf (1, "Test %d: %s (%s)\n", i + 1, tests[i].explanation, sync ? "sync" : "async"); if (!strncmp (tests[i].url, "http", 4)) { http_url = g_strdup (tests[i].url); https_url = g_strdup_printf ("https%s", tests[i].url + 4); } else { http_url = g_strconcat (HTTP_SERVER, tests[i].url, NULL); https_url = g_strconcat (HTTPS_SERVER, tests[i].url, NULL); } test_url (http_url, SIMPLE_PROXY, tests[i].final_status, sync, FALSE); test_url_new_api (http_url, SIMPLE_PROXY, tests[i].final_status, sync, FALSE); test_url (https_url, SIMPLE_PROXY, tests[i].final_status, sync, FALSE); test_url_new_api (https_url, SIMPLE_PROXY, tests[i].final_status, sync, FALSE); test_url (http_url, AUTH_PROXY, tests[i].final_status, sync, FALSE); test_url_new_api (http_url, AUTH_PROXY, tests[i].final_status, sync, FALSE); test_url (https_url, AUTH_PROXY, tests[i].final_status, sync, FALSE); test_url_new_api (https_url, AUTH_PROXY, tests[i].final_status, sync, FALSE); test_url (https_url, AUTH_PROXY, tests[i].final_status, sync, TRUE); test_url_new_api (https_url, AUTH_PROXY, tests[i].final_status, sync, TRUE); test_url (http_url, UNAUTH_PROXY, tests[i].final_status, sync, FALSE); test_url_new_api (http_url, UNAUTH_PROXY, tests[i].final_status, sync, FALSE); test_url (https_url, UNAUTH_PROXY, tests[i].final_status, sync, FALSE); test_url_new_api (https_url, UNAUTH_PROXY, tests[i].final_status, sync, FALSE); g_free (http_url); g_free (https_url); debug_printf (1, "\n"); }
int main() #endif { do { int y, x; for(y = 0; y < 16; ++y){ printf("{"); for(x = 0; x < 16; ++x){ printf("%d, ", (2 * ( y / 8 ) + ( x / 8 ))); } printf("}\n"); } /* Print copyright information */ printf("Doubango Project\nCopyright (C) 2009 Mamadou Diop \n\n"); #if RUN_TEST_LISTS || RUN_TEST_ALL /* linked lists */ test_basic_list(); printf("\n\n"); test_complex_list(); printf("\n\n"); test_filtered_list(); printf("\n\n"); #endif #if RUN_TEST_HEAP || RUN_TEST_ALL /* heap */ test_heap(); printf("\n\n"); #endif #if RUN_TEST_STRINGS || RUN_TEST_ALL /* strings */ test_strings(); printf("\n\n"); #endif #if RUN_TEST_URL || RUN_TEST_ALL /* url */ test_url(); printf("\n\n"); #endif #if RUN_TEST_THREADS || RUN_TEST_ALL /* threads */ test_threads(); printf("\n\n"); #endif #if RUN_TEST_MUTEX || RUN_TEST_ALL /* mutex */ test_mutex(); printf("\n\n"); #endif #if RUN_TEST_CONDWAIT || RUN_TEST_ALL /* condwait */ test_condwait(); printf("\n\n"); #endif #if RUN_TEST_SEMAPHORE || RUN_TEST_ALL /* semaphore */ test_semaphore(); printf("\n\n"); #endif #if RUN_TEST_SAFEOBJECT || RUN_TEST_ALL /* safe object */ //test_safeobject(); printf("\n\n"); #endif #if RUN_TEST_OBJECT || RUN_TEST_ALL /* object */ //test_object(); printf("\n\n"); #endif #if RUN_TEST_PARAMS || RUN_TEST_ALL /* parameters */ test_params(); printf("\n\n"); #endif #if RUN_TEST_OPTIONS || RUN_TEST_ALL /* options */ test_options(); printf("\n\n"); #endif #if RUN_TEST_TIMER || RUN_TEST_ALL /* timer */ test_timer(); printf("\n\n"); #endif #if RUN_TEST_RUNNABLE || RUN_TEST_ALL /* test runnable. */ test_runnable(); printf("\n\n"); #endif #if RUN_TEST_BUFFER || RUN_TEST_ALL /* test buffer */ test_buffer(); #endif #if RUN_TEST_MD5 || RUN_TEST_ALL /* test md5 and hmac_md5 */ test_md5(); test_hmac_md5(); #endif #if RUN_TEST_SHA1 || RUN_TEST_ALL /* test sha1 and hmac_sha-1 */ test_sha1(); test_hmac_sha1(); #endif #if RUN_TEST_BASE64 || RUN_TEST_ALL /* test base64 encoding/decoding */ test_base64(); #endif #if RUN_TEST_UUID || RUN_TEST_ALL /* test fake UUID (version5) */ test_uuid(); #endif #if RUN_TEST_FSM || RUN_TEST_ALL /* test FSM */ test_fsm(); #endif } while(LOOP); getchar(); return 0; }