virtual ::osiris::uint32 write( void const * v, ::osiris::uint32 size ) { ::osiris::PythonState __pystate(getPythonThreadState()); if( ::osiris::PythonOverride func_write = this->get_override( "write" ) ) return func_write( v, size ); else{ __pystate.leave(); return this->::osiris::File::write( v, size ); } }
int main(int argc, char *argv[]) { void (*OldSig)(int); OldSig=signal(SIGINT,SIG_IGN); printf("nn************************************************************rn"); printf("* zFTP *rn"); printf("************************************************************rn"); printf(" Copyright (c) 2005rn"); printf(" All rights reserved.rn"); printf(" By Ji Surn"); if(argc > 0) { printf("nPlease use 'connect <system name> <user>' command to connect to a FTPserverrn"); printf("For anonymous user, please leave <user> blank.rn"); } //Main loop starts; //Checks on keyboard i/o for interaction and socket communication. int exit=0; char command[1024]; printf("nzftp>"); while(!exit) { if( ReadCommand ) { printf("nzftp>"); fflush(stdout); } if( !CheckFds(command) ) continue; switch(check_cmd(command) ) { case READ: func_read(command); break; case WRITE: func_write(command); break; case BINARY: func_binary_mode(); break; case ASCII: func_ascii_mode(); break; case CLOSE: func_close(); break; case CONNECT: func_connect(command); break; case CD: func_cdir(command); break; case DELETE: func_delete(command); break; case PWD: func_pwd(command); break; case LS: func_list(command); break; case HELP: func_help(command); break; case SHELL: func_Shell_cmd(command); break; case EXIT: exit = 1; if( flag_connected ) func_close(); break; default: if(command[0] == 0 ) ; else printf("Invalid command: %sn",command); break; } } (void)signal(SIGINT,OldSig); return 0; }
static void cvbs_debug_store(char *buf) { unsigned int ret = 0; unsigned long addr, start, end, value, length, old; unsigned int argc; char *p = NULL, *para = NULL, *argv[6] = {NULL, NULL, NULL, NULL, NULL, NULL}; char *str_type = NULL; unsigned int i, cmd; unsigned int (*func_read)(unsigned int) = NULL; void (*func_write)(unsigned int, unsigned int) = NULL; unsigned int (*func_getb)(unsigned int, unsigned int, unsigned int) = NULL; void (*func_setb)(unsigned int, unsigned int, unsigned int, unsigned int) = NULL; p = kstrdup(buf, GFP_KERNEL); for (argc = 0; argc < 6; argc++) { para = strsep(&p, " "); if (para == NULL) break; argv[argc] = para; } if (!strcmp(argv[0], "r")) cmd = CMD_REG_READ; else if (!strcmp(argv[0], "rb")) cmd = CMD_REG_READ_BITS; else if (!strcmp(argv[0], "dump")) cmd = CMD_REG_DUMP; else if (!strcmp(argv[0], "w")) cmd = CMD_REG_WRITE; else if (!strcmp(argv[0], "wb")) cmd = CMD_REG_WRITE_BITS; else if (!strncmp(argv[0], "clkdump", strlen("clkdump"))) cmd = CMD_CLK_DUMP; else if (!strncmp(argv[0], "clkmsr", strlen("clkmsr"))) cmd = CMD_CLK_MSR; else if (!strncmp(argv[0], "bist", strlen("bist"))) cmd = CMD_BIST; else if (!strncmp(argv[0], "help", strlen("help"))) cmd = CMD_HELP; else { print_info("[%s] invalid cmd = %s!\n", __func__, argv[0]); goto DEBUG_END; } switch (cmd) { case CMD_REG_READ: if (argc != 3) { print_info("[%s] cmd_reg_read format: r c/h/v address_hex\n", __func__); goto DEBUG_END; } func_type_map(argv[1]); ret = kstrtoul(argv[2], 16, &addr); print_info("read %s[0x%x] = 0x%x\n", str_type, (unsigned int)addr, func_read(addr)); break; case CMD_REG_READ_BITS: if (argc != 5) { print_info("[%s] cmd_reg_read_bits format:\n" "\trb c/h/v address_hex start_dec length_dec\n", __func__); goto DEBUG_END; } func_type_map(argv[1]); ret = kstrtoul(argv[2], 16, &addr); ret = kstrtoul(argv[3], 10, &start); ret = kstrtoul(argv[4], 10, &length); if (length == 1) print_info("read_bits %s[0x%x] = 0x%x, bit[%d] = 0x%x\n", str_type, (unsigned int)addr, func_read(addr), (unsigned int)start, func_getb(addr, start, length)); else print_info("read_bits %s[0x%x] = 0x%x, bit[%d-%d] = 0x%x\n", str_type, (unsigned int)addr, func_read(addr), (unsigned int)start+(unsigned int)length-1, (unsigned int)start, func_getb(addr, start, length)); break; case CMD_REG_DUMP: if (argc != 4) { print_info("[%s] cmd_reg_dump format: dump c/h/v start_dec end_dec\n", __func__); goto DEBUG_END; } func_type_map(argv[1]); ret = kstrtoul(argv[2], 16, &start); ret = kstrtoul(argv[3], 16, &end); for (i = start; i <= end; i++) print_info("%s[0x%x] = 0x%x\n", str_type, i, func_read(i)); break; case CMD_REG_WRITE: if (argc != 4) { print_info("[%s] cmd_reg_write format: w value_hex c/h/v address_hex\n", __func__); goto DEBUG_END; } func_type_map(argv[2]); ret = kstrtoul(argv[1], 16, &value); ret = kstrtoul(argv[3], 16, &addr); func_write(addr, value); print_info("write %s[0x%x] = 0x%x\n", str_type, (unsigned int)addr, (unsigned int)value); break; case CMD_REG_WRITE_BITS: if (argc != 6) { print_info("[%s] cmd_reg_wrute_bits format:\n" "\twb value_hex c/h/v address_hex start_dec length_dec\n", __func__); goto DEBUG_END; } func_type_map(argv[2]); ret = kstrtoul(argv[1], 16, &value); ret = kstrtoul(argv[3], 16, &addr); ret = kstrtoul(argv[4], 10, &start); ret = kstrtoul(argv[5], 10, &length); old = func_read(addr); func_setb(addr, value, start, length); print_info("write_bits %s[0x%x] old = 0x%x, new = 0x%x\n", str_type, (unsigned int)addr, (unsigned int)old, func_read(addr)); break; case CMD_CLK_DUMP: dump_clk_registers(); break; case CMD_CLK_MSR: /* todo */ print_info("cvbs: debug_store: clk_msr todo!\n"); break; case CMD_BIST: if (argc != 2) { print_info("[%s] cmd_bist format:\n" "\tbist 0/1/2/3/off\n", __func__); goto DEBUG_END; } bist_test_store(argv[1]); break; case CMD_HELP: print_info("command format:\n" "\tr c/h/v address_hex\n" "\trb c/h/v address_hex start_dec length_dec\n" "\tdump c/h/v start_dec end_dec\n" "\tw value_hex c/h/v address_hex\n" "\twb value_hex c/h/v address_hex start_dec length_dec\n" "\tbist 0/1/2/3/off\n" "\tclkdump\n"); break; default: break; } DEBUG_END: kfree(p); return; }
SliderVComp::SliderVComp( Client & client ) { name = "SliderV"; func_register = [ &client = client ] ( ) { client.resource_mgr.reg_pool< SliderVData >( num_comp_default ); return 0; }; func_alloc = [ &client = client ] ( PComp * comp ) { comp->anchor = { 0.5f, 0.5f }; comp->dim = { 32, 128 }; auto data = comp->add_data< SliderVData >( ); data->cnt_remesh = 0; data->is_label_visible = true; data->ratio = 0.0f; data->value = 0.0f; data->lower = 0.0f; data->upper = 1.0f; data->width_bar = 8; data->func_read = func_null; data->func_write = func_null; auto resizable = comp->add_comp( "Resizable", "Resizable", [ &client = client ] ( PComp * comp ) { auto data = comp->get < ResizableComp::ResizableData >( ); data->func_resize = [ ] ( PComp * comp ) { comp->dim = comp->parent->dim; comp->offset = -comp->dim / 2; return 0; }; return 0; } ); data->comp_border = resizable->add_comp( "Border", "BorderImage", [ &client = client, data ] ( PComp * comp ) { data->data_border = comp->get< BorderImageComp::BorderImageData >( ); data->data_border->padding_border = 4; data->data_border->set_texture( client, "Gui", "Default/SliderBG", 8 ); auto overable = comp->add_comp( "Overable", "Overable", [ &client = client, data ] ( PComp * comp ) { auto data_over = comp->get< OverableComp::OverableData >( ); data_over->func_enter = [ &client = client, data ] ( PComp * comp ) { data->data_border->color = { 0.5f, 0.5f, 0.5f, 1.0f }; if( data->is_label_visible ) { data->comp_label_bottom->is_visible = true; data->comp_label_top->is_visible = true; } comp->page->is_remesh = true; return 0; }; data_over->func_exit = [ &client = client, data ] ( PComp * comp ) { data->data_border->color = { 1.0f, 1.0f, 1.0f, 1.0f }; if( data->is_label_visible ) { data->comp_label_bottom->is_visible = false; data->comp_label_top->is_visible = false; } comp->page->is_remesh = true; return 0; }; return 0; } ); auto clickable = comp->add_comp( "Clickable", "Clickable", [ &client = client, data ] ( PComp * comp ) { auto data_click = comp->get< ClickableComp::ClickableData >( ); data_click->func_hold = [ &client = client, data ] ( PComp * comp ) { int posl_mouse = client.input_mgr.get_mouse( ).y - ( comp->page->pos.y + data->comp_bar->pos.y ); if( posl_mouse < 0 ) { posl_mouse = 0; } else if( posl_mouse > data->length_bar ) { posl_mouse = data->length_bar; } data->set_ratio( posl_mouse / data->length_bar ); data->func_write( comp ); comp->page->is_remesh = true; return 0; return 0; }; return 0; } ); return 0; } ); data->comp_bar = comp->add_comp( "Bar", "BorderImage", [ &client = client, data ] ( PComp * comp ) { data->data_bar = comp->get< BorderImageComp::BorderImageData >( ); data->data_bar->padding_border = 4; data->data_bar->set_texture( client, "Gui", "Default/SliderBG", 8 ); return 0; } ); data->comp_label_title = comp->add_comp( "TitleLabel", "Label", [ &client = client, data ] ( PComp * comp ) { comp->is_visible = true; comp->anchor = { 0.5f, 1.0f }; comp->offset = { 0.0f, 3.0f }; data->data_label_title = comp->get< LabelComp::LabelData >( ); data->data_label_title->size_text = 12; data->data_label_title->alignment_v = LabelComp::LabelData::AlignVertical::AV_Top; data->data_label_title->alignment_h = LabelComp::LabelData::AlignHorizontal::AH_Center; data->data_label_title->text = "Title"; return 0; } ); data->comp_label_bottom = comp->add_comp( "BottomLabel", "Label", [ &client = client, data ] ( PComp * comp ) { comp->is_visible = false; comp->anchor = { 1.0f, 0.0f }; comp->offset = { 3.0f, 1.0f }; data->data_label_left = comp->get< LabelComp::LabelData >( ); data->data_label_left->size_text = 10; data->data_label_left->alignment_v = LabelComp::LabelData::AlignVertical::AV_Top; data->data_label_left->alignment_h = LabelComp::LabelData::AlignHorizontal::AH_Right; data->data_label_left->text = "Bottom"; return 0; } ); data->comp_label_top = comp->add_comp( "TopLabel", "Label", [ &client = client, data ] ( PComp * comp ) { comp->is_visible = false; comp->anchor = { 1.0f, 1.0f }; comp->offset = { 3.0f, -1.0f }; data->data_label_right = comp->get< LabelComp::LabelData >( ); data->data_label_right->size_text = 10; data->data_label_right->alignment_v = LabelComp::LabelData::AlignVertical::AV_Bottom; data->data_label_right->alignment_h = LabelComp::LabelData::AlignHorizontal::AH_Right; data->data_label_right->text = "Top"; return 0; } ); data->comp_label_value = comp->add_comp( "ValueLabel", "Label", [ &client = client, data ] ( PComp * comp ) { comp->anchor = { 1.0f, 0.5f }; comp->offset = { 3.0f, 0.0f }; data->data_label_value = comp->get< LabelComp::LabelData >( ); data->data_label_value->size_text = 12; data->data_label_value->alignment_v = LabelComp::LabelData::AlignVertical::AV_Center; data->data_label_value->alignment_h = LabelComp::LabelData::AlignHorizontal::AH_Right; data->data_label_value->text = "Value"; return 0; } ); data->comp_slider = comp->add_comp( "Slider", "BorderImage", [ &client = client, data ] ( PComp * comp ) { data->data_slider = comp->get< BorderImageComp::BorderImageData >( ); data->data_slider->padding_border = 4; data->data_slider->set_texture( client, "Gui", "Default/SliderBG", 8 ); return 0; } ); return 0; }; func_update = [ &client = client ] ( PComp * comp ) { auto data = comp->get< SliderVData >( ); data->length_bar = comp->dim.y - data->data_border->padding_border * 2; data->comp_bar->dim = { data->width_bar, data->length_bar }; data->comp_bar->offset = -data->comp_bar->dim / 2; data->comp_slider->anchor = { 0.5f, 0.5f }; data->comp_slider->dim = { comp->dim.x, data->width_bar }; data->comp_slider->offset = -data->comp_slider->dim / 2; data->comp_slider->offset.y += ( data->ratio - 0.5f ) * data->length_bar; data->func_read( comp ); if( ++data->cnt_remesh % 4 == 0 ) { comp->page->is_remesh = true; } return 0; }; }