home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume10 / cbw / part01 / pgate.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-06-16  |  1.2 KB  |  67 lines

  1. /*
  2.  * Routines to use knowledge of Zee to expand knowledge of Perms.
  3.  *
  4.  * Bob Baldwin, January 1985.
  5.  */
  6.  
  7.  
  8. #include    <stdio.h>
  9. #include    "window.h"
  10. #include    "specs.h"
  11.  
  12.  
  13. extern    int    kzee[];
  14. extern    int    kzeeinv[];
  15.  
  16.  
  17. /* User command to propage info from Ai to Aj using Zee**(j-i).
  18.  * Returns NULL if sucessful.
  19.  */
  20. char *pgate(str)
  21. char    *str;
  22. {
  23.     FILE    *fd;
  24.     int        i;
  25.     int        k;
  26.     int        from, to;
  27.     int        *zeek, *zeeinvk;    /* Zee ** k */
  28.     int        *fromperm, *tmp1perm, *tmp2perm;
  29.     int        kexp[BLOCKSIZE+1], kexpinv[BLOCKSIZE+1];
  30.     int        ktmp1perm[BLOCKSIZE+1];
  31.     int        ktmp2perm[BLOCKSIZE+1];
  32.  
  33.     tmp1perm = ktmp1perm;
  34.     tmp2perm = ktmp2perm;
  35.     zeek = kexp;
  36.     zeeinvk = kexpinv;
  37.     from = to = 0;
  38.  
  39.     if ((i = sscanf(str,"%*[^:]: %d %*[^:]: %d", &from, &to)) != 2) {
  40.         return("Could not parse all the arguments.");
  41.         }
  42.  
  43.     if (dbsgetblk(&dbstore) != to)
  44.         dbssetblk(&dbstore, to);
  45.  
  46.     k = to - from;
  47.     if (k >= 0) {
  48.         expperm(kzee, zeek, k);
  49.         expperm(kzeeinv, zeeinvk, k);
  50.         }
  51.     else {
  52.         expperm(kzee, zeeinvk, -k);
  53.         expperm(kzeeinv, zeek, -k);
  54.         }
  55.  
  56.     multperm(refperm(from), zeek, tmp1perm);
  57.     multperm(zeeinvk, tmp1perm, tmp2perm);
  58.  
  59.     if (!dbsmerge(&dbstore, tmp2perm))  {
  60.         wl_rcursor(&user);
  61.         return("Merge conflicts with current plaintext.");
  62.         }
  63.  
  64.     wl_rcursor(&user);
  65.     return(NULL);
  66. }
  67.