char ask_password(char *pass,char text) { char *c; switch (text) { case 0:c ="Provˆ©en¡";break; case 1:c ="Zmˆna hesla";break; case 2:c ="Kontrola";break; } def_dialoge(320-100,240-50,200,90,c); define(-1,10,20,1,1,0,label,"Vlo‘ heslo:"); define(10,10,40,180,12,0,input_line,49); property(def_border(3,WINCOLOR),NULL,flat_color(RGB555(31,31,31)),RGB555(8,8,8)); if (text == 1)set_default(pass);else set_default("");on_event(ask_password_event); define(20,5,5,50,20,2,button,"OK"); property(def_border(1,0),NULL,NULL,WINCOLOR);on_change(terminate); define(30,5,5,50,20,3,button,"Zru¨it"); property(def_border(1,0),NULL,NULL,WINCOLOR);on_change(terminate); redraw_window(); goto_control(10); escape(); if (o_aktual->id == 30) text = 0;else { text = 1; get_value(0,10,pass); } close_current(); return text; }
static lcb_error_t connect_next(http_provider *http) { char *errinfo = NULL; lcb_error_t err; lcb_conn_params params; lcb_connection_t conn = &http->connection; close_current(http); reset_stream_state(http); params.handler = connect_done_handler; params.timeout = PROVIDER_SETTING(&http->base, config_node_timeout); lcb_log(LOGARGS(http, TRACE), "Starting HTTP Configuration Provider %p", http); err = lcb_connection_cycle_nodes(conn, http->nodes, ¶ms, &errinfo); if (err == LCB_SUCCESS) { err = setup_request_header(http); } else { lcb_log(LOGARGS(http, ERROR), "%p: Couldn't schedule connection (0x%x)", http, err); } return err; }
static void protocol_error(http_provider *http, lcb_error_t err) { int can_retry = 1; lcb_log(LOGARGS(http, ERROR), "Got protocol-level error 0x%x", err); PROVIDER_SET_ERROR(&http->base, err); /** * XXX: We only want to retry on some errors. Things which signify an * obvious user error should be left out here; we only care about * actual "network" errors */ if (err == LCB_AUTH_ERROR || err == LCB_PROTOCOL_ERROR || err == LCB_BUCKET_ENOENT) { can_retry = 0; } if (http->retry_on_missing && (err == LCB_BUCKET_ENOENT || err == LCB_AUTH_ERROR)) { LOG(http, INFO, "Retrying on AUTH||BUCKET_ENOENT"); can_retry = 1; } if (!can_retry) { close_current(http); lcb_confmon_provider_failed(&http->base, err); } else { io_error(http); } }
CFGBlock* start_new_block(VMMethod::Iterator& iter) { if(!iter.last_instruction()) { CFGBlock* blk = add_block(iter.next_position()); close_current(iter, blk); return blk; } return 0; }
void edit_side_ok() { int target,smer; target=f_get_value(0,360); smer=f_get_value(0,370); if (edit_side_save(target,smer)) { close_current(); info_sector(target); } }
static void delayed_disconn(lcb_timer_t tm, lcb_t instance, const void *cookie) { http_provider *http = (http_provider *)cookie; lcb_log(LOGARGS(http, DEBUG), "Stopping HTTP provider %p", http); /** closes the connection and cleans up the timer */ close_current(http); lcb_timer_disarm(http->io_timer); reset_stream_state(http); (void)tm; (void)instance; }
HDTBReturnItem NetworkClient::kill() { if(statusInfo.connectionSet) close_current(); if(statusInfo.comm) statusInfo.comm = false; if(statusInfo.blindComm) statusInfo.blindComm = false; statusInfo.connectionSet = false; return HDTBReturnItem(HDTB_RETURN_GOOD, ""); }
static void unwire_setup() { show_names=f_get_value(0,90) & 1; enable_sort=f_get_value(0,100) & 1; autoattack=f_get_value(0,110) & 1; autosave_enabled=f_get_value(0,120) & 1; level_preload=f_get_value(0,130) & 1; delete_from_timer(TM_CHECKBOX); mix_back_sound(32768); close_current(); send_message(E_DONE,E_KEYBOARD,setup_keyboard); wire_proc(); cancel_render=1; SEND_LOG("(GAME) Setup closed",0,0); }
/** * Call when there is an error in I/O. This includes read, write, connect * and timeouts. */ static lcb_error_t io_error(http_provider *http) { lcb_error_t err; lcb_conn_params params; char *errinfo; close_current(http); params.timeout = PROVIDER_SETTING(&http->base, config_node_timeout); params.handler = connect_done_handler; err = lcb_connection_next_node(&http->connection, http->nodes, ¶ms, &errinfo); if (err != LCB_SUCCESS) { lcb_confmon_provider_failed(&http->base, err); lcb_timer_disarm(http->io_timer); return err; } else { setup_request_header(http); } return LCB_SUCCESS; }
/** * Call when there is an error in I/O. This includes read, write, connect * and timeouts. */ static lcb_error_t io_error(http_provider *http, lcb_error_t origerr) { lcb_error_t err; lcb_conn_params params; char *errinfo; int can_retry = 0; close_current(http); params.timeout = PROVIDER_SETTING(&http->base, config_node_timeout); params.handler = connect_done_handler; if (http->base.parent->config) { can_retry = 1; } else if (origerr != LCB_AUTH_ERROR && origerr != LCB_BUCKET_ENOENT) { can_retry = 1; } if (can_retry) { err = lcb_connection_next_node( &http->connection, http->nodes, ¶ms, &errinfo); } else { err = origerr; } if (err != LCB_SUCCESS) { lcb_confmon_provider_failed(&http->base, origerr); lcb_timer_disarm(http->io_timer); if (is_v220_compat(http)) { lcb_log(LOGARGS(http, INFO), "HTTP node list finished. Looping again (disconn_tmo=-1)"); connect_next(http); } return origerr; } else { setup_request_header(http); } return LCB_SUCCESS; }
void build() { find_backward_gotos(); // Construct the root block specially. if(blocks_[0]) { root_ = blocks_[0]; } else { root_ = new CFGBlock(0); blocks_[0] = root_; } current_ = root_; VMMethod::Iterator iter(stream_, stream_size_); for(;;) { if(CFGBlock* next_block = find_block(iter.position())) { if(next_block->loop_p()) { // The handler wasn't setup originally, so we have to set it now. next_block->set_exception_handler(current_->exception_handler()); close_current(iter, next_block); } else { current_ = next_block; } } switch(iter.op()) { case InstructionSequence::insn_goto: case InstructionSequence::insn_goto_if_true: case InstructionSequence::insn_goto_if_false: if(iter.operand1() > iter.position()) { current_->add_child(add_block(iter.operand1())); start_new_block(iter); } else { #ifndef NDEBUG CFGBlock* loop_header = find_block(iter.operand1()); assert(loop_header); assert(loop_header->exception_handler() == current_->exception_handler()); #endif } break; case InstructionSequence::insn_setup_unwind: { assert(iter.operand1() > iter.position()); CFGBlock* handler = add_block(iter.operand1()); handler->set_exception_type(iter.operand2()); current_->add_child(handler); CFGBlock* body = start_new_block(iter); assert(body); // make sure it's not at the end. body->set_exception_handler(handler); break; } case InstructionSequence::insn_pop_unwind: { assert(current_->exception_handler()); CFGBlock* cont = start_new_block(iter); CFGBlock* current_handler = cont->exception_handler(); assert(current_handler); // Effectively pop the current handler by setting the // blocks handler (and thus all blocks after it) to the current // handlers handler. cont->set_exception_handler(current_handler->exception_handler()); break; } case InstructionSequence::insn_ensure_return: case InstructionSequence::insn_raise_exc: case InstructionSequence::insn_raise_return: case InstructionSequence::insn_raise_break: case InstructionSequence::insn_reraise: case InstructionSequence::insn_ret: start_new_block(iter); break; } if(!iter.advance()) break; } current_->set_end_ip(iter.position()); }
HDTBReturnItem NetworkClient::setConnectionInfo(std::string address, int port) { if(statusInfo.comm) return HDTBReturnItem(HDTB_RETURN_BAD, "Can not process request. Comm currently open"); if(statusInfo.blindComm) return HDTBReturnItem(HDTB_RETURN_BAD, "Can not process request. Blind comm currently open"); #ifdef _WIN32 return errorHandler.generateGenericError("OS not yet supported"); #else // If its already connected, close it. if(statusInfo.connectionSet) close_current(); // Set the connection information connectionInfo.port = port; connectionInfo.address = address; connectionInfo.sock = -1; //Create socket connectionInfo.sock = socket(AF_INET , SOCK_STREAM , 0); if (connectionInfo.sock == -1) return errorHandler.generateGenericError("Unable to create socket"); // Make sure address is ip // Ignore the warning generated if(inet_addr(connectionInfo.address.c_str()) == -1) { struct hostent * record = gethostbyname(connectionInfo.address.c_str()); if(record == NULL) return errorHandler.generateGenericError("Unable to resolve hostname"); in_addr * addy = (in_addr * )record->h_addr; connectionInfo.address = inet_ntoa(*addy); std::cout << "Address resolved to : " << connectionInfo.address << std::endl; } // If we already have an ip, set the connection connectionInfo.addr_in.sin_addr.s_addr = inet_addr( connectionInfo.address.c_str() ); connectionInfo.addr_in.sin_family = AF_INET; connectionInfo.addr_in.sin_port = htons( connectionInfo.port ); std::cout << "\t Attempting to make connection. This might take a moment " << std::endl; // Make the connection if (connect(connectionInfo.sock , (struct sockaddr *)&connectionInfo.addr_in , sizeof(connectionInfo.addr_in)) < 0) { return errorHandler.generateGenericError("Unable to connect to address"); } else { // Indicate what was done statusInfo.connectionSet = true; return HDTBReturnItem(HDTB_RETURN_GOOD, ""); } #endif }
int main(int argc,char *argv[]) { char *s; char *pr; char test[50]; char *mask; InitCrashDump(); SetConsoleCtrlHandler(HandlerRoutine,TRUE); filename[0] ='\0'; // strcpy(filename,"TEST.MAP"); args_support(argc-1,argv); printf("Hledam konfiguracni soubor\n"); config_file = read_config("WSKELDAL.INI"); if (config_file == NULL) { puts("...nemohu najit WSKELDAL.INI\n"); return 1; } if (strlen(filename)>3 && stricmp(filename+strlen(filename)-3,"adv") == 0) { TSTR_LIST adv_cfg = read_config(filename); config_file = merge_configs(config_file,adv_cfg); filename[0] = 0; } sample_path = get_text_field(config_file,"CESTA_ZVUKY"); if (sample_path == NULL) sample_path =""; mob_dir = get_text_field(config_file,"CESTA_ENEMY"); if (mob_dir == NULL) mob_dir =""; init_sound(); init(); concat(mask,get_text_field(config_file,"CESTA_MAPY"),"*.map"); atexit(shut_down); // signal(SIGABRT,shut_down); init_mob_list(); InitMapFiles(get_text_field(config_file,"CESTA_MAPY")); do { ask_exit_status = 2; if (filename[0] =='\0') browser(mask,filename); if (filename[0]!='\0') { char *mapy = get_text_field(config_file,"CESTA_MAPY"); memmove(filename+strlen(mapy),filename,strlen(filename)+1); memcpy(filename,mapy,strlen(mapy)); s = pripona(filename,".HI"); background_file = (char *)getmem(strlen(s)+1);strcpy(background_file,s); load_background(); } do_events(); logo(); pr = pripona(filename,SCR); script_name = NewArr(char,strlen(pr)+1); strcpy(script_name,pr); read_full_side_script(pr); read_spec_procs(); read_side_list(ITEMS_SCRIPT,&vzhled_veci,0,4); read_side_list(ITEMS_PICS,&pohledy_veci,0,2); read_dlg_list(DLG_SCRIPT,&dlg_names,&dlg_pgfs); read_side_list(WEAPONS_SCRIPT,&weapons,0,3); read_side_list(WEAPONS_SCRIPT,&weapons_pos,2,3); set_defaults(); init_multiactions(); memset(vyklenky,0,sizeof(vyklenky)); init_item_system(); if (filename[0]!='\0' ) { int sel = 1; init_maps(); set_defaults(); if (load_map(filename)) msg_box(filename,'\01',"Tento soubor je buƒ ne‡iteln˜, nebo po¨kozen˜","Pokra‡ovat",NULL); if (check_password(NULL) == 0) if (ask_password(test,0) == 0 || check_password(test) == 0) { filename[0] = 0; ask_exit_status = 1; goto preskoc; } if (maplen<2) { sel = msg_box(filename,' ',"Soubor neexistuje, bude vytvo©en nov˜. Nyn¡ je nutn‚ nastavit z kladn¡ stˆny" " a jin‚ dal¨¡ parametry pro tuto mapu","Pokra‡ujem","Zav©it",NULL); if (sel == 1) { newmap = 1; } } if (sel == 1) { create_menu(); redraw_window(); escape(); filename[0] = 0; close_current(); } } preskoc: free(background_file); } while (ask_exit_status == 1); ClearMapFiles(); redraw_desktop(); close_manager(); return 0; }