gboolean ui_changed(void) { if(!lock) { ui_read(); memcpy(working,original,(width*height*3)>>1); ui_update(); draw(dialog,width,height); }
void interact( const char *const argv_0) { EditLine *const el = el_init(argv_0, stdin, stdout, stderr); el_set(el, EL_PROMPT, &prompt); el_set(el, EL_EDITOR, "emacs"); History *const hist = history_init(); if (!hist) { fprintf(stderr, "Could not initalize history\n"); exit(EXIT_FAILURE); } HistEvent ev; history(hist, &ev, H_SETSIZE, 100); el_set(el, EL_HIST, history, hist); const pid_t child_pid = _gen_child(); verbose_printf("child process is %d\n", child_pid); if (options.verbose) help(); char buf[PAGE_SIZE]; size_t buf_sz = 0; int end = 0; struct proc_info_t info = {}; ARCH_INIT_PROC_INFO(info); ptrace_launch(child_pid); ptrace_cont(child_pid, &info); ptrace_reap(child_pid, &info); display(&info); for (;;) { int count; const char *const line = el_gets(el, &count); if (count == -1) { perror("el_gets"); exit(EXIT_FAILURE); } // count is 0 == ^d if (!count || strcasestr(line, ".quit") || strcasestr(line, ".exit")) break; // We have input, add it to the our history history(hist, &ev, H_ENTER, line); // If we start with a ., we have a command if (line[0] == '.') { if (strcasestr(line, "help")) { help(); continue; } if (strcasestr(line, "info")) { display(&info); continue; } if (strcasestr(line, "showmap")) { char cmd[PATH_MAX] = { 0 }; snprintf(cmd, sizeof(cmd), "cat /proc/%d/maps", child_pid); if (system(cmd)) fprintf(stderr, "sh: %s failed\n", cmd); continue; } if (strcasestr(line, "read")) { ui_read(child_pid, line); continue; } if (strcasestr(line, "write")) { continue; } if (strcasestr(line, "begin")) { in_block = 1; continue; } // Note the lack of continue. Need to fall through... if (strcasestr(line, "end")) { in_block = 0; end = 1; } } if (buf_sz + count > sizeof(buf)) { printf("Buffer full (max: 0x%lx), please use '.end'\n", sizeof(buf)); continue; } // Since we fell through, we want to avoid adding adding .end to our buffer if (!end) { memcpy(buf + buf_sz, line, count); buf_sz += count; } if (!in_block) { verbose_printf("Trying to assemble(%zu):\n%s", buf_sz, buf); uint8_t bytecode[PAGE_SIZE]; const size_t bytecode_sz = assemble(bytecode, sizeof(bytecode), buf, buf_sz); memset(buf, 0, sizeof(buf)); buf_sz = 0; end = 0; verbose_printf("Got asm(%zu):\n", bytecode_sz); verbose_dump(bytecode, bytecode_sz, -1); if (!bytecode_sz) { fprintf(stderr, "'%s' assembled to 0 length bytecode\n", buf); continue; } ptrace_write(child_pid, (void *)options.start, bytecode, bytecode_sz); ptrace_reset(child_pid, options.start); ptrace_cont(child_pid, &info); ptrace_reap(child_pid, &info); display(&info); } } ptrace_detatch(child_pid, &info); printf("\n"); history_end(hist); el_end(el); }
// // Video is in YV12 Colorspace // // uint8_t DIA_getMPdelogo(MPDELOGO_PARAM *param,AVDMGenericVideoStream *in) { // Allocate space for green-ised video width=in->getInfo()->width; height=in->getInfo()->height; working=new uint8_t [width*height*4]; original=NULL; uint8_t ret=0; dialog=create_dialog1(); gtk_dialog_set_alternative_button_order(GTK_DIALOG(dialog), GTK_RESPONSE_OK, GTK_RESPONSE_CANCEL, -1); gtk_register_dialog(dialog); x=param->xoff; y=param->yoff; w=param->lw; h=param->lh; band=param->band; imgsrc=new ADMImage(width,height); incoming=in; rgbConv=new ColYuvRgb(width,height); rgbConv->reset(width,height); float zoom = UI_calcZoomToFitScreen(GTK_WINDOW(dialog), WID(drawingarea1), width, height); zoomW = width * zoom; zoomH = height * zoom; rgbBufferDisplay=new uint8_t[zoomW*zoomH*4]; gtk_widget_set_usize(WID(drawingarea1), zoomW, zoomH); if (zoom < 1) { UI_centreCanvasWindow((GtkWindow*)dialog, WID(drawingarea1), zoomW, zoomH); resizer = new ADMImageResizer(width, height, zoomW, zoomH, PIX_FMT_RGB32, PIX_FMT_RGB32); } prepare(0); gtk_widget_show(dialog); ui_upload(); ui_update(); #define CONNECT(x,y,z) gtk_signal_connect(GTK_OBJECT(WID(x)), #y,GTK_SIGNAL_FUNC(z), NULL); CONNECT(drawingarea1,expose_event,gui_draw); CONNECT(hscale1,value_changed,frame_changed); #define CONNECT_SPIN(x) CONNECT(spinbutton##x, value_changed,ui_changed) CONNECT_SPIN(X); CONNECT_SPIN(Y); CONNECT_SPIN(W); CONNECT_SPIN(H); CONNECT_SPIN(Band); draw(dialog,width,height); ret=0; int response; while( (response=gtk_dialog_run(GTK_DIALOG(dialog)))==GTK_RESPONSE_APPLY) { ui_changed(); } if(response==GTK_RESPONSE_OK) { ui_read( ); param->xoff=x; param->yoff=y; param->lw=w; param->lh=h; param->band=band; ret=1; } gtk_unregister_dialog(dialog); gtk_widget_destroy(dialog); delete working; delete imgsrc; delete rgbConv; if (resizer) { delete resizer; delete[] rgbBufferDisplay; resizer=NULL; rgbBufferDisplay=NULL; } working=NULL; dialog=NULL; original=NULL; imgsrc=NULL; return ret; }