home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume10 / cbw / part04 / specs.h < prev    next >
Encoding:
C/C++ Source or Header  |  1987-06-16  |  6.4 KB  |  168 lines

  1. /*
  2.  * Specifications of inter-module dependencies.
  3.  *
  4.  * Robert W. Baldwin, December 1984.
  5.  */
  6.  
  7.  
  8. /* General Information. */
  9.  
  10. /* A pvec is an 'string' of integers that represent plaintext
  11.  *    characters.  The string is terminated by a -1.
  12.  * A pbuf is a fixed length array of integers that represent plaintext
  13.  *    characters.  A value of -1 means that the characters is unknown.
  14.  * A cbuf is a fixed length array of bytes that represent ciphertext chars.
  15.  * A perm is a mapping from shifted ciphertext characters to shifted
  16.  *    plaintext characters.  Each character is shifted (incremented) by
  17.  *    its offset in the block of 256 characters that contain it.
  18.  * A gsi is a data structure about a guess that includes information
  19.  *    on the characters that are assumed to be right.
  20.  * An eci is a data structure that descibes a block of cipher and
  21.  *    plain text.
  22.  * A string is a null terminated vector of bytes.
  23.  */
  24.  
  25.  
  26. extern    twindow    banner;
  27. extern    twindow    webster;
  28. extern    twindow    dblabel;
  29. extern    gwindow    dbstore;
  30. extern    twindow    gblabel;
  31. extern    gwindow    gbstore;
  32. extern    twindow    user;
  33.  
  34. extern    gwindow    *ibanner();
  35. extern    gwindow    *iwebster();
  36. extern    gwindow    *idblabel();
  37. extern    gwindow    *idbstore();
  38. extern    gwindow    *igblabel();
  39. extern    gwindow    *igbstore();
  40. extern    gwindow    *iuser();
  41.  
  42. extern    char    *savestr();
  43. extern    int    substrp(/* big, little */);
  44. extern    int    read_slashed(/* *string */);
  45.  
  46. extern    char *(quitcmd(/* arg-string */));
  47. extern    char *(lpbguess(/* arg-string */));
  48. extern    char *(atrguess(/* arg-string */));
  49. extern    char *(kntguess(/* arg-string */));
  50. extern    char *(ecbguess(/* arg-string */));
  51. extern    char *(pwdguess(/* arg-string */));
  52. extern    char *(permsave(/* arg-string */));
  53. extern    char *(permload(/* arg-string */));
  54. extern    char *(webmatch(/* arg-string */));
  55. extern    char *(clearzee(/* arg-string */));
  56. extern    char *(pgate(/* arg-string */));
  57.  
  58. extern    char *(cmddo(/* cmdtab, string */));
  59. extern    char *(cmdcomplete(/* cmdtab, string */));
  60. extern    gblset(/* w, string */);
  61. extern    gbsswitch(/* w, private, keytable, firsttime, lasttime, draw */);
  62. extern    gbsclear(/* w */);
  63. extern    hstadd(/* w, string */);
  64. extern    usrstatus(/* w, string */);
  65. extern    usrhelp(/* w, string */);
  66. extern    dblbnum(/* w, int */);
  67. extern    int    dbsmerge(/* w, perm */);
  68. extern    dbssetblk(/* w, int */);
  69. extern    int    dbsgetblk(/* w */);
  70. extern    dbstrypq(/* ecbi, pque_hdr, pos */);
  71.  
  72. extern    float    score(/* pbuf */);
  73. extern    float    gsi_1score(/* gsi */);        /* Uses 1st order stats. */
  74. extern    float    gsi_2score(/* gsi */);        /* Uses 2nd order stats. */
  75. extern    float    var_1score(/* pvec */);        /* Uses first order stats. */
  76. extern    float    prob_1score(/* pvec */);    /* Uses first order stats. */
  77. extern    float    pvec_1score(/* pvec */);    /* Uses first order stats. */
  78. extern        load_1stats();            /* Loads first order stats. */
  79. extern        print_1stats();
  80.  
  81. extern    int    decode(/* cbuf, pbuf, perm */); /* FALSE if has bad chars. */
  82. /* Return -1 if    bad chars, otherwise # of chars added to pvec. */
  83. extern    int    decode_wire(/* eci, x, y, pvec */);
  84. /* Returns -1 if bad chars, otherwise # of chars added to pvec. */
  85. extern    int    decode_class(/* eci, firstpos, firstplain, pvec */);
  86. /* Returns number of wires added to permvec assuming that plaintext
  87.  * str occurs at pos.  Fills in permvec.  Returns -1 if conflict. */
  88. extern    int    perm_from_string(/* eci, str, pos, permvec */);
  89. /* Fills in pvec with the plaintext characters deduced
  90.  * from the wires in permvec that are not in the positions
  91.  * ranging from butfirst to butlast.  Returns -1 if any
  92.  * non-ascii chars are deduced, else count of chars. */
  93. extern    int    permvec2pvec(/* eci, permvec, pvec, butfirst, butlast */);
  94. extern        permvec_copy(/* from, to, maxnum */);
  95. extern        pvec_copy(/* from, to, maxnum */);
  96. extern        print_pvec(/* stream, pvec */);
  97. extern        char2buf(/* cbuf, pbuf, length */);    /* Fills in pbuf. */
  98. extern        buf2char(/* cbuf, pbuf, length, nonechar */); /* Fill cbuf. */
  99. extern        str2pvec(/* string, pvec */);        /* Fills in pvec. */
  100. extern        pvec2str(/* string, pvec */);        /* Fills in string. */
  101.  
  102. extern    int    fillcbuf(/* blocknum, *cbuf */);   /* Ret TRUE if sucessful. */
  103. extern    int    *refperm(/* blocknum */);       /* Ret NULL if fails. */
  104. extern    copyperm(/* src, dst */);
  105. extern    readperm(/* fd, permbuffer */);    /* Gets chars from fd to fill perm. */
  106. extern    writeperm(/* fd, permbuffer */);       /* Writes perm to file. */
  107. extern    multperm(/* left, right, result = (left)(right) */);
  108. extern    expperm(/* src, dst, k */);           /* dst = src ** k. */
  109. extern    int    permcount(/* perm */);           /* Return # values != -1. */
  110. extern    int    permwcount(/* perm */);           /* Return # of wires. */
  111.  
  112. extern        approx_init();        /* Call before fexp or isqrt. */
  113. extern    float    fexp(/* float */);    /* Fast exp func. */
  114. extern    float    isqrt[];        /* Sqrts of integers < BLOCKSIZE */
  115.  
  116.  
  117. /* Globals State */
  118. extern    char    *cipherfile;        /* Ciphertext file name. */
  119. extern    char    *permfile;        /* Permutation save file name. */
  120. extern    char    *letterstats;        /* Single letter stat file name. */
  121. extern    char    *bigramstats;        /* Letter pair statistics file name. */
  122. extern    char    *trigramstats;        /* Trigram statistics file name. */
  123. extern    int    permchgflg;            /* TRUE if perms chged since save. */
  124. extern    char    statmsg[];        /* Buffer to build status messages. */
  125.  
  126.  
  127. /* Extensions to C */
  128. #ifndef reg
  129. #define    reg        register
  130. #endif
  131. #define    abs(x)    (((x) > 0) ? x : (0 - x))
  132.  
  133.  
  134. /* Macros */
  135. #define graphic(c)    (c & SYMBOL)
  136. #define notascii(c)    (c>127)
  137. #define printable(c)    ((32 <= c) && (c <= 126))
  138. #define lletter(c)    (('a'<= (c)) && ((c) <= 'z'))
  139. #define uletter(c)    (('A'<= (c)) && ((c) <= 'Z'))
  140. #define isspace(c)    ( ((c) == ' ') || ((c) == '\t') || ((c) == '\n') )
  141. #define isletter(c)    (lletter(c) || uletter(c))
  142. #define tolower(c)    ( uletter(c) ? ((c) - 'A' + 'a') : (c) )
  143.  
  144.  
  145. /* Constants */
  146. #define    BLOCKSIZE    256    /* Number of chars in a cipher block. */
  147. #define MODMASK        0377    /* Arithmetic mod 256. */
  148. #define    CHARMASK    0177    /* ASCII char mask. */
  149. #define    MAXCHAR        127    /* Highest ASCII value. */
  150. #define MXBIINDEX    40    /* Num different chars in a bigram. */
  151. #define LINELEN        64    /* Number of characters per line. */
  152. #define    NLINES        4    /* Number of line pairs. */
  153. #define    NONE        (-1)    /* No info on something. */
  154. #define    ERROR        (-1)    /* Procedure can't meet normal case specs. */
  155. #define    EOL        (-37)    /* A hack used by read_char() */
  156. #define    PI        (3.1415926)
  157. #define    NPERMS        15    /* Max number of blocks in a file. */
  158.  
  159. #ifndef    TRUE
  160. #define    TRUE        1    /* The whole truth. */
  161. #endif
  162. #ifndef    FALSE
  163. #define    FALSE        0    /* Lies, falsehoods, etc. */
  164. #endif
  165. #ifndef NULL
  166. #define    NULL        0    /* A zero by any other name ... */
  167. #endif
  168.