int main(void) { mxchipInit(); UART_Init(); printf("\r\n%s\r\nmxchipWNet library version: %s\r\n", APP_INFO, system_lib_version()); readConfig(&configParas); #ifdef LowPowerMode enable_ps_mode(SLEEP_UNIT_MS, 100, 100); #endif memset(&wNetConfig, 0x0, sizeof(network_InitTypeDef_st)); wNetConfig.wifi_mode = Soft_AP; strcpy(wNetConfig.wifi_ssid, configParas.wifi_ssid); strcpy(wNetConfig.wifi_key, configParas.wifi_key); sprintf(wNetConfig.local_ip_addr, "192.168.1.1"); sprintf(wNetConfig.net_mask, "255.255.255.0"); sprintf(wNetConfig.gateway_ip_addr, "192.168.1.1"); sprintf(wNetConfig.dnsServer_ip_addr, "192.168.1.1"); sprintf(wNetConfig.address_pool_start, "192.168.1.100"); sprintf(wNetConfig.address_pool_end, "192.168.1.200"); wNetConfig.dhcpMode = DHCP_Server; StartNetwork(&wNetConfig); printf("Establish soft AP: %s.....\r\n", wNetConfig.wifi_ssid); set_tcp_keepalive(3, 60); http_init(); while(1) { mxchipTick(); http_tick(); } }
SSPEC_MIMETABLE_END void main() { /* * sock_init initializes the TCP/IP stack. * http_init initializes the web server. */ sock_init(); http_init(); /* * tcp_reserveport causes the web server to ignore requests when there * isn't an available socket (HTTP_MAXSERVERS are all serving index_html * or rabbit1.gif). This saves some memory, but can cause the client * delays when retrieving pages. */ tcp_reserveport(80); dlp_init(); /* * http_handler needs to be called to handle the active http servers. */ for(;;) { tcp_tick(NULL); http_handler(); dlp_handler(); } }
void main(void) { /* * Get the compressed sizes of the files */ xmem2root(&text_size, alice_html, 4); text_size &= ZIMPORT_MASK; xmem2root(&image_size, alice_jpg, 4); image_size &= ZIMPORT_MASK; /* * When compressed files are added via the sspec_addxmemfile() function, * they are automatically detected as such. This is in distinction to * the static resource table setup (i.e. SSPEC_RESOURCE_* macros) which * require explicit specification at compile time. * * Note, that jpeg or gif files (as in the following) do not generally * compress well (or at all). Hence, it is best to leave image files uncompressed. */ sspec_addxmemfile("/alice.jpg", alice_jpg, SERVER_HTTP); sspec_addvariable("text_size", &text_size, INT32, "%ld", SERVER_HTTP); sspec_addvariable("image_size", &image_size, INT32, "%ld", SERVER_HTTP); // Start network and wait for interface to come up (or error exit). sock_init_or_exit(1); http_init(); while (1) { http_handler(); } }
struct walker *get_http_walker(const char *url, struct remote *remote) { char *s; struct walker_data *data = xmalloc(sizeof(struct walker_data)); struct walker *walker = xmalloc(sizeof(struct walker)); http_init(remote); data->no_pragma_header = curl_slist_append(NULL, "Pragma:"); data->alt = xmalloc(sizeof(*data->alt)); data->alt->base = xmalloc(strlen(url) + 1); strcpy(data->alt->base, url); for (s = data->alt->base + strlen(data->alt->base) - 1; *s == '/'; --s) *s = 0; data->alt->got_indices = 0; data->alt->packs = NULL; data->alt->next = NULL; data->got_alternates = -1; walker->corrupt_object_found = 0; walker->fetch = fetch; walker->fetch_ref = fetch_ref; walker->prefetch = prefetch; walker->cleanup = cleanup; walker->data = data; #ifdef USE_CURL_MULTI add_fill_function(walker, (int (*)(void *)) fill_active_slot); #endif return walker; }
int main() { int conn = connectsocket("nothings.org", 80); if (conn < 0) { fprintf(stderr, "Failed to connect socket\n"); return -1; } const char request[] = "GET / HTTP/1.0\r\nContent-Length: 0\r\n\r\n"; int len = send(conn, request, sizeof(request) - 1, 0); if (len != sizeof(request) - 1) { fprintf(stderr, "Failed to send request\n"); close(conn); return -1; } HttpResponse response; response.code = 0; http_roundtripper rt; http_init(&rt, responseFuncs, &response); bool needmore = true; char buffer[1024]; while (needmore) { const char* data = buffer; int ndata = recv(conn, buffer, sizeof(buffer), 0); if (ndata <= 0) { fprintf(stderr, "Error receiving data\n"); http_free(&rt); close(conn); return -1; } while (needmore && ndata) { int read; needmore = http_data(&rt, data, ndata, &read); ndata -= read; data += read; } } if (http_iserror(&rt)) { fprintf(stderr, "Error parsing data\n"); http_free(&rt); close(conn); return -1; } http_free(&rt); close(conn); printf("Response: %d\n", response.code); if (!response.body.empty()) { printf("%s\n", &response.body[0]); } return 0; }
int main(void) { // SystemINIT SystemInit(); // Init Debug Serial serial_init(); // Init COOS CoInitOS (); // Setup tasks cli_init(); // Init Serial Client ip_init(); // Init IP Stack http_init(); // Init HTTP Server // Start Tasks! CoStartOS (); // Never to get here!!! while(1) { } }
int main(int argc, char **argv) { http_t me; int res; char *keys[] = {sz1, sz2}; http_init(&me, keys, 2); http_hypertext_attach(&me, ht); http_hypertext_receving(&me, strlen(ht)); res = http_parse_result(&me); /* http_hypertext_detach(&me);*/ hdr_parser_compile(&me); me.hdr_parser_current = me.hdr_parser_root; http_parse_hdr(&me); hdr_parser_dismiss(&me); http_uninit(&me); exit(0); }
main() { /* Set both LED's initially ON. When update_outputs() is called, the * human will see it this way. */ strcpy(led2,led_on_gif); strcpy(led3,led_on_gif); sock_init(); http_init(); tcp_reserveport(80); /* Configure the I/O ports. Disable slave port which makes * Port A an output, and PORT E not have SCS signal. * Read shadow and set PE1 and PE7 as normal I/O. * LED's are controlled by PE1 and PE7, so make them outputs. */ WrPortI(SPCR, NULL, 0x84); WrPortI(PEFR, & PEFRShadow, ~((1<<7)|(1<<1)) & PEFRShadow); WrPortI(PEDDR, & PEDDRShadow, (1<<7)|(1<<1)); while (1) { update_outputs(); http_handler(); } }
void main() { SSL_Cert_t my_cert; // Start network and wait for interface to come up (or error exit). sock_init_or_exit(1); http_init(); memset(&my_cert, 0, sizeof(my_cert)); // When using HTTPS (i.e. HTTP over SSL or TLS), the certificates need // to be parsed and registered with the library. For use with a // server, we need to know our own private key. if (SSL_new_cert(&my_cert, server_pub_cert, SSL_DCERT_XIM, 0) || SSL_set_private_key(&my_cert, server_priv_key, SSL_DCERT_XIM)) exit(7); // Register certificate with HTTPS server. https_set_cert(&my_cert); tcp_reserveport(443); /* * http_handler needs to be called to handle the active http servers. */ while (1) { http_handler(); } }
int main( int argc, char **argv ) { char *cfg_file; char *module_name; module_t *module; __get_args( &cfg_file, &module_name, argc, argv ); main_init(); module = module_get( module_name ); config_init( cfg_file, module->cfg_init_cb ); logger_init(); net_init(); http_init(); module->init_cb(); net_main_loop(); return 0; }
void main(void) { auto int i; // Initialized the #web-registered variables. for (i = 0; i < 5; i++) { array1[i] = i + 1; } array2[0][0] = 2; array2[0][1] = 3; array2[1][0] = 4; array2[1][1] = 5; for (i = 0; i < 3; i++) { array3[i] = i + 5; } // Initialize the TCP/IP stack and HTTP server sock_init(); http_init(); // This yields a performance improvement for an HTTP server tcp_reserveport(80); while (1) { // Drive the HTTP server http_handler(); } }
main() { // Set Port A pins for LEDs low BitWrPortI(PADR, &PADRShadow, 1, DS1); BitWrPortI(PADR, &PADRShadow, 1, DS2); BitWrPortI(PADR, &PADRShadow, 1, DS3); BitWrPortI(PADR, &PADRShadow, 1, DS4); // Make Port A bit-wide output BitWrPortI(SPCR, &SPCRShadow, 1, 2); BitWrPortI(SPCR, &SPCRShadow, 0, 3); strcpy(led1,"ledon.gif"); strcpy(led2,"ledoff.gif"); strcpy(led3,"ledon.gif"); strcpy(led4,"ledoff.gif"); sock_init_or_exit(1); http_init(); tcp_reserveport(80); while (1) { update_outputs(); http_handler(); } }
int main(void) { CoInitOS(); lwip_init(); http_init(); CoStartOS(); while(1); }
static int init_lua( lua_State *L ) { lhttp_t *h = luaL_checkudata( L, 1, MODULE_MT ); http_init( h->r ); return 0; }
void packet_parser_init() { static int done = 0; if (!done) { done = 1; http_init(); } }
void afunix_packet_parser_init() { static int done = 0; if (!done) { DEBUGF(("packet_parser_init\r\n")); done = 1; http_init(); } }
static DWORD download_thread(HWND hwnd) { char path[MAX_PATH], dir[MAX_PATH], *file; GetModuleFileName(NULL, path, MAX_PATH); GetFullPathName(path, sizeof dir, dir, &file); http_init(); if (!file) { MessageBox(NULL, "Error finding my own filename, the heck?", "CnCNet", MB_OK|MB_ICONERROR); PostMessage(hwnd, WM_USER+2, 0, 0); return 0; } data.fh = fopen("cncnet.tmp", "wb"); if (!data.fh) { MessageBox(NULL, "Error opening cncnet.tmp for writing. Could you please remove it for me?", "CnCNet", MB_OK|MB_ICONERROR); PostMessage(hwnd, WM_USER+2, 0, 0); return 0; } data.progress = GetDlgItem(hwnd, IDC_PROGRESS); SendMessage(data.progress, PBM_SETRANGE, 0, MAKELPARAM(0, 100)); if (http_get(CLIENT_URL, (HTTP_CALLBACK)download_write, &data)) { STARTUPINFO sInfo; PROCESS_INFORMATION pInfo; fclose(data.fh); rename(file, "cncnet.ex_"); rename("cncnet.tmp", file); ZeroMemory(&sInfo, sizeof sInfo); sInfo.cb = sizeof sInfo; ZeroMemory(&pInfo, sizeof pInfo); if (CreateProcess(NULL, file, NULL, NULL, TRUE, 0, NULL, NULL, &sInfo, &pInfo) == 0) { MessageBox(NULL, "Error restarting, new exe is corrupted? :-(", "CnCNet", MB_OK|MB_ICONERROR); } } else { fclose(data.fh); } http_release(); PostMessage(hwnd, WM_USER+2, 0, 0); return 0; }
int __stdcall thcrap_plugin_init() { http_init(); update_notify_thcrap(); update_notify_game(); BP_update_poll(NULL, NULL); return 0; }
int gs_init(PSERVER_DATA server, const char *keyDirectory) { mkdirtree(keyDirectory); if (load_unique_id(keyDirectory) != GS_OK) return GS_FAILED; if (load_cert(keyDirectory)) return GS_FAILED; http_init(keyDirectory); return load_server_status(server); }
ls_status_t libswitch_postConfig(apr_pool_t* p, apr_pool_t* plog, apr_pool_t* ptemp, Config* config){ config_core* ccore=NULL; ce_error_list* errorList=NULL; char* error=NULL; char cbuf[APR_CTIME_LEN + 1]; // normalize paths config->config_core_file = apr_pstrcat(p, config->home_dir, "/", config->config_core_file, NULL); config->logfile_name = apr_pstrcat(p, config->home_dir, "/", config->logfile_name, NULL); logcore_openLogFile(p,config->logfile_name); logcore_truncateLogFile(); apr_time_t t1 = apr_time_now(); apr_ctime(cbuf, t1); logcore_printLog("\n°\t Initializing %s [%s][%s]\n",VERSION_ID,config->systemInfo,cbuf); fflush(stdout); http_init(); fflush(stdout); //printf("√ Success using the following configuration:\r\n"); fflush(stdout); //init Error Obj errorList=ce_newErrorListObj(p); //load crypto core logcore_printLog("\r\n\r\n"); ccore=cc_newConfigCoreObj(p); ccore->globals->homeDir=apr_pstrdup(p,config->home_dir); ccore->globals->logsDir=apr_pstrcat(p,config->home_dir,"/logs",NULL); ccore->refreshLogFile=apr_pstrdup(p,config->logfile_name); error=cc_loadConfigCoreFile(p, config->config_core_file, ccore); ce_addErrorWithType(p,errorList,"Config Core Load File",error); if(error==NULL){ cc_printConfigCoreDetails(p,ccore); error=cc_initializeConfigCore(p,ccore); ce_addErrorWithType(p,errorList,"Config Core Init",error); config->configCore=ccore; logcore_printLog("√ Config Core Initialized\n"); logcore_printLog("° Binding Config Core Services\n"); error=libswitch_postRefreshBind(p,config); ce_addErrorWithType(p,errorList,"Config Core Bind",error); } if(!ce_hasErrors(errorList)){ logcore_printLog("\r\n>> %s [%s] - Libswitch initialized <<\r\n",VERSION_ID,config->systemInfo); }else{ logcore_printLog("\r\n>> %s [%s] - Libswitch initialized WITH ERRORS<<\r\n",VERSION_ID,config->systemInfo); ce_printList(p,errorList); return LS_FAILURE; } return LS_SUCCESS; }
void main(void) { // Start network and wait for interface to come up (or error exit). sock_init_or_exit(1); http_init(); tcp_reserveport(80); while (1) { http_handler(); } }
int main() { SystemInit(); printf("aaa"); CoInitOS(); lwip_init_task(); http_init(); CoStartOS(); while(1); }
main(){ int correct, i; brdInit(); // sock_init initializes the TCP/IP stack. // http_init initializes the web server. sock_init(); http_init(); tcp_reserveport(80); mode = -1; // -1 = uninitialized while(1){ if(mode== -1){ InitializeGame(); mode = 0; } http_handler(); if(numUsedGuesses == 6){ // guesses used up mode = 1; numUsedGuesses = 0; strcpy(hint,wrd->answer); } if(character) { // new character entered correct = 0; // assume incorrect guess // see if character is in word for(i = 0 ; i < strlen(wrd->answer) ; i++) { if(wrd->answer[i] == (char)character) { guess[i] = newGuess[2*i] = (char)character; correct = 1; } } // see if word is guessed correctly if( !strcmpi(guess, wrd->answer) ){ prompt[0] = 0; numUsedGuesses = 7; // 7 signals win } else if(correct == 0) { numUsedGuesses++; currentGIF++; // use next GIF sprintf(prompt,"You have %d guesses left!", 6-numUsedGuesses); } character = 0; } } }
int main(int argc, char **argv) { int r, seq1, size1; CF_VALS cf; RT_LLD lld1; time_t time1; ITREE *chain; ROUTE_BUF *rtbuf; cf = cf_create(); http_init(); rt_http_init(cf, 1); /* test 1: is it there? */ r = rt_http_access(TURL1, NULL, TURL1, ROUTE_READOK); if (r) elog_die(FATAL, "[1] shouldn't have read access to http %s", TURL1); r = rt_http_access(TURL1, NULL, TURL1, ROUTE_WRITEOK); if (r) elog_die(FATAL, "[1] shouldn't have write access to http %s", TURL1); /* test 2: open for read only should not create http */ lld1 = rt_http_open(TURL1, "blah", NULL, 0, TURL1); if (!lld1) elog_die(FATAL, "[2] no open http descriptor"); /* test 3: read an http location */ chain = rt_http_read(lld1, 0, 0); if (itree_n(chain) != 1) elog_die(FATAL, "[3] wrong number of buffers: %d", itree_n(chain)); itree_first(chain); rtbuf = itree_get(chain); if (!rtbuf) elog_die(FATAL, "[3] no buffer"); if (!rtbuf->buffer) elog_die(FATAL, "[3] NULL buffer"); if (rtbuf->buflen != strlen(rtbuf->buffer)) elog_die(FATAL, "[3] buffer length mismatch %d != %d", rtbuf->buflen, strlen(rtbuf->buffer)); route_free_routebuf(chain); /* test 4: tell test */ r = rt_http_tell(lld1, &seq1, &size1, &time1); if (r) elog_die(FATAL, "[4] http tell should always fail"); rt_http_close(lld1); cf_destroy(cf); rt_http_fini(); return 0; }
/** * \brief Create ethernet task, for ethernet management. */ void init_ethernet(void) { /** Initialize lwIP */ lwip_init(); /** Set hw and IP parameters, initialize MAC too */ ethernet_configure_interface(); #if defined(HTTP_RAW_USED) /** Bring up the web server */ http_init(); #endif }
int main(void) { char *http_buf = "GET /index HTTP/1.1\r\n" "Content-Type:html/text\r\n" "Content-Length:5\r\n\r\n" "hello\r\n"; http_init(); struct http_pack *http = http_parse(http_buf); http_pack_info(http); return 0; }
void main() { /* FORM stuff */ sspec_addxmemfile("register.html", reg_form, SERVER_HTTP); sspec_addfunction("submit.cgi", submit, SERVER_HTTP); /* normal SSI button stuff */ sspec_addxmemfile("/", index_html, SERVER_HTTP); sspec_addxmemfile("index.shtml", index_html, SERVER_HTTP); sspec_addxmemfile("showsrc.shtml", showsrc_shtml, SERVER_HTTP); sspec_addxmemfile("rabbit1.gif", rabbit1_gif, SERVER_HTTP); sspec_addxmemfile("ledon.gif", ledon_gif, SERVER_HTTP); sspec_addxmemfile("ledoff.gif", ledoff_gif, SERVER_HTTP); sspec_addxmemfile("button.gif", button_gif, SERVER_HTTP); sspec_addxmemfile("ssi.c", ssi_c, SERVER_HTTP); sspec_addvariable("led1", led1, PTR16, "%s", SERVER_HTTP); sspec_addvariable("led2", led2, PTR16, "%s", SERVER_HTTP); sspec_addvariable("led3", led3, PTR16, "%s", SERVER_HTTP); sspec_addvariable("led4", led4, PTR16, "%s", SERVER_HTTP); sspec_addfunction("led1tog.cgi", led1toggle, SERVER_HTTP); sspec_addfunction("led2tog.cgi", led2toggle, SERVER_HTTP); sspec_addfunction("led3tog.cgi", led3toggle, SERVER_HTTP); sspec_addfunction("led4tog.cgi", led4toggle, SERVER_HTTP); sspec_addfunction("audit", audit_list_print, SERVER_HTTP); strcpy(led1,"ledon.gif"); strcpy(led2,"ledon.gif"); strcpy(led3,"ledoff.gif"); strcpy(led4,"ledon.gif"); /* Init the audit history */ AuditInit(); /* init FORM searchable names - must init ALL FORMSpec structs! */ FORMSpec[0].name = "user_name"; FORMSpec[1].name = "user_email"; // Start network and wait for interface to come up (or error exit). sock_init_or_exit(1); http_init(); tcp_reserveport(80); while (1) { http_handler(); } }
static void upload_queue_run(const struct session *session, unsigned const char key[KDF_HASH_LEN]) { _cleanup_free_ char *pid = NULL; upload_queue_kill(); pid_t child = fork(); if (child < 0) die_errno("fork(agent)"); if (child == 0) { _cleanup_free_ char *upload_log_path = NULL; int null = open("/dev/null", 0); int upload_log = null; if (lpass_log_level() >= 0) { upload_log_path = config_path("lpass.log"); upload_log = open(upload_log_path, O_WRONLY | O_CREAT | O_APPEND, 0600); } if (null >= 0) { dup2(null, 0); dup2(upload_log, 1); dup2(null, 2); close(null); close(upload_log); } setsid(); IGNORE_RESULT(chdir("/")); process_set_name("lpass [upload queue]"); signal(SIGHUP, upload_queue_cleanup); signal(SIGINT, upload_queue_cleanup); signal(SIGQUIT, upload_queue_cleanup); signal(SIGTERM, upload_queue_cleanup); signal(SIGALRM, upload_queue_cleanup); setvbuf(stdout, NULL, _IOLBF, 0); if (http_init()) { lpass_log(LOG_ERROR, "UQ: unable to restart curl\n"); _exit(EXIT_FAILURE); } lpass_log(LOG_DEBUG, "UQ: starting queue run\n"); upload_queue_upload_all(session, key); lpass_log(LOG_DEBUG, "UQ: queue run complete\n"); upload_queue_cleanup(0); _exit(EXIT_SUCCESS); } pid = xultostr(child); config_write_string("uploader.pid", pid); }
/** * Does network and HTTP setup */ void setupHttp() { // IP Buffer char buffer[16]; // User ID int userid; // Initialize the board brdInit(); // Initialize the socket sock_init(); // Wait for IP address to be obtained while (ifpending(IF_DEFAULT) == IF_COMING_UP) { tcp_tick(NULL); } // Output the IP Address printf("My IP address is %s\n", inet_ntoa(buffer, gethostid())); //Set up the HTTP Server http_init(); tcp_reserveport(80); // Set redirect http_set_path("/", "/index.zhtml"); // Set up authentication sspec_addrule("/", "Admin", admin, admin, SERVER_ANY, SERVER_AUTH_BASIC, NULL); // Add our users // Ario userid = sauth_adduser("ario", "fish", SERVER_ANY); sauth_setusermask(userid, admin, NULL); // Chan userid = sauth_adduser("chan", "bar", SERVER_ANY); sauth_setusermask(userid, admin, NULL); // Jeff userid = sauth_adduser("jeff", "bar7", SERVER_ANY); sauth_setusermask(userid, admin, NULL); // Shea userid = sauth_adduser("shea", "bar2", SERVER_ANY); sauth_setusermask(userid, admin, NULL); // Toby userid = sauth_adduser("toby", "bar3", SERVER_ANY); sauth_setusermask(userid, admin, NULL); //Done }
void gwlib_init(void) { gw_assert(!init); gw_init_mem(); uuid_init(); octstr_init(); gwlib_protected_init(); gwthread_init(); log_init(); http_init(); socket_init(); charset_init(); cfg_init(); init = 1; }