diff options
-rw-r--r-- | file.c | 7 | ||||
-rw-r--r-- | gtk/main.c | 6 | ||||
-rw-r--r-- | gtk/proto_draw.c | 22 | ||||
-rw-r--r-- | gtk/proto_draw.h | 4 | ||||
-rw-r--r-- | packet-sna.c | 5 | ||||
-rw-r--r-- | packet.h | 9 | ||||
-rw-r--r-- | print.c | 27 | ||||
-rw-r--r-- | print.h | 4 | ||||
-rw-r--r-- | util.c | 154 | ||||
-rw-r--r-- | util.h | 4 |
10 files changed, 146 insertions, 96 deletions
@@ -1,7 +1,7 @@ /* file.c * File I/O routines * - * $Id: file.c,v 1.121 1999/11/19 22:31:48 gram Exp $ + * $Id: file.c,v 1.122 1999/11/22 06:24:38 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -985,6 +985,7 @@ wtap_dispatch_cb(u_char *user, const struct wtap_pkthdr *phdr, int offset, fdata->lnk_t = phdr->pkt_encap; fdata->abs_secs = phdr->ts.tv_sec; fdata->abs_usecs = phdr->ts.tv_usec; + fdata->encoding = CHAR_ASCII; fdata->pseudo_header = phdr->pseudo_header; fdata->cinfo = NULL; @@ -1280,7 +1281,7 @@ print_packets(capture_file *cf, print_args_t *print_args) if (print_args->print_hex) { /* Print the full packet data as hex. */ - print_hex_data(cf->print_fh, cf->pd, fd->cap_len); + print_hex_data(cf->print_fh, cf->pd, fd->cap_len, fd->encoding); } /* Print a blank line if we print anything after this. */ @@ -1557,7 +1558,7 @@ select_packet(capture_file *cf, int row) clear_tree_and_hex_views(); proto_tree_draw(cf->protocol_tree, tree_view); packet_hex_print(GTK_TEXT(byte_view), cf->pd, cf->current_frame->cap_len, - -1, -1); + -1, -1, cf->current_frame->encoding); gtk_text_thaw(GTK_TEXT(byte_view)); /* A packet is selected, so "File/Print Packet" has something to print. */ diff --git a/gtk/main.c b/gtk/main.c index e44abb3052..8a66e81201 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -1,6 +1,6 @@ /* main.c * - * $Id: main.c,v 1.41 1999/11/21 15:06:07 deniel Exp $ + * $Id: main.c,v 1.42 1999/11/22 06:24:54 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -729,8 +729,8 @@ tree_view_cb(GtkWidget *w, gpointer data) { gtk_text_forward_delete(GTK_TEXT(byte_view), gtk_text_get_length(GTK_TEXT(byte_view))); packet_hex_print(GTK_TEXT(byte_view), cf.pd, cf.current_frame->cap_len, - tree_selected_start, - tree_selected_len); + tree_selected_start, tree_selected_len, + cf.current_frame->encoding); gtk_text_thaw(GTK_TEXT(byte_view)); } diff --git a/gtk/proto_draw.c b/gtk/proto_draw.c index 5b3aaeb2a9..072e959fd5 100644 --- a/gtk/proto_draw.c +++ b/gtk/proto_draw.c @@ -1,7 +1,7 @@ /* gtkpacket.c * Routines for GTK+ packet display * - * $Id: proto_draw.c,v 1.5 1999/11/16 11:44:20 guy Exp $ + * $Id: proto_draw.c,v 1.6 1999/11/22 06:24:55 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -43,6 +43,7 @@ #include <stdio.h> #include "main.h" #include "packet.h" +#include "util.h" #include "proto_draw.h" @@ -56,11 +57,12 @@ static void proto_tree_draw_node(GNode *node, gpointer data); void -packet_hex_print(GtkText *bv, guint8 *pd, gint len, gint bstart, gint blen) { +packet_hex_print(GtkText *bv, guint8 *pd, gint len, gint bstart, gint blen, + char_enc encoding) { gint i = 0, j, k, cur; - gchar line[128], hexchars[] = "0123456789abcdef"; + gchar line[128], hexchars[] = "0123456789abcdef", c = '\0'; GdkFont *cur_font, *new_font; - + while (i < len) { /* Print the line number */ sprintf(line, "%04x ", i); @@ -92,13 +94,23 @@ packet_hex_print(GtkText *bv, guint8 *pd, gint len, gint bstart, gint blen) { } line[cur++] = ' '; gtk_text_insert(bv, cur_font, NULL, NULL, line, cur); + cur = 0; i = j; /* Print the ASCII bit */ cur_font = (i >= bstart && i < (bstart + blen)) ? m_b_font : m_r_font; while (i < k) { if (i < len) { - line[cur++] = (isgraph(pd[i])) ? pd[i] : '.'; + if (encoding == CHAR_ASCII) { + c = pd[i]; + } + else if (encoding == CHAR_EBCDIC) { + c = EBCDIC_to_ASCII1(pd[i]); + } + else { + g_assert_not_reached(); + } + line[cur++] = (isgraph(c)) ? c : '.'; } else { line[cur++] = ' '; } diff --git a/gtk/proto_draw.h b/gtk/proto_draw.h index 3527f510d4..2ffeef7329 100644 --- a/gtk/proto_draw.h +++ b/gtk/proto_draw.h @@ -1,7 +1,7 @@ /* gtkpacket.h * Definitions for GTK+ packet display structures and routines * - * $Id: proto_draw.h,v 1.3 1999/11/15 22:52:03 gram Exp $ + * $Id: proto_draw.h,v 1.4 1999/11/22 06:24:56 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -27,7 +27,7 @@ #ifndef __GTKPACKET_H__ #define __GTKPACKET_H__ -void packet_hex_print(GtkText *, guint8 *, gint, gint, gint); +void packet_hex_print(GtkText *, guint8 *, gint, gint, gint, char_enc); #define E_TREEINFO_FIELD_INFO_KEY "tree_info_finfo" diff --git a/packet-sna.c b/packet-sna.c index 4a89e22ddb..e7a8b7c8a7 100644 --- a/packet-sna.c +++ b/packet-sna.c @@ -2,7 +2,7 @@ * Routines for SNA * Gilbert Ramirez <gram@xiexie.org> * - * $Id: packet-sna.c,v 1.9 1999/11/16 11:42:57 guy Exp $ + * $Id: packet-sna.c,v 1.10 1999/11/22 06:24:39 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@unicom.net> @@ -309,6 +309,9 @@ dissect_sna(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) { guint8 th_fid; int sna_header_len = 0, th_header_len = 0; + /* SNA data should be printed in EBCDIC, not ASCII */ + fd->encoding = CHAR_EBCDIC; + if (IS_DATA_IN_FRAME(offset)) { /* Transmission Header Format Identifier */ th_fid = hi_nibble(pd[offset]); @@ -1,7 +1,7 @@ /* packet.h * Definitions for packet disassembly structures and routines * - * $Id: packet.h,v 1.149 1999/11/21 20:02:32 gram Exp $ + * $Id: packet.h,v 1.150 1999/11/22 06:24:40 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -106,6 +106,12 @@ typedef struct _packet_counts { gint total; } packet_counts; +/* Types of character encodings */ +typedef enum { + CHAR_ASCII, /* ASCII */ + CHAR_EBCDIC /* EBCDIC */ +} char_enc; + /* XXX - some of this stuff is used only while a packet is being dissected; should we keep around a separate data structure for that, to save memory? @@ -129,6 +135,7 @@ typedef struct _frame_data { gint row; /* Row number for this packet in the display */ int lnk_t; /* Per-packet encapsulation/data-link type */ gboolean passed_dfilter; /* TRUE = display, FALSE = no display */ + char_enc encoding; /* Character encoding (ASCII, EBCDIC...) */ union pseudo_header pseudo_header; /* "pseudo-header" from wiretap */ } frame_data; @@ -1,7 +1,7 @@ /* print.c * Routines for printing packet analysis trees. * - * $Id: print.c,v 1.22 1999/10/30 06:41:36 guy Exp $ + * $Id: print.c,v 1.23 1999/11/22 06:24:41 gram Exp $ * * Gilbert Ramirez <gram@verdict.uthscsa.edu> * @@ -46,7 +46,8 @@ static void proto_tree_print_node_text(GNode *node, gpointer data); static void proto_tree_print_node_ps(GNode *node, gpointer data); static void ps_clean_string(unsigned char *out, const unsigned char *in, int outbuf_size); -static void print_hex_data_ps(FILE *fh, register const u_char *cp, register u_int length); +static void print_hex_data_ps(FILE *fh, register const u_char *cp, + register u_int length, char_enc encoding); static void print_ps_file(FILE* target_fh, FILE* source_fh); static void print_text_file(FILE* target_fh, FILE* source_fh); @@ -59,6 +60,7 @@ typedef struct { const guint8 *pd; gboolean print_all_levels; gboolean print_hex_for_data; + char_enc encoding; } print_data; FILE *open_print_dest(int to_file, const char *dest) @@ -118,6 +120,7 @@ void proto_tree_print(gboolean print_one_packet, print_args_t *print_args, data.level = 0; data.fh = fh; data.pd = pd; + data.encoding = fd->encoding; data.print_all_levels = print_args->expand_all; data.print_hex_for_data = !print_args->print_hex; /* If we're printing the entire packet in hex, don't @@ -179,7 +182,8 @@ void proto_tree_print_node_text(GNode *node, gpointer data) /* 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) - print_hex_data(pdata->fh, &pdata->pd[fi->start], fi->length); + print_hex_data(pdata->fh, &pdata->pd[fi->start], fi->length, + pdata->encoding); /* If we're printing all levels, or if this level is expanded, recurse into the subtree, if it exists. */ @@ -195,7 +199,8 @@ void proto_tree_print_node_text(GNode *node, gpointer data) /* This routine was created by Dan Lasley <DLASLEY@PROMUS.com>, and only slightly modified for ethereal by Gilbert Ramirez. */ -void print_hex_data(FILE *fh, register const u_char *cp, register u_int length) +void print_hex_data(FILE *fh, register const u_char *cp, register u_int length, + char_enc encoding) { register int ad, i, j, k; u_char c; @@ -211,6 +216,9 @@ void print_hex_data(FILE *fh, register const u_char *cp, register u_int length) line[j++] = binhex[c>>4]; line[j++] = binhex[c&0xf]; if (i&1) j++; + if (encoding == CHAR_EBCDIC) { + c = EBCDIC_to_ASCII1(c); + } line[42+k++] = c >= ' ' && c < 0x7f ? c : '.'; if ((i & 15) == 15) { fprintf (fh, "\n%4x %s", ad, line); @@ -258,7 +266,8 @@ void proto_tree_print_node_ps(GNode *node, gpointer data) /* If it's uninterpreted data, dump it. */ if (fi->hfinfo->id == proto_data) { print_ps_hex(pdata->fh); - print_hex_data_ps(pdata->fh, &pdata->pd[fi->start], fi->length); + print_hex_data_ps(pdata->fh, &pdata->pd[fi->start], fi->length, + pdata->encoding); } /* Recurse into the subtree, if it exists */ @@ -299,7 +308,8 @@ void ps_clean_string(unsigned char *out, const unsigned char *in, } static -void print_hex_data_ps(FILE *fh, register const u_char *cp, register u_int length) +void print_hex_data_ps(FILE *fh, register const u_char *cp, register u_int length, + char_enc encoding) { register int ad, i, j, k; u_char c; @@ -316,9 +326,12 @@ void print_hex_data_ps(FILE *fh, register const u_char *cp, register u_int lengt line[j++] = binhex[c>>4]; line[j++] = binhex[c&0xf]; if (i&1) j++; + if (encoding == CHAR_EBCDIC) { + c = EBCDIC_to_ASCII1(c); + } line[42+k++] = c >= ' ' && c < 0x7f ? c : '.'; if ((i & 15) == 15) { - ps_clean_string(psline, line, MAX_LINE_LENGTH); + ps_clean_string(psline, line, MAX_LINE_LENGTH); fprintf (fh, "(%4x %s) hexdump\n", ad, psline); memset (line, ' ', sizeof line); line[sizeof (line)-1] = j = k = 0; @@ -1,7 +1,7 @@ /* print.h * Definitions for printing packet analysis trees. * - * $Id: print.h,v 1.14 1999/10/30 06:41:36 guy Exp $ + * $Id: print.h,v 1.15 1999/11/22 06:24:41 gram Exp $ * * Gilbert Ramirez <gram@verdict.uthscsa.edu> * @@ -50,6 +50,6 @@ void print_file(FILE* fh, const char* filename); void proto_tree_print(gboolean print_one_packet, print_args_t *print_args, GNode *protocol_tree, const u_char *pd, frame_data *fd, FILE *fh); void print_hex_data(FILE *fh, register const u_char *cp, - register u_int length); + register u_int length, char_enc encoding); #endif /* print.h */ @@ -1,7 +1,7 @@ /* util.c * Utility routines * - * $Id: util.c,v 1.22 1999/10/19 04:11:15 gram Exp $ + * $Id: util.c,v 1.23 1999/11/22 06:24:42 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -289,47 +289,47 @@ create_tempfile(char *namebuf, int namebuflen, const char *pfx) /* ASCII/EBCDIC conversion tables from * http://www.room42.com/store/computer_center/code_tables.shtml */ +static guint8 ASCII_translate_EBCDIC [ 256 ] = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, + 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, + 0x40, 0x5A, 0x7F, 0x7B, 0x5B, 0x6C, 0x50, 0x7D, 0x4D, + 0x5D, 0x5C, 0x4E, 0x6B, 0x60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0x4B, + 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, + 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, + 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, + 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, + 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B +}; + void ASCII_to_EBCDIC(guint8 *buf, guint bytes) { guint i; guint8 *bufptr; - static guint8 ASCII_translate_EBCDIC [ 256 ] = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, - 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, - 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, - 0x40, 0x5A, 0x7F, 0x7B, 0x5B, 0x6C, 0x50, 0x7D, 0x4D, - 0x5D, 0x5C, 0x4E, 0x6B, 0x60, 0x4B, 0x61, - 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, - 0xF9, 0x7A, 0x5E, 0x4C, 0x7E, 0x6E, 0x6F, - 0x7C, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, - 0xC9, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, - 0xD7, 0xD8, 0xD9, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, - 0xE8, 0xE9, 0xAD, 0xE0, 0xBD, 0x5F, 0x6D, - 0x7D, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, - 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, - 0x97, 0x98, 0x99, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, - 0xA8, 0xA9, 0xC0, 0x6A, 0xD0, 0xA1, 0x4B, - 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, - 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, - 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, - 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, - 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, - 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, - 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, - 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, - 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, - 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, - 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, - 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, - 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, - 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, - 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, - 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B - }; - bufptr = buf; for (i = 0; i < bytes; i++, bufptr++) { @@ -337,47 +337,53 @@ ASCII_to_EBCDIC(guint8 *buf, guint bytes) } } +guint8 +ASCII_to_EBCDIC1(guint8 c) +{ + return ASCII_translate_EBCDIC[c]; +} + +static guint8 EBCDIC_translate_ASCII [ 256 ] = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07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, + 0x2E, 0x2E, 0x2E, 0x2E, 0x5D, 0x2E, 0x2E, + 0x7B, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, + 0x49, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, + 0x7D, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, + 0x52, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, + 0x5C, 0x2E, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, + 0x5A, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, + 0x39, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E +}; + void EBCDIC_to_ASCII(guint8 *buf, guint bytes) { guint i; guint8 *bufptr; - static guint8 EBCDIC_translate_ASCII [ 256 ] = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, - 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, - 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, - 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, - 0x2E, 0x2E, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, - 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x2E, 0x3F, - 0x20, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, - 0x2E, 0x2E, 0x2E, 0x3C, 0x28, 0x2B, 0x7C, - 0x26, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, - 0x2E, 0x21, 0x24, 0x2A, 0x29, 0x3B, 0x5E, - 0x2D, 0x2F, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, - 0x2E, 0x7C, 0x2C, 0x25, 0x5F, 0x3E, 0x3F, - 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, - 0x2E, 0x3A, 0x23, 0x40, 0x27, 0x3D, 0x22, - 0x2E, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, - 0x69, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, - 0x2E, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, - 0x72, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, - 0x2E, 0x7E, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, - 0x7A, 0x2E, 0x2E, 0x2E, 0x5B, 0x2E, 0x2E, - 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, - 0x2E, 0x2E, 0x2E, 0x2E, 0x5D, 0x2E, 0x2E, - 0x7B, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, - 0x49, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, - 0x7D, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, - 0x52, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, - 0x5C, 0x2E, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, - 0x5A, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, - 0x39, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E - }; - bufptr = buf; for (i = 0; i < bytes; i++, bufptr++) { @@ -385,3 +391,9 @@ EBCDIC_to_ASCII(guint8 *buf, guint bytes) } } +guint8 +EBCDIC_to_ASCII1(guint8 c) +{ + return EBCDIC_translate_ASCII[c]; +} + @@ -1,7 +1,7 @@ /* util.h * Utility definitions * - * $Id: util.h,v 1.12 1999/10/19 04:11:16 gram Exp $ + * $Id: util.h,v 1.13 1999/11/22 06:24:42 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -49,7 +49,9 @@ void simple_dialog(gint, gint *, gchar *, ...); int create_tempfile(char *, int, const char *); void ASCII_to_EBCDIC(guint8 *buf, guint bytes); +guint8 ASCII_to_EBCDIC1(guint8 c); void EBCDIC_to_ASCII(guint8 *buf, guint bytes); +guint8 EBCDIC_to_ASCII1(guint8 c); #ifdef __cplusplus } |