home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1998 December / PCO_1298.ISO / filesbbs / os2 / fn128os2.arj / FN128OS2.ZIP / fn128os2 / src / morpher.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-10-02  |  3.3 KB  |  130 lines

  1. /*
  2.  # $Id: morpher.h,v 1.5 1998/04/10 10:27:56 fbm Exp fbm $
  3.  # Copyright (C) 1997,1998 Farrell McKay
  4.  # All rights reserved.
  5.  #
  6.  # This file is part of the Fortify distribution, a toolkit for
  7.  # upgrading the cryptographic strength of the Netscape Navigator
  8.  # web browser, authored by Farrell McKay.
  9.  #
  10.  # This toolkit is provided to the recipient under the
  11.  # following terms and conditions:-
  12.  #   1.  This copyright notice must not be removed or modified.
  13.  #   2.  This toolkit may not be reproduced or included in any commercial
  14.  #       media distribution, or commercial publication (for example CD-ROM,
  15.  #       disk, book, magazine, journal) without first obtaining the author's
  16.  #       express permission.
  17.  #   3.  This toolkit, or any component of this toolkit, may not be
  18.  #       commercially resold, redeveloped, rewritten, enhanced or otherwise
  19.  #       used as the basis for commercial venture, without first obtaining
  20.  #       the author's express permission.
  21.  #   4.  Subject to the above conditions being observed (1-3), this toolkit
  22.  #       may be freely reproduced or redistributed.
  23.  #   5.  This software is provided "as-is", without express or implied
  24.  #       warranty.  In no event shall the author be liable for any direct,
  25.  #       indirect or consequential damages however caused.
  26.  #   6.  Subject to the above conditions being observed (1-5),
  27.  #       this toolkit may be used at no cost to the recipient.
  28.  #
  29.  # Farrell McKay
  30.  # Wayfarer Systems Pty Ltd        contact@fortify.net
  31.  */
  32.  
  33. #ifndef DEFS_H
  34. #define DEFS_H
  35.  
  36. #include "index.h"
  37.  
  38. #define    ADDR_UNKN    (unsigned long)-1
  39. #define GRAMMAR_MAJOR    1
  40. #define GRAMMAR_MINOR    2
  41.  
  42. #define DEFAULT_GRADE    1
  43.  
  44. #define    VEC_NUM_FMT    0
  45. #define    VEC_STR_FMT    1
  46.  
  47. #define ERR_OPEN    1
  48. #define ERR_NOMATCH    2
  49. #define ERR_LXCOMPR    3
  50. #define ERR_ISSCRIPT    4
  51.  
  52. #if defined(GNU_WIN32) || defined(OS2)
  53. #define OPENFL(a)    ((a)|O_BINARY)
  54. #else
  55. #define OPENFL(a)    (a)
  56. #endif
  57.  
  58. #ifndef OS2
  59. #define    min(a,b)    ((a) < (b)? (a): (b))
  60. #define    max(a,b)    ((a) > (b)? (a): (b))
  61. #endif
  62.  
  63. #define is_bool_op(a)    ((a)==eq||(a)==ne||(a)==lt||(a)==le||(a)==gt||(a)==ge)
  64.  
  65. enum verb_t {
  66.     print, assert
  67. };
  68.  
  69. enum op_t {
  70.     constant, ptr, base, addr, offset, eq, ne, lt, le, gt, ge
  71. };
  72.  
  73. typedef struct {
  74.     int        len;
  75.     unsigned char    *data;
  76.     int        format;
  77. } vec_t;
  78.  
  79. typedef struct exp {
  80.     enum op_t    op;
  81.     int        nargs;
  82.     union {
  83.       unsigned long ul;
  84.       struct exp    *p;
  85.       char        *cp;
  86.     }        arg1, arg2;
  87. } exp_t;
  88.  
  89. typedef struct cmd {
  90.     struct cmd    *next;
  91.     enum verb_t    verb;
  92.     exp_t        *exp;
  93. } cmd_t;
  94.  
  95. typedef struct {
  96.     char        *name;
  97.     int        seg;
  98.     char        *msg;
  99.     unsigned long    base;
  100.     unsigned long    offset;
  101.     unsigned long    filepos;
  102.     int        grade;
  103.     int        is_context;
  104.     vec_t        old, new;
  105.     cmd_t        *cmds;
  106. } morph_t;
  107.  
  108. typedef struct {
  109.     int        grammar_major;
  110.     int        grammar_minor;
  111.     char        *target;
  112.     unsigned long    main;
  113.     long        offsets[NSEGS];
  114.     int        nmorphs;        /* no. of morphs in morphs[] */
  115.     int        morphs_sz;        /* len of morphs[] array */
  116.     morph_t        **morphs;
  117. } morph_set;
  118.  
  119. morph_set    *parse(FILE* fp);
  120. void        lex_file_input(FILE* fp);
  121. morph_t        *find_morph(morph_set *ms, char *name);
  122. void        dump_bool_op(FILE *fp, enum op_t op);
  123. void        dump_morph(FILE *fp, morph_set *ms, morph_t *mp, void (*eval_fn)(), void *vp);
  124. void        dump_init(FILE *fp, morph_set *ms);
  125. void        dump_set(FILE *fp, morph_set *ms, void (*eval_fn)(), void *vp);
  126.  
  127. int        morpher(char *tgt, char *morph_file, index_entry_t *ent, int nowrite, int old_grade, int new_grade, int verbose);
  128.  
  129. #endif
  130.