END_TEST static void do_md5sum_test(const char *endfile, int warnings, void setup_callback(struct asfd *asfd, struct sbuf *sb)) { struct asfd *asfd; struct cntr *cntr; struct sbuf *sb; const char *path="somepath"; const char *datapth="/datapth"; const char *best=BASE "/existent"; clean(); cntr=setup_cntr(); sb=setup_sbuf(path, datapth, endfile, 0/*compression*/); build_file(best, "blah"); asfd=asfd_mock_setup(&areads, &awrites); setup_callback(asfd, sb); // Returns 0 so that the parent process continues. fail_unless(!verify_file(asfd, sb, 0 /*patches*/, best, cntr)); fail_unless(cntr->ent[CMD_WARNING]->count==warnings); tear_down(&sb, &cntr, NULL, &asfd); }
static void frontend_psp_init(void *data) { #ifndef IS_SALAMANDER #ifndef VITA (void)data; /* TODO/FIXME - Err on the safe side for now and * assume these aren't there with the PSP2/Vita SDKs. */ /* initialize debug screen */ pspDebugScreenInit(); pspDebugScreenClear(); setup_callback(); pspFpuSetEnable(0); /* disable FPU exceptions */ scePowerSetClockFrequency(333,333,166); #else scePowerSetArmClockFrequency(444); #endif #endif #if defined(HAVE_KERNEL_PRX) || defined(IS_SALAMANDER) #ifndef VITA pspSdkLoadStartModule("kernel_functions.prx", PSP_MEMORY_PARTITION_KERNEL); #endif #endif }
static void frontend_psp_init(void *data) { #ifndef IS_SALAMANDER #ifdef VITA scePowerSetArmClockFrequency(444); sceSysmoduleLoadModule(SCE_SYSMODULE_NET); pthread_init(); #else (void)data; /* initialize debug screen */ pspDebugScreenInit(); pspDebugScreenClear(); setup_callback(); pspFpuSetEnable(0); /* disable FPU exceptions */ scePowerSetClockFrequency(333,333,166); #endif #endif #if defined(HAVE_KERNEL_PRX) || defined(IS_SALAMANDER) #ifndef VITA pspSdkLoadStartModule("kernel_functions.prx", PSP_MEMORY_PARTITION_KERNEL); #endif #endif }
static void system_init(void) { //initialize debug screen pspDebugScreenInit(); pspDebugScreenClear(); setup_callback(); }
bool window::init() { SciterSetOption(_hwnd, SCITER_ALPHA_WINDOW, TRUE); SetWindowLongPtr(_hwnd, GWLP_USERDATA, LONG_PTR(this)); setup_callback(); load_file(L"res:default.htm"); return true; }
window::window( UINT creationFlags, RECT frame): _hwnd(NULL) { _hwnd = ::SciterCreateWindow(creationFlags,&frame,&msg_delegate,this,NULL); if( _hwnd ) { add_ref(); setup_callback(); sciter::attach_dom_event_handler(get_hwnd(),this); } }
window::window( UINT creationFlags, RECT frame): _hwnd(NULL) { _hwnd = SAPI()->SciterCreateWindow(creationFlags, (frame.right - frame.left) > 0 ? &frame: NULL,NULL,this,NULL); if( _hwnd ) { add_ref(); setup_callback(); sciter::attach_dom_event_handler(get_hwnd(),this); } }
static void frontend_psp_init(void *data) { (void)data; //initialize debug screen pspDebugScreenInit(); pspDebugScreenClear(); setup_callback(); pspFpuSetEnable(0);//disable FPU exceptions scePowerSetClockFrequency(333,333,166); }
static void do_snapshot_test( const char *orig_client, int expected_ret, void setup_callback( struct asfd *csin, struct asfd *csout, struct asfd *so_asfd ) ) { struct asfd *csin; struct asfd *csout; struct asfd *so_asfd; struct async *as; struct sel *sel; as=setup_async(); csin=asfd_mock_setup(&reads_csin, &writes_csin); csout=asfd_mock_setup(&reads_csout, &writes_csout); so_asfd=asfd_mock_setup(&reads_so, &writes_so); fail_unless((csin->desc=strdup_w("csin", __func__))!=NULL); fail_unless((csout->desc=strdup_w("csout", __func__))!=NULL); fail_unless((so_asfd->desc=strdup_w("so_asfd", __func__))!=NULL); as->asfd_add(as, csin); as->asfd_add(as, csout); as->asfd_add(as, so_asfd); as->read_write=async_rw_simple; as->write=async_write_simple; setup_callback(csin, csout, so_asfd); fail_unless((sel=sel_alloc())!=NULL); fail_unless(!status_client_ncurses_init(ACTION_STATUS_SNAPSHOT)); fail_unless(status_client_ncurses_main_loop( as, so_asfd, sel, orig_client )==expected_ret); sel_free(&sel); asfd_free(&csin); asfd_free(&csout); asfd_free(&so_asfd); asfd_mock_teardown(&reads_csin, &writes_csin); asfd_mock_teardown(&reads_csout, &writes_csout); asfd_mock_teardown(&reads_so, &writes_so); async_free(&as); alloc_check(); }
/*---------------------------------------------------------------------------*/ static void send_packet(mac_callback_t sent, void *ptr) { int size; /* 3 bytes per packet attribute is required for serialization */ uint8_t buf[PACKETBUF_NUM_ATTRS * 3 + PACKETBUF_SIZE + 3]; int sid; packetbuf_set_addr(PACKETBUF_ADDR_SENDER, &linkaddr_node_addr); /* ack or not ? */ packetbuf_set_attr(PACKETBUF_ATTR_MAC_ACK, 1); if(NETSTACK_FRAMER.create_and_secure() < 0) { /* Failed to allocate space for headers */ LOG6LBR_ERROR("br-rdc: send failed, too large header\n"); mac_call_sent_callback(sent, ptr, MAC_TX_ERR_FATAL, 1); } else { /* here we send the data over SLIP to the radio-chip */ size = 0; if(sixlbr_config_slip_serialize_tx_attrs) { size = packetutils_serialize_atts(&buf[3], sizeof(buf) - 3); } if(size < 0 || size + packetbuf_totlen() + 3 > sizeof(buf)) { LOG6LBR_ERROR("br-rdc: send failed, too large header\n"); mac_call_sent_callback(sent, ptr, MAC_TX_ERR_FATAL, 1); } else { sid = setup_callback(sent, ptr); if (sid != -1) { LOG6LBR_PRINTF(PACKET, RADIO_OUT, "write: %d (sid: %d, cb: %d)\n", packetbuf_datalen(), sid, callback_count); LOG6LBR_DUMP_PACKET(RADIO_OUT, packetbuf_dataptr(), packetbuf_datalen()); buf[0] = '!'; buf[1] = 'S'; buf[2] = sid; /* sequence or session number for this packet */ /* Copy packet data */ memcpy(&buf[3 + size], packetbuf_hdrptr(), packetbuf_totlen()); callbacks[sid].buf_len = packetbuf_totlen() + size + 3; memcpy(callbacks[sid].buf, buf, callbacks[sid].buf_len); write_to_slip(buf, callbacks[sid].buf_len); } else { LOG6LBR_INFO("native-rdc queue full\n"); mac_call_sent_callback(sent, ptr, MAC_TX_NOACK, 1); } } } }
static void frontend_psp_init(void *data) { #ifndef IS_SALAMANDER (void)data; //initialize debug screen pspDebugScreenInit(); pspDebugScreenClear(); setup_callback(); pspFpuSetEnable(0);//disable FPU exceptions scePowerSetClockFrequency(333,333,166); #endif #if defined(HAVE_KERNEL_PRX) || defined(IS_SALAMANDER) pspSdkLoadStartModule("kernel_functions.prx", PSP_MEMORY_PARTITION_KERNEL); #endif }
/*---------------------------------------------------------------------------*/ static void send_packet(mac_callback_t sent, void *ptr) { int size; /* 3 bytes per packet attribute is required for serialization */ uint8_t buf[PACKETBUF_NUM_ATTRS * 3 + PACKETBUF_SIZE + 3]; uint8_t sid; packetbuf_set_addr(PACKETBUF_ADDR_SENDER, &rimeaddr_node_addr); /* ack or not ? */ packetbuf_set_attr(PACKETBUF_ATTR_MAC_ACK, 1); if(NETSTACK_FRAMER.create() < 0) { /* Failed to allocate space for headers */ PRINTF("br-rdc: send failed, too large header\n"); mac_call_sent_callback(sent, ptr, MAC_TX_ERR_FATAL, 1); } else { /* here we send the data over SLIP to the radio-chip */ size = 0; #if SERIALIZE_ATTRIBUTES size = packetutils_serialize_atts(&buf[3], sizeof(buf) - 3); #endif if(size < 0 || size + packetbuf_totlen() + 3 > sizeof(buf)) { PRINTF("br-rdc: send failed, too large header\n"); mac_call_sent_callback(sent, ptr, MAC_TX_ERR_FATAL, 1); } else { PRINTF("SLIP: Sending %d\n", packetbuf_totlen()); sid = setup_callback(sent, ptr); buf[0] = '!'; buf[1] = 'S'; buf[2] = sid; /* sequence or session number for this packet */ /* Copy packet data */ memcpy(&buf[3 + size], packetbuf_hdrptr(), packetbuf_totlen()); write_to_slip(buf, packetbuf_totlen() + size + 3); } } }
static void run_test(int expected_ret, const char *expected_server_version, void setup_callback(struct asfd *asfd)) { struct asfd *asfd=asfd_mock_setup(&reads, &writes); char *server_version=NULL; setup_callback(asfd); fail_unless(authorise_client(asfd, &server_version, "testclient", "password", NULL /* cntr */)==expected_ret); if(expected_server_version) ck_assert_str_eq(expected_server_version, server_version); else fail_unless(server_version==NULL); free_w(&server_version); tear_down(&asfd); }
void HostSciter::Setup() { //#if !DEBUG #if 1 // bind resources[] (defined in "archive.cpp") with the archive - RELEASE mode only #include "archive.cpp" sciter::archive::instance().open(aux::elements_of(resources)); #endif // Setup sciter::host and load HTML setup_callback(); wchar_t* default_url; #if DEBUG default_url = L""; #else default_url = L"this://app/index.html"; #endif bool load = load_file(default_url); assert(load); }
static void run_test(int expected_ret, int slist_entries, enum protocol protocol, void setup_callback(struct asfd *asfd, struct slist *slist)) { int result; struct slist *slist=NULL; const char *conffile=BASE "/burp.conf"; struct asfd *asfd; struct conf **confs; const char *buf; if(protocol==PROTO_1) buf=MIN_CLIENT_CONF "protocol=1\n"; else buf=MIN_CLIENT_CONF "protocol=2\n"; base64_init(); asfd=asfd_mock_setup(&reads, &writes); confs=setup_conf(); fail_unless(recursive_delete(BASE)==0); build_file(conffile, buf); fail_unless(!conf_load_global_only(conffile, confs)); if(slist_entries) slist=build_slist_phase1(BASE, protocol, slist_entries); setup_callback(asfd, slist); result=do_restore_client(asfd, confs, ACTION_RESTORE, 0 /* vss_restore */); fail_unless(result==expected_ret); slist_free(&slist); tear_down(&asfd, &confs); }
bool wxSciterControl::Create(wxWindow* parent, wxWindowID id, const wxPoint& pos /*= wxDefaultPosition*/, const wxSize& size /*= wxDefaultSize*/, long style /*= wxSUNKEN_BORDER*/, const wxValidator& validator /*= wxDefaultValidator*/) { if (!wxControl::Create(parent, id, pos, size, style, validator)) return false; SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); SetInitialSize(size); // Create Sciter child window with size exactly as our control. const auto crc = this->GetClientRect(); RECT rc = {crc.GetLeft(), crc.GetTop(), crc.GetRight(), crc.GetBottom()}; m_hwnd = SciterCreateWindow(SW_CHILD, &rc, nullptr, nullptr, this->GetHandle()); if(m_hwnd) { static volatile sciter::debug_output setup_dbg; // Setup sciter callbacks setup_callback(); sciter::attach_dom_event_handler(m_hwnd, this); // Adjust our window style to eliminate double edge if(this->HasFlag(wxBORDER_MASK)) { auto style = this->GetWindowStyleFlag(); style &= ~wxBORDER_MASK; style |= wxBORDER_NONE; this->SetWindowStyleFlag(style); } // Show Sciter window #ifdef __WINDOWS__ ::ShowWindow(m_hwnd, this->IsShown() ? SW_SHOW : SW_HIDE); #endif this->Refresh(); } return true; }
bool frame::setup(const wchar_t* url, HWND parent) { _hwnd = CreateWindowEx(0,WINDOW_CLASS_NAME, L"sciter-frame", WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, parent, NULL, ghInstance, this); if (!_hwnd) return false; SetWindowLongPtr(_hwnd, GWLP_USERDATA, LONG_PTR(this)); setup_callback(); // to receive SC_LOAD_DATA, SC_DATA_LOADED, etc. notification attach_dom_event_handler(_hwnd,this); // to receive DOM events //#ifdef _DEBUG // SciterSetMediaType(_hwnd,L"on-debug"); //#endif init_window(); load_file(url); dom::element root_el = root(); //json::string s = root_el.combine_url(json::string()); assert(root_el.is_valid()); if(root_el) { init_instance(root_el); dom::element title_el = root_el.find_first(":root>head>title"); set_title(title_el.text()); } ShowWindow(_hwnd, SW_SHOW); UpdateWindow(_hwnd); return true; }
static void do_simple_test( const char *orig_client, int expected_ret, void setup_callback(struct asfd *asfd), void setup_stdout_callback(struct asfd *asfd) ) { struct asfd *asfd; struct asfd *so_asfd; struct async *as; as=setup_async(); asfd=asfd_mock_setup(&reads, &writes); so_asfd=asfd_mock_setup(&reads_so, &writes_so); as->asfd_add(as, asfd); as->asfd_add(as, so_asfd); asfd->as=as; as->read_write=async_rw_simple; as->write=async_write_simple; setup_callback(asfd); if(setup_stdout_callback) setup_stdout_callback(so_asfd); fail_unless(!status_client_ncurses_init(ACTION_STATUS_SNAPSHOT)); fail_unless(status_client_ncurses_main_loop( as, so_asfd, orig_client )==expected_ret); asfd_free(&asfd); asfd_free(&so_asfd); asfd_mock_teardown(&reads, &writes); asfd_mock_teardown(&reads_so, &writes_so); async_free(&as); alloc_check(); }
/* * Take the Lua stack item at index i and convert it into an * ActionScript value. */ AS3_Val get_as3_value_from_lua_stack_type(lua_State * L, int i, int type) { /* WARNING: Panic alert! Use L*_FN checkers here! */ LCALL(L, stack); AS3_Val value; switch (type) { case LUA_TSTRING: /* strings */ { size_t length = 0; const char * str = lua_tolstring(L, i, &length); if (str == NULL) /* NOTE: This is unreachable. Assert instead */ { length = 6; str = "(null)"; } /* NOTE: Alchemy .5a truncates embedded zeroes in string * regardless to the passed length */ value = AS3_StringN(str, length); } break; case LUA_TBOOLEAN: /* booleans */ value = lua_toboolean(L, i) ? AS3_True() : AS3_False(); break; case LUA_TNUMBER: /* numbers */ value = AS3_Number(lua_tonumber(L, i)); break; case LUA_TNONE: /* fall through */ case LUA_TNIL: /* nil */ value = AS3_Null(); break; case LUA_TUSERDATA: /* userdata */ { void * userdata = lua_touserdata(L, i); lua_getfield(L, LUA_REGISTRYINDEX, AS3LUA_METATABLE); if (userdata == NULL || !lua_getmetatable(L, i)) { lua_pop(L, 1); /* Pop AS3LUA_METATABLE */ value = as3_value_from_foreign_userdata(L, i); } else if (!lua_rawequal(L, -2, -1)) { lua_pop(L, 2); /* Pop AS3LUA_METATABLE and userdata metatable */ value = as3_value_from_foreign_userdata(L, i); } else { lua_pop(L, 2); /* Pop AS3LUA_METATABLE and userdata metatable */ AS3LuaUserData * userdata = (AS3LuaUserData *)lua_touserdata(L, i); value = userdata->value; /* * We just created one more reference to the AS3 value, * as it still lives inside Lua. * (And will probably be collected by GC.) */ AS3_Acquire(value); } } break; case LUA_TFUNCTION: /* function */ value = setup_callback(L, i); break; case LUA_TLIGHTUSERDATA: /* TODO: blackbox this type */ case LUA_TTABLE: /* TODO: deal with this type */ case LUA_TTHREAD: /* TODO: blackbox this type */ value = AS3_String(lua_typename(L, type)); break; default: /* unreachable */ fatal_error("unknown Lua type"); break; } #ifdef DO_SPAM SPAM(("get_as3_value_from_lua_stack(): end")); AS3_Trace( AS3_Call( getQualifiedClassName_method, NULL, AS3_Array("AS3ValType", value) ) ); #endif /* DO_SPAM */ LCHECK_FN(L, stack, 0, fatal_error); return value; }
/*---------------------------------------------------------------------------*/ static void send_packet(mac_callback_t sent, void *ptr) { int size; /* 3 bytes per packet attribute is required for serialization */ uint8_t buf[PACKETBUF_NUM_ATTRS * 3 + PACKETBUF_SIZE + 3]; uint8_t sid; packetbuf_set_addr(PACKETBUF_ADDR_SENDER, &rimeaddr_node_addr); /* ack or not ? */ packetbuf_set_attr(PACKETBUF_ATTR_MAC_ACK, 1); if(NETSTACK_FRAMER.create() < 0) { /* Failed to allocate space for headers */ LOG6LBR_ERROR("br-rdc: send failed, too large header\n"); mac_call_sent_callback(sent, ptr, MAC_TX_ERR_FATAL, 1); } else { /* here we send the data over SLIP to the radio-chip */ size = 0; #if SERIALIZE_ATTRIBUTES size = packetutils_serialize_atts(&buf[3], sizeof(buf) - 3); #endif if(size < 0 || size + packetbuf_totlen() + 3 > sizeof(buf)) { LOG6LBR_ERROR("br-rdc: send failed, too large header\n"); mac_call_sent_callback(sent, ptr, MAC_TX_ERR_FATAL, 1); } else { LOG6LBR_PRINTF(PACKET, RADIO_OUT, "write: %d\n", packetbuf_datalen()); if (LOG6LBR_COND(DUMP, RADIO_OUT)) { uint8_t *data = packetbuf_dataptr(); int len = packetbuf_datalen(); int i; #if WIRESHARK_IMPORT_FORMAT printf("0000"); for(i = 0; i < len; i++) printf(" %02x", data[i]); #else printf(" "); for(i = 0; i < len; i++) { printf("%02x", data[i]); if((i & 3) == 3) printf(" "); if((i & 15) == 15) printf("\n "); } #endif printf("\n"); } sid = setup_callback(sent, ptr); buf[0] = '!'; buf[1] = 'S'; buf[2] = sid; /* sequence or session number for this packet */ /* Copy packet data */ memcpy(&buf[3 + size], packetbuf_hdrptr(), packetbuf_totlen()); write_to_slip(buf, packetbuf_totlen() + size + 3); } } }
END_TEST static void do_status_test( const char *orig_client, int expected_ret, void setup_callback( struct asfd *csin, struct asfd *csout, struct asfd *nin, struct asfd *so_asfd ), void check_sel_callback( struct sel *sel ) ) { struct asfd *csin; struct asfd *csout; struct asfd *nin; struct asfd *so_asfd; struct async *as; struct sel *sel; as=setup_async(); csin=asfd_mock_setup(&reads_csin, &writes_csin); csout=asfd_mock_setup(&reads_csout, &writes_csout); nin=asfd_mock_setup(&reads_nin, &writes_nin); so_asfd=asfd_mock_setup(&reads_so, &writes_so); fail_unless((csin->desc=strdup_w("csin", __func__))!=NULL); fail_unless((csout->desc=strdup_w("csout", __func__))!=NULL); fail_unless((nin->desc=strdup_w("nin", __func__))!=NULL); fail_unless((so_asfd->desc=strdup_w("so_asfd", __func__))!=NULL); nin->streamtype=ASFD_STREAM_NCURSES_STDIN; as->asfd_add(as, csin); as->asfd_add(as, csout); as->asfd_add(as, nin); as->asfd_add(as, so_asfd); as->read_write=async_rw_both; as->write=async_write_simple; setup_callback(csin, csout, nin, so_asfd); fail_unless((sel=sel_alloc())!=NULL); fail_unless(!status_client_ncurses_init(ACTION_STATUS)); fail_unless(status_client_ncurses_main_loop( as, so_asfd, sel, orig_client )==expected_ret); if(check_sel_callback) check_sel_callback(sel); sel_free(&sel); asfd_free(&csin); asfd_free(&csout); asfd_free(&nin); asfd_free(&so_asfd); asfd_mock_teardown(&reads_csin, &writes_csin); asfd_mock_teardown(&reads_csout, &writes_csout); asfd_mock_teardown(&reads_nin, &writes_nin); asfd_mock_teardown(&reads_so, &writes_so); async_free(&as); alloc_check(); }