+ retap_packets()

+ complete gtk TextWindow
+ fix elua_dumper
+ fix elua_proto


svn path=/trunk/; revision=17462
This commit is contained in:
Luis Ontanon 2006-03-05 02:01:16 +00:00
parent e6886d90ce
commit 568ad6c34e
5 changed files with 62 additions and 32 deletions

View File

@ -71,6 +71,8 @@ typedef struct _funnel_ops_t {
GLogLevelFlags log_level,
const gchar *message,
gpointer user_data);
void (*retap_packets)(void);
} funnel_ops_t;

View File

@ -234,6 +234,7 @@ static void text_window_append(funnel_text_window_t* tw, const char *str)
#if GTK_MAJOR_VERSION < 2
gtk_text_set_point(GTK_TEXT(txt),gtk_text_get_length(GTK_TEXT(txt)));
gtk_text_insert(GTK_TEXT(txt), user_font_get_regular(), NULL, NULL, str, nchars);
#else
buf= gtk_text_view_get_buffer(GTK_TEXT_VIEW(txt));
@ -268,16 +269,57 @@ static void text_window_set_text(funnel_text_window_t* tw, const gchar* text)
static void text_window_prepend(funnel_text_window_t* tw, const char *str _U_) {
GtkWidget *txt;
int nchars = strlen(str);
#if GTK_MAJOR_VERSION >= 2
GtkTextBuffer *buf;
GtkTextIter iter;
#endif
if (! tw->win) return;
/* XXX todo */
txt = tw->txt;
nchars = strlen(str);
#if GTK_MAJOR_VERSION < 2
gtk_text_set_point(GTK_TEXT(txt),0);
gtk_text_insert(GTK_TEXT(txt), user_font_get_regular(), NULL, NULL, str, nchars);
#else
buf= gtk_text_view_get_buffer(GTK_TEXT_VIEW(txt));
gtk_text_buffer_get_start_iter(buf, &iter);
gtk_widget_modify_font(GTK_WIDGET(txt), user_font_get_regular());
if (!g_utf8_validate(str, -1, NULL))
printf("Invalid utf8 encoding: %s\n", str);
gtk_text_buffer_insert(buf, &iter, str, nchars);
#endif
}
static const gchar* text_window_get_text(funnel_text_window_t* tw) {
GtkWidget *txt;
#if GTK_MAJOR_VERSION >= 2
GtkTextBuffer *buf;
GtkTextIter start;
GtkTextIter end;
#endif
if (! tw->win) return "";
/* XXX todo */
return "";
txt = tw->txt;
#if GTK_MAJOR_VERSION < 2
/* to do */
return "";
#else
buf= gtk_text_view_get_buffer(GTK_TEXT_VIEW(txt));
gtk_text_buffer_get_start_iter(buf, &start);
gtk_text_buffer_get_end_iter(buf, &end);
return gtk_text_buffer_get_text(buf, &start, &end, FALSE);
#endif
}
static void text_window_set_close_cb(funnel_text_window_t* tw, text_win_close_cb_t cb, void* data) {
@ -414,6 +456,10 @@ static void funnel_logger(const gchar *log_domain _U_,
fputs(message,stderr);
}
static void elua_retap_packets(void) {
cf_retap_packets(&cfile, FALSE);
}
static const funnel_ops_t funnel_ops = {
new_text_window,
@ -426,7 +472,8 @@ static const funnel_ops_t funnel_ops = {
text_window_destroy,
/*...,*/
funnel_new_dialog,
funnel_logger
funnel_logger,
funnel_retap_packets
};

View File

@ -117,9 +117,9 @@ ELUA_CONSTRUCTOR PseudoHeader_atm(lua_State* L) {
ELUA_CONSTRUCTOR PseudoHeader_mtp2(lua_State* L) {
/* Creates an MTP2 PseudoHeader */
#define ELUA_OPTARG_PseudoHeader_mtp2_SENT /* True if the packet is sent, False if received. */
#define ELUA_OPTARG_PseudoHeader_mtp2_ANNEXA /* True if annex A is used */
#define ELUA_OPTARG_PseudoHeader_mtp2_LINKNUM /* Link Number */
#define ELUA_OPTARG_PseudoHeader_mtp2_SENT 1 /* True if the packet is sent, False if received. */
#define ELUA_OPTARG_PseudoHeader_mtp2_ANNEXA 2 /* True if annex A is used */
#define ELUA_OPTARG_PseudoHeader_mtp2_LINKNUM 3 /* Link Number */
PseudoHeader ph = g_malloc(sizeof(struct lua_pseudo_header));
ph->type = PHDR_MTP2;
ph->wph = g_malloc(sizeof(union wtap_pseudo_header));
@ -171,7 +171,7 @@ ELUA_CONSTRUCTOR Dumper_new(lua_State* L) {
Dumper:new_for_current() will probably be a better choice.
*/
#define ELUA_ARG_Dumper_new_FILENAME 1 /* The name of the capture file to be created */
#define ELUA_OPTARG_Dumper_new_FILETYPE 3 /* The type of the file to be created */
#define ELUA_OPTARG_Dumper_new_FILETYPE 2 /* The type of the file to be created */
#define ELUA_OPTARG_Dumper_new_ENCAP 3 /* The encapsulation to be used in the file to be created */
Dumper d;
const char* filename = luaL_checkstring(L,1);

View File

@ -627,25 +627,9 @@ static const luaL_reg ProtoField_meta[] = {
};
int ProtoField_register(lua_State* L) {
const eth_ft_types_t* ts;
const struct base_display_string_t* b;
ELUA_REGISTER_CLASS(ProtoField);
/* add a global FT_* variable for each FT_ type */
for (ts = ftenums; ts->str; ts++) {
lua_pushstring(L, ts->str);
lua_pushstring(L, ts->str);
lua_settable(L, LUA_GLOBALSINDEX);
}
/* add a global BASE_* variable for each BASE_ */
for (b=base_displays;b->str;b++) {
lua_pushstring(L, b->str);
lua_pushstring(L, b->str);
lua_settable(L, LUA_GLOBALSINDEX);
}
return 1;
}
@ -862,7 +846,7 @@ static int Proto_tostring(lua_State* L) {
return 1;
}
static int Proto_register_postdissector(lua_State* L) {
ELUA_FUNCTION elua_register_postdissector(lua_State* L) {
Proto proto = checkProto(L,1);
if (!proto) return 0;
@ -1028,10 +1012,6 @@ int Proto_register(lua_State* L) {
ELUA_REGISTER_META(Proto);
lua_pushstring(L, "register_postdissector");
lua_pushcfunction(L, Proto_register_postdissector);
lua_settable(L, LUA_GLOBALSINDEX);
lua_pushstring(L, "Proto");
lua_pushcfunction(L, Proto_new);
lua_settable(L, LUA_GLOBALSINDEX);

View File

@ -72,7 +72,8 @@ static const funnel_ops_t funnel_ops = {
NULL,
/*...,*/
NULL,
funnel_logger
funnel_logger,
NULL
};