home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / x / volume19 / Xod / part03 < prev    next >
Encoding:
Text File  |  1993-04-28  |  63.8 KB  |  2,448 lines

  1. Newsgroups: comp.sources.x
  2. From: rfs@se28.wg2.waii.com (Robert Starr)
  3. Subject: v19i020:  Xod - Octal dump for Xwindows, Part03/04
  4. Message-ID: <1993Mar9.211207.21938@sparky.imd.sterling.com>
  5. X-Md4-Signature: 158714dab792f036b3139d7665fb02c7
  6. Date: Tue, 9 Mar 1993 21:12:07 GMT
  7. Approved: chris@sparky.imd.sterling.com
  8.  
  9. Submitted-by: rfs@se28.wg2.waii.com (Robert Starr)
  10. Posting-number: Volume 19, Issue 20
  11. Archive-name: Xod/part03
  12. Environment: X11R4 X11R5 gcc
  13.  
  14. ---- Cut Here and unpack ----
  15. #!/bin/sh
  16. # this is part 3 of a multipart archive
  17. # do not concatenate these parts, unpack them in order with /bin/sh
  18. # file ctw.h continued
  19. #
  20. CurArch=3
  21. if test ! -r s2_seq_.tmp
  22. then echo "Please unpack part 1 first!"
  23.      exit 1; fi
  24. ( read Scheck
  25.   if test "$Scheck" != $CurArch
  26.   then echo "Please unpack part $Scheck next!"
  27.        exit 1;
  28.   else exit 0; fi
  29. ) < s2_seq_.tmp || exit 1
  30. echo "x - Continuing file ctw.h"
  31. sed 's/^X//' << 'SHAR_EOF' >> ctw.h
  32. X    CTW_TOP_LINE,    /* Top line changed. Allow application to change */
  33. X            /* thumb on a scrollbar.             */
  34. X    CTW_BUTTON_DOWN,/* Button down event.                 */
  35. X    CTW_BUTTON_UP,    /* Button up event.                 */
  36. X    CTW_BUTTON_MOTION,/* Button motion event.             */
  37. X    CTW_SELECTION,    /* User is selecting text -- tell app to not give us */
  38. X            /* any more data.                */
  39. X    CTW_PASTE,    /* Received selection from owner.        */
  40. X    CTW_OPEN_WINDOW,/* Uniconise window.                */
  41. X    CTW_CLOSE_WINDOW,/* Iconise window.                */
  42. X    CTW_MOVE_WINDOW, /* Change window position.            */
  43. X    CTW_SIZE_WINDOW_PIXELS, /* Change window size.            */
  44. X    CTW_FRONT_WINDOW,/* Raise window.                */
  45. X    CTW_BACK_WINDOW,    /* Lower window.                */
  46. X    CTW_SIZE_WINDOW_CHARS /* Change window size.            */
  47. X    };
  48. X
  49. Xtypedef struct ctw_callback_t {
  50. X    enum ctw_reasons    reason;
  51. X    char            *ptr;
  52. X    int            len;
  53. X    int            top_line;
  54. X    int            x, y;
  55. X    int            width, height;
  56. X    XEvent            *event;
  57. X    } ctw_callback_t;
  58. X/**********************************************************************/
  59. X/*   Index into array of flag values.                      */
  60. X/**********************************************************************/
  61. Xenum ctw_flags {
  62. X    CTW_AUTOWRAP = 0,
  63. X    CTW_AUTOLINEFEED,
  64. X    CTW_APPL_KEYPAD,
  65. X    CTW_APPL_MOUSE,
  66. X    CTW_CURSOR_KEYPAD,
  67. X    CTW_COLOR_RESET,
  68. X    CTW_CUT_NEWLINES,
  69. X    CTW_DESTRUCTIVE_TABS,
  70. X    CTW_ERASE_BLACK,
  71. X    CTW_ESC_LITERAL,
  72. X    CTW_FONT_SIZE,
  73. X    CTW_LITERAL_MODE,
  74. X    CTW_NEWLINE_GLITCH,
  75. X    CTW_PC_CHARSET,
  76. X    CTW_RESET,
  77. X    CTW_SCROLLING_REGION,
  78. X    CTW_SIZE,
  79. X    CTW_SLOW_MODE,
  80. X    CTW_SMOOTH_SCROLL,
  81. X    CTW_SUN_FUNCTION_KEYS,
  82. X    CTW_ISC_DRIVER,
  83. X    CTW_SCO_DRIVER,
  84. X
  85. X    CTW_MAX_ATTR
  86. X    };
  87. X
  88. X/**********************************************************************/
  89. X/*   Following  macro  used  to  allow  compilation  with ANSI C and  */
  90. X/*   non-ANSI C compilers automatically.                  */
  91. X/**********************************************************************/
  92. X# if !defined(PROTO)
  93. X#     if    defined(__STDC__)
  94. X#        define    PROTO(x)    x
  95. X#    else
  96. X#        define    PROTO(x)    ()
  97. X#    endif
  98. X# endif
  99. X
  100. X/**********************************************************************/
  101. X/*   Add a string to be displayed including ANSI escape sequences.    */
  102. X/**********************************************************************/
  103. Xvoid    ctw_add_string PROTO((CtwWidget, char *, int));
  104. X
  105. X/**********************************************************************/
  106. X/*   Return  line  number  at  top  of screen. Used for implementing  */
  107. X/*   scrollable area.                              */
  108. X/**********************************************************************/
  109. Xint    ctw_get_top_line PROTO((CtwWidget));
  110. X
  111. X/**********************************************************************/
  112. X/*   Set  the  line at the top of the display. Used for implementing  */
  113. X/*   scrollable area.                              */
  114. X/**********************************************************************/
  115. Xvoid    ctw_set_top_line PROTO((CtwWidget, int));
  116. X
  117. X/**********************************************************************/
  118. X/*   Function to retrieve current state of the various attributes.     */
  119. X/**********************************************************************/
  120. Xint    ctw_get_attributes PROTO((CtwWidget, int **, char ***));
  121. X/**********************************************************************/
  122. X/*   Function  to  set  attributes  current  state  of  the  various  */
  123. X/*   attributes.                              */
  124. X/**********************************************************************/
  125. Xvoid    ctw_set_attributes PROTO((CtwWidget, int *));
  126. X
  127. X/**********************************************************************/
  128. X/*   Tell widget to grab the contents of the selection.              */
  129. X/**********************************************************************/
  130. Xvoid    ctw_get_selection PROTO((CtwWidget));
  131. X#endif /* _Ctw_h */
  132. SHAR_EOF
  133. echo "File ctw.h is complete"
  134. chmod 0644 ctw.h || echo "restore of ctw.h fails"
  135. set `wc -c ctw.h`;Sum=$1
  136. if test "$Sum" != "8032"
  137. then echo original size 8032, current size $Sum;fi
  138. echo "x - extracting ctwP.h (Text)"
  139. sed 's/^X//' << 'SHAR_EOF' > ctwP.h &&
  140. X/*# include <X11/copyright.h>*/
  141. X
  142. X/* $XConsortium: TemplateP.h,v 1.4 89/07/21 01:41:48 kit Exp $ */
  143. X/* Copyright    Massachusetts Institute of Technology    1987, 1988 */
  144. X
  145. X#ifndef _CtwP_h
  146. X#define _CtwP_h
  147. X
  148. X# include "ctw.h"
  149. X/* include superclass private header file */
  150. X#include <X11/CoreP.h>
  151. X
  152. X/* define unique representation types not found in <X11/StringDefs.h> */
  153. X
  154. X#define XtRCtwResource "CtwResource"
  155. X
  156. Xtypedef struct {
  157. X/* private: */
  158. X    int    dummy;
  159. X} CtwClassPart;
  160. X
  161. Xtypedef struct _CtwClassRec {
  162. X    CoreClassPart    core_class;
  163. X    CtwClassPart    ctw_class;
  164. X} CtwClassRec;
  165. X
  166. Xextern CtwClassRec ctwClassRec;
  167. X
  168. X# define    BEL        0x07
  169. X# define    ESC        0x1b
  170. X# define    XON        ('q' & 0x1f)
  171. X# define    XOFF        ('s' & 0x1f)
  172. X
  173. X# define    MAX_ESCBUF    128
  174. X
  175. X/**********************************************************************/
  176. X/*   Structure containing stats.                      */
  177. X/**********************************************************************/
  178. X# define COLLECT_STATS    1
  179. X# if COLLECT_STATS
  180. Xstruct stats {
  181. X    unsigned long    lines_scrolled;
  182. X    unsigned long    lines_jumped;
  183. X    unsigned long    scroll_ups;
  184. X    } ctw_stats;
  185. X# endif
  186. X
  187. X/**********************************************************************/
  188. X/*   Definitions for the multi-click code.                  */
  189. X/**********************************************************************/
  190. X# define    CLICK_CHAR    0
  191. X# define    CLICK_WORD    1
  192. X# define    CLICK_LINE    2
  193. X
  194. X/**********************************************************************/
  195. X/*   Define  a  'byte'. A byte represents a character on the screen.  */
  196. X/*   Its  4-bytes  wide containing an 8-bit character, plus a 'font'  */
  197. X/*   indicator.   This  is  used  to  indicate  whether  we  have  a  */
  198. X/*   line-drawing  character  at that position. Another byte is used  */
  199. X/*   to   encode  color  information.  One  more  byte  for  display  */
  200. X/*   attributes  (such  as  bold,  reverse  video). And one which is  */
  201. X/*   spare for now.                              */
  202. X/**********************************************************************/
  203. X# define    VB_LINE        0x01
  204. X# define    VB_REVERSE    0x02
  205. X# define    VB_BOLD        0x04
  206. X# define    VB_FLASHING    0x08
  207. X# define    VB_UNDERLINE    0x10
  208. X# define    VB_SELECT    0x20
  209. X
  210. Xtypedef struct vbyte_t {
  211. X    union {
  212. X        unsigned long    lbyte;
  213. X        struct vb {
  214. X            unsigned char    byte;
  215. X            unsigned char    attr;
  216. X            unsigned char    color;
  217. X            unsigned char    spare;
  218. X            } vbyte;
  219. X        } u;
  220. X    } vbyte_t;
  221. X# define    vb_byte        u.vbyte.byte
  222. X# define    vb_attr        u.vbyte.attr
  223. X# define    vb_color    u.vbyte.color
  224. X# define    vb_spare    u.vbyte.spare
  225. X# define    vb_all        u.lbyte
  226. X
  227. X/**********************************************************************/
  228. X/*   Color manipulation macros.                          */
  229. X/**********************************************************************/
  230. X# define    FG_COLOR    0xf0
  231. X# define    BG_COLOR    0x0f
  232. X# define    FG(x)        ((x) << 4)
  233. X# define    BG(x)        (x)
  234. X# define    GET_FG(x)    ((x) >> 4)
  235. X# define    GET_BG(x)    ((x) & 0x0f)
  236. X
  237. Xenum cursor_type {
  238. X    CURSOR_OFF,
  239. X    CURSOR_ON,
  240. X    CURSOR_SORT_OF,
  241. X    CURSOR_HIDDEN
  242. X    };
  243. X
  244. Xtypedef struct {
  245. X    /* resources */
  246. X    Pixel        window_background;
  247. X    String        table;
  248. X    Pixel        cursor_color;
  249. X    int        rows;
  250. X    int        columns;
  251. X    XtCallbackList    kbd_callback;
  252. X    Boolean        sun_function_keys;
  253. X    int        max_lines;
  254. X    XtCallbackList    resize_callback;
  255. X    XtCallbackList    top_callback;
  256. X    XtCallbackList    mouse_callback;
  257. X    XtCallbackList    appl_callback;
  258. X    char        *geometry;
  259. X    int        flashrate;
  260. X    char        *font;
  261. X    char        *font1;
  262. X    char        *font2;
  263. X    char        *font3;
  264. X    char        *font4;
  265. X    char        *font5;
  266. X    char        *font6;
  267. X    Pixel        hilite_fg;
  268. X    Pixel        hilite_bg;
  269. X    int        multiClickTime;
  270. X
  271. X/* private: */
  272. X    XFontStruct    *fontp;
  273. X    XFontStruct    *line_fontp;    /* Font for line-drawing graphics. */
  274. X    /***********************************************/
  275. X    /*   Need  to  keep  track  of size of window  */
  276. X    /*   allocated  so  if  window  is resized to  */
  277. X    /*   be  larger  than what we have we need to  */
  278. X    /*   allocate a new window.               */
  279. X    /***********************************************/
  280. X    int    win_width_allocated;
  281. X    int    win_height_allocated;
  282. X
  283. X    /***********************************************/
  284. X    /*   Graphics contexts                   */
  285. X    /***********************************************/
  286. X    GC    gc;        /* Normal text.        */
  287. X    GC    line_gc;    /* Line-drawing GC.    */
  288. X    GC    cursor_gc;    /* For drawing cursor.    */
  289. X
  290. X    int    font_height;
  291. X    int    font_width;
  292. X    int    char_set;
  293. X
  294. X    int    x, y;
  295. X    int    saved_x, saved_y;
  296. X    int    cursor_visible;
  297. X    XtIntervalId    cursor_timer;
  298. X    enum cursor_type    cursor_state;
  299. X    int    have_focus;    /* Used for cursor flashing.    */
  300. X
  301. X    char    escbuf[MAX_ESCBUF];    /* Used to assemble escape sequences*/
  302. X    char    *escp;
  303. X
  304. X    int    num_exposures;    /* Number of Exposure events to wait for. */
  305. X
  306. X    int    old_top_line;
  307. X    int    top_line;
  308. X
  309. X    int    scroll_top;    /* Top and bottom scrolling region lines. */
  310. X    int    scroll_bot;
  311. X
  312. X    int    old_rows;
  313. X    int    old_columns;
  314. X    vbyte_t    *memory;    /* Pointer to originally allocated */
  315. X                /* memory.               */
  316. X    vbyte_t    **orig_lines;    /* Array of lines pointers.       */
  317. X    vbyte_t    **lines;    /* Array of lines corresponding to screen */
  318. X
  319. X    Time    timestamp;    /* Time of last event.    */
  320. X    char    *sel_string;    /* Copy of selected text.    */
  321. X    int    sel_length;
  322. X    int    sel_start_x, sel_start_y; /* Starting co-ordinate of hilite*/
  323. X    int    sel_cur_x, sel_cur_y;    /* Current motion position.    */
  324. X    int    num_clicks;    /* Number of button clicks for selecting text */
  325. X    /***********************************************/
  326. X    /*   ANSI escape attributes.               */
  327. X    /***********************************************/
  328. X    int    old_color;
  329. X    vbyte_t    attr;        /* Current display attributes.        */
  330. X    int    flags[CTW_MAX_ATTR];
  331. X} CtwPart;
  332. X
  333. Xtypedef struct _CtwRec {
  334. X    CorePart        core;
  335. X    CtwPart        ctw;
  336. X} CtwRec;
  337. X
  338. X#endif /* _CtwP_h */
  339. SHAR_EOF
  340. chmod 0644 ctwP.h || echo "restore of ctwP.h fails"
  341. set `wc -c ctwP.h`;Sum=$1
  342. if test "$Sum" != "5457"
  343. then echo original size 5457, current size $Sum;fi
  344. echo "x - extracting decode.c (Text)"
  345. sed 's/^X//' << 'SHAR_EOF' > decode.c &&
  346. Xstatic char *RcsID = "$Id: decode.c,v 1.11 1993/03/02 00:45:01 rfs Exp $";
  347. X/*
  348. X * $Log: decode.c,v $
  349. X * Revision 1.11  1993/03/02  00:45:01  rfs
  350. X * Added integrity checks.
  351. X *
  352. X * Revision 1.10  1993/02/26  21:36:37  rfs
  353. X * *** empty log message ***
  354. X *
  355. X * Revision 1.9  1993/02/23  18:22:17  rfs
  356. X * fixed display of ascii decoded data.
  357. X *
  358. X * Revision 1.8  1993/02/17  22:55:01  rfs
  359. X * *** empty log message ***
  360. X *
  361. X * Revision 1.7  1993/02/16  23:13:00  rfs
  362. X * removed "smartness" about handling Home & End
  363. X *
  364. X * Revision 1.6  1993/02/13  23:23:03  rfs
  365. X * Added logic to prevent any display activity on Home or End
  366. X * if we're already there.
  367. X *
  368. X * Revision 1.5  1993/02/13  17:35:50  rfs
  369. X * Fixed pronblem with ASCII decode, and keep mouse position
  370. X * constant whne hcanging view modes.
  371. X *
  372. X * Revision 1.4  1993/02/13  13:41:20  rfs
  373. X * mouse highlight on DisplayFullPagge
  374. X *
  375. X * Revision 1.3  1993/02/13  12:18:24  rfs
  376. X * Added function PackedColumn
  377. X *
  378. X * Revision 1.1  1993/02/13  02:06:39  rfs
  379. X * Initial revision
  380. X *
  381. X * Revision 1.1  1993/02/13  02:06:39  rfs
  382. X * Initial revision
  383. X *
  384. X*/
  385. X
  386. X#include <xod.h>
  387. X#include <ctype.h>
  388. X#include <xod.pt>
  389. X
  390. Xstatic char *escbeg, *escend;
  391. X
  392. X/* what column packed ascii strip begins at */
  393. Xint
  394. XPackedColumn(void) {
  395. X    return CtwColumns-BytesHoriz;
  396. X}
  397. X
  398. Xstatic char *
  399. XAsciiDecode(unsigned char ch) {
  400. X    static char chbuf[128];
  401. X    char buf[10], *p;
  402. X    int  parity = 0;
  403. X
  404. X    if (ch > 127) {
  405. X        parity = 1;
  406. X        ch -= 127;
  407. X    }
  408. X    *buf = ch;
  409. X    *(buf+1) = (char)0;
  410. X    p = buf;
  411. X
  412. X    if (ch < ' ') {
  413. X        switch (ch) {
  414. X            case 0: p = "nul"; break;
  415. X            case 1: p = "soh"; break;
  416. X            case 2: p = "stx"; break;
  417. X            case 3: p = "etx"; break;
  418. X            case 4: p = "eot"; break;
  419. X            case 5: p = "enq"; break;
  420. X            case 6: p = "ack"; break;
  421. X            case 7: p = "bel"; break;
  422. X            case 8: p = "bs"; break;
  423. X            case 9: p = "ht"; break;
  424. X            case 10: p = "nl"; break;
  425. X            case 11: p = "vt"; break;
  426. X            case 12: p = "np"; break;
  427. X            case 13: p = "cr"; break;
  428. X            case 14: p = "so"; break;
  429. X            case 15: p = "si"; break;
  430. X            case 16: p = "dle"; break;
  431. X            case 17: p = "dc1"; break;
  432. X            case 18: p = "dc2"; break;
  433. X            case 19: p = "dc3"; break;
  434. X            case 20: p = "dc4"; break;
  435. X            case 21: p = "nak"; break;
  436. X            case 22: p = "syn"; break;
  437. X            case 23: p = "etb"; break;
  438. X            case 24: p = "can"; break;
  439. X            case 25: p = "em"; break;
  440. X            case 26: p = "sub"; break;
  441. X            case 27: p = "esc"; break;
  442. X            case 28: p = "fs"; break;
  443. X            case 29: p = "gs"; break;
  444. X            case 30: p = "rs"; break;
  445. X            case 31: p = "us"; break;
  446. X        }
  447. X    }
  448. X    if (ch == 127)
  449. X        p = "del";
  450. X    if (parity)
  451. X        sprintf(chbuf, "%s%3s%s", UNDERLINE, p, DATANORMAL);
  452. X    else
  453. X        sprintf(chbuf, "%3s", p);
  454. X    return chbuf;
  455. X}
  456. X
  457. Xstatic char *
  458. XPackedEncode(unsigned char *data,  int length) {
  459. X    static char buffer[MAXLEN];
  460. X    unsigned char *src = data;
  461. X    unsigned char *dest = buffer;
  462. X    unsigned ch;
  463. X    int i, ndx;
  464. X
  465. X    for (i=0, ndx =0; i < BytesHoriz; i++) {
  466. X        if (i >= length) {
  467. X            *dest++ = ' ';
  468. X            continue;
  469. X        }
  470. X        ch = *src;
  471. X        *dest = (isprint(ch)) ? ch : ' ';
  472. X        src++;
  473. X        dest++;
  474. X    }
  475. X    *dest = (char)0;
  476. X    return buffer;
  477. X}
  478. X
  479. Xchar *
  480. XGetFormat(int *width) {
  481. X    char *fmt;
  482. X    int  n = 3;
  483. X
  484. X    switch (DataMode) {
  485. X        case HEX:
  486. X            n = 2;
  487. X            fmt = " %02x";
  488. X            break;
  489. X        case OCTAL:
  490. X            fmt = " %03o";
  491. X            break;
  492. X        case DECIMAL:
  493. X            fmt = " %03d";
  494. X            break;
  495. X        case ASCII:
  496. X            fmt = " %3s";
  497. X            break;
  498. X        default:
  499. X            n = 2;
  500. X            fmt = " %02x";
  501. X            break;
  502. X    }
  503. X    *width = n;
  504. X    return fmt;
  505. X}
  506. X
  507. X/* code to highlight the byte under the mouse click */
  508. Xstatic void
  509. XMouseLight(int mousex, int mousey, int hilite) {
  510. X    char buffer[MAXLEN], chbuf[MAXLEN];
  511. X    char *fmt, *pa;
  512. X    unsigned char ch;
  513. X    int  width, chpos, row, col;
  514. X
  515. X    switch (hilite) {
  516. X        case 0:
  517. X            escbeg = DATANORMAL;
  518. X            escend = "";
  519. X            break;
  520. X        case 1:
  521. X            escbeg = RevVideo();
  522. X            escend = DATANORMAL;
  523. X            break;
  524. X    }
  525. X    fmt = GetFormat(&width);
  526. X    /* account for space in front of each entry */
  527. X    width++;
  528. X    chpos = (mousex-1)/width;
  529. X    chpos++;
  530. X    if (chpos > BytesHoriz)
  531. X        return;
  532. X    ch = ByteAtPosition(mousey, chpos);
  533. X    row = mousey;
  534. X    col = (mousex-1)-((mousex-1)%width)+1;
  535. X    if (DataMode == ASCII) {
  536. X        *chbuf = ' '; *(chbuf+1) = NIL;
  537. X        strcat(chbuf, (hilite) ? RevVideo() : DATANORMAL);
  538. X        strcat(chbuf, AsciiDecode(ch));
  539. X    }
  540. X    else
  541. X        sprintf(chbuf, fmt, ch);
  542. X    sprintf(buffer, "%s%s%s", escbeg, chbuf, escend);
  543. X    CursorAt(row, col);
  544. X    SendString(buffer);
  545. X    /* and, highlight the packed ascii portion too */
  546. X    CursorAt(mousey, PackedColumn()+chpos-1);
  547. X    pa = PackedEncode(&ch, 1);
  548. X    *(pa+1) = NIL;
  549. X    sprintf(buffer, "%s%s%s", escbeg, pa, escend);
  550. X    SendString(buffer);
  551. X    /* send cursor to lower right of screen */
  552. X    CursorAt(NumberRows, CtwColumns);
  553. X}
  554. X
  555. Xvoid
  556. XMouseHighlight(int mousex, int mousey) {
  557. X    MouseLight(mousex, mousey, 1);
  558. X}
  559. X
  560. Xvoid
  561. XMouseUnhighlight(int mousex, int mousey) {
  562. X    MouseLight(mousex, mousey, 0);
  563. X}
  564. X
  565. Xchar *
  566. XBuildLine(unsigned char *data, int length) {
  567. X    static char buffer[3*MAXLEN];
  568. X    char minibuf[MAXLEN];
  569. X    char *fmt, *here;
  570. X    char *p;
  571. X    int i, n;
  572. X
  573. X    *buffer = (char)0;
  574. X    here = buffer;
  575. X    fmt = GetFormat(&n);
  576. X
  577. X    for (i=0; i < length; i++) {
  578. X        if (DataMode == ASCII) {
  579. X            p = AsciiDecode(*data);
  580. X            sprintf(here, " %s", p);
  581. X            here += strlen(p)+1;
  582. X        }
  583. X        else {
  584. X            sprintf(here, fmt, *data);
  585. X            here += n+1;
  586. X        }
  587. X        data++;
  588. X    }
  589. X
  590. X    if (DataMode == ASCII) {
  591. X        p = AsciiDecode(0);
  592. X        n = strlen(p);
  593. X    }
  594. X    else {
  595. X        sprintf(minibuf, fmt, 0);
  596. X        p = minibuf;
  597. X    }
  598. X
  599. X    for (i=length; i < BytesHoriz; i++) {
  600. X        sprintf(here, "%s", p);
  601. X        here += n+1;
  602. X    }
  603. X    return buffer;
  604. X}
  605. X
  606. X/* display a single line of binary data in the CTW widget */
  607. Xvoid
  608. XDisplayLine(unsigned char *data, int length, int line) {
  609. X    char buffer[MAXLEN];
  610. X    char *cp;
  611. X
  612. X    line++;
  613. X    CursorAt(line, 1);
  614. X    cp = BuildLine(data, length);
  615. X    SendString(cp);
  616. X    CursorAt(line, PackedColumn());
  617. X    SendString(PackedEncode(data, length));
  618. X}
  619. X
  620. Xvoid
  621. XDisplayFullPage(int line, int moff) {
  622. X    unsigned char *data;
  623. X    static int dispcnt = 0;
  624. X    int i, cline, cmoff, maxline;
  625. X
  626. X    /* don't do End if we're already there */
  627. X    if (line < 0 && IsAtEOF()) return;
  628. X    /* don't do Home if we're already there */
  629. X    if (dispcnt)
  630. X        DataLocation(&cline, &cmoff);
  631. X
  632. X    maxline = LargestLine();
  633. X    if (line > maxline) line = maxline;
  634. X    data = ReadBlock(line, BytesHoriz, NumberRows, moff);
  635. X    if (!dispcnt)
  636. X        ClearScreen();
  637. X    dispcnt++;
  638. X    for (i=0; i < NumberRows; i++)  {
  639. X        DisplayLine(data+(i*BytesHoriz), BytesHoriz, i);
  640. X    }
  641. X    ResetMouseCoord();
  642. X    MouseHighlight(1, 1);
  643. X    UpdateStatus();
  644. X}
  645. X
  646. Xvoid
  647. XRedisplayPage(void) {
  648. X    int line, moff;
  649. X    int x, y;
  650. X
  651. X    GetCursorOnData(&x, &y);
  652. X    DataLocation(&line, &moff);
  653. X    ClearScreen();
  654. X    DisplayFullPage(line, moff);
  655. X    MouseUnhighlight(1, 1);
  656. X    /*
  657. X    SetMouseCoord(mx, my);
  658. X    MouseHighlight(mx, my);
  659. X    */
  660. X    SetCursorOnData(x, y);
  661. X}
  662. SHAR_EOF
  663. chmod 0644 decode.c || echo "restore of decode.c fails"
  664. set `wc -c decode.c`;Sum=$1
  665. if test "$Sum" != "6496"
  666. then echo original size 6496, current size $Sum;fi
  667. echo "x - extracting defines.h (Text)"
  668. sed 's/^X//' << 'SHAR_EOF' > defines.h &&
  669. X#define XOD_OK 1
  670. X#define XOD_CANCEL 2
  671. X
  672. X/* foreground & background escape sequences */
  673. X#define FGBLACK "\033[30m"
  674. X#define FGRED "\033[31m"
  675. X#define FGGREEN "\033[32m"
  676. X#define FGYELLOW "\033[33m"
  677. X#define FGBLUE "\033[34m"
  678. X#define FGMAGENTA "\033[35m"
  679. X#define FGCYAN "\033[36m"
  680. X#define FGWHITE "\033[37m"
  681. X
  682. X#define BGBLACK "\033[40m"
  683. X#define BGRED "\033[41m"
  684. X#define BGGREEN "\033[42m"
  685. X#define BGYELLOW "\033[43m"
  686. X#define BGBLUE "\033[44m"
  687. X#define BGMAGENTA "\033[45m"
  688. X#define BGCYAN "\033[46m"
  689. X#define BGWHITE "\033[47m"
  690. X
  691. X#define REVVID "\033[7m"
  692. X#define UNDERLINE "\033[4m"
  693. X#define DATANORMAL "\033[0m\033[34m\033[47m"
  694. X
  695. X/* various decoding modes */
  696. X#define HEX         0
  697. X#define OCTAL         1
  698. X#define DECIMAL     2
  699. X#define ASCII         3
  700. X#define PACKASCII     4
  701. X
  702. X#define SHORT 1
  703. X#define USHORT 2
  704. X#define LONG 3
  705. X#define ULONG 4
  706. X#define FLOAT 5
  707. X#define DOUBLE 6
  708. X#define dASCII 7
  709. X
  710. X/* what user types in search box means */
  711. X#define SmGrep 0
  712. X#define SmLine 1
  713. X#define SmAdvance 2
  714. X#define SmRetard 3
  715. X
  716. X#define MAXLEN 256
  717. SHAR_EOF
  718. chmod 0644 defines.h || echo "restore of defines.h fails"
  719. set `wc -c defines.h`;Sum=$1
  720. if test "$Sum" != "989"
  721. then echo original size 989, current size $Sum;fi
  722. echo "x - extracting fileio.c (Text)"
  723. sed 's/^X//' << 'SHAR_EOF' > fileio.c &&
  724. Xstatic char *RcsId = "$Id: fileio.c,v 1.9 1993/03/02 02:56:05 rfs Exp $";
  725. X
  726. X/*
  727. X * $Log: fileio.c,v $
  728. X * Revision 1.9  1993/03/02  02:56:05  rfs
  729. X * Better ahndling of opening bogus ilfe names
  730. X *
  731. X * Revision 1.8  1993/03/02  00:46:04  rfs
  732. X * Added several routines, and comments.
  733. X *
  734. X * Revision 1.7  1993/02/26  21:36:59  rfs
  735. X * *** empty log message ***
  736. X *
  737. X * Revision 1.6  1993/02/25  00:44:11  rfs
  738. X * *** empty log message ***
  739. X *
  740. X * Revision 1.5  1993/02/24  23:14:10  rfs
  741. X * Added ReadNbytes, for use in decoding.
  742. X *
  743. X * Revision 1.4  1993/02/13  23:23:51  rfs
  744. X * Fixed bug in computation of the offeset on End.
  745. X *
  746. X * Revision 1.3  1993/02/13  17:59:19  rfs
  747. X * fixed problem with byte offsets when user hits End
  748. X *
  749. X * Revision 1.2  1993/02/13  13:40:35  rfs
  750. X * Mouse coordinates reset on new file load.
  751. X *
  752. X * Revision 1.1  1993/02/13  02:20:18  rfs
  753. X * Initial revision
  754. X *
  755. X * Revision 1.1  1993/02/13  02:20:18  rfs
  756. X * Initial revision
  757. X *
  758. X*/
  759. X
  760. X#include <stdio.h>
  761. X#include <malloc.h>
  762. X
  763. X#define True 1
  764. X#define False 0;
  765. X#define SRCHBUF 4096
  766. Xtypedef int Boolean;
  767. X
  768. Xstatic unsigned char *data = NULL;
  769. Xstatic char *FileName;
  770. Xstatic long FileSize = 0L;
  771. Xstatic FILE *fp = (FILE *)NULL;
  772. Xstatic Boolean AtEOF = 0;
  773. Xstatic long DataOffset = 0L;
  774. Xstatic int Dwidth, Dheight, Dblksize;
  775. X
  776. X/* returns line # and offset from Dwidth of left corner byte */
  777. Xvoid
  778. XDataLocation(int *line, int *moff) {
  779. X    int Dwidth = GetBytesHoriz();
  780. X
  781. X    *line = DataOffset/Dwidth;
  782. X    *moff = DataOffset % Dwidth;
  783. X}
  784. X
  785. Xlong
  786. XGetDataOffset(void) {
  787. X    return DataOffset;
  788. X}
  789. X
  790. Xchar *
  791. XGetFileName(void) {
  792. X    return FileName;
  793. X}
  794. X
  795. XBoolean
  796. XIsAtEOF(void) {
  797. X    return AtEOF;
  798. X}
  799. X
  800. X/* 
  801. X    search for specified pattern starting 1 byte past cursor...
  802. X    wrap if required.
  803. X*/
  804. XDoSearch(unsigned char *pattern, int len) {
  805. X    unsigned char buffer[SRCHBUF];
  806. X    long begin = DataOffset;
  807. X    long start;
  808. X    long end = DataOffset+(Dwidth*Dheight)-1;
  809. X    long offset, where;
  810. X    int  pass = 0;
  811. X    int  x, y;
  812. X    int  line, moff;
  813. X    int  i, j, bytes;
  814. X
  815. X    offset = begin;
  816. X    GetCursorOnData(&x, &y);
  817. X    offset += (y-1)*Dwidth + (x-1) + 1;
  818. X    start = offset-1;
  819. X    while (1) {
  820. X        fseek(fp, offset, 0);
  821. X        bytes = fread(buffer, sizeof(unsigned char), SRCHBUF, fp);
  822. X        for (i=0; i < bytes; i++) {
  823. X            if (buffer[i] == *pattern) {
  824. X                for (j=0; j < len; j++) {
  825. X                    if (buffer[i+j] != *(pattern+j)) break;
  826. X                }
  827. X                /* did we find a match? */
  828. X                if (j == len) {
  829. X                    where = offset+i;
  830. X                    line = where/Dwidth;
  831. X                    if (line < 0) line = 1;
  832. X                    moff = begin % Dwidth;
  833. X                    if (where > end || pass) {
  834. X                        begin = line*Dwidth + moff;
  835. X                        DisplayFullPage(line, moff);
  836. X                    }
  837. X                    y = (where-begin)/Dwidth + 1;
  838. X                    x = (where-begin)-((y-1)*Dwidth) + 1;
  839. X
  840. X                    if (where <= end) {
  841. X                        SetCursorOnData(x, y);
  842. X                    }
  843. X                    else {
  844. X                        DisplayFullPage(line, moff);
  845. X                        SetCursorOnData(x, y);
  846. X                    }
  847. X                    return;
  848. X                }
  849. X            }
  850. X        }
  851. X        offset += SRCHBUF-len+1;
  852. X        if (bytes < SRCHBUF) {
  853. X            if (start == 0L)
  854. X                break;
  855. X            else {
  856. X                pass++;
  857. X                offset = 0;
  858. X                start =0;
  859. X                continue;
  860. X            }
  861. X        }
  862. X        if (pass > 0 && offset > begin)
  863. X            break;
  864. X    }
  865. X}
  866. X
  867. Xunsigned char *
  868. XReadBlock(int startline, int width, int height, int moff) {
  869. X    int blksize = width*height;
  870. X    int offset = startline*width+moff;
  871. X    int i, diff, bytes;
  872. X
  873. X    /* implies end-of-file */
  874. X    if (startline < 0) {
  875. X        /* compute offset, and be sure offset % width is 0 */
  876. X        offset = FileSize-blksize;
  877. X        if (offset < 0) offset = moff;
  878. X        diff = offset % width;
  879. X        if (diff)
  880. X            offset += (width-diff);
  881. X    }
  882. X    DataOffset = offset;
  883. X    Dwidth = width;
  884. X    Dheight = height;
  885. X    Dblksize = blksize;
  886. X
  887. X    /* always read into the same place */
  888. X    if (!data)
  889. X        data = (unsigned char *)malloc(blksize*sizeof(unsigned char));
  890. X    fseek(fp, offset, 0);
  891. X    bytes = fread(data, sizeof(unsigned char), blksize, fp);
  892. X    AtEOF = (bytes < blksize) ? True : False;
  893. X    if ((offset+bytes+1) >= FileSize)
  894. X        AtEOF = True;
  895. X    /* ensure we return a full block.  pad w/ zeros if necessary */
  896. X    for (i=bytes; i < blksize; i++) {
  897. X        *(data+i) = (unsigned char)0;
  898. X    }
  899. X    return data;
  900. X}
  901. X
  902. X/* read n bytes starting at begin... this is for decoding */
  903. XReadNbytes(long begin, int n, unsigned char *where) {
  904. X    fseek(fp, begin, 0);
  905. X    fread(where, sizeof(unsigned char), n, fp);
  906. X}
  907. X
  908. X/* return byte that is at specified position */
  909. Xunsigned char
  910. XByteAtPosition(int line, int chpos) {
  911. X    int  off = ((line-1)*Dwidth)+chpos-1;
  912. X
  913. X    return *(data+off);
  914. X}
  915. X
  916. X/* Returns True if the specified address is on the screen, False otherwise */
  917. XBoolean
  918. XAddressOnScreen(long addr) {
  919. X    long begin = DataOffset;
  920. X    long end = begin + Dblksize -1;
  921. X
  922. X    return (addr >= begin && addr <= end) ? True : False;
  923. X}
  924. X
  925. X
  926. XBoolean
  927. XFileOpen(char *filename) {
  928. X    FILE *oldfp = fp;
  929. X    FILE *newfp;
  930. X
  931. X    if (filename)
  932. X        newfp = fopen(filename, "r");
  933. X    else
  934. X        return False;
  935. X
  936. X    if (newfp) {
  937. X        if (oldfp) fclose(oldfp);
  938. X        fp = newfp;
  939. X    }
  940. X    else
  941. X        return False;
  942. X
  943. X    ResetMouseCoord();
  944. X    /* save the file name being looked at */
  945. X    if (FileName)
  946. X        free(FileName);
  947. X    FileName = (char *)malloc(strlen(filename)+1);
  948. X    strcpy(FileName, filename);
  949. X
  950. X    /* figure out the size of the file we're looking at */
  951. X    fseek(fp, 0, 2);
  952. X    FileSize = ftell(fp);
  953. X    fseek(fp, 0, 0);
  954. X    return True;
  955. X}
  956. X
  957. X/* return largest allowed line #, knowing size of file */
  958. XLargestLine(void) {
  959. X    return FileSize/GetBytesHoriz();
  960. X}
  961. X
  962. Xlong
  963. XCurrentFileSize(void) {
  964. X    return FileSize;
  965. X}
  966. SHAR_EOF
  967. chmod 0644 fileio.c || echo "restore of fileio.c fails"
  968. set `wc -c fileio.c`;Sum=$1
  969. if test "$Sum" != "5196"
  970. then echo original size 5196, current size $Sum;fi
  971. echo "x - extracting frowny.xbm (Text)"
  972. sed 's/^X//' << 'SHAR_EOF' > frowny.xbm &&
  973. X#define frowny_width 16
  974. X#define frowny_height 16
  975. Xstatic char frowny_bits[] = {
  976. X   0xe0, 0x03, 0x18, 0x0c, 0x04, 0x10, 0x32, 0x23, 0x32, 0x23, 0x01, 0x40,
  977. X   0x01, 0x40, 0x01, 0x40, 0xe1, 0x43, 0x11, 0x44, 0x0a, 0x28, 0x02, 0x20,
  978. X   0x04, 0x10, 0x18, 0x0c, 0xe0, 0x03, 0x00, 0x00};
  979. SHAR_EOF
  980. chmod 0644 frowny.xbm || echo "restore of frowny.xbm fails"
  981. set `wc -c frowny.xbm`;Sum=$1
  982. if test "$Sum" != "281"
  983. then echo original size 281, current size $Sum;fi
  984. echo "x - extracting getres.c (Text)"
  985. sed 's/^X//' << 'SHAR_EOF' > getres.c &&
  986. Xstatic char *RcsID = "$Id: getres.c,v 1.2 1993/02/13 14:34:24 rfs Exp $";
  987. X/*
  988. X * $Log: getres.c,v $
  989. X * Revision 1.2  1993/02/13  14:34:24  rfs
  990. X * *** empty log message ***
  991. X *
  992. X * Revision 1.1  1993/02/13  02:06:39  rfs
  993. X * Initial revision
  994. X *
  995. X * Revision 1.1  1993/02/13  02:06:39  rfs
  996. X * Initial revision
  997. X *
  998. X*/
  999. X
  1000. X/*
  1001. X * Get resources that don't apply to widgets, per se.
  1002. X *
  1003. X * cursorFg: foreground color for "cursor"
  1004. X * cursorBg: background color for "cursor"
  1005. X *
  1006. X * Note: "cursor" is the data byte clicked on with the mouse
  1007. X*/
  1008. X
  1009. X#include <xod.h>
  1010. X
  1011. X/* #defined here, since no one else need to know about them */
  1012. X#define XtNcursorForeground "cursorFg"
  1013. X#define XtCCursorForeground "CursorFg"
  1014. X#define XtNcursorBackground "cursorBg"
  1015. X#define XtCCursorBackground "CursorBg"
  1016. X
  1017. X/* the 7 colors allowed by the CTW widget */
  1018. Xstatic char *CTWcolors[] = {
  1019. X    "black",
  1020. X    "red",
  1021. X    "green",
  1022. X    "yellow",
  1023. X    "blue",
  1024. X    "magenta",
  1025. X    "cyan",
  1026. X    "white"
  1027. X};
  1028. X
  1029. Xstatic char *intoRev = NULL;
  1030. Xstatic char *selCurFg = NULL;
  1031. Xstatic char *selCurBg = NULL;
  1032. X
  1033. X/* returns ESC seequence to set desired reverse video on data */
  1034. Xchar *
  1035. XRevVideo(void) {
  1036. X    return intoRev;
  1037. X}
  1038. X
  1039. Xtypedef struct {
  1040. X    String cursorFg;
  1041. X    String cursorBg;
  1042. X} InstanceRec;
  1043. X
  1044. Xstatic XtResource resources[] = {
  1045. X    { 
  1046. X        XtNcursorForeground, XtCCursorForeground,
  1047. X        XtRString, sizeof(char *),
  1048. X        XtOffsetOf(InstanceRec, cursorFg),
  1049. X        XtRString, "black"
  1050. X    },
  1051. X    { 
  1052. X        XtNcursorBackground, XtCCursorBackground,
  1053. X        XtRString, sizeof(char *),
  1054. X        XtOffsetOf(InstanceRec, cursorBg),
  1055. X        XtRString, "yellow"
  1056. X    }
  1057. X};
  1058. X
  1059. Xstatic int
  1060. XXlateColor(char *color) {
  1061. X    int  i;
  1062. X
  1063. X    for (i=0; i < (sizeof(CTWcolors)/sizeof(char *)); i++) {
  1064. X        if (!strcmp(CTWcolors[i], color))
  1065. X            return i;
  1066. X    }
  1067. X    return -1;
  1068. X}
  1069. X
  1070. Xvoid
  1071. XFigureRevVidSeq(void) {
  1072. X    char buffer[MAXLEN];
  1073. X    char *cfg, *cbg;
  1074. X    int fg, bg;
  1075. X
  1076. X    fg = XlateColor(selCurFg);
  1077. X    bg = XlateColor(selCurBg);
  1078. X    if (fg < 0)
  1079. X        fprintf(stderr, "Foreground color %s is illegal\n", selCurFg);
  1080. X    if (bg < 0)
  1081. X        fprintf(stderr, "Background color %s is illegal\n", selCurBg);
  1082. X    if (fg < 0 || bg < 0)
  1083. X        exit(1);
  1084. X    switch (fg) {
  1085. X        case 0: cfg = FGBLACK; break;
  1086. X        case 1: cfg = FGRED; break;
  1087. X        case 2: cfg = FGGREEN; break;
  1088. X        case 3: cfg = FGYELLOW; break;
  1089. X        case 4: cfg = FGBLUE; break;
  1090. X        case 5: cfg = FGMAGENTA; break;
  1091. X        case 6: cfg = FGCYAN; break;
  1092. X        case 7: cfg = FGWHITE; break;
  1093. X    }
  1094. X    switch (bg) {
  1095. X        case 0: cbg = BGBLACK; break;
  1096. X        case 1: cbg = BGRED; break;
  1097. X        case 2: cbg = BGGREEN; break;
  1098. X        case 3: cbg = BGYELLOW; break;
  1099. X        case 4: cbg = BGBLUE; break;
  1100. X        case 5: cbg = BGMAGENTA; break;
  1101. X        case 6: cbg = BGCYAN; break;
  1102. X        case 7: cbg = BGWHITE; break;
  1103. X    }
  1104. X    sprintf(buffer, "%s%s", cfg, cbg);
  1105. X    intoRev = (char *)malloc(strlen(buffer)+1);
  1106. X    strcpy(intoRev, buffer);
  1107. X}
  1108. X
  1109. Xvoid
  1110. XXodGetResources(Widget top) {
  1111. X    InstanceRec ir;
  1112. X    XtGetApplicationResources(top, &ir, resources, XtNumber(resources),
  1113. X        NULL, 0);
  1114. X    selCurFg = ir.cursorFg;
  1115. X    selCurBg = ir.cursorBg;
  1116. X}
  1117. SHAR_EOF
  1118. chmod 0644 getres.c || echo "restore of getres.c fails"
  1119. set `wc -c getres.c`;Sum=$1
  1120. if test "$Sum" != "2844"
  1121. then echo original size 2844, current size $Sum;fi
  1122. echo "x - extracting gvars.h (Text)"
  1123. sed 's/^X//' << 'SHAR_EOF' > gvars.h &&
  1124. X#include    <stdio.h>
  1125. X#include    <X11/X.h>
  1126. X
  1127. X#ifdef XOD_MAIN
  1128. X#    define Dextern
  1129. X#else
  1130. X#    define Dextern extern
  1131. X#endif
  1132. X
  1133. XDextern FILE *datafp;
  1134. XDextern int  FileSize;
  1135. XDextern int  DataOffset;
  1136. XDextern int  DataMode;
  1137. XDextern int  BytesHoriz;
  1138. XDextern int  DataLeftCol;
  1139. XDextern int  OffsetClickedOn;
  1140. XDextern int  MatchAt;
  1141. XDextern int  NumberRows;
  1142. XDextern int  charwidth;
  1143. XDextern int  charheight;
  1144. XDextern int  SearchMode;
  1145. XDextern char *OffsetFmt;
  1146. XDextern int  OffsetMode;
  1147. XDextern int  MaxOffset;
  1148. XDextern int  CtwColumns;        /* actual width of CTW display, in chars */
  1149. SHAR_EOF
  1150. chmod 0644 gvars.h || echo "restore of gvars.h fails"
  1151. set `wc -c gvars.h`;Sum=$1
  1152. if test "$Sum" != "549"
  1153. then echo original size 549, current size $Sum;fi
  1154. echo "x - extracting gwidgets.h (Text)"
  1155. sed 's/^X//' << 'SHAR_EOF' > gwidgets.h &&
  1156. X#include <stdio.h>
  1157. X#include <X11/X.h>
  1158. X#include <X11/Intrinsic.h>
  1159. X#include <Dialog.h>
  1160. X
  1161. X#ifdef XOD_MAIN
  1162. X#    define Dextern
  1163. X#else
  1164. X#    define Dextern extern
  1165. X#endif
  1166. X
  1167. XDextern Widget HelpDialog, ModeSelect, GrepText;
  1168. XDextern Widget ByteAddress, ctwWidget, ByteOffsetWidget;
  1169. XDextern Widget StatusWidget, ErrorDialog, DecodeWidget;
  1170. XDextern Dialog GotoByteDialog;
  1171. SHAR_EOF
  1172. chmod 0644 gwidgets.h || echo "restore of gwidgets.h fails"
  1173. set `wc -c gwidgets.h`;Sum=$1
  1174. if test "$Sum" != "350"
  1175. then echo original size 350, current size $Sum;fi
  1176. echo "x - extracting helpdialog.c (Text)"
  1177. sed 's/^X//' << 'SHAR_EOF' > helpdialog.c &&
  1178. Xstatic char *RcsId = "$Id: helpdialog.c,v 1.8 1993/03/02 23:05:41 rfs Exp $";
  1179. X
  1180. X/*
  1181. X * $Log: helpdialog.c,v $
  1182. X * Revision 1.8  1993/03/02  23:05:41  rfs
  1183. X * *** empty log message ***
  1184. X *
  1185. X * Revision 1.7  1993/03/02  00:46:34  rfs
  1186. X * Updated messages.
  1187. X *
  1188. X * Revision 1.6  1993/02/26  21:37:32  rfs
  1189. X * *** empty log message ***
  1190. X *
  1191. X * Revision 1.5  1993/02/23  18:22:53  rfs
  1192. X * position the popup.
  1193. X *
  1194. X * Revision 1.4  1993/02/13  23:25:14  rfs
  1195. X * Added code for error dialog popup.
  1196. X *
  1197. X * Revision 1.3  1993/02/13  18:02:40  rfs
  1198. X * generalized slightly for other dialogs.
  1199. X *
  1200. X * Revision 1.2  1993/02/13  14:34:43  rfs
  1201. X * *** empty log message ***
  1202. X *
  1203. X * Revision 1.1  1993/02/13  02:20:18  rfs
  1204. X * Initial revision
  1205. X *
  1206. X * Revision 1.1  1993/02/13  02:20:18  rfs
  1207. X * Initial revision
  1208. X *
  1209. X*/
  1210. X
  1211. X#include <xod.h>
  1212. X#include <Dialog.h>
  1213. X#include <X11/Xaw/Dialog.h>
  1214. X#include <X11/Xaw/Paned.h>
  1215. X#include <X11/Xaw/Form.h>
  1216. X#include <X11/Xaw/Label.h>
  1217. X#include <X11/Xaw/Command.h>
  1218. X
  1219. Xstatic char *viHelp = "\
  1220. Xj    | cursor down\n\
  1221. Xk    | cursor up\n\
  1222. Xh    | cursor left\n\
  1223. Xl    | cursor right\n\
  1224. X(arrow keys also work)\n\
  1225. X^F   | page forward\n\
  1226. X^B   | page backward\n\
  1227. XG    | end-of-file\n\
  1228. X$    | end-of-line \n\
  1229. Xq    | quit xod\n";
  1230. X
  1231. Xstatic char *moveHelp = "\
  1232. XHome | top-of-file\n\
  1233. XEnd  | end-of-file\n\
  1234. X     |\n\
  1235. X+    | move cursor ahead n bytes\n\
  1236. X-    | move cursor back n bytes\n\
  1237. X/    | search for a string\n\
  1238. X(popup will appear)\n\
  1239. Xn    | next search\n";
  1240. X
  1241. Xstatic char *otherHelp = "\
  1242. XMeta-h | hex\n\
  1243. XMeta-o | octal\n\
  1244. XMeta-d | decimal\n\
  1245. XMeta-a | ASCII\n\
  1246. XAlt-h  | offset format in hex\n\
  1247. XAlt-o  | offset format in octal\n\
  1248. XAlt-d  | offset format in decimal\n";
  1249. X
  1250. Xvoid SetSelected();
  1251. X
  1252. Xstatic void 
  1253. XPopdownDialog(Widget w, XtPointer clientData, XtPointer callData) {
  1254. X    XtPopdown((Widget)clientData);
  1255. X}
  1256. X
  1257. Xstatic Widget 
  1258. XHelpCreateDialog(Widget parent) {
  1259. X    Widget pushell, mainpane, helppane, helpform, helplabel, okbutton;
  1260. X
  1261. X    pushell = XtCreatePopupShell("helpDialog", transientShellWidgetClass, 
  1262. X        parent, NULL, 0);
  1263. X    /* pane for window title */
  1264. X    mainpane = XtCreateManagedWidget("paneMain", panedWidgetClass,
  1265. X        pushell, NULL, 0);
  1266. X    helpform = XtCreateManagedWidget("form", formWidgetClass,
  1267. X        mainpane, NULL, 0);
  1268. X    helplabel = XtCreateManagedWidget("labelHelp", labelWidgetClass,
  1269. X        helpform, NULL, 0);
  1270. X    XtVaSetValues(helplabel, XtNlabel, "Xod Quick Help", NULL);
  1271. X    /* pane for first help block */
  1272. X    helppane = XtCreateManagedWidget("pane", panedWidgetClass,
  1273. X        mainpane, NULL, 0);
  1274. X    helpform = XtCreateManagedWidget("form", formWidgetClass,
  1275. X        helppane, NULL, 0);
  1276. X    helplabel = XtCreateManagedWidget("labelHelp", labelWidgetClass,
  1277. X        helpform, NULL, 0);
  1278. X    XtVaSetValues(helplabel, XtNlabel, viHelp, NULL);
  1279. X    helpform = XtCreateManagedWidget("form", formWidgetClass,
  1280. X        helppane, NULL, 0);
  1281. X    helplabel = XtCreateManagedWidget("labelHelp", labelWidgetClass,
  1282. X        helpform, NULL, 0);
  1283. X    XtVaSetValues(helplabel, XtNlabel, moveHelp, NULL);
  1284. X    /* form for second help block */
  1285. X    helpform = XtCreateManagedWidget("form", formWidgetClass,
  1286. X        mainpane, NULL, 0);
  1287. X    helplabel = XtCreateManagedWidget("labelHelp", labelWidgetClass,
  1288. X        helpform, NULL, 0);
  1289. X    XtVaSetValues(helplabel, XtNlabel, otherHelp, NULL);
  1290. X    /* form for the OK button */
  1291. X    helpform = XtCreateManagedWidget("form", formWidgetClass,
  1292. X        mainpane, NULL, 0);
  1293. X    okbutton = XtCreateManagedWidget("helpOK", commandWidgetClass,
  1294. X        helpform, NULL, 0);
  1295. X    XtVaSetValues(okbutton, XtNlabel, "Dismiss", NULL);
  1296. X    XtAddCallback(okbutton, XtNcallback, PopdownDialog, 
  1297. X        (XtPointer)pushell);
  1298. X    return pushell;
  1299. X}
  1300. X
  1301. XWidget
  1302. XCreateHelpDialog(Widget parent) {
  1303. X    Widget w;
  1304. X    w = HelpCreateDialog(parent);
  1305. X    return w;
  1306. X}
  1307. X
  1308. XPopupHelpDialog(void) {
  1309. X    XtPopup(HelpDialog, XtGrabNone);
  1310. X    PositionPopup(GetTopLevel(), HelpDialog);
  1311. X}
  1312. X
  1313. XWidget 
  1314. XErrorCreateDialog(Widget parent, char *bits, int width, int height) {
  1315. X    Widget pushell, mainpane, errlabel, okbutton;
  1316. X    Pixmap bm;
  1317. X
  1318. X    pushell = XtCreatePopupShell("errorDialog", transientShellWidgetClass, 
  1319. X        parent, NULL, 0);
  1320. X    if (bits) {
  1321. X        bm = XCreateBitmapFromData(XtDisplay(pushell), 
  1322. X            RootWindowOfScreen(XtScreen(pushell)), bits, width, height);
  1323. X    }
  1324. X    /* pane for window title */
  1325. X    mainpane = XtCreateManagedWidget("paneMain", panedWidgetClass,
  1326. X        pushell, NULL, 0);
  1327. X    errlabel = XtCreateManagedWidget("labelError", labelWidgetClass,
  1328. X        mainpane, NULL, 0);
  1329. X    XtVaSetValues(errlabel, XtNleftBitmap, bm, NULL);
  1330. X    okbutton = XtCreateManagedWidget("errorOK", commandWidgetClass,
  1331. X        mainpane, NULL, 0);
  1332. X    XtVaSetValues(okbutton, XtNlabel, "OK", NULL);
  1333. X    XtAddCallback(okbutton, XtNcallback, PopdownDialog, 
  1334. X        (XtPointer)pushell);
  1335. X    AddWidgetAssoc(pushell, errlabel);
  1336. X    return pushell;
  1337. X}
  1338. X
  1339. Xvoid
  1340. XPopupErrorDialog(Widget w, char *msg) {
  1341. X    Widget label;
  1342. X
  1343. X    label = (Widget)GetWidgetAssoc(w);
  1344. X    XtVaSetValues(label, XtNlabel, msg, NULL);
  1345. X    PositionPopup(GetTopLevel(), w);
  1346. X    XtPopup(w, XtGrabExclusive);
  1347. X}
  1348. SHAR_EOF
  1349. chmod 0644 helpdialog.c || echo "restore of helpdialog.c fails"
  1350. set `wc -c helpdialog.c`;Sum=$1
  1351. if test "$Sum" != "4782"
  1352. then echo original size 4782, current size $Sum;fi
  1353. echo "x - extracting keyhandler.c (Text)"
  1354. sed 's/^X//' << 'SHAR_EOF' > keyhandler.c &&
  1355. Xstatic char *RcsID = "$Id: keyhandler.c,v 1.5 1993/03/02 00:47:01 rfs Exp $";
  1356. X
  1357. X/*
  1358. X * $Log: keyhandler.c,v $
  1359. X * Revision 1.5  1993/03/02  00:47:01  rfs
  1360. X * Added new features.
  1361. X *
  1362. X * Revision 1.4  1993/02/26  21:38:22  rfs
  1363. X * *** empty log message ***
  1364. X *
  1365. X * Revision 1.3  1993/02/23  18:23:38  rfs
  1366. X * Many mods, all for the better.
  1367. X *
  1368. X * Revision 1.2  1993/02/14  01:15:09  rfs
  1369. X * made certain keys work properly
  1370. X *
  1371. X * Revision 1.1  1993/02/13  02:19:24  rfs
  1372. X * Initial revision
  1373. X *
  1374. X*/
  1375. X
  1376. X#include <xod.h>
  1377. X#include <keys.h>
  1378. X
  1379. X/*
  1380. X * This is the function that handles all keys the user hits
  1381. X * while focus is in the data display window.
  1382. X*/
  1383. X
  1384. XXtEventHandler
  1385. Xkeyhandler(Widget w, void *cd, XKeyEvent *event) {
  1386. X    static int ctrl = 0;
  1387. X    static int meta = 0;
  1388. X    static int alt = 0;
  1389. X    static int lastch = 0;
  1390. X    char buffer[MAXLEN];
  1391. X    KeySym keysym;
  1392. X    XComposeStatus compose;
  1393. X    int line, moff, x, y;
  1394. X    int isctrl = False;
  1395. X    int ismeta = False;
  1396. X    int isalt = False;
  1397. X    int isshift = False;
  1398. X
  1399. X    
  1400. X    XLookupString(event, buffer, MAXLEN, &keysym, &compose);
  1401. X
  1402. X    /* see if key is a meta or ctrl key */
  1403. X    if (keysym == XK_Meta_L || keysym == XK_Meta_R)
  1404. X        ismeta = True;
  1405. X    if (keysym == XK_Control_L || keysym == XK_Control_R)
  1406. X        isctrl = True;
  1407. X    if (keysym == XK_Alt_L || keysym == XK_Alt_R)
  1408. X        isalt = True;
  1409. X    if (keysym == XK_Shift_L || keysym == XK_Shift_R)
  1410. X        isshift = True;
  1411. X
  1412. X    /* ignore KeyRelease for non-meta or ctrl keys */
  1413. X    if (isshift)
  1414. X        return;
  1415. X    if (!ismeta && !isctrl && !isalt && (event->type != KeyPress))
  1416. X        return;
  1417. X
  1418. X    /* set internal state of meta, ctrl, and alt */
  1419. X    if (isctrl) {
  1420. X        ctrl = (event->type == KeyPress) ? 1 : 0;
  1421. X        return;
  1422. X    }
  1423. X    else if (ismeta) {
  1424. X        meta = (event->type == KeyPress) ? 1 : 0;
  1425. X        return;
  1426. X    }
  1427. X    else if (isalt) {
  1428. X        alt = (event->type == KeyPress) ? 1 : 0;
  1429. X        return;
  1430. X    }
  1431. X
  1432. X    /* Meta keys */
  1433. X    if (meta) {
  1434. X        switch (keysym) {
  1435. X            case 'h': DataMode = HEX; ClearScreen(); break;
  1436. X            case 'o': DataMode = OCTAL; ClearScreen(); break;
  1437. X            case 'd': DataMode = DECIMAL; ClearScreen(); break;
  1438. X            case 'a': DataMode = ASCII; ClearScreen(); break;
  1439. X        }
  1440. X    }
  1441. X    /* Alt keys */
  1442. X    else if (alt) {
  1443. X        long addr = GetDataOffset();
  1444. X        /* select offset display mode */
  1445. X        switch (keysym) {
  1446. X            case 'h':
  1447. X                UpdateAll(HEX, addr);
  1448. X                break;
  1449. X            case 'o':
  1450. X                UpdateAll(OCTAL, addr);
  1451. X                break;
  1452. X            case 'd':
  1453. X                UpdateAll(DECIMAL, addr);
  1454. X                break;
  1455. X        }
  1456. X        UpdateByteOffset();
  1457. X        return;
  1458. X    }
  1459. X    /* Ctrl keys */
  1460. X    else if (ctrl) {
  1461. X        switch (keysym) {
  1462. X            case 'f': keysym = PgDn; break;
  1463. X            case 'b': keysym = PgUp; break;
  1464. X            case 'c': exit(0); break;
  1465. X            case 'v': keysym = PgDn; break;            /* emacs... ulk */
  1466. X            case 'n': keysym = DownArrow; break;    /* emacs... ulk */
  1467. X            case 'p': keysym = UpArrow; break;        /* emacs... ulk */
  1468. X        }
  1469. X    }
  1470. X    /* regular keys */
  1471. X    else {
  1472. X        switch (keysym) {
  1473. X            case 'h': keysym = LeftArrow; break;
  1474. X            case 'l': keysym = RightArrow; break;
  1475. X            case 'j': keysym = DownArrow; break;
  1476. X            case 'k': keysym = UpArrow; break;
  1477. X            case 'n': NextSearch(); return; break;
  1478. X            case 'v': 
  1479. X                if (lastch == XK_Escape) keysym = PgUp;    /* emacs... ulk */
  1480. X                break;
  1481. X            case XK_slash: 
  1482. X                PopupSearch("Search for:");
  1483. X                return;
  1484. X                break;
  1485. X        }
  1486. X    }
  1487. X    switch (keysym) {
  1488. X        case 'G':
  1489. X            keysym = End;
  1490. X            break;
  1491. X        case '+':
  1492. X            break;
  1493. X        case '-':
  1494. X            break;
  1495. X    }
  1496. X    DataLocation(&line, &moff);
  1497. X    switch (keysym) {
  1498. X        case '+':
  1499. X            PopupAdvanceToByte("+");
  1500. X            return;
  1501. X            break;
  1502. X        case '-':
  1503. X            PopupAdvanceToByte("-");
  1504. X            return;
  1505. X            break;
  1506. X        case '<':
  1507. X        case '>':
  1508. X            return;
  1509. X            break;
  1510. X        case '?':
  1511. X            PopupHelpDialog();
  1512. X            return;
  1513. X            break;
  1514. X        case '$':
  1515. X            GetCursorOnData(&x, &y);
  1516. X            if (x < BytesHoriz)
  1517. X                SetCursorOnData(BytesHoriz, y);
  1518. X            return;
  1519. X            break;
  1520. X        case 'q':
  1521. X            exit(0);
  1522. X            break;
  1523. X        case XK_Return:
  1524. X            if (!IsAtEOF())
  1525. X                line++;
  1526. X            break;
  1527. X        case PgUp:
  1528. X            if (line == 0)
  1529. X                moff = 0;
  1530. X            if (line > 0)
  1531. X                line -= NumberRows;
  1532. X            if (line < 0) {
  1533. X                line = 0;
  1534. X                moff = 0;
  1535. X            }
  1536. X            DataOffset -= NumberRows*BytesHoriz;
  1537. X            break;
  1538. X        case PgDn:
  1539. X            if (!IsAtEOF())
  1540. X                line += NumberRows;
  1541. X            break;
  1542. X        case Home:
  1543. X            line = moff = 0;
  1544. X            break;
  1545. X        case End:
  1546. X            CursorToAbsByte(CurrentFileSize());
  1547. X            return;
  1548. X            break;
  1549. X        case RightArrow:
  1550. X            GetCursorOnData(&x, &y);
  1551. X            x++;
  1552. X            if (x <= BytesHoriz) 
  1553. X                SetCursorOnData(x, y);
  1554. X            else {
  1555. X                x = 1;
  1556. X                y++;
  1557. X                if (y > NumberRows) {
  1558. X                    if (IsAtEOF()) return;
  1559. X                    line++;
  1560. X                    DisplayFullPage(line, moff);
  1561. X                    SetCursorOnData(x, 0);
  1562. X                }
  1563. X                else
  1564. X                    SetCursorOnData(x, y);
  1565. X            }
  1566. X            return;
  1567. X            break;
  1568. X        case LeftArrow:
  1569. X            GetCursorOnData(&x, &y);
  1570. X            if (x == 1) {
  1571. X                y--;
  1572. X                if (y == 0) {
  1573. X                    line--;
  1574. X                    if (line >= 1)
  1575. X                        DisplayFullPage(line, moff);
  1576. X                }
  1577. X                x = BytesHoriz;
  1578. X                SetCursorOnData(x, y);
  1579. X            }
  1580. X            else {
  1581. X                if (x >= 1)
  1582. X                    SetCursorOnData(--x, y);
  1583. X            }
  1584. X            return;
  1585. X            break;
  1586. X        case DownArrow:
  1587. X            GetCursorOnData(&x, &y);
  1588. X            if (y >= NumberRows) {
  1589. X                if (IsAtEOF()) return;
  1590. X                line++;
  1591. X                DisplayFullPage(line, moff);
  1592. X                SetCursorOnData(x, NumberRows);
  1593. X            }
  1594. X            else {
  1595. X                SetCursorOnData(x, ++y);
  1596. X            }
  1597. X            return;
  1598. X            break;
  1599. X        case UpArrow:
  1600. X            GetCursorOnData(&x, &y);
  1601. X            y--;
  1602. X            if (y == 0) {
  1603. X                line--;
  1604. X                if (line < 0) return;
  1605. X                DisplayFullPage(line, moff);
  1606. X                SetCursorOnData(x, y);
  1607. X            }
  1608. X            else
  1609. X                SetCursorOnData(x, y);
  1610. X            return;
  1611. X            break;
  1612. X    }
  1613. X    lastch = keysym;
  1614. X    DisplayFullPage(line, moff);
  1615. X}
  1616. SHAR_EOF
  1617. chmod 0644 keyhandler.c || echo "restore of keyhandler.c fails"
  1618. set `wc -c keyhandler.c`;Sum=$1
  1619. if test "$Sum" != "5210"
  1620. then echo original size 5210, current size $Sum;fi
  1621. echo "x - extracting keys.h (Text)"
  1622. sed 's/^X//' << 'SHAR_EOF' > keys.h &&
  1623. X#include <X11/keysym.h>
  1624. X
  1625. X/* various keys on keyboard, Sun4 & Linux tested */
  1626. X#ifdef linux
  1627. X#define PgUp XK_Prior
  1628. X#define PgDn XK_Next
  1629. X#define Home XK_Home
  1630. X#define End  XK_End
  1631. X#else
  1632. X#define PgUp XK_R9
  1633. X#define PgDn XK_R15
  1634. X#define Home XK_R7
  1635. X#define End  XK_R13
  1636. X#endif
  1637. X#define UpArrow XK_Up
  1638. X#define DownArrow XK_Down
  1639. X#define LeftArrow XK_Left
  1640. X#define RightArrow XK_Right
  1641. SHAR_EOF
  1642. chmod 0644 keys.h || echo "restore of keys.h fails"
  1643. set `wc -c keys.h`;Sum=$1
  1644. if test "$Sum" != "367"
  1645. then echo original size 367, current size $Sum;fi
  1646. echo "x - extracting main.c (Text)"
  1647. sed 's/^X//' << 'SHAR_EOF' > main.c &&
  1648. Xstatic char *RcsID = "$Id: main.c,v 1.10 1993/03/02 02:55:46 rfs Exp $";
  1649. X/*
  1650. X * $Log: main.c,v $
  1651. X * Revision 1.10  1993/03/02  02:55:46  rfs
  1652. X * *** empty log message ***
  1653. X *
  1654. X * Revision 1.9  1993/03/02  00:47:41  rfs
  1655. X * *** empty log message ***
  1656. X *
  1657. X * Revision 1.8  1993/02/26  21:38:39  rfs
  1658. X * *** empty log message ***
  1659. X *
  1660. X * Revision 1.7  1993/02/24  23:33:37  rfs
  1661. X * *** empty log message ***
  1662. X *
  1663. X * Revision 1.6  1993/02/23  18:24:38  rfs
  1664. X * Added search dialog.
  1665. X *
  1666. X * Revision 1.5  1993/02/13  23:25:41  rfs
  1667. X * pop up error dialog if file to be opened can't be.
  1668. X *
  1669. X * Revision 1.4  1993/02/13  14:37:09  rfs
  1670. X * accept a new file name & load it
  1671. X *
  1672. X * Revision 1.3  1993/02/13  13:42:17  rfs
  1673. X * resources read before DisplayFullPage called.
  1674. X *
  1675. X * Revision 1.2  1993/02/13  11:35:12  rfs
  1676. X * position cursor initially over 1st byte in file
  1677. X *
  1678. X * Revision 1.1  1993/02/13  02:06:39  rfs
  1679. X * Initial revision
  1680. X *
  1681. X * Revision 1.1  1993/02/13  02:06:39  rfs
  1682. X * Initial revision
  1683. X *
  1684. X*/
  1685. X
  1686. X
  1687. X#define XOD_MAIN 1
  1688. X#include <xod.h>
  1689. X#include <X11/Xaw/Paned.h>
  1690. X#include <X11/Xaw/Form.h>
  1691. X#include <X11/Xaw/Box.h>
  1692. X#include <X11/Xaw/Command.h>
  1693. X#include <X11/Xaw/Toggle.h>
  1694. X#include <X11/Xaw/MenuButton.h>
  1695. X#include <X11/Xaw/SimpleMenu.h>
  1696. X#include <X11/Xaw/SmeLine.h>
  1697. X#include <X11/Xaw/SmeBSB.h>
  1698. X#include <buttons.h>
  1699. X#include <version.h>
  1700. X#include <xod.pt>
  1701. X
  1702. Xstatic Widget top;
  1703. Xstatic unsigned char *SearchPattern = NULL;
  1704. Xstatic int  SearchPatternLength = 0;
  1705. X
  1706. X/* show version information */
  1707. Xchar *
  1708. XXodVersion(void) {
  1709. X    return VERSION;
  1710. X}
  1711. X
  1712. X/* set the toplevel widget */
  1713. Xvoid
  1714. XSetTopLevel(Widget w) {
  1715. X    top = w;
  1716. X}
  1717. X
  1718. X/* get the toplevel widget */
  1719. XWidget
  1720. XGetTopLevel(void) {
  1721. X    return top;
  1722. X}
  1723. X
  1724. X/* how many bytes to be displayed horizontally */
  1725. Xint
  1726. XGetBytesHoriz(void) {
  1727. X    return BytesHoriz;
  1728. X}
  1729. X
  1730. X/* data initialization */
  1731. XgvInit() {
  1732. X    datafp = (FILE *)NULL;
  1733. X    FileSize = 0;
  1734. X    DataOffset = 0;
  1735. X    BytesHoriz = 16;
  1736. X    OffsetClickedOn = -1;
  1737. X    MatchAt = -1;
  1738. X    SearchMode = SmGrep;
  1739. X    OffsetFmt = NULL;
  1740. X    OffsetMode = HEX;
  1741. X    MaxOffset = 0;
  1742. X    DataMode = HEX;
  1743. X}
  1744. X
  1745. Xvoid
  1746. XEditModeCB(Widget w, XtPointer client, XtPointer call) {
  1747. X    ButtonPtr bp = (ButtonPtr)client;
  1748. X    int  x, y;
  1749. X
  1750. X    GetCursorOnData(&x, &y);
  1751. X    DataMode = bp->id;
  1752. X    RedisplayPage();
  1753. X    SetCursorOnData(x, y);
  1754. X}
  1755. X
  1756. Xvoid
  1757. XEditDecodeCB(Widget w, XtPointer client, XtPointer call) {
  1758. X    ButtonPtr bp = (ButtonPtr)client;
  1759. X    DoDecode(bp->id);
  1760. X}
  1761. X
  1762. XXtActionProc
  1763. XJunk() {
  1764. X}
  1765. X
  1766. Xvoid SetDialogButton();
  1767. X
  1768. XBoolean image_visible = False;
  1769. XPixmap check_mark;
  1770. XDialog NewFileDialog, SearchDialog, qsave_dialog;
  1771. XString filename = NULL, basename = NULL, format;
  1772. Xchar message[80];
  1773. X
  1774. X
  1775. Xvoid 
  1776. XFileMenuCallback(Widget w, XtPointer clientData, XtPointer callData) {
  1777. X    String file;
  1778. X    char buffer[MAXLEN];
  1779. X    int *id = (int *)clientData;
  1780. X    int stat;
  1781. X
  1782. X    switch (*id) {
  1783. X        case New:
  1784. X            stat = PopupDialog(NewFileDialog, "File to dump:", "", &file,
  1785. X                XtGrabExclusive);
  1786. X            if (stat == Okay) {
  1787. X                if (strlen(file)) {
  1788. X                    if (FileOpen(file)) {
  1789. X                        DisplayFullPage(0, 0);
  1790. X                    }
  1791. X                    else {
  1792. X                        sprintf(buffer, "Cannot open file %s", file);
  1793. X                        PopupErrorDialog(ErrorDialog, buffer);
  1794. X                    }
  1795. X                }
  1796. X            }
  1797. X            break;
  1798. X        case Quit:
  1799. X            exit(0);
  1800. X            break;
  1801. X    }
  1802. X}
  1803. X
  1804. XNextSearch(void) {
  1805. X    if (!SearchPattern) return;
  1806. X    DoSearch(SearchPattern, SearchPatternLength);
  1807. X}
  1808. X
  1809. Xvoid 
  1810. XPopupSearch(String message) {
  1811. X    String search4;
  1812. X    char buffer[MAXLEN];
  1813. X    int stat, len;
  1814. X
  1815. X    stat = PopupDialog(SearchDialog, message, "", &search4,
  1816. X        XtGrabExclusive);
  1817. X    if (stat == Okay) {
  1818. X        if (SearchPattern)
  1819. X            XtFree(SearchPattern);
  1820. X        len = strlen(search4);
  1821. X        SearchPattern = XtMalloc(len+1);
  1822. X        strcpy(SearchPattern, search4);
  1823. X        SearchPatternLength = len;
  1824. X        DoSearch(search4, len);
  1825. X    }
  1826. X}
  1827. X
  1828. Xvoid 
  1829. Xmain(int argc, char **argv) {
  1830. X    Arg wargs[2];
  1831. X    char buffer[MAXLEN];
  1832. X    int rows, columns;
  1833. X    int i, n;
  1834. X
  1835. X    gvInit();
  1836. X    MakeWidgets(&argc, argv);
  1837. X    ParseCommandLine(argc, argv);
  1838. X
  1839. X    XtVaGetValues(ctwWidget, XtNrows, &rows, XtNcolumns, &columns, NULL);
  1840. X    NumberRows = rows;
  1841. X    CtwColumns = columns;
  1842. X    ShowByteAddress(0);
  1843. X
  1844. X    /* capture keystrokes in the CTW widget */
  1845. X    XtAddEventHandler(ctwWidget, KeyPressMask|KeyReleaseMask, False,
  1846. X        (XtEventHandler)keyhandler, (XtPointer)NULL);
  1847. X
  1848. X    XtRealizeWidget(top); 
  1849. X    sprintf(buffer, "xod v%s", VERSION);
  1850. X    XStoreName(XtDisplay(top), XtWindow(top), buffer);
  1851. X
  1852. X    /* see getres.c to see what this does */
  1853. X    XodGetResources(top);
  1854. X    FigureRevVidSeq();
  1855. X    DisplayFullPage(0, 0);
  1856. X    /* do what may have been told us via cmd line args */
  1857. X    CmdLineInit();
  1858. X
  1859. X    /* create all the dialogs we'll be using */
  1860. X    NewFileDialog = CreateDialog(top, "newFile", Okay | Cancel);
  1861. X    SearchDialog = CreateDialog(top, "search", Okay | Cancel);    
  1862. X    GotoByteDialog = CreateDialog(top, "gotoByte", Okay | Cancel);    
  1863. X    HelpDialog = CreateHelpDialog(top);
  1864. X
  1865. X    XtMainLoop();
  1866. X}
  1867. SHAR_EOF
  1868. chmod 0644 main.c || echo "restore of main.c fails"
  1869. set `wc -c main.c`;Sum=$1
  1870. if test "$Sum" != "4647"
  1871. then echo original size 4647, current size $Sum;fi
  1872. echo "x - extracting mkwidgets.c (Text)"
  1873. sed 's/^X//' << 'SHAR_EOF' > mkwidgets.c &&
  1874. Xstatic char *RcsID = "$Id: mkwidgets.c,v 1.7 1993/03/02 01:03:48 rfs Exp $";
  1875. X
  1876. X/*
  1877. X * $Log: mkwidgets.c,v $
  1878. X * Revision 1.7  1993/03/02  01:03:48  rfs
  1879. X * Make cc stop complaining.
  1880. X *
  1881. X * Revision 1.6  1993/03/02  00:48:02  rfs
  1882. X * Added going to absolute byte routines.
  1883. X *
  1884. X * Revision 1.5  1993/02/26  21:39:59  rfs
  1885. X * *** empty log message ***
  1886. X *
  1887. X * Revision 1.4  1993/02/14  01:16:04  rfs
  1888. X * The byte-offset label now responds to button press.
  1889. X *
  1890. X * Revision 1.3  1993/02/13  23:26:42  rfs
  1891. X * Create ErrorDialog.
  1892. X *
  1893. X * Revision 1.2  1993/02/13  14:35:39  rfs
  1894. X * *** empty log message ***
  1895. X *
  1896. X * Revision 1.1  1993/02/13  02:20:18  rfs
  1897. X * Initial revision
  1898. X *
  1899. X * Revision 1.1  1993/02/13  02:20:18  rfs
  1900. X * Initial revision
  1901. X *
  1902. X*/
  1903. X
  1904. X#include <xod.h>
  1905. X#include <X11/Xaw/Paned.h>
  1906. X#include <X11/Xaw/Form.h>
  1907. X#include <X11/Xaw/Box.h>
  1908. X#include <X11/Xaw/Command.h>
  1909. X#include <X11/Xaw/Toggle.h>
  1910. X#include <X11/Xaw/MenuButton.h>
  1911. X#include <X11/Xaw/SimpleMenu.h>
  1912. X#include <X11/Xaw/SmeLine.h>
  1913. X#include <X11/Xaw/SmeBSB.h>
  1914. X#include <buttons.h>
  1915. X#include <xod.pt>
  1916. X#include <frowny.xbm>
  1917. X
  1918. Xstatic XtActionsRec actions_table[] = {
  1919. X  {(String)"fix-menu", (XtActionProc)Junk},
  1920. X  {(String)"set-dialog-button", (XtActionProc)SetDialogButton}
  1921. X};
  1922. X
  1923. Xstatic Widget 
  1924. X    parent_widget,
  1925. X    formy_widget,
  1926. X    fileButton_widget, fileMenu_widget,
  1927. X    editButton_widget, editMenu_widget,
  1928. X    pane_widget, 
  1929. X    form_widget;
  1930. X
  1931. Xvoid 
  1932. XPopupGotoByte(void) {
  1933. X    String gotobyte;
  1934. X    char buffer[MAXLEN];
  1935. X    long addr;
  1936. X    int stat, len;
  1937. X
  1938. X    stat = PopupDialog(GotoByteDialog, "Go to byte:", "", &gotobyte,
  1939. X        XtGrabExclusive);
  1940. X    if (stat == Okay) {
  1941. X        addr = AddressConvert(gotobyte);
  1942. X        CursorToAbsByte(addr);
  1943. X    }
  1944. X}
  1945. X
  1946. Xvoid 
  1947. XPopupAdvanceToByte(char *direction) {
  1948. X    String gotobyte;
  1949. X    char buffer[MAXLEN], *label;
  1950. X    long addr, bias;
  1951. X    int stat, len, line, moff;
  1952. X
  1953. X    if (*direction == '+')
  1954. X        label = "Ahead n bytes:";
  1955. X    else
  1956. X        label = "Back n bytes:";
  1957. X    DataLocation(&line, &moff);
  1958. X    addr = (line*BytesHoriz) + moff + AbsByteOffset();
  1959. X    stat = PopupDialog(GotoByteDialog, label, "", &gotobyte,
  1960. X        XtGrabExclusive);
  1961. X    if (stat == Okay) {
  1962. X        bias = AddressConvert(gotobyte);
  1963. X        addr += (*direction == '+') ? bias : -bias;
  1964. X        if (addr < 0) addr = 0;
  1965. X        CursorToAbsByte(addr);
  1966. X    }
  1967. X}
  1968. X
  1969. X/* make all the widgets we'll be needing */
  1970. Xvoid
  1971. XMakeWidgets(int *argc, char **argv) {
  1972. X    Widget w, pane, form, top;
  1973. X    int  i;
  1974. X
  1975. X    top = XtInitialize(NULL, "Xod", NULL, 0, argc, argv);
  1976. X    SetTopLevel(top);
  1977. X    XtAddActions(actions_table, XtNumber(actions_table));
  1978. X
  1979. X    parent_widget = XtCreateManagedWidget("parent", panedWidgetClass,
  1980. X        top, NULL, 0);
  1981. X
  1982. X    formy_widget = XtCreateManagedWidget("formy", formWidgetClass,
  1983. X        parent_widget, NULL, 0);
  1984. X
  1985. X    fileMenu_widget = XtCreatePopupShell("menu", 
  1986. X        simpleMenuWidgetClass, formy_widget, NULL, 0);
  1987. X
  1988. X    fileButton_widget = XtCreateManagedWidget("File", menuButtonWidgetClass, 
  1989. X        formy_widget, NULL, 0);
  1990. X
  1991. X    /* put buttons in the File pulldown menu */
  1992. X    for (i = 0; i < XtNumber(file_menu); i++) {
  1993. X        w = XtCreateManagedWidget(file_menu[i].name, 
  1994. X            (file_menu[i].trap ? smeBSBObjectClass : smeLineObjectClass),
  1995. X            fileMenu_widget, NULL, 0),
  1996. X        XtAddCallback(w, XtNcallback, FileMenuCallback, 
  1997. X            (XtPointer)&file_menu[i].id);
  1998. X        file_menu[i].widget = w;
  1999. X    }
  2000. X
  2001. X    StatusWidget = XtCreateManagedWidget("status", labelWidgetClass, 
  2002. X        formy_widget, NULL, 0);
  2003. X    DecodeWidget = XtCreateManagedWidget("decode", labelWidgetClass, 
  2004. X        formy_widget, NULL, 0);
  2005. X    ByteOffsetWidget = XtCreateManagedWidget("byteoffset", labelWidgetClass,
  2006. X        formy_widget, NULL, 0);
  2007. X    XtVaSetValues(DecodeWidget, XtNwidth, 200, NULL);
  2008. X    XtAddEventHandler(ByteOffsetWidget, ButtonPressMask, False,
  2009. X        (XtEventHandler)PopupGotoByte, (XtPointer)NULL);
  2010. X    pane = XtCreateManagedWidget("pane", panedWidgetClass, parent_widget,
  2011. X        NULL, 0);
  2012. X    form = XtCreateManagedWidget("form", formWidgetClass, pane,
  2013. X        NULL, 0);
  2014. X
  2015. X    for (i = 0; i < XtNumber(buttonsMode); i++) {
  2016. X        w = XtCreateManagedWidget(buttonsMode[i].name, 
  2017. X            (buttonsMode[i].trap ? toggleWidgetClass : commandWidgetClass), 
  2018. X            form, NULL, 0);
  2019. X        XtAddCallback(w, XtNcallback, EditModeCB, 
  2020. X            (XtPointer)&buttonsMode[i]);
  2021. X        buttonsMode[i].widget = w;
  2022. X    }
  2023. X    for (i = 0; i < XtNumber(buttonsDecode); i++) {
  2024. X        w = XtCreateManagedWidget(buttonsDecode[i].name, 
  2025. X            (buttonsDecode[i].trap ? toggleWidgetClass : commandWidgetClass), 
  2026. X            form, NULL, 0);
  2027. X        XtAddCallback(w, XtNcallback, EditDecodeCB, 
  2028. X            (XtPointer)&buttonsDecode[i]);
  2029. X        buttonsDecode[i].widget = w;
  2030. X    }
  2031. X
  2032. X    /* holds the base address of each column */
  2033. X    ByteAddress = XtCreateManagedWidget("byteoff", labelWidgetClass, 
  2034. X        pane, NULL, 0);
  2035. X    /* Create CTW widget. */
  2036. X    ctwWidget = XtCreateManagedWidget("vt100", ctwWidgetClass,
  2037. X        pane, NULL, 0);
  2038. X    XtAddCallback(ctwWidget, XtNmouseCallback, (XtCallbackProc)MouseCB,
  2039. X         (XtPointer)NULL);
  2040. X
  2041. X    ErrorDialog = ErrorCreateDialog(top, frowny_bits, frowny_width,
  2042. X        frowny_height);
  2043. X}
  2044. SHAR_EOF
  2045. chmod 0644 mkwidgets.c || echo "restore of mkwidgets.c fails"
  2046. set `wc -c mkwidgets.c`;Sum=$1
  2047. if test "$Sum" != "4791"
  2048. then echo original size 4791, current size $Sum;fi
  2049. echo "x - extracting rotate.c (Text)"
  2050. sed 's/^X//' << 'SHAR_EOF' > rotate.c &&
  2051. Xstatic char *RcsID = "$Id: rotate.c,v 1.1 1993/02/13 18:40:43 rfs Exp $";
  2052. X/*
  2053. X * $Log: rotate.c,v $
  2054. X * Revision 1.1  1993/02/13  18:40:43  rfs
  2055. X * Initial revision
  2056. X *
  2057. X *
  2058. X*/
  2059. X
  2060. X/**********************************************************************/
  2061. X/*   Function  to  rotate a block of memory. Can be used for example  */
  2062. X/*   with an array of pointers.                          */
  2063. X/**********************************************************************/
  2064. X# include    <malloc.h>
  2065. X# include    <memory.h>
  2066. X
  2067. X# if defined(MSDOS) || defined(__MSDOS__)
  2068. X#     define    TMP_SIZE    1024
  2069. X# else
  2070. X#     define    TMP_SIZE    8192
  2071. X# endif
  2072. X
  2073. Xstatic void    my_memcpy();
  2074. X
  2075. X/**********************************************************************/
  2076. X/*   If amount > 0 then copy from start=>start+amount.              */
  2077. X/*   If amount < 0 then copy from start+amount=>start.              */
  2078. X/**********************************************************************/
  2079. Xvoid
  2080. Xrotate_mem(ptr, ptr_end, amount)
  2081. Xchar    *ptr;
  2082. Xchar    *ptr_end;
  2083. Xint    amount;
  2084. X{    char    tmpbuf[TMP_SIZE];
  2085. X    char    *tmp;
  2086. X    int    abs_amount = amount < 0 ? -amount : amount;
  2087. X    int    size = ptr_end - ptr;
  2088. X
  2089. X    if (amount == 0 || size == 0)
  2090. X        return;
  2091. X
  2092. X    if (abs_amount <= TMP_SIZE)
  2093. X        tmp = tmpbuf;
  2094. X    else
  2095. X        tmp = malloc(abs_amount);
  2096. X    if (amount < 0) {
  2097. X        memcpy(tmp, ptr, abs_amount);
  2098. X        memcpy(ptr, ptr + abs_amount, size - abs_amount);
  2099. X        memcpy(ptr + size - abs_amount, tmp, abs_amount);
  2100. X        }
  2101. X    else {
  2102. X        memcpy(tmp, ptr + size - abs_amount, abs_amount);
  2103. X        my_memcpy(ptr + abs_amount, ptr, size - abs_amount);
  2104. X        memcpy(ptr, tmp, abs_amount);
  2105. X        }
  2106. X    if (tmp != tmpbuf)
  2107. X        free(tmp);
  2108. X}
  2109. Xstatic void
  2110. Xmy_memcpy(p1, p2, len)
  2111. Xchar    *p1;
  2112. Xchar    *p2;
  2113. Xint    len;
  2114. X{
  2115. X    p1 += len;
  2116. X    p2 += len;
  2117. X    if (((int) p1 & 3) == 0 && ((int) p2 & 3) == 0 && (len & 3) == 0
  2118. X       && sizeof(long) == 4) {
  2119. X        while (len >= sizeof(long)) {
  2120. X            p1 -= sizeof(long);
  2121. X            p2 -= sizeof(long);
  2122. X            *(long *) p1 = *(long *) p2;
  2123. X            len -= sizeof(long);
  2124. X            }
  2125. X        }
  2126. X    while (len-- > 0)
  2127. X        *--p1 = *--p2;
  2128. X}
  2129. SHAR_EOF
  2130. chmod 0644 rotate.c || echo "restore of rotate.c fails"
  2131. set `wc -c rotate.c`;Sum=$1
  2132. if test "$Sum" != "1908"
  2133. then echo original size 1908, current size $Sum;fi
  2134. echo "x - extracting utils.c (Text)"
  2135. sed 's/^X//' << 'SHAR_EOF' > utils.c &&
  2136. Xstatic char *RcsId = "$Id: utils.c,v 1.3 1993/03/02 00:48:38 rfs Exp $";
  2137. X
  2138. X/*
  2139. X * $Log: utils.c,v $
  2140. X * Revision 1.3  1993/03/02  00:48:38  rfs
  2141. X * Added AddressConvert routine.
  2142. X *
  2143. X * Revision 1.2  1993/02/13  14:35:15  rfs
  2144. X * *** empty log message ***
  2145. X *
  2146. X * Revision 1.1  1993/02/13  02:20:18  rfs
  2147. X * Initial revision
  2148. X *
  2149. X * Revision 1.1  1993/02/13  02:20:18  rfs
  2150. X * Initial revision
  2151. X *
  2152. X*/
  2153. X
  2154. X#include "xod.h"
  2155. X
  2156. X/* Position cursor */
  2157. XCursorAt(int x, int y) {
  2158. X    char buffer[MAXLEN];
  2159. X    sprintf(buffer, "\033[%d;%dH", x, y);
  2160. X    SendString(buffer);
  2161. X}
  2162. X
  2163. X/* clear screen and home cursor */
  2164. XClearScreen() {
  2165. X    char buffer[MAXLEN];
  2166. X    sprintf(buffer, "\033[2J%s", DATANORMAL);
  2167. X    CursorAt(1, 1);
  2168. X    SendString(buffer);
  2169. X}
  2170. X
  2171. X/* convert ASCII address in decimal, octal, or hext to numeric equiv */
  2172. Xlong
  2173. XAddressConvert(char *caddr) {
  2174. X    long addr;
  2175. X    char *p, *fmt;
  2176. X
  2177. X    if (!strncmp(caddr, "0x", 2)) {
  2178. X        p = caddr+2;
  2179. X        fmt = "%x";
  2180. X    }
  2181. X    else if (*caddr == '0') {
  2182. X        p++;
  2183. X        fmt = "%o";
  2184. X    }
  2185. X    else {
  2186. X        p = caddr;
  2187. X        fmt = "%d";
  2188. X    }
  2189. X    sscanf(p, fmt, &addr);
  2190. X    return addr;
  2191. X}
  2192. SHAR_EOF
  2193. chmod 0644 utils.c || echo "restore of utils.c fails"
  2194. set `wc -c utils.c`;Sum=$1
  2195. if test "$Sum" != "1025"
  2196. then echo original size 1025, current size $Sum;fi
  2197. echo "x - extracting version.h (Text)"
  2198. sed 's/^X//' << 'SHAR_EOF' > version.h &&
  2199. X#define VERSION "1.01"
  2200. SHAR_EOF
  2201. chmod 0644 version.h || echo "restore of version.h fails"
  2202. set `wc -c version.h`;Sum=$1
  2203. if test "$Sum" != "23"
  2204. then echo original size 23, current size $Sum;fi
  2205. echo "x - extracting xod.1 (Text)"
  2206. sed 's/^X//' << 'SHAR_EOF' > xod.1 &&
  2207. X.TH XOD 1 "October 15, 1992"
  2208. X.SH NAME
  2209. Xxod \- X-based octal dump program
  2210. X.SH SYNOPSIS
  2211. Xxod [options] filename
  2212. X.SH DESCRIPTION
  2213. X.I xod
  2214. Xis a program like the od(1) program, allowing you to examine binary files
  2215. Xin several different ways.  The data can be viewed in a variety of
  2216. Xfashions, based on command line switches, or menu selectable.  The default
  2217. Xviewing mode is hex.
  2218. X.LP
  2219. XOn the screen, you will see the data displayed in your specified viewing
  2220. Xmode, with an ASCII equivalent on the right.  The ASCII on the right
  2221. Xshows only printable ASCII characters.  Non-printable ones are shown as
  2222. Xwhitespace.
  2223. X.LP
  2224. XThe screen is divided into 3 areas.  The strip along the top contains
  2225. Xthe File button, a status area, a place for decoded binary data, and
  2226. Xthe  byte offset (the byte offset in the file where the cursor is located).
  2227. X.LP
  2228. XThe left side of the screen shows pushbuttons that allow you to do
  2229. Xseveral things.  The top bank of buttons allows you to chose
  2230. Xthe data view mode (hex, octal, decimal, or ASCII).  The ASCII view mode is
  2231. Xlike done od(1).  Small, unprintable ASCII characters are shown by their
  2232. XANSI names.  If the byte is > 127, it is shown underlined, but the value
  2233. Xdisplayed is < 127.  That is, if you see it underlined, you can assume
  2234. Xthat it has a value > 127.
  2235. X.LP
  2236. XThe buttons below this allow you to decode the data your cursor is
  2237. Xon in a variety of fashions.  Merely click the mouse on a byte in
  2238. Xthe data area, and then click on a decode mode.  The decoded data will
  2239. Xbe displayed at the top of the window.  If you chose to decode in float
  2240. Xor double, and the decoded value is a huge number, you can generally
  2241. Xassume that the data wasn't a real floating point number.
  2242. X.LP
  2243. XMoving around the decoded data can be accomplished using the PgUp, PgDn
  2244. Xand arrow keys, or certain vi-like or emacs equivalents.  Position the
  2245. Xmouse in the data area, and hit "?" to get a popup showing what keystrokes
  2246. Xare available to you.
  2247. X.LP
  2248. XClicking the mouse on the byte offset label (upper right corner of the
  2249. Xwindow) brings up a popup, allowing you to specify an absolute byte to
  2250. Xgo to.  The address may be supplied in hex (precede address with 0x),
  2251. Xoctal (precede address with 0), or decimal.
  2252. X.SH OPTIONS
  2253. X.IP -x 10
  2254. XDisplay data in hex
  2255. X.IP -o 10
  2256. XDisplay data in octal
  2257. X.IP -d 10
  2258. XDisplay data in decimal
  2259. X.IP -a 10
  2260. XDisplay data in ASCII.
  2261. X.IP "-off n" 10
  2262. XStart displaying the file at offset n.  N may be decimal, octal (begins
  2263. Xwith 0), or hex (begins with 0x).
  2264. X.IP "-odf type" 10
  2265. XSet the offset display format.  This is the legend which shows byte offsets
  2266. Xinto the data file.  The default is hex.  Type can be o (octal), d (decimal),
  2267. Xor h or x (hex).
  2268. X.LP
  2269. XAfter choosing a display mode on the command line (hex is the default),
  2270. Xthere are radio buttons under the data display area which allow you to
  2271. Xview the data in one of 4 ways, at the click of a button.
  2272. X.LP
  2273. XThe mouse is active over the data area.  Clicking mouse button 1
  2274. Xchanges that byte into reverse video.
  2275. X.LP
  2276. XThe reverse video data byte determines the starting byte for decoding.
  2277. XDecoding is accomplished via clicking one of the buttons
  2278. Xcorresponding to how you want the data decoded.
  2279. X.SH AUTHOR
  2280. X.I xod
  2281. Xwas written for fast analysis of binary file data.  The Unix-supplied
  2282. X.I od
  2283. Xwasn't good enough in many situations.  Thus,
  2284. X.I xod
  2285. Xwas born.  I couldn't find anything similar, so I wrote this.
  2286. X.LP
  2287. X.I xod
  2288. Xis built upon Paul Fox's (paul@demon.co.uk) CTW (color
  2289. Xterminal) widget.  This was done because CTW is very fast, and
  2290. Xprevented me from having to make this more difficult than it really needed
  2291. Xto be.  Xod was written by  RF Starr (starr@wg2.waii.com).
  2292. X.SH NOTE
  2293. XBefore you run
  2294. X.I xod,
  2295. Xbe *sure* that the app-defaults file is  loaded somewhere where it
  2296. Xcan be found.  The  app-defaults file is named "Xod.ad".  It should be
  2297. Xcopied into a valid app-defaults directory, and renamed "Xod".
  2298. X.LP
  2299. XThe key bindings are not described in the man page.  You can see what they
  2300. Xare by hitting "?" with the mouse in the data area.  Not shown in the
  2301. Xhelp popup are some emacs bindings.  Try them.
  2302. X.SH BUGS
  2303. XAs noted in the CTW documentation, the CTW widget
  2304. Xhas only been tested on a Sun.  I developed this on a 486 running Linux,
  2305. Xand it appears to work fine.  Note that ctw.c has been marginally enhanced.
  2306. SHAR_EOF
  2307. chmod 0644 xod.1 || echo "restore of xod.1 fails"
  2308. set `wc -c xod.1`;Sum=$1
  2309. if test "$Sum" != "4234"
  2310. then echo original size 4234, current size $Sum;fi
  2311. echo "x - extracting xod.h (Text)"
  2312. sed 's/^X//' << 'SHAR_EOF' > xod.h &&
  2313. X#include <stdio.h>
  2314. X#include <fcntl.h>
  2315. X#include <string.h>
  2316. X#include <X11/X.h>
  2317. X#include <X11/Intrinsic.h>
  2318. X#include <X11/StringDefs.h>
  2319. X#include <X11/Shell.h>
  2320. X#include <ctw.h>
  2321. X#include <Dialog.h>
  2322. X#include <stdlib.h>
  2323. X#include <memory.h>
  2324. X#include <defines.h>
  2325. X#include <gwidgets.h>
  2326. X#include <gvars.h>
  2327. X
  2328. X#ifndef NIL
  2329. X#    define NIL 0
  2330. X#endif
  2331. SHAR_EOF
  2332. chmod 0644 xod.h || echo "restore of xod.h fails"
  2333. set `wc -c xod.h`;Sum=$1
  2334. if test "$Sum" != "329"
  2335. then echo original size 329, current size $Sum;fi
  2336. echo "x - extracting xod.pt (Text)"
  2337. sed 's/^X//' << 'SHAR_EOF' > xod.pt &&
  2338. X#if defined(__STDC__) || defined(__cplusplus)
  2339. X# define _P_XOD(s) s
  2340. X#else
  2341. X# define _P_XOD(s) ()
  2342. X#endif
  2343. X
  2344. X
  2345. X/* main.c */
  2346. Xvoid SetTopLevel _P_XOD((Widget w));
  2347. XWidget GetTopLevel _P_XOD((void));
  2348. Xchar *XodVersion _P_XOD((void));
  2349. Xint gvInit _P_XOD((void));
  2350. Xvoid EditModeCB _P_XOD((Widget w, XtPointer client, XtPointer call));
  2351. Xvoid EditDecodeCB _P_XOD((Widget w, XtPointer client, XtPointer call));
  2352. XXtActionProc Junk _P_XOD((void));
  2353. Xvoid FileMenuCallback _P_XOD((Widget w, XtPointer clientData, XtPointer callData));
  2354. Xint NextSearch _P_XOD((void));
  2355. Xvoid PopupSearch _P_XOD((String message));
  2356. Xvoid main _P_XOD((int argc, char **argv));
  2357. X
  2358. X/* rotate.c */
  2359. Xvoid rotate_mem _P_XOD((char *ptr, char *ptr_end, int amount));
  2360. X
  2361. X/* ctw.c */
  2362. Xvoid HandleFocusChange _P_XOD((Widget widget, CtwWidget w, XFocusChangeEvent *event));
  2363. Xint ctw_set_font _P_XOD((Widget w, char *font_name));
  2364. Xvoid ctw_add_string _P_XOD((CtwWidget w, char *str, int len));
  2365. Xint ctw_get_top_line _P_XOD((CtwWidget ctw));
  2366. Xvoid ctw_set_top_line _P_XOD((CtwWidget ctw, int top_line));
  2367. Xint ctw_get_attributes _P_XOD((CtwWidget w, int **ip, char ***strp));
  2368. Xvoid ctw_set_attributes _P_XOD((CtwWidget w, int *ip));
  2369. Xvoid ctw_get_selection _P_XOD((CtwWidget w));
  2370. X
  2371. X/* math_util.c */
  2372. Xvoid HpToIeee _P_XOD((int HpType, unsigned char *in, double *out));
  2373. Xdouble hp4_2_dbl _P_XOD((unsigned char *in));
  2374. Xdouble hp6_2_dbl _P_XOD((unsigned char *in));
  2375. Xint dbl_2_hp4 _P_XOD((unsigned char *out, double in));
  2376. Xint dbl_2_hp6 _P_XOD((unsigned char *out, double in));
  2377. Xvoid math_tst _P_XOD((int argc, char *argv[]));
  2378. X
  2379. X/* xutils.c */
  2380. Xint ResetMouseCoord _P_XOD((void));
  2381. Xvoid GetMouseCoord _P_XOD((int *x, int *y));
  2382. Xvoid SetMouseCoord _P_XOD((int x, int y));
  2383. Xvoid GetCursorOnData _P_XOD((int *x, int *y));
  2384. Xvoid SetCursorOnData _P_XOD((int x, int y));
  2385. Xint AbsByteOffset _P_XOD((void));
  2386. Xint CursorToAbsByte _P_XOD((long addr));
  2387. Xvoid UpdateByteOffset _P_XOD((void));
  2388. Xvoid DoDecode _P_XOD((int mode));
  2389. Xvoid UpdateAll _P_XOD((int mode, long addr));
  2390. Xvoid UpdateStatus _P_XOD((void));
  2391. Xvoid SetWidgetLabel _P_XOD((Widget w, char *value));
  2392. Xint SendString _P_XOD((char *string));
  2393. Xvoid get_font_size _P_XOD((CtwWidget w, int *fwidth, int *fheight));
  2394. XXtCallbackProc MouseCB _P_XOD((Widget widget, char *name, ctw_callback_t *reason));
  2395. Xvoid AddWidgetAssoc _P_XOD((Widget a, Widget b));
  2396. XWidget GetWidgetAssoc _P_XOD((Widget w));
  2397. X
  2398. X/* Dialog.c */
  2399. Xvoid SetSelected _P_XOD((Widget w, XtPointer clientData, XtPointer callData));
  2400. Xvoid SetDialogButton _P_XOD((Widget w, XEvent *event, String *argv, Cardinal *argc));
  2401. XDialog CreateDialog _P_XOD((Widget top_widget, String name, unsigned long options));
  2402. Xvoid PopdownDialog _P_XOD((Dialog popup, String *answer));
  2403. Xunsigned long PopupDialog _P_XOD((Dialog popup, String message, String suggestion, String *answer, XtGrabKind grab));
  2404. Xvoid PositionPopup _P_XOD((Widget top, Widget popup));
  2405. Xvoid PositionPopupDialog _P_XOD((Widget top_widget, Widget shell_widget, Dimension *width, Dimension *height));
  2406. X
  2407. X/* keyhandler.c */
  2408. XXtEventHandler keyhandler _P_XOD((Widget w, void *cd, XKeyEvent *event));
  2409. X
  2410. X/* helpdialog.c */
  2411. XWidget CreateHelpDialog _P_XOD((Widget parent));
  2412. Xint PopupHelpDialog _P_XOD((void));
  2413. XWidget ErrorCreateDialog _P_XOD((Widget parent, char *bits, int width, int height));
  2414. Xvoid PopupErrorDialog _P_XOD((Widget w, char *msg));
  2415. X
  2416. X/* stubs.c */
  2417. Xint SetModeWidget _P_XOD((void));
  2418. Xint PrintOffset _P_XOD((void));
  2419. Xint Search _P_XOD((void));
  2420. Xint SetGrepLabel _P_XOD((void));
  2421. Xint XmTextSetString _P_XOD((void));
  2422. Xint SimulateButton _P_XOD((void));
  2423. Xint CorrectOffset _P_XOD((void));
  2424. X
  2425. X/* byteaddress.c */
  2426. Xvoid SetAddressMode _P_XOD((int mode));
  2427. Xchar *FmtOffset _P_XOD((long addr));
  2428. Xvoid ShowByteAddress _P_XOD((long startaddr));
  2429. X
  2430. X/* decode.c */
  2431. Xint PackedColumn _P_XOD((void));
  2432. Xchar *GetFormat _P_XOD((int *width));
  2433. Xvoid MouseHighlight _P_XOD((int mousex, int mousey));
  2434. Xvoid MouseUnhighlight _P_XOD((int mousex, int mousey));
  2435. Xchar *BuildLine _P_XOD((unsigned char *data, int length));
  2436. SHAR_EOF
  2437. echo "End of part 3"
  2438. echo "File xod.pt is continued in part 4"
  2439. echo "4" > s2_seq_.tmp
  2440. exit 0
  2441.  
  2442. exit 0 # Just in case...
  2443. -- 
  2444.   // chris@IMD.Sterling.COM            | Send comp.sources.x submissions to:
  2445. \X/  Amiga - The only way to fly!      |
  2446.  "It's intuitively obvious to the most |    sources-x@imd.sterling.com
  2447.   casual observer..."                  |
  2448.