static void execute_button_clicked(struct trace_capture *cap) { struct stat st; GtkResponseType ret; const char *filename; char *tracecmd; if (end_capture(cap)) return; tracecmd = find_tracecmd(); if (!tracecmd) { warning("trace-cmd not found in path"); return; } free(tracecmd); filename = gtk_entry_get_text(GTK_ENTRY(cap->file_entry)); if (stat(filename, &st) >= 0) { ret = trace_dialog(GTK_WINDOW(cap->main_dialog), TRACE_GUI_ASK, "The file '%s' already exists.\n" "Are you sure you want to replace it", filename); if (ret == GTK_RESPONSE_NO) return; } gtk_button_set_label(GTK_BUTTON(cap->run_button), CAP_STOP); run_command(cap); }
/** Codel csStopCapture of activity CaptureSound. * * Triggered by capture_end, capture_stop. * Yields to capture_ether. <<<<<<< user version * Throws capture_BUFFER_OVERRUN, capture_BUFFER_UNDERRUN. ======= * Throws capture_BUFFER_UNDERRUN, capture_BUFFER_OVERRUN. >>>>>>> template version */ genom_event csStopCapture(void) { printf("Stopping sound capture.\n"); end_capture(&_capture_params); //DBG: Save Big Buffer to text file #ifdef DBG _fp = fopen("home/boris/Bureau/cap.txt","w"); if(_fp==NULL){ printf("Cannot open file.\n"); int errnum = errno; fprintf(stderr, "Value of errno: %d\n", errno); perror("Error printed by perror"); fprintf(stderr, "Error opening file: %s\n", strerror( errnum )); } int ii; for(ii=0;ii<max_length;++ii){ fprintf(_fp,"%f %f\n",buf_l[ii],buf_r[ii]); } fclose(_fp); free(buf_l); free(buf_r); #endif return capture_ether; }
static const char *match (lua_State *L, const char *s, const char *p, struct Capture *cap) { init: /* using goto's to optimize tail recursion */ switch (*p) { case '(': /* start capture */ return start_capture(L, s, p, cap); case ')': /* end capture */ return end_capture(L, s, p, cap); case ESC: /* may be %[0-9] or %b */ if (isdigit((unsigned char)(*(p+1)))) { /* capture? */ s = match_capture(L, s, *(p+1), cap); if (s == NULL) return NULL; p+=2; goto init; /* else return match(L, s, p+2, cap) */ } else if (*(p+1) == 'b') { /* balanced string? */ s = matchbalance(L, s, p+2, cap); if (s == NULL) return NULL; p+=4; goto init; /* else return match(L, s, p+4, cap); */ } else goto dflt; /* case default */ case '\0': /* end of pattern */ return s; /* match succeeded */ case '$': if (*(p+1) == '\0') /* is the '$' the last char in pattern? */ return (s == cap->src_end) ? s : NULL; /* check end of string */ else goto dflt; default: dflt: { /* it is a pattern item */ const char *ep = luaI_classend(L, p); /* points to what is next */ int m = s<cap->src_end && luaI_singlematch((unsigned char)*s, p, ep); switch (*ep) { case '?': { /* optional */ const char *res; if (m && ((res=match(L, s+1, ep+1, cap)) != NULL)) return res; p=ep+1; goto init; /* else return match(L, s, ep+1, cap); */ } case '*': /* 0 or more repetitions */ return max_expand(L, s, p, ep, cap); case '+': /* 1 or more repetitions */ return (m ? max_expand(L, s+1, p, ep, cap) : NULL); case '-': /* 0 or more repetitions (minimum) */ return min_expand(L, s, p, ep, cap); default: if (!m) return NULL; s++; p=ep; goto init; /* else return match(L, s+1, ep, cap); */ } } } }
static void cb_StartCam( Fl_Widget*, void* ) { if( started ) cb_PauseResume(0,0); end_capture(); #ifdef WIN32 Sleep(10); #endif is_avi = 0; capture = cvCaptureFromCAM( -1 ); cb_PauseResume(0,0); }
static const lua_WChar *match (MatchState *ms, const lua_WChar *s, const lua_WChar *p) { init: /* using goto's to optimize tail recursion */ switch (*p) { case '(': /* start capture */ if (*(p+1) == ')') /* position capture? */ return start_capture(ms, s, p+2, CAP_POSITION); else return start_capture(ms, s, p+1, CAP_UNFINISHED); case ')': /* end capture */ return end_capture(ms, s, p+1); case ESC: /* may be %[0-9] or %b */ if (iswdigit(*(p+1))) { /* capture? */ s = match_capture(ms, s, *(p+1)); if (s == NULL) return NULL; p+=2; goto init; /* else return match(ms, s, p+2) */ } else if (*(p+1) == 'b') { /* balanced string? */ s = matchbalance(ms, s, p+2); if (s == NULL) return NULL; p+=4; goto init; /* else return match(ms, s, p+4); */ } else goto dflt; /* case default */ case '\0': /* end of pattern */ return s; /* match succeeded */ case '$': if (*(p+1) == '\0') /* is the `$' the last char in pattern? */ return (s == ms->src_end) ? s : NULL; /* check end of string */ else goto dflt; default: dflt: { /* it is a pattern item */ const lua_WChar *ep = luaI_classend(ms, p); /* points to what is next */ int m = s<ms->src_end && luaI_singlematch(*s, p, ep); switch (*ep) { case '?': { /* optional */ const lua_WChar *res; if (m && ((res=match(ms, s+1, ep+1)) != NULL)) return res; p=ep+1; goto init; /* else return match(ms, s, ep+1); */ } case '*': /* 0 or more repetitions */ return max_expand(ms, s, p, ep); case '+': /* 1 or more repetitions */ return (m ? max_expand(ms, s+1, p, ep) : NULL); case '-': /* 0 or more repetitions (minimum) */ return min_expand(ms, s, p, ep); default: if (!m) return NULL; s++; p=ep; goto init; /* else return match(ms, s+1, ep); */ } } } }
static void cb_StartAVI( const char* newfile, int start_pos, int was_started ) { if( newfile != 0 ) { end_capture(); capture = cvCaptureFromAVI( newfile ); if( capture ) { was_started = 1; if( start_pos != 0 ) cvSetCaptureProperty( capture, CV_CAP_PROP_POS_FRAMES, start_pos ); } is_avi = 1; } if( was_started ) cb_PauseResume(0,0); }
static const char *match (MatchState *ms, const char *s, const char *p) { init: /* using goto's to optimize tail recursion */ switch (*p) { case '(': { /* start capture */ if (*(p+1) == ')') /* position capture? */ return start_capture(ms, s, p+2, CAP_POSITION); else return start_capture(ms, s, p+1, CAP_UNFINISHED); } case ')': { /* end capture */ return end_capture(ms, s, p+1); } case L_ESC: { switch (*(p+1)) { case 'b': { /* balanced string? */ s = matchbalance(ms, s, p+2); if (s == NULL) return NULL; p+=4; goto init; /* else return match(ms, s, p+4); */ } case 'f': { /* frontier? */ const char *ep; char previous; p += 2; if (*p != '[') luaL_error(ms->L, "missing " LUA_QL("[") " after " LUA_QL("%%f") " in pattern"); ep = classend(ms, p); /* points to what is next */ previous = (s == ms->src_init) ? '\0' : *(s-1); if (matchbracketclass(uchar(previous), p, ep-1) || !matchbracketclass(uchar(*s), p, ep-1)) return NULL; p=ep; goto init; /* else return match(ms, s, ep); */ } default: { if (isdigit(uchar(*(p+1)))) { /* capture results (%0-%9)? */ s = match_capture(ms, s, uchar(*(p+1))); if (s == NULL) return NULL; p+=2; goto init; /* else return match(ms, s, p+2) */ } goto dflt; /* case default */ } } } case '\0': { /* end of pattern */ return s; /* match succeeded */ } case '$': { if (*(p+1) == '\0') /* is the `$' the last char in pattern? */ return (s == ms->src_end) ? s : NULL; /* check end of string */ else goto dflt; } default: dflt: { /* it is a pattern item */ const char *ep = classend(ms, p); /* points to what is next */ int m = s<ms->src_end && singlematch(uchar(*s), p, ep); switch (*ep) { case '?': { /* optional */ const char *res; if (m && ((res=match(ms, s+1, ep+1)) != NULL)) return res; p=ep+1; goto init; /* else return match(ms, s, ep+1); */ } case '*': { /* 0 or more repetitions */ return max_expand(ms, s, p, ep); } case '+': { /* 1 or more repetitions */ return (m ? max_expand(ms, s+1, p, ep) : NULL); } case '-': { /* 0 or more repetitions (minimum) */ return min_expand(ms, s, p, ep); } default: { if (!m) return NULL; s++; p=ep; goto init; /* else return match(ms, s+1, ep); */ } } } } }
static const char * match(struct match_state *ms, const char *s, const char *p) { const char *ep, *res; char previous; if (ms->matchdepth-- == 0) { match_error(ms, "pattern too complex"); return (NULL); } /* using goto's to optimize tail recursion */ init: /* end of pattern? */ if (p != ms->p_end) { switch (*p) { case '(': /* start capture */ if (*(p + 1) == ')') /* position capture? */ s = start_capture(ms, s, p + 2, CAP_POSITION); else s = start_capture(ms, s, p + 1, CAP_UNFINISHED); break; case ')': /* end capture */ s = end_capture(ms, s, p + 1); break; case '$': /* is the '$' the last char in pattern? */ if ((p + 1) != ms->p_end) { /* no; go to default */ goto dflt; } /* check end of string */ s = (s == ms->src_end) ? s : NULL; break; case L_ESC: /* escaped sequences not in the format class[*+?-]? */ switch (*(p + 1)) { case 'b': /* balanced string? */ s = matchbalance(ms, s, p + 2); if (s != NULL) { p += 4; /* return match(ms, s, p + 4); */ goto init; } /* else fail (s == NULL) */ break; case 'f': /* frontier? */ p += 2; if (*p != '[') { match_error(ms, "missing '['" " after '%f' in pattern"); break; } /* points to what is next */ ep = classend(ms, p); if (ms->error != NULL) break; previous = (s == ms->src_init) ? '\0' : *(s - 1); if (!matchbracketclass(uchar(previous), p, ep - 1) && matchbracketclass(uchar(*s), p, ep - 1)) { p = ep; /* return match(ms, s, ep); */ goto init; } /* match failed */ s = NULL; break; case '0' ... '9': /* capture results (%0-%9)? */ s = match_capture(ms, s, uchar(*(p + 1))); if (s != NULL) { p += 2; /* return match(ms, s, p + 2) */ goto init; } break; default: goto dflt; } break; default: /* pattern class plus optional suffix */ dflt: /* points to optional suffix */ ep = classend(ms, p); if (ms->error != NULL) break; /* does not match at least once? */ if (!singlematch(ms, s, p, ep)) { if (ms->repetitioncounter-- == 0) { match_error(ms, "max repetition items"); s = NULL; /* fail */ /* accept empty? */ } else if (*ep == '*' || *ep == '?' || *ep == '-') { p = ep + 1; /* return match(ms, s, ep + 1); */ goto init; } else { /* '+' or no suffix */ s = NULL; /* fail */ } } else { /* matched once */ /* handle optional suffix */ switch (*ep) { case '?': /* optional */ if ((res = match(ms, s + 1, ep + 1)) != NULL) s = res; else { /* * else return * match(ms, s, ep + 1); */ p = ep + 1; goto init; } break; case '+': /* 1 or more repetitions */ s++; /* 1 match already done */ /* FALLTHROUGH */ case '*': /* 0 or more repetitions */ s = max_expand(ms, s, p, ep); break; case '-': /* 0 or more repetitions (minimum) */ s = min_expand(ms, s, p, ep); break; default: /* no suffix */ s++; p = ep; /* return match(ms, s + 1, ep); */ goto init; } } break; } } ms->matchdepth++; return s; }
static const char *match (MatchState *ms, const char *s, const char *p) { if (ms->matchdepth-- == 0) luaL_error(ms->L, "pattern too complex"); init: /* using goto's to optimize tail recursion */ if (p != ms->p_end) { /* end of pattern? */ switch (*p) { case '(': { /* start capture */ if (*(p + 1) == ')') /* position capture? */ s = start_capture(ms, s, p + 2, CAP_POSITION); else s = start_capture(ms, s, p + 1, CAP_UNFINISHED); break; } case ')': { /* end capture */ s = end_capture(ms, s, p + 1); break; } case '$': { if ((p + 1) != ms->p_end) /* is the `$' the last char in pattern? */ goto dflt; /* no; go to default */ s = (s == ms->src_end) ? s : NULL; /* check end of string */ break; } case L_ESC: { /* escaped sequences not in the format class[*+?-]? */ switch (*(p + 1)) { case 'b': { /* balanced string? */ s = matchbalance(ms, s, p + 2); if (s != NULL) { p += 4; goto init; /* return match(ms, s, p + 4); */ } /* else fail (s == NULL) */ break; } case 'f': { /* frontier? */ const char *ep; char previous; p += 2; if (*p != '[') luaL_error(ms->L, "missing " LUA_QL("[") " after " LUA_QL("%%f") " in pattern"); ep = classend(ms, p); /* points to what is next */ previous = (s == ms->src_init) ? '\0' : *(s - 1); if (!matchbracketclass(uchar(previous), p, ep - 1) && matchbracketclass(uchar(*s), p, ep - 1)) { p = ep; goto init; /* return match(ms, s, ep); */ } s = NULL; /* match failed */ break; } case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': { /* capture results (%0-%9)? */ s = match_capture(ms, s, uchar(*(p + 1))); if (s != NULL) { p += 2; goto init; /* return match(ms, s, p + 2) */ } break; } default: goto dflt; } break; } default: dflt: { /* pattern class plus optional suffix */ const char *ep = classend(ms, p); /* points to optional suffix */ /* does not match at least once? */ if (!singlematch(ms, s, p, ep)) { if (*ep == '*' || *ep == '?' || *ep == '-') { /* accept empty? */ p = ep + 1; goto init; /* return match(ms, s, ep + 1); */ } else /* '+' or no suffix */ s = NULL; /* fail */ } else { /* matched once */ switch (*ep) { /* handle optional suffix */ case '?': { /* optional */ const char *res; if ((res = match(ms, s + 1, ep + 1)) != NULL) s = res; else { p = ep + 1; goto init; /* else return match(ms, s, ep + 1); */ } break; } case '+': /* 1 or more repetitions */ s++; /* 1 match already done */ /* go through */ case '*': /* 0 or more repetitions */ s = max_expand(ms, s, p, ep); break; case '-': /* 0 or more repetitions (minimum) */ s = min_expand(ms, s, p, ep); break; default: /* no suffix */ s++; p = ep; goto init; /* return match(ms, s + 1, ep); */ } } break; } } } ms->matchdepth++; return s; }
static const char *match(LuaMatchState *ms, const char *s, const char *p) { init: // using goto's to optimize tail recursion if (p == ms->p_end) // end of pattern? return s; // match succeeded switch (*p) { case '(': { // start capture if (*(p+1) == ')') // position capture? return start_capture(ms, s, p+2, CAP_POSITION); else return start_capture(ms, s, p+1, CAP_UNFINISHED); } case ')': { // end capture return end_capture(ms, s, p+1); } case '$': { if ((p+1) == ms->p_end) // is the `$' the last char in pattern? return (s == ms->src_end) ? s : NULL; // check end of string else goto dflt; } case L_ESC: { // escaped sequences not in the format class[*+?-]? switch (*(p+1)) { case 'b': { // balanced string? s = matchbalance(ms, s, p+2); if (s == NULL) return NULL; p+=4; goto init; // else return match(ms, s, p+4); } case 'f': { // frontier? const char *ep; char previous; p += 2; if (*p != '['){ ms->error = "missing " LUA_QL("[") " after " LUA_QL("%%f") " in pattern"; return NULL; } if(!classend(ms, p, &ep)) return NULL; // points to what is next previous = (s == ms->src_init) ? '\0' : *(s-1); if (matchbracketclass(uchar(previous), p, ep-1) || !matchbracketclass(uchar(*s), p, ep-1)) return NULL; p=ep; goto init; // else return match(ms, s, ep); } case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': { // capture results (%0-%9)? s = match_capture(ms, s, uchar(*(p+1))); if (s == NULL) return NULL; p+=2; goto init; // else return match(ms, s, p+2) } default: goto dflt; } } default: dflt: { // pattern class plus optional suffix const char *ep; int m; if(!classend(ms, p, &ep)) return NULL; // points to what is next m = s < ms->src_end && singlematch(uchar(*s), p, ep); switch (*ep) { case '?': { // optional const char *res; if (m && ((res=match(ms, s+1, ep+1)) != NULL)) return res; p=ep+1; goto init; // else return match(ms, s, ep+1); } case '*': { // 0 or more repetitions return max_expand(ms, s, p, ep); } case '+': { // 1 or more repetitions return (m ? max_expand(ms, s+1, p, ep) : NULL); } case '-': { // 0 or more repetitions (minimum) return min_expand(ms, s, p, ep); } default: { if (!m) return NULL; s++; p=ep; goto init; // else return match(ms, s+1, ep); } } } } }
static void *monitor_pipes(void *data) { struct trace_capture *cap = data; GtkTextIter start_iter; GtkTextIter cut_iter; GtkTextIter iter; gchar buf[BUFSIZ+1]; struct timeval tv; const char *val; fd_set fds; gboolean eof; int max_size; int total; int del; int ret; int r; gdk_threads_enter(); /* get the max size */ val = gtk_entry_get_text(GTK_ENTRY(cap->max_num_entry)); max_size = atoi(val); /* Clear the buffer */ gtk_text_buffer_get_start_iter(cap->output_buffer, &start_iter); gtk_text_buffer_get_end_iter(cap->output_buffer, &cut_iter); gtk_text_buffer_delete(cap->output_buffer, &start_iter, &cut_iter); total = 0; gdk_threads_leave(); do { FD_ZERO(&fds); FD_SET(cap->command_input_fd, &fds); tv.tv_sec = 6; tv.tv_usec = 0; ret = select(cap->command_input_fd+1, &fds, NULL, NULL, &tv); if (ret < 0) break; eof = TRUE; while ((r = read(cap->command_input_fd, buf, BUFSIZ)) > 0) { eof = FALSE; buf[r] = 0; total += r; if (total > max_size) del = total - max_size; else del = 0; gdk_threads_enter(); if (del) { gtk_text_buffer_get_start_iter(cap->output_buffer, &start_iter); gtk_text_buffer_get_start_iter(cap->output_buffer, &cut_iter); gtk_text_iter_forward_chars(&cut_iter, del); gtk_text_buffer_delete(cap->output_buffer, &start_iter, &cut_iter); total -= del; } gtk_text_buffer_get_end_iter(cap->output_buffer, &iter); gtk_text_buffer_insert(cap->output_buffer, &iter, buf, -1); gdk_threads_leave(); } } while (!cap->capture_done && !eof); if (eof) { gdk_threads_enter(); end_capture(cap); gdk_threads_leave(); } pthread_exit(NULL); }
/* * Trace Capture Dialog Window * * +--------------------------------------------------------------------+ * | Dialog Window | * | +-------------------------------+-------------------------------+ | * | | Paned Window | +---------------------------+ | | * | | +---------------------------+ | | Scroll window | | | * | | | Hbox | | | +-----------------------+ | | | * | | | Label Plugin Combo | | | | Event Tree | | | | * | | +---------------------------+ | | | | | | | * | | | | | | | | | * | | | | +-----------------------+ | | | * | | | +---------------------------+ | | * | +-------------------------------+-------------------------------+ | * +--------------------------------------------------------------------+ */ static void tracing_dialog(struct shark_info *info, const char *tracing) { struct pevent *pevent; GtkWidget *dialog; GtkWidget *button; GtkWidget *combo; GtkWidget *label; GtkWidget *entry; GtkWidget *frame; GtkWidget *vbox; GtkWidget *scrollwin; GtkWidget *table; GtkWidget *table2; GtkWidget *event_tree; GtkWidget *viewport; GtkWidget *textview; GtkWidget *hbox; GtkTextBuffer *buffer; GtkTextIter start_iter; GtkTextIter end_iter; char **plugins; int nr_plugins; struct trace_capture cap; const gchar *file; const char *command; const char *val; GString *str; gint result; memset(&cap, 0, sizeof(cap)); cap.info = info; plugins = tracecmd_local_plugins(tracing); /* Skip latency plugins */ nr_plugins = trim_plugins(plugins); if (!nr_plugins && plugins) { tracecmd_free_list(plugins); plugins = NULL; } /* Send parse warnings to status display */ trace_dialog_register_alt_warning(vpr_stat); pevent = tracecmd_local_events(tracing); trace_dialog_register_alt_warning(NULL); cap.pevent = pevent; if (!pevent && !nr_plugins) { warning("No events or plugins found"); return; } dialog = gtk_dialog_new(); gtk_window_set_title(GTK_WINDOW(dialog), "Capture"); button = gtk_button_new_with_label("Run"); gtk_dialog_add_action_widget(GTK_DIALOG(dialog), button, GTK_RESPONSE_ACCEPT); gtk_widget_show(button); cap.run_button = button; gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CLOSE, GTK_RESPONSE_REJECT); cap.main_dialog = dialog; /* --- Top Level Hpaned --- */ table = gtk_table_new(4, 2, FALSE); /* It is possible that no pevents exist. */ if (pevent) { scrollwin = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwin), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_table_attach(GTK_TABLE(table), scrollwin, 0, 1, 1, 2, GTK_FILL, GTK_FILL|GTK_EXPAND, 0, 0); gtk_widget_show(scrollwin); event_tree = trace_create_event_list_view(pevent, NULL, cap.info->cap_all_events, cap.info->cap_systems, cap.info->cap_events); gtk_container_add(GTK_CONTAINER(scrollwin), event_tree); gtk_widget_show(event_tree); cap.event_view = event_tree; } else { /* No events */ label = gtk_label_new("No events enabled on system"); gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2, GTK_FILL, GTK_EXPAND|GTK_FILL, 0, 10); gtk_widget_show(label); cap.event_view = NULL; } gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), table, TRUE, TRUE, 0); gtk_widget_show(table); /*------------------ Frame Settings --------------------------- */ frame = gtk_frame_new("Settings"); gtk_table_attach(GTK_TABLE(table), frame, 0, 1, 0, 1, GTK_FILL, 0, 0, 10); gtk_widget_show(frame); table2 = gtk_table_new(2, 3, FALSE); gtk_container_add(GTK_CONTAINER(frame), table2); gtk_widget_show(table2); gtk_table_set_col_spacings(GTK_TABLE(table2), 5); button = gtk_button_new_with_label("Save Settings"); gtk_table_attach_defaults(GTK_TABLE(table2), button, 0, 1, 0, 1); gtk_widget_show(button); g_signal_connect (button, "clicked", G_CALLBACK (save_settings_clicked), (gpointer)&cap); button = gtk_button_new_with_label("Import Settings"); gtk_table_attach_defaults(GTK_TABLE(table2), button, 1, 2, 0, 1); gtk_widget_show(button); g_signal_connect (button, "clicked", G_CALLBACK (import_settings_clicked), (gpointer)&cap); button = gtk_button_new_with_label("Export Settings"); gtk_table_attach_defaults(GTK_TABLE(table2), button, 2, 3, 0, 1); gtk_widget_show(button); g_signal_connect (button, "clicked", G_CALLBACK (export_settings_clicked), (gpointer)&cap); if (cap.info->cap_settings_name) set_settings(&cap); label = gtk_label_new("Available Settings: "); gtk_table_attach_defaults(GTK_TABLE(table2), label, 0, 1, 1, 2); gtk_widget_show(label); combo = trace_create_combo_box(NULL, NULL, create_settings_model, NULL); gtk_table_attach_defaults(GTK_TABLE(table2), combo, 1, 3, 1, 2); cap.settings_combo = combo; g_signal_connect (combo, "changed", G_CALLBACK (settings_changed), (gpointer)&cap); /*------------------ Frame Settings --------------------------- */ frame = gtk_frame_new("Execute"); gtk_table_attach(GTK_TABLE(table), frame, 0, 1, 3, 4, GTK_FILL, 0, 0, 10); gtk_widget_show(frame); table2 = gtk_table_new(3, 3, FALSE); gtk_container_add(GTK_CONTAINER(frame), table2); gtk_widget_show(table2); label = gtk_label_new("Plugin: "); gtk_table_attach_defaults(GTK_TABLE(table2), label, 0, 1, 0, 1); gtk_widget_show(label); combo = trace_create_combo_box(NULL, NULL, create_plugin_combo_model, plugins); cap.plugin_combo = combo; gtk_table_attach_defaults(GTK_TABLE(table2), combo, 1, 3, 0, 1); if (cap.info->cap_plugin) set_plugin(&cap); label = gtk_label_new("Command:"); gtk_table_attach_defaults(GTK_TABLE(table2), label, 0, 1, 1, 2); gtk_widget_show(label); entry = gtk_entry_new(); gtk_table_attach_defaults(GTK_TABLE(table2), entry, 1, 3, 1, 2); gtk_widget_show(entry); cap.command_entry = entry; if (cap.info->cap_command) gtk_entry_set_text(GTK_ENTRY(entry), cap.info->cap_command); label = gtk_label_new("Output file: "); gtk_table_attach_defaults(GTK_TABLE(table2), label, 0, 1, 2, 3); gtk_widget_show(label); entry = gtk_entry_new(); gtk_table_attach_defaults(GTK_TABLE(table2), entry, 1, 2, 2, 3); gtk_widget_show(entry); if (cap.info->cap_file) file = cap.info->cap_file; else file = default_output_file; gtk_entry_set_text(GTK_ENTRY(entry), file); cap.file_entry = entry; button = gtk_button_new_with_label("Browse"); gtk_table_attach_defaults(GTK_TABLE(table2), button, 2, 3, 2, 3); gtk_widget_show(button); g_signal_connect (button, "clicked", G_CALLBACK (file_clicked), (gpointer)&cap); /*------------------ Command Output ------------------ */ vbox = gtk_vbox_new(FALSE, 0); gtk_table_attach_defaults(GTK_TABLE(table), vbox, 1, 2, 0, 4); gtk_widget_show(vbox); gtk_widget_set_size_request(GTK_WIDGET(vbox), 500, 0); label = gtk_label_new("Output Display:"); gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); gtk_widget_show(label); scrollwin = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwin), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_box_pack_start(GTK_BOX(vbox), scrollwin, TRUE, TRUE, 0); gtk_widget_show(scrollwin); viewport = gtk_viewport_new(NULL, NULL); gtk_widget_show(viewport); gtk_container_add(GTK_CONTAINER(scrollwin), viewport); textview = gtk_text_view_new(); buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview)); gtk_container_add(GTK_CONTAINER(viewport), textview); gtk_widget_show(textview); cap.output_text = textview; cap.output_buffer = buffer; /* set the buffer from its previous setting */ if (info->cap_buffer_output) gtk_text_buffer_set_text(buffer, info->cap_buffer_output, strlen(info->cap_buffer_output)); hbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); gtk_widget_show(hbox); label = gtk_label_new("Max # of characters in output display: "); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); gtk_widget_show(label); entry = gtk_entry_new(); gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 0); gtk_widget_show(entry); cap.max_num_entry = entry; if (!info->cap_max_buf_size) info->cap_max_buf_size = DEFAULT_MAX_BUF_SIZE; str = g_string_new(""); g_string_append_printf(str, "%d", info->cap_max_buf_size); gtk_entry_set_text(GTK_ENTRY(entry), str->str); g_string_free(str, TRUE); g_signal_connect (entry, "insert-text", G_CALLBACK (insert_text), (gpointer)&cap); gtk_widget_set_size_request(GTK_WIDGET(dialog), DIALOG_WIDTH, DIALOG_HEIGHT); gtk_widget_show(dialog); cont: result = gtk_dialog_run(GTK_DIALOG(dialog)); if (result == GTK_RESPONSE_ACCEPT) { execute_button_clicked(&cap); goto cont; } /* Make sure no capture is running */ end_capture(&cap); /* Get the max buffer size */ val = gtk_entry_get_text(GTK_ENTRY(entry)); info->cap_max_buf_size = atoi(val); gtk_text_buffer_get_start_iter(cap.output_buffer, &start_iter); gtk_text_buffer_get_end_iter(cap.output_buffer, &end_iter); g_free(info->cap_buffer_output); info->cap_buffer_output = gtk_text_buffer_get_text(cap.output_buffer, &start_iter, &end_iter, FALSE); /* save the plugin and file to reuse if we come back */ update_plugin(&cap); free(info->cap_file); cap.info->cap_file = strdup(gtk_entry_get_text(GTK_ENTRY(cap.file_entry))); free(info->cap_command); command = gtk_entry_get_text(GTK_ENTRY(cap.command_entry)); if (command && strlen(command) && !is_just_ws(command)) cap.info->cap_command = strdup(command); else cap.info->cap_command = NULL; update_events(&cap); gtk_widget_destroy(dialog); if (pevent) pevent_free(pevent); if (plugins) tracecmd_free_list(plugins); }