int main(int argc, const char * const *argv) { apr_pool_t *pool; UploaderConfig *config; int status; apr_app_initialize(&argc, &argv, NULL); apr_pool_create(&pool, NULL); config = NULL; status = 0; try { config = UploaderConfigReader::read(pool, CONF_FILE_NAME); config->child_init(); // ベンチマーク用 bench_count = atoi(getenv("UPLOADER_BENCH")); if (bench_count == 0) { bench_count++; } STRACE_MARKER(); for (apr_size_t i = 0; i < bench_count; i++) { TemporaryPool temp_pool(pool); CGIResponse::Handle handle(temp_pool.get()); status = uploader_command_handler<CGIResponse> (&handle, config, arg); } STRACE_MARKER(); config->finalize(); apr_pool_destroy(pool); apr_terminate(); return status; } catch(const char *message) { std::cout << "Fatal Error: " << message << std::endl; if (config != NULL) { config->finalize(); } apr_pool_destroy(pool); apr_terminate(); return EXIT_FAILURE; } }
VOID jk2_isapi_starter( LPVOID lpParam ) { Sleep(1000); apr_initialize(); apr_pool_create( &jk_globalPool, NULL ); initialize_extension(); if (is_inited) { if (init_jk(NULL)) is_mapread = JK_TRUE; } SetEvent(jk2_inited_event); WaitForSingleObject(jk2_starter_event, INFINITE); if (is_inited) { was_inited = JK_TRUE; is_inited = JK_FALSE; if (workerEnv) { jk_env_t *env = workerEnv->globalEnv; jk2_iis_close_pool(env); workerEnv->close(env, workerEnv); } is_mapread = JK_FALSE; } apr_pool_destroy(jk_globalPool); apr_terminate(); /* Clean up and die. */ ExitThread(0); }
int main( int argc, char const * const *argv ) { json_t *json; int ret; apr_status_t status; apr_pool_t *mp; apr_file_t *xml_fp; apr_file_t *out_fp; const char *xml_file; const char *out_file; int preserve_root; int indent; apr_app_initialize( NULL, NULL, NULL ); apr_pool_create( &mp, NULL ); xml2json_init( argc, argv, mp, &xml_file, &out_file, &preserve_root, &indent ); if ( open_apr_input_file( mp, xml_file, &xml_fp ) && open_apr_output_file( mp, out_file, &out_fp ) && xml_to_json( mp, xml_fp, !preserve_root, &json ) ) { json_dump( out_fp, json, indent ); ret = 0; } else { fprintf( stderr, "failed to convert\n" ); ret = 1; } apr_pool_destroy( mp ); apr_terminate(); return ret; }
int main(int argc,char **argv) { apr_initialize(); apr_pool_t *pool; apr_pool_create(&pool,NULL); apr_status_t st; apr_thread_t *t1; apr_thread_t *t2; apr_thread_t *t3; apr_thread_create(&t1,NULL,thread_func,(void *)1L,pool); apr_thread_create(&t2,NULL,thread_func,(void *)2L,pool); apr_thread_create(&t3,NULL,thread_func,(void *)3L,pool); apr_thread_join(&st,t1); apr_thread_join(&st,t2); apr_thread_join(&st,t3); apr_pool_destroy(pool); apr_terminate(); return 0; }
int main(void) { struct { apr_lockmech_e mech; const char *mech_name; } lockmechs[] = { {APR_LOCK_DEFAULT, "default"} #if APR_HAS_FLOCK_SERIALIZE ,{APR_LOCK_FLOCK, "flock"} #endif #if APR_HAS_SYSVSEM_SERIALIZE ,{APR_LOCK_SYSVSEM, "sysvsem"} #endif #if APR_HAS_POSIXSEM_SERIALIZE ,{APR_LOCK_POSIXSEM, "posix"} #endif #if APR_HAS_FCNTL_SERIALIZE ,{APR_LOCK_FCNTL, "fcntl"} #endif #if APR_HAS_PROC_PTHREAD_SERIALIZE ,{APR_LOCK_PROC_PTHREAD, "proc_pthread"} #endif }; int i; assert(apr_initialize() == APR_SUCCESS); for (i = 0; i < sizeof(lockmechs) / sizeof(lockmechs[0]); i++) { test_mech(lockmechs[i].mech, lockmechs[i].mech_name); } apr_terminate(); return 0; }
int main() { apr_initialize(); apr_pool_t *mempool; apr_sockaddr_t *socket_addr; apr_socket_t *socket; apr_pool_create( &mempool, NULL ); apr_sockaddr_info_get( &socket_addr, NULL, APR_INET, REPLY_PORT, 0, mempool ); apr_socket_create( &socket, socket_addr->family, SOCK_STREAM, APR_PROTO_TCP, mempool ); apr_socket_bind( socket, socket_addr ); apr_socket_listen( socket, SOMAXCONN ); apr_socket_t *accepted; apr_socket_accept( &accepted, socket, mempool ); int *replies = (int*)malloc( frl_reply_size ); apr_size_t len = frl_reply_size; do { apr_socket_recv( accepted, (char*)replies, &len ); int *iter_replies = replies+2; for ( int i = 0; i < 100; i++, iter_replies+=2 ) { std::cout<<*iter_replies<<" "<<*(iter_replies+1)<<std::endl; } std::cout<<"The End."<<std::endl; } while (1); apr_terminate(); return 0; }
int main() { apr_thread_t* push_thds[1000]; apr_thread_t* pop_thds[1000]; apr_threadattr_t* thd_attr; apr_initialize(); apr_pool_create(&global_pool, NULL); apr_atomic_init(global_pool); frl_queue_create(&queue, global_pool, 1, FRL_LOCK_FREE); apr_threadattr_create(&thd_attr, global_pool); apr_time_t now = apr_time_now(); for (int i = 0; i < 100; i++) { apr_thread_create(&pop_thds[i], thd_attr, threadsafe_test_pop, (void*)i, global_pool); apr_thread_create(&push_thds[i], thd_attr, threadsafe_test_push, (void*)i, global_pool); } apr_status_t rv; for (int i = 0; i < 100; i++) { printf("Stop at %d\n", i+1); apr_thread_join(&rv, push_thds[i]); apr_thread_join(&rv, pop_thds[i]); } printf("Pass with %dus.\n", apr_time_now()-now); apr_terminate(); }
int DB_init() { apr_status_t rv; apr_pool_t *mp; rv = apr_initialize(); assert(rv == APR_SUCCESS); apr_pool_create(&mp, NULL); if (access(DB_DIR, W_OK | X_OK) == -1) { apr_status_t rc = apr_dir_make_recursive( DB_DIR, APR_UREAD | APR_UWRITE | APR_UEXECUTE | APR_GREAD | APR_GWRITE | APR_GEXECUTE, mp ); assert(rc == APR_SUCCESS); } if (access(DB_FILE, W_OK) == -1) { FILE *db = DB_open(DB_FILE, "w"); assert(db != NULL); DB_close(db); } apr_pool_destroy(mp); apr_terminate(); return 0; }
/** * # gcc lookup.c -o lookup $(apr-1-config --cflags --cppflags --includes --link-ld) * # ./lookup google.com * * @author [email protected] */ int main(int argc, char *argv[]) { if (argc < 1) { printf("Usage: %s host\n", argv[0]); return APR_EGENERAL; } apr_status_t rv; apr_pool_t *pool; apr_sockaddr_t *addr; char *host = argv[1]; rv = apr_initialize(); if (rv != APR_SUCCESS) { printf("APR apr_initialize err\n"); return APR_EGENERAL; } apr_pool_create(&pool, NULL); rv = apr_sockaddr_info_get(&addr, host, APR_UNSPEC, 0, APR_IPV4_ADDR_OK, pool); if (rv != APR_SUCCESS) { printf("APR apr_sockaddr_info_get err\n"); return APR_EGENERAL; } printf("%s => %s\n", addr->hostname, inet_ntoa(addr->sa.sin.sin_addr)); apr_pool_destroy(pool); apr_terminate(); return APR_SUCCESS; }
int main(int argc, char ** argv) { apr_status_t rv; apr_pool_t * memoryPool = 0; char * buffer1 = 0; char * buffer2 = 0; rv = apr_initialize(); if (rv != APR_SUCCESS) { assert(0); return -1; } apr_pool_create(&memoryPool, NULL); buffer1 = apr_palloc(memoryPool, MEM_MALLOC); buffer2 = apr_palloc(memoryPool, MEM_MALLOC); apr_pool_destroy(memoryPool); apr_terminate(); return 0; }
int main(int argc,char **argv) { apr_initialize(); apr_pool_t *pool; apr_pool_create(&pool,NULL); apr_status_t st; apr_thread_pool_t *tpl; st=apr_thread_pool_create(&tpl,8,128,pool); apr_size_t n; for(long i=0;i<30;i++) { apr_thread_pool_push(tpl,thread_func,(void *)i,APR_THREAD_TASK_PRIORITY_NORMAL,NULL); apr_sleep(50000); } for(long i=0;i<10;i++) { n=apr_thread_pool_idle_count(tpl); printf("idle thread: %d\n",n); apr_sleep(1000000); } for(long i=100;i<130;i++) { apr_thread_pool_push(tpl,thread_func,(void *)i,APR_THREAD_TASK_PRIORITY_NORMAL,NULL); apr_sleep(50000); } for(long i=0;i<10;i++) { n=apr_thread_pool_idle_count(tpl); printf("idle thread: %d\n",n); apr_sleep(1000000); } apr_thread_pool_destroy(tpl); apr_pool_destroy(pool); apr_terminate(); return 0; }
int main(int argc, char **argv) { int bufsize = 1024*1024; char buffer[bufsize], *bstate; int n; Net_timeout_t dt; NetStream_t *ns; char cmd[512]; char *host; int port = 6714; int timeout = 15; if (argc < 2) { printf("get_version -a | host [port timeout]\n"); printf(" -a -Use the local host and default port\n"); return(0); } if (strcmp(argv[1], "-a") == 0) { host = (char *)malloc(1024); gethostname(host, 1023); } else { host = argv[1]; } if (argc > 2) port = atoi(argv[2]); if (argc == 4) timeout = atoi(argv[3]); set_net_timeout(&dt, timeout, 0); sprintf(cmd, "1 4 5 %d\n", timeout); // IBP_ST_VERSION command assert(apr_initialize() == APR_SUCCESS); dns_cache_init(10); ns = cmd_send(host, port, cmd, &bstate, timeout); if (ns == NULL) return(-1); if (bstate != NULL) free(bstate); //** Read the result. Termination occurs when the line "END" is read. //** Note that readline_netstream strips the "\n" from the end of the line n = NS_OK; while (n == NS_OK) { n = readline_netstream(ns, buffer, bufsize, dt); if (n == NS_OK) { if (strcmp(buffer, "END") == 0) { n = NS_OK+1; } else { printf("%s\n", buffer); } } } //** Close the connection close_netstream(ns); apr_terminate(); return(0); }
int main(int argc,char **argv) { apr_initialize(); apr_pool_t *pool; apr_pool_create(&pool,NULL); apr_status_t st; apr_hash_t *ht; ht=apr_hash_make(pool); char *key; char *value; key="laomeng"; value="*****@*****.**"; apr_hash_set(ht,key,strlen(key),value); key="laozhang"; value="*****@*****.**"; apr_hash_set(ht,key,strlen(key),value); char *getvalue=apr_hash_get(ht,key,strlen(key)); printf("getvalue : %s\n",getvalue); printf("total items: %u\n",apr_hash_count(ht)); apr_hash_set(ht,key,strlen(key),NULL); printf("total items: %u\n",apr_hash_count(ht)); apr_hash_clear(ht); printf("total items: %u\n",apr_hash_count(ht)); getvalue=apr_hash_get(ht,key,strlen(key)); printf("getvalue : %s\n",getvalue); apr_pool_destroy(pool); apr_terminate(); return 0; }
/** * memory pool sample code * @remark Error checks omitted */ int main(int argc, const char *argv[]) { apr_status_t rv; apr_pool_t *mp; char *buf1; char *buf2; /* per-process initialization */ rv = apr_initialize(); if (rv != APR_SUCCESS) { assert(0); return -1; } /* create a memory pool. */ apr_pool_create(&mp, NULL); /* allocate memory chunks from the memory pool */ buf1 = apr_palloc(mp, MEM_ALLOC_SIZE); buf2 = apr_palloc(mp, MEM_ALLOC_SIZE); /* destroy the memory pool. These chunks above are freed by this */ apr_pool_destroy(mp); apr_terminate(); return 0; }
void ll_cleanup_apr() { LL_INFOS("APR") << "Cleaning up APR" << LL_ENDL; if (gLogMutexp) { // Clean up the logging mutex // All other threads NEED to be done before we clean up APR, so this is okay. apr_thread_mutex_destroy(gLogMutexp); gLogMutexp = NULL; } if (gCallStacksLogMutexp) { // Clean up the logging mutex // All other threads NEED to be done before we clean up APR, so this is okay. apr_thread_mutex_destroy(gCallStacksLogMutexp); gCallStacksLogMutexp = NULL; } if (gAPRPoolp) { apr_pool_destroy(gAPRPoolp); gAPRPoolp = NULL; } apr_terminate(); }
int main(int argc,char **argv) { apr_initialize(); apr_pool_t *pool; apr_pool_create(&pool,NULL); apr_status_t st; apr_dbm_t *dbm; st=apr_dbm_open(&dbm,"friends",APR_DBM_RWCREATE,APR_OS_DEFAULT ,pool); apr_datum_t key,value; key.dptr="laomeng"; key.dsize=strlen(key.dptr); value.dptr="*****@*****.**"; value.dsize=strlen(value.dptr); st=apr_dbm_store(dbm,key,value); apr_datum_t pvalue; st=apr_dbm_fetch(dbm,key,&pvalue); char *pstr=apr_pstrndup(pool,pvalue.dptr,pvalue.dsize); printf("value => %s\n",pstr); apr_dbm_close(dbm); apr_pool_destroy(pool); apr_terminate(); return 0; }
static void terminate(void) { apr_terminate(); #ifdef NETWARE pressanykey(); #endif }
int main(int argc, const char * const * argv, const char * const *env) { apr_app_initialize(&argc, &argv, &env); apr_terminate(); }
int main(int argc, char **argv, char **env) { if (apr_app_initialize(&argc, (const char * const **) argv, (const char * const **) env) != APR_SUCCESS) { printf("apr_app_initialize failed\n"); return -1; } apr_pool_t *pool = NULL; apr_pool_create(&pool, NULL); request_rec *r = test_setup(pool); OpenSSL_add_all_digests(); char *result = all_tests(pool, r); if (result != 0) { printf("Failed: %s\n", result); } else { printf("All %d tests passed!\n", test_nr_run); } EVP_cleanup(); apr_pool_destroy(pool); apr_terminate(); return result != 0; }
// In fact, the main is a register function int main(int argc, const char *argv[]) { apr_status_t rv; apr_pool_t *mp; apr_hash_t *ht; struct proto_function *ppfun; apr_initialize(); apr_pool_create(&mp, NULL); ht = apr_hash_make(mp); // now register the module register_modules(&pfun, ht, mp); if (pfun.event == HELLO_EVENT) { ppfun = apr_hash_get(ht, "HELLO_EVENT", APR_HASH_KEY_STRING); if (ppfun != NULL) { ppfun->hello(); } } apr_pool_destroy(mp); apr_terminate(); return 0; }
int main(int argc, const char * const *argv) { apt_test_framework_t *test_framework; apt_test_suite_t *test_suite; apr_pool_t *pool; /* one time apr global initialization */ if(apr_initialize() != APR_SUCCESS) { return 0; } /* create test framework */ test_framework = apt_test_framework_create(); pool = apt_test_framework_pool_get(test_framework); /* create test suites and add them to test framework */ test_suite = set_get_test_suite_create(pool); apt_test_framework_suite_add(test_framework,test_suite); test_suite = parse_gen_test_suite_create(pool); apt_test_framework_suite_add(test_framework,test_suite); /* run tests */ apt_test_framework_run(test_framework,argc,argv); /* destroy test framework */ apt_test_framework_destroy(test_framework); /* final apr global termination */ apr_terminate(); return 0; }
void lt_templates_terminate(void) { // terminate our own structures // terminate APR library apr_terminate(); }
int main(int argc, const char *argv[]) { apr_pool_t *pool; int exit_code = EXIT_SUCCESS; svn_error_t *err; const char *url; svn_revnum_t revision; const char *propname; svn_string_t *propval; svn_string_t *old_propval; char *digits_end = NULL; svn_boolean_t want_error; const char *config_dir; if (argc != 7) { fprintf(stderr, USAGE_MSG, argv[0], KEY_OLD_PROPVAL, KEY_NEW_PROPVAL); exit(1); } if (apr_initialize() != APR_SUCCESS) { fprintf(stderr, "apr_initialize() failed.\n"); exit(1); } /* set up the global pool */ pool = svn_pool_create(NULL); /* Parse argv. */ url = svn_uri_canonicalize(argv[1], pool); revision = strtol(argv[2], &digits_end, 10); propname = argv[3]; SVN_INT_ERR(extract_values_from_skel(&old_propval, &propval, argv[4], pool)); want_error = !strcmp(argv[5], "1"); config_dir = svn_dirent_canonicalize(argv[6], pool); if ((! SVN_IS_VALID_REVNUM(revision)) || (! digits_end) || *digits_end) SVN_INT_ERR(svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL, _("Invalid revision number supplied"))); /* Do something. */ err = change_rev_prop(url, revision, propname, propval, old_propval, want_error, config_dir, pool); if (err) { svn_handle_error2(err, stderr, FALSE, "atomic-ra-revprop-change: "); svn_error_clear(err); exit_code = EXIT_FAILURE; } /* Clean up, and get outta here */ svn_pool_destroy(pool); apr_terminate(); return exit_code; }
/** * Shutdown callback for AOLserver */ void jk2_shutdown_system (void* data) { if (--jkInitCount == 0) { apr_pool_terminate (); apr_terminate (); } }
int main(int argc, char* argv[]) { apr_initialize(); apr_pool_create(&g_mp,NULL); apr_pool_destroy(g_mp); apr_terminate(); return 0; }
void free_apr_lib() { /* apr_terminate: * Tear down any APR internal data structures which aren't torn down automatically. * apr_terminate must be called once for every call to apr_initialize() or apr_app_initialize(). * */ apr_terminate(); }
void SVN_finish(void) { if(svn_data.initialized) { printf("SVN_finish\n"); svn_pool_destroy(svn_data.pool); apr_terminate(); svn_data.initialized = FALSE; } }
int main(int argc, const char *argv[]) { apr_pool_t *pool; int exit_code = EXIT_SUCCESS; svn_error_t *err; const char *path; const char *cmd; if (argc < 2 || argc > 4) { fprintf(stderr, "USAGE: entries-dump [--entries|--subdirs|--tree-dump] DIR_PATH\n"); exit(1); } if (svn_cmdline_init("entries-dump", stderr) != EXIT_SUCCESS) { return EXIT_FAILURE; } /* Create our top-level pool. Use a separate mutexless allocator, * given this application is single threaded. */ pool = apr_allocator_owner_get(svn_pool_create_allocator(FALSE)); path = svn_dirent_internal_style(argv[argc-1], pool); if (argc > 2) cmd = argv[1]; else cmd = NULL; if (!cmd || !strcmp(cmd, "--entries")) err = entries_dump(path, NULL, pool); else if (!strcmp(cmd, "--subdirs")) err = directory_dump(path, pool); else if (!strcmp(cmd, "--tree-dump")) err = tree_dump(path, pool); else err = svn_error_createf(SVN_ERR_INCORRECT_PARAMS, NULL, "Invalid command '%s'", cmd); if (err) { svn_handle_error2(err, stderr, FALSE, "entries-dump: "); svn_error_clear(err); exit_code = EXIT_FAILURE; } /* Clean up, and get outta here */ svn_pool_destroy(pool); apr_terminate(); return exit_code; }
int main(void) { apr_status_t rv = APR_SUCCESS; apr_status_t s = APR_SUCCESS; properties_pt config = NULL; char *autoStart = NULL; apr_pool_t *pool = NULL; bundle_pt fwBundle = NULL; rv = apr_initialize(); if (rv != APR_SUCCESS) { return CELIX_START_ERROR; } apr_pool_t *memoryPool; s = apr_pool_create(&memoryPool, NULL); if (s != APR_SUCCESS) { return CELIX_START_ERROR; } struct framework * framework = NULL; celix_status_t status = CELIX_SUCCESS; status = framework_create(&framework, memoryPool, config); if (status == CELIX_SUCCESS) { status = fw_init(framework); if (status == CELIX_SUCCESS) { // Start the system bundle framework_getFrameworkBundle(framework, &fwBundle); bundle_start(fwBundle); bundle_context_pt context = NULL; bundle_getContext(fwBundle, &context); // do some stuff bundle_pt bundle = NULL; status = CELIX_DO_IF(status, bundleContext_installBundle(context, "../test_bundle1/test_bundle1.zip", &bundle)); status = CELIX_DO_IF(status, bundle_start(bundle)); // Stop the system bundle, sleep a bit to let stuff settle down sleep(5); bundle_stop(fwBundle); framework_destroy(framework); } } if (status != CELIX_SUCCESS) { printf("Problem creating framework\n"); } apr_pool_destroy(memoryPool); apr_terminate(); printf("LAUNCHER: Exit\n"); return 0; }
int mpl_threads_deinit(void) { if (mpl_global_pool_p != NULL){ apr_pool_destroy(mpl_global_pool_p); mpl_global_pool_p = NULL; } apr_terminate(); return 0; }