home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a014 / 1.ddi / CDBINC.EXE / COMM.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-09-18  |  18.8 KB  |  832 lines

  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include <alloc.h>
  4. #include<dos.h>
  5. #define pr(x)  fprintf(fp,x)
  6. #define  MAXP  10
  7. #define CONT 20
  8. #define CB 14
  9. #define VIDEO 0x10
  10. #define F1 15104
  11. typedef struct bb{
  12.          char MEAN[21],DB[9],KEY[4][11],COFLAG,COPATH[11];
  13.          int no;
  14.          struct bb *next;
  15.         }BASE;
  16. typedef struct cc {
  17.          char field[128][11],ftype[128];
  18.          int len1[128];
  19.                  int NN;
  20.          int no;
  21.          struct cc *next;
  22.            }CONTENT;
  23. typedef struct ll {
  24.             int  MAR[6][128];
  25.             int  no;
  26.             struct ll *next;
  27.             }LINK;
  28. extern LINK *flink,*mylink;
  29. extern BASE *fbase;
  30. extern CONTENT *fcon;
  31. extern char *explain,PATH[30],lname[5][31],lnamebak[5][3][11];
  32. extern int NB,repeat,I,J,II,JJ,linkflag;
  33. int code;
  34. getbase()
  35. {  int i,j,row,col,ctcn;
  36.    char buff[80], sh[2];
  37.    FILE *fp;
  38.    BASE *mybase;
  39.    code=0;
  40. /*   strcpy(buff,PATH)    ;*/
  41.    strcpy( buff, "db.txt" )    ;
  42.    fp=fopen( buff, "r");
  43.    fbase = (BASE *)malloc(sizeof(BASE));
  44.    mybase = fbase;
  45.    mybase->next = NULL;
  46.    mybase->no = 0;
  47.    for(NB=0; (fgets(buff,80,fp)!=NULL); NB++)
  48.      {  if(NB!=0)
  49.       {
  50.         mybase->next=(BASE*)malloc(sizeof(BASE));
  51.         mybase=mybase->next;
  52.         mybase->no=NB;
  53.         mybase->next=NULL;
  54.       }
  55.  
  56.     sscanf(buff,"#%[^#]#,#%[^#]#,#%[^#]#,#%[^#]#,#%[^#]#,#%[^#]#,#%c#,#%c#,#%[^#]#\n",
  57.            mybase->MEAN,mybase->KEY[0],mybase->KEY[1],
  58.            mybase->KEY[2],mybase->KEY[3],mybase->DB,sh,&mybase->COFLAG,mybase->COPATH)    ;
  59.     fflush(fp)    ;
  60.      }
  61.     fclose(fp);
  62.     }
  63.  
  64.  
  65.  
  66. getcontent(char *aarr,int *s)
  67. {  int i,j,k,wh,cu=0;
  68.    char name[30],buff[60];
  69.    FILE *fp;
  70.    CONTENT *mycon;
  71.    BASE *mybase;
  72.    for (wh=0;s[wh]!=0;wh++)
  73.       {
  74.      if(wh==0)
  75.       {
  76.          if((fcon=(CONTENT*)malloc(sizeof(CONTENT)))==NULL)  printf("memory if not enough");
  77.          mycon=fcon;
  78.          mycon->no=s[wh]-1;
  79.          mycon->next=NULL;
  80.          mybase=fbase;
  81.          while (mybase->no!=s[wh]-1) mybase=mybase->next;
  82.       }
  83.      else
  84.       {
  85.          if((mycon->next=(CONTENT*)malloc(sizeof(CONTENT)))==NULL) printf("=+++++++++++");
  86.          mycon=mycon->next;
  87.          mycon->next=NULL;
  88.          mycon->no=s[wh]-1;
  89. /*         mybase=mybase->next;*/
  90.          mybase=fbase;
  91.          while (mybase->no!=s[wh]-1) mybase=mybase->next;
  92.       }
  93.      strcpy(name,aarr);
  94. /*     strcpy( name, "creat\\")    ;*/
  95.      strcat(name,mybase->DB);
  96.      strcat(name,".txt");
  97.      fp=fopen(name,"r");
  98.      for(i=0; (fgets(buff,80,fp)!=NULL) ; i++,cu++)
  99.      {
  100.           sscanf(buff,"#%[^#]#,#%c#,%d,%d\n",mycon->field[cu],&mycon->ftype[cu],&mycon->len1[cu],&j)    ;
  101.           fflush(fp)    ;
  102.      }
  103.      mycon->NN = cu    ;
  104.      fclose(fp);
  105.      cu=0;
  106.       }
  107. }
  108.  
  109.  
  110.  
  111.  /* ╩Σ╚δ┐Γ╓«╝Σ┴¼╜╙┬╖╛╢*/
  112. getroad(aarr,s,l)
  113. char *aarr;
  114. int *s,l;
  115. {  int i,n,x,y,nn,col,j,cir,ii;
  116.    FILE *codef;
  117.    clear_win(0,0,24,79,0x70)    ;
  118.    II=0;
  119.    cursor(15,10);
  120.    printf("╟δ╢¿╥σ╡┌ %d ╕÷▓┘╫≈┐Γ",l+1);
  121.    clear_win(18,20,22,62,0)    ;
  122.    clear_win(17,18,21,60,30)    ;
  123. /*   gframe(17,18,21,60,"",0|226)    ;*/
  124.    color_puts("╟δ╩Σ╚δ┐Γ╡─┤·║┼(0╘≥▒φ╩╛╜ß╩°╤í╘±) : ",0|226,18,22)    ;
  125.    chpage(0);
  126.    i=0;
  127. L:   if ((n=get((long) II,(long)JJ,20,24))!=0)
  128.      {  if (n=='H')
  129.       {  help1();
  130.          while ((n=get((long)II,(long)JJ,20,24))=='H')
  131.            {
  132.          help1();
  133.         }
  134.          if (n==0) return(0); }
  135.     if (n=='U'||n=='D'||n=='u'||n=='d')
  136.        {
  137.           chpage(n);
  138.           goto L;
  139.         }
  140.     nn=n%CB;
  141.      if(nn==0)
  142.        nn=CB;
  143.     y=((nn-1)%2)*35+6;
  144.     x=(nn-1)/2+5;
  145.     cursor(x,y);
  146.     printf("*");
  147.     s[i]=n;
  148.     i++;
  149.     cursor(20,25);
  150.     printf("_");
  151.     col=26;
  152.     while ((n=get((long)II,(long)JJ,20,col))!=0)
  153.       {  if (n=='H')  {  help1();
  154.                  continue;  }
  155.              if (n=='U'||n=='D')
  156.        {
  157.           chpage(n);
  158.           continue;
  159.         }
  160.          for (j=0;j<i;j++)
  161.            if (s[j]==n) {  cir=1;
  162.                    break;
  163.                 }
  164.            else cir=0;
  165.          if (cir)  {
  166.               color_puts("▓╗─▄│÷╧╓╓╪╕┤╤í╘±╣╣│╔╗╪┬╖! ╟δ╘┘┤╬╩Σ╚δ",12,24,45);
  167.               dela();
  168.               color_puts("                                    ",0|75,24,45);
  169.               continue;
  170.                }
  171.          if (n!=0)
  172.            {  nn=n%CB;
  173.           if(nn==0)
  174.             nn=CB;
  175.           y=((nn-1)%2)*35+6;
  176.           x=(nn-1)/2+5;
  177.           cursor(20,++col);
  178.           printf("_");
  179.           cursor(x,y);
  180.           printf("*");
  181.           cursor(20,++col);
  182.           s[i]=n;
  183.           i++;
  184.            }
  185.       }
  186.     s[i]=0;
  187.     getcontent(aarr,s);
  188.     if (i==1) return(i);
  189.     clear_win(15,36,19,72,0)    ;
  190.     clear_win(14,34,18,70,0|53)    ;
  191.     color_puts("╤í╘±╢α┐Γ┴¬╜╙╖╜╩╜",0|53,15,44);
  192.     n=selete("┤«╨═", "╨╟╨═",17,43,56,0|53);
  193.     linkflag=((n==1)?0:1);
  194.     if ((codef=fopen("code.dbf","r"))!=NULL)
  195.        {
  196.        color_puts("╩╟ ╖± ╥¬ ┤· ┬δ ▓┘ ╫≈",0|53,15,42);
  197.        n=selete("Yes ", "No  ",17,43,56,0|53)    ;
  198.        if (n==1) code=1;
  199.        }
  200.     fclose(codef);
  201.     return(i);
  202.      }
  203.    else
  204.      return(0);
  205. }
  206.  
  207.  
  208. disp()
  209. {  int i,x,y,n;
  210.    BASE *mybase;
  211.    color_puts(explain,56,0,0);
  212.    color_puts("  F1-Help  Esc-Exit  ╗╪│╡: ═╦│÷▒╛─ú┐Θ                                           ",0|75,24,0);
  213.    color_puts("----  ▒╛╧╡═│╓╨╡─╚½▓┐╩²╛▌┐Γ╚τ╧┬  ----",0|113,2,22)    ;
  214.    gframe(4,2,12,75,0,0|226);
  215.    x=5;
  216.    y=7;
  217.    n=0;
  218.    mybase=fbase;
  219.    while (mybase->no!=II)
  220.      mybase=mybase->next;
  221.    for (i=II;i<NB&&n<CB;i++)
  222.       {  cursor(x,y);
  223.      printf("\033[1;33;44m%2d. %-10s",i+1,mybase->MEAN);
  224.      printf("\033[0;0;0m")    ;
  225.      y+=35;
  226.      if (y>60)
  227.        {  x++;
  228.           y=7;
  229.        }
  230.      mybase=mybase->next;
  231.      n++;
  232.       }
  233. }
  234.  
  235.  
  236.  
  237. disp_base(ch)
  238. int ch;
  239. {  int row,col,i,n;
  240.    BASE *mybase;
  241.    CONTENT *mycon;
  242.    mybase=fbase;
  243.    mycon=fcon;
  244. /*   for(i=0;i<NB;i++)
  245.      {
  246.     if(i!=0)
  247.      {
  248.        mybase=mybase->next;
  249.        mycon=mycon->next;
  250.      }
  251.     if(mybase->no==(ch-1))
  252.      break;
  253.      }  */
  254.    while (mybase->no!=ch-1) mybase=mybase->next;
  255.    while (mycon->no!=ch-1) mycon=mycon->next;
  256.    color_puts(" ",43,0,1);
  257.    ch=ch-1;
  258.    cursor(1,16);
  259.    printf("\033[0;0;7m-----  ┐Γ # %s # ╓╨║¼╙╨╥╘╧┬╫╓╢╬  ----",mybase->MEAN);
  260.    gframe(3,2,11,75,0,0|226);
  261.    row=5;
  262.    col=5;
  263.    n=1;
  264.    for (i=I;i<mycon->NN&&row<10;i++)
  265.       {  cursor(row,col);
  266.      printf("\033[1;33;44m%2d. %-s",n+I,mycon->field[i]);
  267.      col+=17;
  268.      n++;
  269.      if (col>60)
  270.        {  row++;
  271.           col=5;
  272.        }
  273.       }
  274. }
  275.  
  276.  
  277.  
  278.  
  279. cmp(char *str,int aa)
  280. {  int i,bb;
  281.    CONTENT *meycon;
  282.    meycon=fcon;
  283.    while(meycon->no!=aa)
  284.     meycon=meycon->next;
  285.    bb=meycon->NN;
  286.    for (i=0;i<bb;i++)
  287.       if (strcmp(str,meycon->field[i])==0)  return(i);
  288.    return(-1);
  289. }
  290.  
  291.  
  292.  
  293.  
  294. deflink(s,dname,whmy)
  295. int *s;
  296. char *dname,*whmy;
  297. {  int i,c,n,ctcn,ct;
  298.    FILE *whfp;
  299.    CONTENT *midcon,*mycon;
  300.    BASE *mybase;
  301.    char middst[41],strchar[11];
  302.    repeat=1; ct=0;
  303.    color_puts("╢¿╥σ┴¼╜╙┐Γ╡─╩╢▒≡├√(╫ε╢α20╕÷╫╓╖√): ",0|53,15,36)    ;
  304.    color_puts("                         ",0|53,17,40)    ;
  305.    cursor( 17, 43 )    ;
  306.    scanf("%s",dname);
  307.    clear_win(0,0,24,79,0x70)    ;
  308.    for (i=0;i<5;i++) {strcpy(lname[i],NULL); lname[i][0]='\0';}
  309.    I=0;
  310.    i=1;ctcn=0;
  311.    while (s[i]!=0)
  312.      {
  313.      judge(0,s[ctcn]);
  314.      while (s[i]!=0) {
  315.      cursor(16,15);
  316.      clear_win(18,20,22,60,0)    ;
  317.      clear_win(17,18,21,58,30)    ;
  318.      color_puts("╟δ╚╖╢¿╦∙╢¿╥σ╡─┴¼╜╙┐Γ╡─┴¼╜╙╫╓╢╬ : ",0|226,18,22)    ;
  319.      color_puts("╫ó╥Γ: ┴¼╜╙╫╓╢╬▒╪╨δ─▄╬¿╥╗╡╪╩╢▒≡╥╗╕÷╝╟┬╝!",12,15,10)    ;
  320.      color_puts(" ╓╗╨Φ╝ⁿ╚δ╫╓╢╬╡─┤·║┼                                                                   ",0|75,24,0)    ;
  321.      c=get((long)I,(long)J,20,34);
  322.      if (c=='U'||c=='D')
  323.        {  judge(c,s[ctcn]);
  324.           continue;
  325.        }
  326.      if (c==0)
  327.         {
  328.         if (lname[i-1][0]=='\0')  continue;
  329.         else break;
  330.         }
  331.      mycon=fcon;
  332.      while(mycon->no!=(s[ctcn]-1))
  333.       mycon=mycon->next;
  334.      midcon=mycon;
  335.      if (s[i]!=0)
  336.        {   n=s[i]-1;
  337.            mybase=fbase;
  338.            while(mybase->no!=n)
  339.          mybase=mybase->next;
  340.            strcpy(middst,mycon->field[c-1]);
  341.            if (cmp(mycon->field[c-1],n)<0)
  342.          {  cursor(20,10);
  343.             printf("%s ▓╗┤µ╘┌ # %s # ╫╓╢╬, ╬▐╖¿┴¼╜╙. ╟δ╓╪╨┬╤í╘±┴¼╜╙╫╓╢╬",mybase->MEAN,midcon->field[c-1]);
  344.             dela();
  345.             cursor(20,10);
  346.             printf("                                                                       ");
  347.             continue;
  348.          }
  349.            else {
  350.             if (lname[i-1][0]!='\0') strcat(lname[i-1],"+");
  351.             if (mycon->ftype[c-1]=='D')
  352.                {
  353.                strcpy(middst,NULL); strcat(middst,"DTOC(");
  354.                strcat(middst,mycon->field[c-1]); strcat(middst,")");
  355.                }
  356.             if (mycon->ftype[c-1]=='N')
  357.                {
  358.                strcpy(middst,NULL); strcat(middst,"STR(");
  359.                strcat(middst,mycon->field[c-1]); strcat(middst,",");
  360.                strcat(middst,"19");strcat(middst,")");
  361.                }
  362.             if (mycon->ftype[c-1]=='C')
  363.                strcpy(middst,mycon->field[c-1]);
  364.            if (lname[i-1][0]!='\0')  strcat(lname[i-1],middst);
  365.             else strcpy(lname[i-1],middst);
  366.             strcpy(lnamebak[i-1][ct],mycon->field[c-1]); ++ct;
  367.             }
  368.        }
  369.     }
  370.      if (linkflag==1) i++;
  371.      else {ctcn++;i++;}
  372.      ct=0;
  373.      }
  374.     /* strcpy(middst,PATH)*/;
  375.      strcpy(middst,whmy);
  376.      strcat(middst,"ndx.txt");
  377.      whfp=fopen(middst,"a");
  378.      for (i=1;s[i]!=0;i++)
  379.     {   n=s[i]-1;
  380.         mybase=fbase;
  381.         while(mybase->no!=n)
  382.         mybase=mybase->next;
  383.         fprintf(whfp,"#%s#,#%s#,##,0,0\n",mybase->DB,lname[i-1]);
  384.     }
  385.      fclose(whfp);
  386. }
  387.  
  388.  
  389.  
  390. sele_disp(int *s,int l)
  391. {  int i,k,m,n,t,c,x,y;
  392.    BASE *mybase,*midbase;
  393.    CONTENT *mycon;
  394. /*   LINK *mylink;*/
  395.    mylink=flink;
  396. /*   while (mylink->no!=l)
  397.      mylink=mylink->next;*/
  398.    clear_win(0,0,24,79,0)    ;
  399.    color_puts(explain,14,0,1);
  400.    color_puts("       *** ╧┬├µ╟δ╢¿╥σ╜ß╣√╧╘╩╛╧ε ***",11,6,15);
  401.    color_puts("    ─·╓╗╨Φ┤╙▒╗┴¼╜╙╡─╕≈╕÷┐Γ╓╨╖╓▒≡╤í╘±╚⌠╕╔╫╓╢╬╝┤┐╔.",11,8,12)    ;
  402.    color_puts("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",14,4,10);
  403.    cursor(11,20);
  404.    printf("╙╔ ╧┬ ┴╨ ┐Γ ┴¼ ╜╙ ╫Θ │╔:");
  405.    cursor(13,20);
  406.    i=1;
  407.    midbase=fbase;
  408.    while(midbase->no!=(s[0]-1))
  409.      midbase=midbase->next;
  410.    printf("%s",midbase->DB);
  411.    while(s[i]!=0)
  412.    { midbase=fbase;
  413.      while(midbase->no!=(s[i]-1))
  414.        midbase=midbase->next;
  415.      i++;
  416.      printf("->%s",midbase->DB);
  417.    }
  418.   color_puts("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",14,15,10);
  419.   color_puts("    ░┤ ╚╬ ╥Γ ╝ⁿ......     ",0|48,17,25);
  420.    bioskey(0);
  421.    i=0;
  422.    clear_win(0,0,24,79,0x70)    ;
  423.    while (s[i]!=0)
  424.      {     n=s[i]-1;
  425.      mybase=fbase;
  426.      mycon=fcon;
  427. /*     while(mybase->no!=n)
  428.       {
  429.        mybase=mybase->next;
  430.        mycon=mycon->next;
  431.       }*/
  432.      while (mybase->no!=n) mybase=mybase->next;
  433.      while (mycon->no!=n) mycon=mycon->next;
  434.      I=0;
  435.      judge(0,s[i]);
  436.     clear_win(15,16,19,52,0)    ;
  437.     clear_win(14,14,18,50,0|53)    ;
  438.     color_puts("╟δ╩Σ╚δ╧╘╩╛╖╜╩╜",0|53,15,24);
  439.     c=selete("╚½▓┐╧╘╩╛", "▓┐╖╓╧╘╩╛",17,23,36,0|53);
  440.     if (c==1)
  441.         for (t=0;t<mycon->NN;t++)
  442.             mylink->MAR[n][t]=1    ;
  443.     else
  444.       {
  445.           clear_win(17,42,21,63,0)    ;
  446.           clear_win(16,40,20,61,0x10)    ;
  447.           color_puts("╨Φ╥¬╧╘╩╛╡─╫╓╢╬╙╨ ",286,17,43);
  448.           while ((c=get((long)I,(long)J,19,50))!=0)
  449.         {
  450.             if (c=='U'||c=='D')
  451.               {  judge(c,s[i]);
  452.              continue;
  453.               }
  454.             mark(c);
  455.             mylink->MAR[n][c-1]=1;
  456.         }
  457.        }
  458.      clear_win(16,10,23,65,0x70)    ;
  459.      i++;
  460.      }
  461. }
  462.  
  463.  
  464. in_c(s,i)
  465. int *s,*i;
  466. {  int n=0;
  467.    if (s[1]!=0)
  468.     color_puts("╟δ╤í╘±╠⌡╝■╫╓╢╬ (╝ⁿ╚δíⁿ/í²╤í╘±▓┘╫≈┐Γ) :",10,24,10);
  469.    else
  470.     color_puts("╟δ╤í╘±╠⌡╝■╫╓╢╬ :",10,24,20);
  471.    while (n==0)
  472.      {  if (s[1]!=0)
  473.       {  while ((n=get((long)I,(long)J,24,50))!=0)
  474.            {  if (n=='u'||n=='d')
  475.             {  if (n=='u'&&*i>0)  (*i)--;
  476.                else if (s[*i+1]!=0)  (*i)++;
  477.                I=0;
  478.                judge(0,s[*i]);
  479.             }
  480.           else  if (n=='U'||n=='D')
  481.               {  judge(n,s[*i]);
  482.                  continue;
  483.               }
  484.             else break;
  485.            }
  486.       }
  487.     else
  488.       {  n=get((long) I,(long)J,24,38);
  489.          if (n=='U'||n=='D')
  490.            {  judge(n,s[*i]);
  491.           n=0;
  492.           continue;
  493.            }
  494.       }
  495.     if (n==0) error();
  496.      }
  497.    return(n);
  498. }
  499.  
  500.  
  501.  
  502. help1()
  503. {  char c;
  504.    int i;
  505.    char *temp    ;
  506.    unsigned int  row=12, col=13    ;
  507.  
  508.    temp = ( char * ) malloc(sizeof( char )*1152)    ;
  509.    now_cursor( &row, &col )    ;
  510.    video_save( 6, 11, 77, 18, temp )    ;
  511.    color_puts("⌐│⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐╖",15,11,6)    ;
  512.    color_puts("⌐º    ─·┐╔╤í╘±╔╧╩÷┐Γ, ╜°╨╨╡Ñ┐Γ╗≥╢α┐Γ▓┘╫≈. ╚⌠╥¬╔·│╔╢╘╢α┐Γ▓┘╫≈, ╘≥╕≈┐Γ╝Σ⌐º",15,12,6)    ;
  513.    color_puts("⌐º▒╪╨δ╙╨╧α═¼╫╓╢╬, ╟╥╧α═¼╫╓╢╬╘┌▒╗┴¼╜╙┐Γ╓╨╙ª╩╟╣╪╝ⁿ╫╓.                   ⌐º",15,13,6)    ;
  514.    color_puts("⌐º    ╘┌╤í┐Γ╩▒, ╚τ╣√─·╓╗╤í╘±┴╦╥╗╕÷┐Γ, ╘≥▒φ╩╛╢╘╡Ñ┐Γ▓┘╫≈; ╚τ╣√─·╤í╘±┴╦┴╜⌐º",15,14,6)    ;
  515.    color_puts("⌐º╕÷╥╘╔╧╡─┐Γ, ╘≥▒φ╩╛╢╘╢α┐Γ▓┘╫≈, ╧╡═│╜½╫╘╢»╕∙╛▌─·╤í╘±╡─╦│╨≥░╤╕≈┐Γ┴¼╜╙╞≡⌐º",15,15,6)    ;
  516.    color_puts("⌐º└┤.                                                                 ⌐º",15,16,6)    ;
  517.    color_puts("⌐º                    ╫ó╥Γ : ┐╔┴¼╜╙╡─┐Γ╫ε╢α─▄╙╨6╕÷                    ⌐º",15,17,6)    ;
  518.    color_puts("⌐╗⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐┐",15,18,6)    ;
  519. /*   movcur();*/
  520.    bioskey(0);
  521.    video_restore( 6, 11, 77, 18, temp )    ;
  522. /*   clear_win(11,0,18,79,0x70)    ;
  523.    setcur();                     */
  524.  
  525.    cursor( row, col )    ;
  526. }
  527. /*╠⌡╝■▓┘╫≈╣½╙├╫╙│╠╨≥*/
  528.  
  529.  
  530.  
  531.  
  532.  
  533. dela()
  534. {  int i,j;
  535.    for (i=0;i<10;i++)
  536.       for (j=-30000;j<30000;j++) ;
  537. }
  538.  
  539.  
  540.  
  541. getcc()
  542. {  union REGS r;
  543.    r.h.ah=0;
  544.    int86(0x16,&r,&r);
  545.    if (r.h.al==27) exit(0);
  546.    if (r.h.al) return(r.h.al);
  547.    return(r.x.ax);
  548. }
  549.  
  550.  
  551.  
  552. get(i,j,row,col)
  553. long i,j    ;
  554. int row,col;
  555. {  int key,c    ;
  556.    long n=0;
  557.    color_puts("   ",30,row,col);
  558.    cursor(row,col);
  559.    while ((key=getcc())!=0x0D)
  560.      {
  561.     switch (key)
  562.       {  case 18432 : return('u');
  563.          case 18688 : return('U');
  564.          case 20480 : return('d');
  565.          case 20736 : return('D');
  566.          case 15104 : return('H');
  567.          case    8  : if (n!=0) n=n/10;
  568.               else  {  error();  cursor(row,col);  }
  569.               break;
  570.          default    : if( key <= '9' && key >= '0')
  571.                 printf("\033[1;33;44m%c",key)    ;
  572.               n=10*n+key%256-'0';
  573.               break;
  574.       }
  575.      }
  576.    if ((n>j||n<=i)&&n!=0) {  error();
  577.                  get((long)i,(long)j,row,col);
  578.               }
  579.    else return(n);
  580.    }
  581.  
  582.  
  583.  
  584.  
  585. cursor(int y, int x)
  586. {
  587.   _DH = (unsigned char)y    ;
  588.   _DL = (unsigned char)x    ;
  589.   _AH = (unsigned char)2    ;
  590.   _BH = (unsigned char)0    ;
  591.   geninterrupt(0x10)    ;
  592. }
  593.  
  594. color_puts(char *string, int  color, int row, int col)
  595. {
  596.   _SI = (unsigned int) string    ;
  597.   _DH = (unsigned char) row    ;
  598.   _DL = (unsigned char) col    ;
  599.   _CX = 1    ;
  600.   while(*(( char * ) _SI))
  601.    {
  602.      _AH = (unsigned char) 2    ;
  603.      _BH = (unsigned char) 0    ;
  604.      __int__(0x10)    ;
  605.      ++_DL    ;
  606.  
  607.      _AH = (unsigned char) 9    ;
  608.      _AL = *((char *)_SI)    ;
  609.      _SI++    ;
  610.      _BH = (unsigned char) 0    ;
  611.      _BL = (unsigned char) color    ;
  612.      __int__(0x10)    ;
  613.    }
  614. }
  615.  
  616.  
  617. clear_win(startrow,startcol,endrow,endcol,attribe)
  618. int startrow,startcol;
  619. int endrow,endcol;
  620. int attribe;
  621. {
  622.   _AH = (unsigned char) 6    ;
  623.   _AL = (unsigned char) 0    ;
  624.   _BH = (unsigned char) attribe    ;
  625.   _CH = (unsigned char) startrow    ;
  626.   _CL = (unsigned char) startcol    ;
  627.   _DH = (unsigned char) endrow    ;
  628.   _DL = (unsigned char) endcol    ;
  629.   geninterrupt(0x10)    ;
  630. }
  631.  
  632.  
  633. now_cursor(unsigned int *row, unsigned int *col )
  634. {
  635.     _AH = (unsigned char) 3    ;
  636.     _BH = (unsigned char) 0    ;
  637.     geninterrupt( 0x10 )    ;
  638.     *row = _DH    ;
  639.     *col = _DL    ;
  640. }
  641.  
  642.  
  643.  
  644. judge(c,n)
  645. int n,c;
  646. {
  647.    BASE *mybase;
  648.    CONTENT *mycon;
  649.  
  650.    if (c=='U') I-=CONT;
  651.    if (c=='D') I+=CONT;
  652.    if (I<0) I=0;
  653.    mycon=fcon;
  654.    while(mycon->no!=(n-1))
  655.      mycon=mycon->next;
  656.    if (I>mycon->NN) I-=CONT;
  657.    disp_base(n);
  658.    J=I+CONT;
  659.    if (J>mycon->NN) J=mycon->NN;
  660. }
  661.  
  662. mark( int n )
  663. {  int x,y;
  664.    x=(n-I-1)/4+5;
  665.    y=(n-1)%4*16+3+n%4+(n%4==0?4:0);
  666.    cursor(x,y);
  667.    printf("*")    ;
  668. }
  669.  
  670. movcur()
  671. {  union REGS regs;
  672.    regs.h.ah=19;
  673.    regs.h.al=0;
  674.    int86(0x10,®s,®s);
  675. }
  676.  
  677.  
  678.  
  679.  
  680. setcur()
  681. {  union REGS regs;
  682.    regs.h.ah=19;
  683.    regs.h.al=1;
  684.    int86(0x10,®s,®s);
  685. }
  686.  
  687.  
  688.  
  689. error()
  690. {  color_puts("###### ╩Σ╚δ┤φ╬≤! ╟δ╓╪╨┬╘┘╩Σ ######",12,24,46);
  691.    dela();
  692.    color_puts("                                   ",0|75,24,46);
  693. }
  694.  
  695.  
  696. chpage(int c)
  697. {
  698.   if (c=='U') II-=CB;
  699.   if (c=='D') II+=CB;
  700.   if (II<0) II=0;
  701.   if (II>NB) II-=CB;
  702.   disp();
  703.   JJ=II+CB;
  704.   if (JJ>NB) JJ=NB;
  705.  }
  706.  
  707. /*=========================gframe============================*/
  708. gframe(startx,starty,endx,endy,sss,color)
  709. int startx,starty;
  710. int endx,endy;
  711. int sss;
  712. int color;
  713. {
  714. static char dd[3][6][3]={
  715.       "⌐Ñ","⌐º","⌐│","⌐╖","⌐╗","⌐┐",
  716.       "⌐ñ","⌐ª","⌐░","⌐┤","⌐╕","⌐╝" ,
  717.       "  ","  ","  ","  ","  ","  "
  718.                      };
  719. int row,col;
  720. char *s;
  721. clear_win(startx+1,starty+2,endx+1,endy+2,0)    ;
  722. clear_win(startx,starty,endx,endy,0x10)    ;
  723. color_puts(dd[sss][2],color,startx,starty);
  724. for(col=starty+2; col<endy-2; col+=2)
  725.        color_puts(dd[sss][0],color,startx,col);
  726. color_puts(dd[sss][3],color,startx,endy-1);
  727.  
  728. for(row=startx+1; row<endx; ++row)
  729.  {
  730.    color_puts(dd[sss][1],color,row,starty);
  731.    color_puts(dd[sss][1],color,row,endy-1);
  732.    cursor(row,starty+2);
  733.   }
  734.  color_puts(dd[sss][4],color,endx,starty);
  735.  
  736.   for(col=starty+2; col<endy-2; ++col,++col)
  737.        color_puts(dd[sss][0],color,endx,col);
  738.   color_puts(dd[sss][5],color,endx,endy-1);
  739.    return;
  740. }
  741.  
  742.  
  743. /* --- selete a choice from  two term ----------    */
  744. /*       if selete a return 1                */
  745. /*       else return 2                                  */
  746. /*-----------------------------------------------    */
  747. selete(char *a, char *b, int row, int acol, int bcol, char color)
  748. {
  749.   int in,bb=1    ;
  750.  
  751.   color_puts(a,0|15,row,acol)    ;
  752.   color_puts(b,color,row,bcol)    ;
  753.   for(;;)
  754. {
  755.   in=getcc()    ;
  756.   switch(in)
  757.    {
  758.      case 19712 :
  759.           color_puts(a,color,row,acol)    ;
  760.           color_puts(b,0|15,row,bcol)    ;
  761.           bb=2;
  762.           continue;
  763.      case 19200 :
  764.           color_puts(a,0|15,row,acol)    ;
  765.           color_puts(b,color,row,bcol)    ;
  766.           bb=1    ;
  767.           continue;
  768.      case F1 :    help1()    ;
  769.           continue    ;
  770.      case 13 :
  771.           return(bb);
  772.    }
  773.   }
  774. }
  775.  
  776. video_save( startx, starty, endx, endy, destin )
  777.     int  startx, starty, endx, endy;
  778.     char *destin;
  779. {
  780.     union REGS r;
  781.     register int i, j;
  782.  
  783. /*    win( 1, 1, 80, 25 );*/
  784.     for ( j = starty ; j <= endy ; j++ )
  785.       for ( i = startx ; i <= endx ; i++ )  {
  786.         cursor( j, i )    ;
  787.         r.h.ah = 8; /* read character & attribute from screen */
  788.         r.h.bh = 0;  /* page 0 */
  789.         int86( VIDEO, &r, &r );
  790.         *destin++ = r.h.al;
  791.         *destin++ = r.h.ah;
  792.       }
  793. /*    win( startx, starty, endx, endy );*/
  794. }
  795.  
  796. /*--------------------------------------------------
  797.    Function : restore screen area from buffer source.
  798.    Variable :
  799.        startx, starty, endx, endy: screen area.
  800.        source : pointer to buffer.
  801.    ----------------------------------------------*/
  802. video_restore( startx, starty, endx, endy, source )
  803.     int  startx, starty, endx, endy;
  804.     char *source;
  805. {
  806.     register int i, j;
  807.     union REGS r;
  808.  
  809. /*    win( 1, 1, 80, 25 );*/
  810.     for ( j = starty ; j <= endy ; j++ )
  811.     for ( i = startx ; i <= endx ; i++ ) {
  812.           cursor( j, i )    ;
  813.           r.h.ah = 9;
  814.           r.h.bh = 0;
  815.           r.x.cx = 1;
  816.           r.h.al = *source++;
  817.           r.h.bl = *source++;
  818.           int86( VIDEO, &r, &r );
  819.     }
  820. /*    win( startx, starty, endx, endy );*/
  821. }
  822.  
  823. /*win( startx, starty, endx, endy )
  824.   int startx, starty;
  825.   int endx, endy;
  826. {
  827.   S_X = startx;
  828.   S_Y = starty;
  829.   E_X = endx;
  830.   E_Y = endy;
  831. }
  832.   */