home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a014 / 1.ddi / CDBINC.EXE / SUB5.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-11-11  |  13.2 KB  |  510 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. typedef struct bb{
  10.          char MEAN[21],DB[9],KEY[4][11],COFLAG,COPATH[11];
  11.          int no;
  12.          struct bb *next;
  13.         }BASE;
  14. typedef struct cc {
  15.          char field[128][11],ftype[128];
  16.          int len1[128];
  17.                  int NN;
  18.          int no;
  19.          struct cc *next;
  20.            }CONTENT;
  21. typedef struct ll {
  22.             int  MAR[9][128];
  23.             int  no;
  24.             struct ll *next;
  25.             }LINK;
  26. LINK *flink,*mylink;
  27. BASE *fbase;
  28. CONTENT *fcon;
  29. char *explain="***╠⌡╝■╔╛│²***";
  30. int NB,repeat,I,J,II,JJ,linkflag;
  31. int  coflag[10]    ;
  32. char lname[5][31],PATH[31];
  33. /**/char lnamebak[5][3][11];
  34.  
  35. /*╠⌡╝■╔╛│²*/
  36. main(int argc,char *argv[])
  37. { int road[30][6],k,j,i=0,fs[30],aa,modi_ctc;
  38.   char dname[30][20],buff[60];
  39.   int p    ;
  40.   FILE *fp;
  41.   BASE *mybase;
  42.   CONTENT *mycon;
  43.   if(argc<2)
  44.     return;
  45.    strcpy(PATH,argv[1]);
  46.   clear_win(0,0,24,79,0)    ;
  47.   fp=fopen("creat\\meno1.txt","w");
  48.   fclose(fp);
  49.   fp=fopen("creat\\meno2.txt","w");
  50.   fclose(fp);
  51.   i=0;
  52.   if ((fp = fopen("creat\\delete.txt", "r"))!=NULL)
  53.     {
  54.        fscanf(fp,"%d",&i)    ;
  55.        for(p=0; p<i; p++)
  56.        fscanf(fp,"%s",dname[p])    ;
  57.     }
  58.   getbase();
  59. /*  getcontent(argv[1]); */
  60.   modi_ctc=i;
  61.   for(;;)
  62.   {
  63.      clear_win(0,0,24,79,0x70);
  64.      clear_win(8,22,14,62,0);
  65.      clear_win(7,20,13,60,30);
  66.      color_puts("─· ╥╤ ╔· │╔ ┴╦    ╕÷ ▓┘ ╫≈ ─ú ┐Θ",30,8,24);
  67.      cursor(8,39);
  68.      printf("%d",modi_ctc);
  69.      color_puts("╟δ ╩Σ ╚δ ─· ╜½ ╨▐ ╕─ ╔· │╔ ─ú ┐Θ",30,9,24);
  70.      color_puts("╡─ ╨≥ ║┼ (0 ╬¬ ═╦ │÷,   ┤≤ ╙┌  ",30,10,24);
  71.      printf("%d",modi_ctc);
  72.      color_puts("╘≥ ╠φ ╝╙ ╔· │╔,╖± ╘≥,╨▐ ╕─ ╔· │╔",30,11,24);
  73.      cursor(12,40);
  74.      scanf("%d",&i);
  75.      if (i==0) break;
  76.      if (i>modi_ctc) modi_ctc++;
  77.      i=(i>modi_ctc)?(modi_ctc-1):i-1;
  78.   if((aa=getroad(argv[1],road[i],i))!=0)
  79.     {
  80.        if(aa==1)
  81.        { /*j=0;
  82.      mybase=fbase;
  83.      while(mybase->no!=(road[i][0]-1))
  84.        mybase=mybase->next;
  85.      while (mybase->DB[j]!='\0')
  86.      dname[i][j]=mybase->MEAN[j++];
  87.      dname[i][j]='\0';*/
  88.      clear_win(15,36,19,72,0)    ;
  89.      clear_win(14,34,18,70,0|53)    ;
  90.      color_puts("╢¿╥σ┴¼╜╙┐Γ╡─╩╢▒≡├√(╫ε╢α20╕÷╫╓╖√): ",0|53,15,36)    ;
  91.      color_puts("                         ",0|53,17,40)    ;
  92.      cursor( 17, 43 )    ;
  93.      scanf("%s",dname[i]);
  94.        }
  95.        else
  96.       deflink(road[i],dname[i]);
  97.        flink=(LINK*)malloc(sizeof(LINK));
  98.        flink->next=NULL;
  99.        flink->no=i;
  100.        mylink=flink;
  101.        getcondition(&aa);
  102.        if(aa!=0)
  103.      {
  104.        if(aa==1) get_dc(road[i]);
  105.        if(aa==2) get_fc(road[i]);
  106.        fs[i]=aa;
  107.       }
  108.        cr_sub5(road[i],lname,i,fs[i],argv[1]);
  109.        i++;
  110.        free(flink);
  111.        mycon=fcon;
  112.        while (fcon!=NULL)
  113.           {
  114.           fcon=fcon->next;
  115.           mycon->next=NULL;
  116.           free(mycon);
  117.           mycon=fcon;
  118.           }
  119.     }
  120.    else break;
  121.    }
  122.    i=modi_ctc;
  123.    system("cls");
  124.    cursor(12,20);
  125.    puts("╒²╘┌╔·│╔╠⌡╝■╔╛│²│╠╨≥");
  126.    cr_sub51(dname,i);
  127.  
  128.  
  129.    fp = fopen("creat\\delete.txt","w")    ;
  130.   fprintf(fp,"%d\n",i)    ;
  131.   for(k=0; k<i; k++)
  132.     fprintf(fp,"%s\n",dname[k])    ;
  133.   fclose(fp)    ;
  134.  
  135.   }
  136.  
  137.  
  138.  
  139.  
  140. /* ╔·│╔╠⌡╝■╔╛│ⁿ│╠╨≥ */
  141. cr_sub5(s,lname,i,fs,aarr)
  142. int i,*s,fs;
  143. char lname[5][31],*aarr;
  144. {FILE *fp,*dp,*tp;
  145.  char name[15],buff[130],fd[120][10],db[14][20],ft[14],cc[14][10],tname[5];
  146.  int j,k,l,ii,ll,jj,kk,la,lb,lla,llb,row,col,m,n,fl[14];
  147.  BASE *mybase;
  148.  dp=fopen("creat\\meno2.txt","r");
  149.  tp=fopen("creat\\meno1.txt","r");
  150.   if (i+1<10) {tname[0]='1'+i;tname[1]='\0';}
  151.   if (i+1>9)  {tname[0]='0'+(i+1)/10; tname[1]='0'+(i+1)%10; tname[2]='\0';}
  152.   strcpy(name,"dsub"); strcat(name,tname); strcat(name,".prg");
  153.  
  154.    fp=fopen(name,"w");
  155.    j=0;
  156.    pr("clear\nset color to w+/B\n");
  157.      n=s[0]-1;
  158.     mybase=fbase;
  159.     while(mybase->no!=n)
  160.     mybase=mybase->next;
  161.     fprintf(fp,"sele 10\nuse %s%s exclusive\n",aarr,"ndx");
  162.     if( mybase->COFLAG == 'Y' || mybase->COFLAG == 'y' )
  163.     {
  164.     fprintf(fp,"sele A\nuse %s%s\n",mybase->COPATH,mybase->DB)    ;
  165.     coflag[1] = 1    ;
  166.     }
  167.     else
  168.     {
  169.     fprintf(fp,"sele A\nuse %s%s exclusive\n",aarr,mybase->DB)    ;
  170.     coflag[1] = 0    ;
  171.     }
  172.     j=1;
  173.     while(s[j]!=0)
  174.      {
  175.        mybase=fbase;
  176.        while(mybase->no!=(s[j]-1))
  177.      mybase=mybase->next;
  178.        fprintf(fp,"sele 10\ngo top\n");
  179.        fprintf(fp,"loca for trim(╦≈╥²╫╓╢╬)='%s'.and.trim(┐Γ├√)='%s'\n",lname[j-1],mybase->DB);
  180.        fprintf(fp,"nf=trim(╦≈╥²╬─╝■)\n");
  181.        fprintf(fp,"select %c\n",j+1+64);
  182.        if( mybase->COFLAG != 'Y' && mybase->COFLAG != 'y')
  183.       {
  184.      fprintf(fp,"sele 10\n use %sndx exclusive\ngo top\n",aarr);
  185.        fprintf(fp,"loca for trim(╦≈╥²╫╓╢╬)='%s'.and.trim(┐Γ├√)='%s'\n",lname[j-1],mybase->DB);
  186.        fprintf(fp,"nf=trim(╦≈╥²╬─╝■)\n");
  187.        fprintf(fp,"select %c\n",j+65);
  188.    coflag[j+1]=0    ;
  189.        fprintf(fp,"use %s%s inde %s&nf exclusive\naflag%c=1\n",aarr,mybase->DB,aarr,s[j]+64)    ;
  190.       }
  191.        else
  192.       {
  193.        fprintf(fp,"sele 10\n use %sndx \ngo top\n",mybase->COPATH);
  194.        fprintf(fp,"loca for trim(╦≈╥²╫╓╢╬)='%s'.and.trim(┐Γ├√)='%s'\n",lname[j-1],mybase->DB);
  195.        fprintf(fp,"nf=trim(╦≈╥²╬─╝■)\n");
  196.        fprintf(fp,"select %c\n",j+65);
  197.  
  198.         coflag[j+1] = 1    ;
  199.         fprintf(fp,"use %s%s inde %s&nf\naflag%c=1\n",mybase->COPATH,mybase->DB,mybase->COPATH,s[j]+64)    ;
  200.         fprintf(fp,"sele 10\nuse %sndx exclusive\n",aarr)    ;
  201.       }
  202.        if (linkflag==0)
  203.       fprintf(fp,"sele A\nset rela to %s into %c \n",lname[j-1],j+65);
  204.        else
  205.       fprintf(fp,"sele %c\nset rela to %s into %c addi\n",j+64,lname[j-1],j+65);
  206.        j++;
  207.      }
  208.      if(fs==1)
  209.      {
  210.     while(fgets(buff,120,dp))
  211.       { if(buff[1]=='#')  break;
  212.         pr("clear\nselect 1\ngo top\ndo while .not. eof()\n");
  213.         l=0;
  214.         color_puts(" Please asssure  condition ", 0x56,24,0)    ;
  215.         line_edit(24,25,31,buff,60)    ;
  216.         while(buff[l]!='\n') l++;
  217.         buff[l]='\0';
  218.        pr("select 1\n");
  219.        fprintf(fp,"if  %s\n",buff);
  220.        pr("clear\nset color to w+/B\n");
  221.        fprintf(fp,"@1,5 say \"╕∙╛▌╠⌡╝■ :  %s\"\n",buff);
  222.        dlook(fp,s,i,j);
  223.       }
  224.     }
  225.      if(fs==2)
  226.     {
  227.         while(fgets(buff,120,tp))
  228.          { if(buff[1]=='#') break;
  229.      mcon(fp,buff);
  230.      pr("clear\n");
  231.      pr("select 1\ndo while .not. eof()\n");
  232.      pr("select 1\n");
  233.      fprintf(fp,"if  &condition\n");
  234.      pr("clear\n");
  235.      pr("@1,1 say condition\n");
  236.      dlook(fp,s,i,j);
  237.       }
  238.     }
  239.    if(fs==3)
  240.   {
  241.     j=0;
  242.     while(s[j]!=0)
  243.      {
  244.        mybase=fbase;
  245.        while(mybase->no!=(s[j]-1))
  246.      mybase=mybase->next;
  247.        fprintf(fp,"sele %c\ncopy to s%s stru exte\n",j+65,mybase->DB);
  248.        j++;
  249.      }
  250.     pr("@0,0 say '╚╬╥Γ╠⌡╝■╔╛│²'\n");
  251.     pr("condition=''\n");
  252.     pr("cb=1\n");
  253.     pr("cs=.t.\n");
  254.     pr("do while cs\n");
  255.     rcon(i,j,s,fp);
  256.     pr("do rcon with renu,cb,condition,cs\n");
  257.     pr("enddo\n");
  258.     pr("clear\n");
  259.     pr("select 1\ngo top\ndo while .not. eof()\n");
  260.     pr("select 1\n");
  261.     fprintf(fp,"if  &condition\n");
  262.     pr("clear\n");
  263.     pr("@1,1 say condition\n");
  264.     dlook(fp,s,i,j);
  265.     }
  266.     j=0;
  267. /***    fprintf(fp,"sele 10\nuse ndx exclusive\n",aarr);****/
  268.     fprintf(fp,"sele 10\nuse %sndx exclusive\n",aarr);
  269.     while(s[j]!=0)
  270.      {
  271.        mybase=fbase;
  272.        while(mybase->no!=(s[j]-1))
  273.      mybase=mybase->next;
  274.        fprintf(fp,"select %c\n",j+1+64);
  275.        if( mybase->COFLAG == 'Y' || mybase->COFLAG == 'y')
  276.       fprintf(fp,"use %s%s exclusive\npack\n",mybase->COPATH,mybase->DB);
  277.        else
  278.       fprintf(fp,"use %s%s exclusive\npack\n",aarr,mybase->DB )    ;
  279.        fprintf(fp,"sele 10\ngo top\n");
  280.        fprintf(fp,"loca for trim(┐Γ├√)='%s'\n",mybase->DB);
  281.        fprintf(fp,"do while .not.eof()\nnf=trim(╦≈╥²╬─╝■)\n");
  282.        fprintf(fp,"select %c\n",j+1+64);
  283.        if( mybase->COFLAG == 'Y' || mybase->COFLAG == 'y')
  284.       fprintf(fp,"use %s%s inde %s&nf exclusive\n",mybase->COPATH,mybase->DB,mybase->COPATH)    ;
  285.        else
  286.       fprintf(fp,"use %s%s inde &nf exclusive\n",aarr,mybase->DB)    ;
  287.        pr("reinde\nuse\nsele 10\ncontinue\nenddo\n")    ;
  288.        j++;
  289.      }
  290.     pr("return\n");
  291.     fclose(fp);
  292.       fclose(dp);
  293.       fclose(tp);
  294. }
  295.  
  296. cr_sub51(dname,i)
  297. int i;
  298. char dname[14][20];
  299. {FILE *fp;
  300.  int k,row,col;
  301.  fp=fopen("delete.prg","w");
  302.  pr("set procedu to proced\nset talk off\ndo while .t.\nset color to /w\nclear\nset color to w+/B\n");
  303.  pr("@0,0 say '***╠⌡╝■╔╛│²***'\n");
  304.  pr("@2,26 say '─·┐╔╢╘╧┬┴╨┐Γ╜°╨╨▓┘╫≈'\n");
  305.  pr("@3,26 say '~~~~~~~~~~~~~~~~~~~~'\nset color to W/B\n");
  306.  fprintf(fp,"set color to w+/n\n@6,15 clea to %d,65\n",6+i/2+i%2+1);
  307.  fprintf(fp,"set color to w+/b\n@5,13 clea to %d,63\n",5+i/2+i%2+1);
  308.  row=6;col=15;
  309.  for(k=0;k<i;k++)
  310.  { fprintf(fp,"@%d,%d say '%d. %s'\n",row,col,k+1,dname[k]);
  311.    if(col==45) {col=15;row++;}
  312.    else col+=30;
  313.  }
  314.  for(k=1;k<=6;k++)
  315.     fprintf(fp,"select %d\nuse\n",k);
  316.  pr("choice=space(2)\nset color to w+/b\n");
  317.  pr("@22,10 say '╟δ╩Σ╚δ─·╡─╤í╘±, 0 ▒φ╩╛═╦│÷    : ' get choice\nread\n");
  318.  pr("set color to W+/N\nif trim(choice)='0'\n");
  319.  pr("return\nendif\n");
  320.  pr("nn='dsub'+trim(choice)+'.prg'\n");
  321.  pr("if FILE(nn)\n");
  322.  pr("do dsub&choice\n");
  323.  pr("endif\n");
  324.  pr("enddo\n");
  325.  fclose(fp);
  326.  }
  327.  
  328.  
  329.  
  330. /*---------------- This is a line editer -----------------------*/
  331. /*        row,col     posite the starting cursor         */
  332. /*        color       denote the color of the        */
  333. /*                  blackbord and the  character    */
  334. /*        buff        line-editer's interal denoting    */
  335. /*--------------------------------------------------------------*/
  336. line_edit(int row, int col, int color, char *buff, int len)
  337. {
  338.     int in_number=0, ins=1, i, j, flag=0    ;
  339.     char *str    ;
  340.     union {
  341.         int i;
  342.         char ch[2];
  343.           }key;
  344.  
  345.     len -= 2    ;
  346.     color_puts(buff, color, row, col )    ;
  347.     while(1)
  348.       {
  349.         cursor( row, col+in_number )    ;
  350.         key.i = bioskey(0)    ;
  351.         switch(key.i)
  352.           {
  353.             case 15104:    /*    F1    */
  354.                 break    ;
  355.  
  356.             case 19200:    /*    left arrow    */
  357.                 if(in_number)
  358.                     in_number=confirm(buff,in_number-1);
  359.                 cursor( row, col+in_number )    ;
  360.                 break    ;
  361.  
  362.             case 19712:    /*    right arrow    */
  363.                 if( buff[in_number]=='\0' )
  364.                     buff[in_number]=' '    ;
  365.                 if((unsigned)buff[in_number]>128 && (unsigned)buff[in_number]>128)
  366.                     in_number+=2    ;
  367.                 else
  368.                     in_number++    ;
  369.                 if(in_number>len)
  370.                     in_number=0    ;
  371.                 break    ;
  372.  
  373.             case 29440:    /*    Ctrl_left    */
  374.                 in_number=confirm(buff,in_number-8)    ;
  375.                 if( in_number <0 )
  376.                     in_number=0    ;
  377.                 break    ;
  378.  
  379.             case 29696:    /*    ctrl_right    */
  380.                 in_number = confirm(buff, in_number+8)    ;
  381.                 if( in_number>(i=strlen(buff)))
  382.                     in_number = i    ;
  383.                 break    ;
  384.  
  385.             case 18176:    /*    Home    */
  386.                 in_number=0    ;
  387.                 cursor( row, col )    ;
  388.                 break    ;
  389.  
  390.             case 20224:    /*    End    */
  391.                 in_number=strlen(buff)    ;
  392.                 cursor( row, col+in_number )    ;
  393.                 break    ;
  394.  
  395.             case 21248:     /*    Del    */
  396.                 if( in_number==strlen(buff) )
  397. /*                    printf("\007");*/    ;
  398.                 else
  399.                   {
  400.                     if( (unsigned)buff[in_number]>128 && (unsigned)buff[in_number]>128 )
  401.                       {
  402.                         for( i=in_number+2,j=strlen(buff); i<=j; i++ )
  403.                             buff[i-2]=buff[i]    ;
  404.                         color_puts( "  ", color, row, col+j-2 )    ;
  405.                       }
  406.                     else
  407.                       {
  408.                         for( i=in_number+1,j=strlen(buff); i<=j; i++)
  409.                             buff[i-1] = buff[i]    ;
  410.                         color_puts( " ", color, row, col+j-1 )    ;
  411.                       }
  412.                     str = &buff[in_number]    ;
  413.                     color_puts(str, color, row, col+in_number)    ;
  414.                   }
  415.                 break    ;
  416.  
  417.             case 3592:    /*    Backspace    */
  418.                 if(in_number)
  419.                   {
  420.                     if( (unsigned)buff[in_number-1]>128 && (unsigned)buff[in_number-2]>128 && in_number>1 )
  421.                       {
  422.                         for( i=in_number,j=strlen(buff); i<=j; i++)
  423.                             buff[i-2] = buff[i]    ;
  424.                         in_number-=2    ;
  425.                         color_puts( "  ", color, row, col+j-2 )    ;
  426.                       }
  427.                     else
  428.                       {
  429.                         for( i=in_number,j=strlen(buff); i<=j; i++)
  430.                             buff[i-1] = buff[i]    ;
  431.                         in_number--    ;
  432.                         color_puts( " ", color, row, col+j-1 )    ;
  433.                       }
  434.                     str = &buff[in_number]    ;
  435.                     color_puts( str, color, row, col+in_number )    ;
  436.                   }
  437.                 else
  438.                     /*  printf("\007"); */    ;
  439.                 break    ;
  440.  
  441.             case 20992:    /*    Ins    */
  442.                 ins=(ins?0:1)    ;
  443.                 break    ;
  444.  
  445.             case 7181:    /*    Enter    */
  446.                 for( i=strlen(buff)-1; buff[i]==' '&&i>=0; i--);
  447.                 buff[i+1]='\0'    ;
  448.                 return    ;
  449.  
  450.             default:
  451.                 if( ins )
  452.                   {
  453.  
  454.                     if( strlen(buff)>=len || key.ch[0]==0)
  455.                     /*    printf("\007")    ;    */;
  456.                     else
  457.                       {
  458.                         for( i=strlen(buff); i>in_number; i--)
  459.                             buff[i] = buff[i-1]    ;
  460.                         buff[in_number] = key.ch[0]    ;
  461.                         if( (unsigned)key.ch[0]>128 )
  462.                            if( flag==0 )    /*    the forehalf of chinese    */
  463.                              {
  464.                             flag++    ;
  465.                             in_number++    ;
  466.                              }
  467.                            else
  468.                              {
  469.                             flag--    ;
  470.                             str = &buff[in_number-1]    ;
  471.                             color_puts( str, color, row, col-1+in_number++ )    ;
  472.                              }
  473.                         else
  474.                           {
  475.                             str = &buff[in_number]    ;
  476.                             color_puts( str, color,row, col+in_number++ )    ;
  477.                           }
  478.                       }
  479.                   }
  480.                 else
  481.                   {
  482.                     if( in_number>=len || key.ch[0]==0 )
  483.                     /*    printf("\007")    ;    */;
  484.                     else
  485.                       {
  486.                         buff[in_number] = key.ch[0]    ;
  487.                         str = &buff[in_number]    ;
  488.                         color_puts( str, color, row, col+in_number++ )    ;
  489.                       }
  490.                   }
  491.  
  492.          }
  493.     }
  494. }
  495.  
  496.  
  497. /*-----  if the charater is chinese , and then the cursor must be in the first position----*/
  498. confirm(char *s, int col)
  499. {
  500.     int i    ;
  501.     if( (unsigned)s[col]<128)
  502.         return(col)    ;
  503.     for(i=col; (unsigned)s[i]>128&&i>0; i--)    ;
  504.     if((col-i)%2!=0)
  505.         return(col)    ;
  506.     else
  507.         return(col-1)    ;
  508. }
  509.  
  510.