- line[50+k++] = c >= ' ' && c < 0x7f ? c : '.';
- if ((i & 15) == 15) {
- fprintf (fh, "\n%04x %s", ad, line);
- /*if (i==15) printf (" %d", length);*/
- memset (line, ' ', sizeof line);
- line[sizeof (line)-1] = j = k = 0;
- ad += 16;
- }
- }
-
- if (line[0] != ' ') fprintf (fh, "\n%04x %s", ad, line);
- fprintf(fh, "\n");
- return;
-
-}
-
-#define MAX_LINE_LENGTH 256
-
-/* Print a node's data, and any child nodes, in PostScript */
-static
-void proto_tree_print_node_ps(GNode *node, gpointer data)
-{
- field_info *fi = PITEM_FINFO(node);
- print_data *pdata = (print_data*) data;
- gchar label_str[ITEM_LABEL_LENGTH];
- gchar *label_ptr;
- const guint8 *pd;
- char psbuffer[MAX_LINE_LENGTH]; /* static sized buffer! */
-
- if (!fi->visible)
- return;
-
- /* was a free format label produced? */
- if (fi->representation) {
- label_ptr = fi->representation;
- }
- else { /* no, make a generic label */
- label_ptr = label_str;
- proto_item_fill_label(fi, label_str);
- }
-
- /* Print the text */
- ps_clean_string(psbuffer, label_ptr, MAX_LINE_LENGTH);
- fprintf(pdata->fh, "%d (%s) putline\n", pdata->level, psbuffer);
-
- /* If it's uninterpreted data, dump it (unless our caller will
- be printing the entire packet in hex). */
- if (fi->hfinfo->id == proto_data && pdata->print_hex_for_data) {
- /*
- * Find the data for this field.
- */
- pd = get_field_data(pdata->src_list, fi);
- print_hex_data_ps(pdata->fh, pd, fi->length, pdata->encoding);
- }
-
- /* Recurse into the subtree, if it exists */
- if (g_node_n_children(node) > 0) {
- pdata->level++;
- g_node_children_foreach(node, G_TRAVERSE_ALL,
- proto_tree_print_node_ps, pdata);
- pdata->level--;
+ line[k++] = c >= ' ' && c < 0x7f ? c : '.';
+ i++;
+ if ((i & 15) == 0 || i == length) {
+ /*
+ * We'll be starting a new line, or
+ * we're finished printing this buffer;
+ * dump out the line we've constructed,
+ * and advance the offset.
+ */
+ line[k] = '\0';
+ print_line(fh, 0, format, line);
+ ad += 16;
+ }