aboutsummaryrefslogtreecommitdiffstats
path: root/packet-lpd.c
diff options
context:
space:
mode:
authorGilbert Ramirez <gram@alumni.rice.edu>1999-03-23 03:14:46 +0000
committerGilbert Ramirez <gram@alumni.rice.edu>1999-03-23 03:14:46 +0000
commitef3dfe2077c3fd49997b7d9f3c31ba9f65ff27e2 (patch)
tree50607383870e1a22da46616611b6af517557c1e3 /packet-lpd.c
parente3db269e00f32936d8385aa04df895edcbed1547 (diff)
Removed all references to gtk objects from packet*.[ch] files. They now
reference the protocol tree with struct proto_tree and struct proto_item objects. That way, the packet decoding source code file can be used with non-gtk packet decoders, like a curses-based ethereal, e.g. I also re-arranged some of the information in packet.h to more appropriate places (like other packet-*.[ch] files). svn path=/trunk/; revision=223
Diffstat (limited to 'packet-lpd.c')
-rw-r--r--packet-lpd.c43
1 files changed, 17 insertions, 26 deletions
diff --git a/packet-lpd.c b/packet-lpd.c
index afd4a9c354..b1164b611f 100644
--- a/packet-lpd.c
+++ b/packet-lpd.c
@@ -2,7 +2,7 @@
* Routines for LPR and LPRng packet disassembly
* Gilbert Ramirez <gram@verdict.uthscsa.edu>
*
- * $Id: packet-lpd.c,v 1.6 1998/12/17 05:42:28 gram Exp $
+ * $Id: packet-lpd.c,v 1.7 1999/03/23 03:14:39 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@unicom.net>
@@ -28,31 +28,22 @@
# include "config.h"
#endif
-#include <gtk/gtk.h>
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
-#ifdef HAVE_NETINET_IN_H
-# include <netinet/in.h>
-#endif
-
+#include <string.h>
-#include "ethereal.h"
+#include <glib.h>
#include "packet.h"
-#include "etypes.h"
enum lpr_type { request, response };
void
-dissect_lpd(const u_char *pd, int offset, frame_data *fd, GtkTree *tree)
+dissect_lpd(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
{
- GtkWidget *lpd_tree, *ti;
+ proto_tree *lpd_tree;
+ proto_item *ti;
enum lpr_type lpr_packet_type;
char *newline, *printer, *line_pos;
int substr_len, curr_offset;
@@ -102,34 +93,34 @@ dissect_lpd(const u_char *pd, int offset, frame_data *fd, GtkTree *tree)
}
if (tree) {
- ti = add_item_to_tree(GTK_WIDGET(tree), offset, fd->cap_len - offset,
+ ti = proto_tree_add_item(tree, offset, fd->cap_len - offset,
"Line Printer Daemon Protocol");
- lpd_tree = gtk_tree_new();
- add_subtree(ti, lpd_tree, ETT_LPD);
+ lpd_tree = proto_tree_new();
+ proto_item_add_subtree(ti, lpd_tree, ETT_LPD);
if (lpr_packet_type == request) {
if (pd[offset] <= 9) {
- add_item_to_tree(lpd_tree, offset, 1,
+ proto_tree_add_item(lpd_tree, offset, 1,
lpd_client_code[pd[offset]]);
}
else {
- add_item_to_tree(lpd_tree, offset, 1,
+ proto_tree_add_item(lpd_tree, offset, 1,
lpd_client_code[0]);
}
- printer = strdup(&pd[offset+1]);
+ printer = g_strdup(&pd[offset+1]);
/* get rid of the new-line so that the tree prints out nicely */
if (printer[fd->cap_len - offset - 2] == 0x0a) {
printer[fd->cap_len - offset - 2] = 0;
}
- add_item_to_tree(lpd_tree, offset+1, fd->cap_len - (offset+1),
+ proto_tree_add_item(lpd_tree, offset+1, fd->cap_len - (offset+1),
/*"Printer/options: %s", &pd[offset+1]);*/
"Printer/options: %s", printer);
- free(printer);
+ g_free(printer);
}
else {
if (pd[offset] <= 3) {
- add_item_to_tree(lpd_tree, offset, 2, "Response: %s",
+ proto_tree_add_item(lpd_tree, offset, 2, "Response: %s",
lpd_server_code[pd[offset]]);
}
else {
@@ -139,13 +130,13 @@ dissect_lpd(const u_char *pd, int offset, frame_data *fd, GtkTree *tree)
while (fd->cap_len > curr_offset) {
newline = strchr(line_pos, '\n');
if (!newline) {
- add_item_to_tree(lpd_tree, curr_offset,
+ proto_tree_add_item(lpd_tree, curr_offset,
fd->cap_len - offset, "Text: %s", line_pos);
break;
}
*newline = 0;
substr_len = strlen(line_pos);
- add_item_to_tree(lpd_tree, curr_offset, substr_len + 1,
+ proto_tree_add_item(lpd_tree, curr_offset, substr_len + 1,
"Text: %s", line_pos);
curr_offset += substr_len + 1;
line_pos = newline + 1;