home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a014 / 1.ddi / CDBINC.EXE / CONTROL.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-11-12  |  19.1 KB  |  681 lines

  1. #include <stdio.h>
  2. #include <fcntl.h>
  3. #include <io.h>
  4. #include <ctype.h>
  5. #include <dos.h>
  6. #include <alloc.h>
  7. #include <dir.h>
  8. #include <string.h>
  9. #include <stdarg.h> //========
  10.  
  11. #define black  0
  12. #define blue   1
  13. #define green  2
  14. #define eblue  3
  15. #define red    4
  16. #define pred   5
  17. #define eyellow 6
  18. #define white  7
  19. #define intense 8
  20. #define yellow 14
  21. #define ewhite 15
  22. #define blue_back 16
  23. #define green_back 32
  24. #define red_back   64
  25.  
  26. char pathname[14];
  27. FILE *fp;
  28. int js1,js2;
  29.  
  30. struct dbfile {
  31.           struct dbf{
  32.             char mean[20];
  33.             char dbname[10];
  34.             char mainkey[4][12];
  35.             char flag[2];
  36.             char flag_share[2];
  37.             char share_path[30];
  38.             } db[10];
  39.           int count;
  40.           struct dbfile *last,*next;
  41.           } *dbfhead,*p,*q;
  42.  
  43. main()
  44. {
  45.    int charact;
  46.    char *path={"c:\\cdbag\\"};
  47.    int count1,count2,count3;
  48.    char sub_dir[9];
  49.    char drive_no[3];
  50.    char file_no[9];
  51.    char ext_no[5];
  52.    int flag_no;
  53.  
  54.    char *baoqi=" ╬ó ╗· ═° ┬τ ╗╖ ╛│ ╧┬ ╣▄ └φ ╚φ ╝■ ╫╘ ╢» ╔· │╔ ╞≈ ";
  55.    char biaoti[4][14]={
  56.            "▓╦╡Ñ╔·│╔",
  57.            "┐Γ╜ß╣╣╔·│╔",
  58.            "╙ª╙├│╠╨≥╔·│╔",
  59.            "═╦│÷"
  60.            };
  61.    cls(1,0,24,79,0|113); system("c:");
  62.    print(0,0,0|30,"     ▓╦╡Ñ╔·│╔            ┐Γ╜ß╣╣╔·│╔          ╙ª╙├│╠╨≥╔·│╔        ═╦│÷           ");
  63.    /*cls(7,18,15,66,6|1);*/
  64.    cls(4,16,22,69,0);
  65.    frame(4,15,22,67,0|30);
  66.    print(4,17,yellow | blue_back,"                                                ");
  67.    print(5,17,yellow | blue_back,"%s",baoqi);
  68.    print(6,17,yellow | blue_back,"                                                ");
  69.    print(7,17,yellow | blue_back,"              ú├ú─ú┬ú┴ú╟  ú┤ú«ú░░µ              ");
  70.    print(8,17,yellow | blue_back,"                                                ");
  71.    print(9,17,yellow | blue_back,"            ▒▒╛⌐║╜┐╒║╜╠∞┤≤╤º╝╞╦π╗·╧╡            ");
  72.    print(10,17,yellow | blue_back,"                                                ");
  73.    print(11,17,yellow | blue_back,"          ╝╞╦π╗·╕▀╝╝╩⌡▓·╞╖┐¬╖ó╓╨╨─╤╨╓╞          ");
  74.    print(12,17,yellow | blue_back,"                                                ");
  75.    print(13,17,yellow | blue_back,"  ╡╪╓╖ú║▒▒║╜602╜╠╤╨╩╥       ╡τ╗░ú║2017251-603   ");
  76.    print(14,17,yellow | blue_back,"                                                ");
  77.    print(15,17,yellow | blue_back,"  ╠╪╘╝╛¡╧·ú║╬≈░▓║╜┐╒╝╞╦π╝╝╩⌡╣½╦╛ ╡τ╗░ú║752137   ");
  78.    print(16,17,yellow | blue_back,"                                                ");
  79.    print(17,17,yellow | blue_back,"  ╛¡╧·╡╪╓╖ú║╬≈░▓╩╨╠½░╫─╧┬╖29║┼(▒▀╝╥┤σ╩«╫╓─╧)    ");
  80.    print(18,17,yellow | blue_back,"                                                ");
  81.    print(19,17,yellow | blue_back,"                ╥╗╛┼╛┼╥╗─Ω╩«╥╗╘┬                ");
  82.    print(20,17,yellow | blue_back,"                                                ");
  83.    getchb();
  84.    cls(3,10,23,76,0|113);
  85.    cls(5,10,19,73,0);
  86.    frame(5,9,19,71,0|30);
  87.    print(6,32,yellow | blue_back,"╧╡  ═│  ╝≥  ╜Θ");
  88.    print(8,11,yellow | blue_back,"    CDBAG 4.0╩╟╝╠CDBAG 3.0╔╠╞╖╗»░µ▒╛╓«║≤╡─╫ε╨┬░µ▒╛ú║");
  89.    print(10,11,yellow | blue_back,"    ó┘  ╕∙╛▌╙├╗º╜╗╗Ñ╩╜╨Φ╟≤╢¿╥σú¼┐∞╦┘╫╘╢»╔·│╔╡Ñ╙├╗º╗≥═°");
  90.    print(11,11,yellow | blue_back,"        ┬τ╢α╙├╗ºú═ú╔ú╙╧╡═│íú");
  91.    print(12,11,yellow | blue_back,"    ó┌  ╫╘╢»╔·│╔DBASE ó≤ PLUSú»FOXBASE PLUS ╘┤│╠╨≥╧╡═│íú");
  92.    print(13,11,yellow | blue_back,"    ó█  ╓º│╓┐∞╦┘╘¡╨═⌐ñ⌐ñ╘¡╨═╘÷┴┐╨┬╡─ú═ú╔ú╙┐¬╖ó╖╜╖¿íú");
  93.    print(14,11,yellow | blue_back,"    ó▄  ╔·│╔╡─ú═ú╔ú╙╝»│╔╥╗╠σ╗»ú¼╗²─╛╫Θ║╧┐¬╖┼╩╜╜ß╣╣íú");
  94.    print(15,11,yellow | blue_back,"    ó▌  ╬¬╙ª╙├┐¬╖ó╚╦╘▒║═╫ε╓╒╙├╗º╠ß╣⌐╫█║╧╡─╥╗╠σ╗»╡─┐¬╖┼");
  95.    print(16,11,yellow | blue_back,"        ╩╜ú═ú╔ú╙┐¬╖ó╗╖╛│║═╣ñ╛▀íú");
  96.    getchb();
  97.    cls(1,5,22,76,0|113);
  98.   /* cls(7,25,10,55,yellow | blue_back);*/
  99.    cls(8,28,12,59,0);
  100.    frame(8,27,12,57,0|30);
  101.    print(8,28,yellow | blue_back,"  ╟δ╩Σ╚δ╙ª╙├╧╡═│╫╙─┐┬╝├√");
  102.    print(10,29,0|113,"%-26s"," ");
  103.    print(10,29,0|113," ");
  104.    read_string(pathname,13);
  105.    flag_no=fnsplit(pathname,drive_no,sub_dir,file_no,ext_no);
  106.    if (flag_no & DRIVE)
  107.       system(drive_no);
  108.    while (mkdir(pathname)!=0)
  109.      {
  110.      print(8,28,yellow | blue_back," ╕├╙ª╙├╧╡═│╫╙─┐┬╝├√╥╤╛¡┤µ╘┌ ");
  111.      print(9,28,yellow | blue_back,"  ╩╟ ╖± ╓╪ ╨┬ ╩Σ ╚δ(Y/N) ?  ");
  112.      print(10,29,0|113,"%-26s");
  113.      print(10,29,0|113," ");
  114.      charact=getchb();
  115.      while (charact!='N'&&charact!='n'&&charact!='Y'&&charact!='y') charact=getchb();
  116.      if (charact=='n'||charact=='N') break;
  117.      /*cls(7,25,10,55,yellow | blue_back);*/
  118.      print(8,28,yellow | blue_back,"   ╟δ╩Σ╚δ╙ª╙├╧╡═│╫╙─┐┬╝├√   ");
  119.      print(9,28,0|30,"%-26s"," ");
  120.      print(10,29,0|113,"%-26s"," ");
  121.      print(10,29,0|113," ");
  122.      read_string(pathname,13);
  123.      flag_no=fnsplit(pathname,drive_no,sub_dir,file_no,ext_no);
  124.      if (flag_no & DRIVE)
  125.         system(drive_no);
  126.      }
  127.    chdir(pathname);
  128.    cls(7,25,12,59,0|113);
  129.    count1=0;
  130.    print(0,5,0|15,"%s",biaoti[count1]);
  131.    for (;;)
  132.        {
  133.        charact=getchb();
  134.  
  135.        switch (charact)
  136.       {
  137.       case 275:
  138.            print(0,5+20*count1,0|30,"%s",biaoti[count1]);
  139.            count1=(count1-1<0)?3:count1-1;
  140.            break;
  141.       case 277:
  142.            print(0,5+20*count1,0|30,"%s",biaoti[count1]);
  143.            count1=(count1+1>3)?0:count1+1;
  144.            break;
  145.       case  27:return(0);
  146.       case  13:switch (count1)
  147.               {
  148.               case 0:system("c:\\cdbag4\\menu 1 wh");
  149. /*                 print(0,5,white,"▓╦╡Ñ╔·│╔            ┐Γ╜ß╣╣╔·│╔\
  150.                     ╙ª╙├│╠╨≥╔·│╔        ═╦│÷");*/
  151.                  cls(0,0,24,79,0|113);
  152.                  print(0,0,0|30,"     ▓╦╡Ñ╔·│╔            ┐Γ╜ß╣╣╔·│╔          ╙ª╙├│╠╨≥╔·│╔        ═╦│÷           ");
  153.                  break;
  154.               case 1:edit_dbfstru();
  155.                  cls(2,2,21,77,0|113);
  156.                  break;
  157.               case 2:progag(pathname);
  158.                  break;
  159.               case 3:mainprg(pathname);
  160.                  cls(1,0,24,79,0|113);
  161.                  cls(10,31,12,51,6|1);
  162.                  cls(9,29,11,49,yellow | blue_back);
  163.                  print(10,35,yellow | blue_back,"Generate...");
  164.                  system("copy c:\\cdbag4\\ndx.dbf *.* > oztom");
  165.                  system("copy c:\\cdbag4\\dbf_stru.dbf *.* > oztom");
  166.                  system("copy c:\\cdbag4\\menu.dbf *.* > oztom");
  167.                  system("copy c:\\cdbag4\\lmenu.prg *.* > oztom");
  168.                  system("copy c:\\cdbag4\\pro.prg *.* >oztom");
  169.                  system("copy c:\\cdbag4\\db.dbf *.* > oztom");
  170.                  system("copy c:\\cdbag4\\choice.prg *.* > oztom");
  171.                  system("copy c:\\cdbag4\\pro.prg *.* > oztom");
  172.                  system("copy c:\\cdbag4\\dbmenu.prg *.* > oztom");
  173.                  system("copy c:\\cdbag4\\ndx.prg *.* > oztom");
  174.                  system("copy c:\\cdbag4\\get_choi.prg *.* > oztom");
  175.                  system("copy c:\\cdbag4\\brow.exe *.* > oztom");
  176.                  system("cd \\"); cls(0,0,24,79,white);
  177.                  return(0);
  178.               }
  179.            break;
  180.       }
  181.        print(0,5+count1*20,0|15,"%s",biaoti[count1]);
  182.        }
  183. }
  184.  
  185. getmem()
  186. {
  187.    int i,n;
  188.    p=(struct dbfile *) malloc(sizeof(struct dbfile));
  189.    p->count=0;
  190.    p->next=p->last=NULL;
  191.    for (i=0;i<10;i++)
  192.        {
  193.        strcpy(p->db[i].mean,NULL);
  194.        strcpy(p->db[i].dbname,NULL);
  195.        for (n=0;n<4;n++)
  196.        strcpy(p->db[i].mainkey[n],NULL);
  197.        strcpy(p->db[i].flag,NULL);
  198.        strcpy(p->db[i].flag_share,NULL);
  199.        strcpy(p->db[i].share_path,NULL);
  200.        }
  201.    return(1);
  202. }
  203.  
  204. edit_dbfstru()
  205. {
  206.    char miss[80];
  207.    char dbfname[19];
  208.    int i,j;
  209.    strcpy(dbfname,pathname);
  210.    strcat(dbfname,"\\db.txt");
  211.    if ((fp=fopen(dbfname,"r"))==NULL)
  212.       {
  213.       /*cls(9,28,11,56,6|1);*/
  214.       cls(8,26,12,59,6|1);
  215.       frame(8,25,12,57,white | red_back);
  216.       print(8,27,white | red_back,"   ─·├╗╙╨╬¬▒╛╧╡═│╢¿╥σ┐Γ▓╬╩²  ");
  217.       print(9,27,white | red_back,"        ▓╗─▄╔·│╔┐Γ╜ß╣╣       ");
  218.       print(10,27,white | red_back,"  ╝ⁿ  ╚╬  ╥╗  ╝ⁿ  ╝╠  ╨°.... ");
  219.       getchb();
  220.       cls(8,27,12,59,0|113);
  221.       return(0);
  222.       }
  223.    i=0; getmem();  dbfhead=q=p;
  224.    while (fgets(miss,120,fp)!=NULL)
  225.      {
  226.      if (i==10)
  227.         {
  228.         i=0; getmem();
  229.         q->next=p; p->last=q; q=p;
  230.         }
  231.      sscanf(miss,"#%[^#]#,#%[^#]#,#%[^#]#,#%[^#]#,#%[^#]#,#%[^#]#,#%[^#]#,#%[^#]#,#%[^#]#",p->db[i].mean,\
  232.      p->db[i].mainkey[0],p->db[i].mainkey[1],p->db[i].mainkey[2],p->db[i].mainkey[3],\
  233.      p->db[i].dbname,p->db[i].flag,p->db[i].flag_share,p->db[i].share_path);
  234.      j=strlen(p->db[i].dbname);
  235.      while (p->db[i].dbname[j-1]==' ') j--;
  236.      p->db[i].dbname[j]='\0';
  237.      i++;  p->count++;
  238.      }
  239.    fclose(fp);
  240.    p=dbfhead;
  241.    sele_dbf();
  242.    fp=fopen("db.txt","w");
  243.    p=dbfhead;
  244.    for (;;)
  245.      {
  246.      for (i=0;i<p->count;i++)
  247.          fprintf(fp,"#%s#,#%s#,#%s#,#%s#,#%s#,#%s#,#%s#,#%s#,#%s#\n",p->db[i].mean,\
  248.          p->db[i].mainkey[0],p->db[i].mainkey[1],p->db[i].mainkey[2],p->db[i].mainkey[3],\
  249.          p->db[i].dbname,p->db[i].flag,p->db[i].flag_share,p->db[i].share_path);
  250.      p=p->next;
  251.      if (p==q->next) break;
  252.      dbfhead->next=NULL; p->last=NULL;
  253.      free(dbfhead); dbfhead=p;
  254.      }
  255.    free(dbfhead);
  256.    fclose(fp);
  257.    return(1);
  258. }
  259.  
  260. disp_midd(row,color)
  261. int row,color;
  262. {
  263.    print(7+row,9,color,"%-20s",p->db[row].mean);
  264.    print(7+row,41,color,"%-10s",p->db[row].dbname);
  265.    print(7+row,66,color,"%s",p->db[row].flag);
  266. }
  267.  
  268. disp_dbf()
  269. {
  270.    int i;
  271.    /*cls(5,8,16,74,6|1);
  272.    cls(4,7,15,73,yellow | blue_back);*/
  273.    frame(5,7,18,73,0|30);
  274.    print(5,9,yellow | blue_back,"╩²╛▌┐Γ▓╦╡Ñ║¼╥σ                  ╩²╛▌┐Γ├√              ╜¿┐Γ▒Ω╓╛");
  275.    print(6,9,white  | blue_back,"--------------------------------------------------------------");
  276.    for (i=0;i<p->count;i++) disp_midd(i,yellow | blue_back);
  277.    return(0);
  278. }
  279.  
  280. disp_instruc()
  281. {
  282.    /*cls(20,8,23,74,6|1);
  283.    cls(19,7,22,73,yellow | blue_back);
  284.    print(20,20,yellow | blue_back,"╟δ  ╤í  ╘±  ─·  ╨Φ  ▓┘  ╫≈  ╡─  ╩²  ╛▌  ┐Γ ");*/
  285.    print(24,0,0|75,"%-80s","PgDn ╔╧╖¡  PgUp ╧┬╖¡  íⁿ ╔╧╥╞╣Γ┤°  í² ╧┬╥╞╣Γ┤°  Enter╤í╘±   Esc ═╦│÷ ");
  286. }
  287.  
  288. sele_dbf()
  289. {
  290.    int i,n,m,k,j;
  291.    char *opertype[3]={
  292.              "▒α ╝⌐ ┐Γ ╜ß ╣╣ (╜¿ ┴ó \\╨▐ ╕─)",
  293.              "╜½ ╥╤ ╙╨ ╡─ ┐Γ ╜ß ╣╣ ┐╜ ╚δ ",
  294.              "╔╛ │² ╥╤ ╙╨ ╡─ ┐Γ ╜ß ╣╣"
  295.              };
  296.    disp_instruc();
  297.    disp_dbf();
  298.    i=0; disp_midd(i,0|113);
  299.    while ((n=getchb())!=27)
  300.      {
  301.      switch (n)
  302.         {
  303.         case 273:if (p==dbfhead) break;
  304.              i=0; p=p->last;
  305.              disp_dbf();
  306.              break;
  307.  
  308.         case 281:if (p==q) break;
  309.              i=0; p=p->next;
  310.              disp_dbf();
  311.              break;
  312.         case 272:if (i==0) break;
  313.              disp_midd(i,yellow | blue_back);
  314.              i--;
  315.              break;
  316.         case 280:if (i==p->count-1) break;
  317.              disp_midd(i,yellow | blue_back);
  318.              i++;
  319.              break;
  320.         case  13:
  321.              /*cls(10,20,14,51,6|1);
  322.              cls(9,19,13,50,0|113);*/
  323.              cls(10,20,14,54,0);
  324.              frame(10,18,14,52,0|113);
  325.              print(10,20,0|113,"%s",opertype[0]);
  326.              print(11,20,0|113,"%s",opertype[1]);
  327.              print(12,20,0|113,"%s",opertype[2]);
  328.              m=0; print(10,20,yellow | blue_back,"%-30s",opertype[m]);
  329.              js1=i; j=1;
  330.              while ((k=getchb())!=27)
  331.                    {
  332.                    switch (k)
  333.                       {
  334.                       case 272:
  335.                            print(10+m,20,0|113,"%-30s",opertype[m]);
  336.                            m=(m==0)?2:m-1;
  337.                            break;
  338.                       case 280:
  339.                            print(10+m,20,0|113,"%-30s",opertype[m]);
  340.                            m=(m==2)?0:m+1;
  341.                            break;
  342.                       case  13:if (m==0) {edit_stru(); j=0;}
  343.                            if (m==1) {copy_stru(); j=0;}
  344.                            if (m==2) {dele_stru(); j=0;}
  345.                       }
  346.                    if (j==0) break;
  347.                    print(10+m,20,yellow | blue_back,"%-30s",opertype[m]);
  348.                    }
  349.              disp_dbf();
  350.              break;
  351.         }
  352.      disp_midd(i,0|113);
  353.      }
  354.    cls(1,0,24,79,0|113);
  355.    return(0);
  356. }
  357.  
  358. edit_stru()
  359. {
  360.    FILE *fw;
  361.    char editpath[50];
  362.    strcpy(editpath,"c:\\cdbag4\\mc 2 ");
  363.    strcat(editpath,p->db[js1].mean);
  364.    strcat(editpath," ");
  365.    strcat(editpath,p->db[js1].dbname);
  366.    strcat(editpath,".txt");
  367.    system(editpath);
  368.    strcpy(editpath,p->db[js1].dbname);
  369.    strcat(editpath,".txt");
  370.    if ((fw=fopen(editpath,"r"))!=NULL)
  371.       {
  372.       p->db[js1].flag[0]='Y';
  373.       YN_value(p->db[js1].dbname,p->db[js1].flag);
  374.       fclose(fw);
  375.       }
  376.    cls(17,0,18,79,0|113);
  377.    return(0);
  378. }
  379.  
  380. copy_stru()
  381. {
  382.    char path_name[40];
  383.    char path_name1[30];
  384.    char copypath[80];
  385.    FILE *fw;
  386.    strcpy(copypath,"copy ");
  387.    /*cls(14,15,17,59,6|1);
  388.    cls(13,14,16,58,0|113);*/
  389.    cls(14,16,16,60,0);
  390.    frame(14,14,17,58,0|30);
  391.    print(17,15,6|1,"%-.*s",46,"⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ");
  392.    print(14,16,yellow | blue_back,"╟δ  ╩Σ  ╚δ  ╘┤  ╬─  ╝■  ├√ :           ");
  393.    print(15,16,0|113,"%-40s"," ");
  394.    print(15,16,0|113," ");
  395.    read_string(path_name,35);
  396.    strcat(path_name,".dbf");
  397.    if ((fw=fopen(path_name,"r"))==NULL)
  398.       {
  399.       /*cls(13,14,15,58,0|30);
  400.       cls(14,16,17,60,0);*/
  401.       frame(14,14,17,58,0|75);
  402.  
  403.       print(14,22,0|75,"    ╕├ ╘┤ ╬─ ╝■ ▓╗ ┤µ ╘┌    ");
  404.       print(15,22,0|75,"Press any key to continue...");
  405.       getchb(); fclose(fw);
  406.       cls(17,0,18,79,0|113);
  407.       return(0);
  408.       }
  409.    fclose(fw);
  410.    strcat(copypath,path_name); strcat(copypath," ");
  411.    strcat(copypath,pathname); strcat(copypath,"\\");
  412.    strcat(copypath,p->db[js1].dbname); strcat(copypath,".dbf"); strcat(copypath," > oztom");
  413.    system(copypath); p->db[js1].flag[0]='Y';
  414.    YN_value(p->db[js1].dbname,p->db[js1].flag);
  415.    strcpy(path_name1,p->db[js1].dbname); strcat(path_name1,".txt");
  416.    field_read(path_name,path_name1);
  417.    cls(17,0,18,79,0|113);
  418.    return(0);
  419. }
  420.  
  421. dele_stru()
  422. {
  423.    char path[80],delpath[80];
  424.    int i;
  425.    strcpy(path,"del ");
  426.    /*cls(14,23,17,51,6|1);
  427.    cls(13,22,16,50,yellow | red_back);*/
  428.    cls(13,21,16,52,0);
  429.    frame(13,20,16,50,0|75);
  430.    print(13,51,6|1,"⌐┐");
  431.    if (p->db[js1].flag[0]=='y'||p->db[js1].flag[0]=='Y')
  432.       {
  433.       print(13,22,0|75,"┤╦▓┘╫≈╜½╡╝╓┬╩²╛▌┐Γ╜ß╣╣╢¬╩º");
  434.       print(14,22,0|75,"    ╚╖    ╨┼    ╖±(Y/N)   ");
  435.       i=getchb();
  436.       while (i!='y'&&i!='Y'&&i!='n'&&i!='N') i=getchb();
  437.       if (i=='y'||i=='Y')
  438.      {
  439.      strcat(path,pathname); strcat(path,"\\");
  440.      strcat(path,p->db[js1].dbname); strcpy(delpath,path);
  441.      strcat(path,".txt"); strcat(delpath,".dbf"); strcat(delpath," > oztom");
  442.      strcat(path," > oztom");
  443.      system(path); system(delpath);
  444.      p->db[js1].flag[0]='N';
  445.      YN_value(p->db[js1].dbname,p->db[js1].flag);
  446.      }
  447.       }
  448.       else
  449.          {
  450.      print(13,22,0|75,"┤╦┐Γ▒╛└┤▓ó╬▐╜ß╣╣, ▓╗─▄╔╛│²");
  451.      print(14,22,0|75,"Press any key to continue.");
  452.          getchb();
  453.          }
  454.    cls(17,0,18,79,0|113);
  455.    return(0);
  456. }
  457.  
  458. field_read(string1,string2)
  459. char *string1,*string2;
  460. {
  461.    struct FIELD {
  462.           char field_name[11];
  463.           char field_type;
  464.           int field_len;
  465.           int field_doc;
  466.           struct FIELD *next,*last;
  467.           };
  468.    struct FIELD *head,*work,*nall;
  469.    int  handle;
  470.    FILE *ft;
  471.    char int_buff[5];
  472.    char char_buff[33];
  473.    int field_ctc=0;
  474.    handle=_open(string1,O_RDONLY);
  475.    lseek(handle,32,SEEK_SET);
  476.    _read(handle,int_buff,2);
  477.    nall=(struct FIELD *) malloc(sizeof(struct FIELD));
  478.    nall->next=nall->last=NULL;
  479.    head=work=nall;
  480.    strcpy(char_buff,NULL);
  481.    while (int_buff[0]!=0x0d)
  482.       {
  483.       work=nall; lseek(handle,(field_ctc+1)*32,SEEK_SET);
  484.       strcpy(char_buff,NULL);
  485.       _read(handle,char_buff,32);
  486.       sscanf(char_buff,"%s",work->field_name);
  487.       work->field_type=char_buff[11];
  488.       work->field_len=char_buff[16];
  489.       work->field_doc=char_buff[17];
  490.       if (work->field_len<0) work->field_len=work->field_len+256;
  491.       field_ctc++;
  492.       nall=(struct FIELD *) malloc(sizeof(struct FIELD));
  493.       nall->next=nall->last=NULL;
  494.       work->next=nall;
  495.       nall->last=work;
  496.       _read(handle,int_buff,2);
  497.       }
  498.    work->next=NULL; nall->last=NULL; free(nall);
  499.    work=head;
  500.    ft=fopen(string2,"w");
  501.    while (work!=NULL)
  502.      {
  503.      fprintf(ft,"#%s#,#%c#,%d,%d\n",work->field_name,work->field_type,\
  504.          work->field_len,work->field_doc);
  505.      work=work->next;
  506.      }
  507.    fclose(ft);
  508. }
  509.  
  510. YN_value(string,value)
  511. char *string,*value;
  512. {
  513.    int i;
  514.    struct dbfile *dn;
  515.    dn=dbfhead;
  516.    for (;;)
  517.        {
  518.        for (i=0;i<dn->count;i++)
  519.        if (strcmp(string,dn->db[i].dbname)==0) strcpy(dn->db[i].flag,value);
  520.        dn=dn->next;
  521.        if (dn==q->next);
  522.        break;
  523.        }
  524.    return(0);
  525. }
  526. /*------------------------------------------------------------------------*/
  527.  print(int row,int col,int attr,char *format,...)
  528. {
  529.     va_list arg;
  530.     char print_str[254],*string;
  531.     va_start(arg,format);
  532.     vsprintf(print_str,format,arg);
  533.     string=print_str;
  534.   _SI =(unsigned int) string;
  535.   _DH =(unsigned char)row;
  536.   _DL =(unsigned char)col;
  537.   _CX=1;
  538.    while(*((char *)_SI)){
  539.    _AH=(unsigned char)2;
  540.    _BH=(unsigned char)0;
  541.    geninterrupt(0x10);
  542.    ++_DL;
  543.   _AH=(unsigned char)9;
  544.   _AL=*((char *)_SI);
  545.   _SI++;
  546.   _BH=(unsigned char)0;
  547.   _BL=(unsigned char)attr;
  548.   geninterrupt(0x10);
  549.  }
  550. }
  551.  
  552. /*------------------------------------------------------------------------*/
  553.  print1(int attr,char *format,...)
  554. {
  555.     va_list arg;
  556.     int row,col;
  557.     char print_str[254],*string;
  558.     va_start(arg,format);
  559.     vsprintf(print_str,format,arg);
  560.     string=print_str;
  561.   _AH =(unsigned char)3;
  562.   _BH =(unsigned char)0;
  563.   geninterrupt(0x10);
  564.   _DL++;
  565.  _SI =(unsigned int) string;
  566.   _CX=1;
  567.    while(*((char *)_SI)){
  568.    _AH=(unsigned char)2;
  569.    _BH=(unsigned char)0;
  570.    geninterrupt(0x10);
  571.    ++_DL;
  572.   _AH=(unsigned char)9;
  573.   _AL=*((char *)_SI);
  574.   _SI++;
  575.   _BH=(unsigned char)0;
  576.   _BL=(unsigned char)attr;
  577.   geninterrupt(0x10);
  578.  }
  579. }
  580.  
  581. /*-----------------------------CLEAR SCREEN---------------------------------*/
  582. cls(S_X,S_Y,E_X,E_Y,attr)
  583. int S_X,S_Y,E_X,E_Y,attr;
  584. {
  585.  _AH=(unsigned char)6;
  586.  _AL=(unsigned char)0;
  587.  _BH=(unsigned char)attr;
  588.  _CH=(unsigned char)S_X;
  589.  _CL=(unsigned char)S_Y;
  590.  _DH=(unsigned char)E_X;
  591.  _DL=(unsigned char)E_Y;
  592.  geninterrupt(0x10);
  593. }
  594.  
  595. read_string(string,length)
  596. char *string;
  597. int length;
  598. {
  599.    char middstr[41];
  600.    int  ctc,charact;
  601.    int x,y;
  602.    for (ctc=0;ctc<20;ctc++) middstr[ctc]='\0';
  603.    ctc=0;
  604.    while (ctc<length-1)
  605.       {
  606.       charact=getchb();
  607.       if (charact==13) break;
  608.       if ((charact==8)&&(ctc>0)) {
  609.      now_cursor(&x,&y);
  610.      go_to(x+1,y); printf(" ");
  611.      go_to(x+1,y); middstr[--ctc]='\0';
  612.      continue;
  613.      }
  614.       if (charact<=30 || charact>=128) continue;
  615.       printf("%c",charact);
  616.       middstr[ctc++]=charact;
  617.       }
  618.    if (strcmp(middstr,NULL)!=0)
  619.       strcpy(string,middstr);
  620.    return(0);
  621. }
  622.  
  623. getchb()
  624. {
  625.   union REGS regs;
  626.   int t,m;
  627.   regs.x.ax=0;
  628.   int86(0x16,®s,®s);
  629.   t=regs.x.ax & 0x00ff;
  630.   m=(regs.x.ax-t)/256;
  631.   if (t!=0) return(t);
  632.   return(m+200);
  633. }
  634. /*----------------------------CURSOR POSITION-------------------------------*/
  635. go_to(int row,int col)
  636. {
  637.     _AH=(unsigned char)2;
  638.     _BH=(unsigned char)0;
  639.     _DH=(unsigned char)row-1;
  640.     _DL=(unsigned char)col-1;
  641.     geninterrupt(0x10);
  642. }
  643.  
  644. now_cursor(int *row,int *col)
  645. {
  646.     _AH=(unsigned char)3;
  647.     _BH=(unsigned char)0;
  648.     geninterrupt(0x10);
  649.     *row=_DH;
  650.     *col=_DL;
  651. }
  652.  
  653. /*---------------------------------------------------------------------------------*/
  654. frame(s_r,s_c,e_r,e_c,attr)
  655. int s_r,s_c,e_r,e_c,attr;
  656. {
  657.   int i,j;
  658.   char line[80];
  659.   union REGS r;
  660.   r.h.ah=6;
  661.   r.h.al=0;
  662.   r.h.bh=attr;
  663.   r.h.ch=s_r-1;
  664.   r.h.cl=s_c-1;
  665.   r.h.dh=e_r-1;
  666.   r.h.dl=e_c-1;
  667.   int86(0x10,&r,&r);
  668.   strcpy(line,"⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ");
  669.   print(s_r-1,s_c-1,attr,"⌐│");
  670.   print(s_r-1,s_c+1,attr,"%-.*s",e_c-s_c-2,line);
  671.   print(s_r-1,e_c-1,attr,"⌐╖");
  672.   for(i=s_r+1;i<e_r;i++)
  673.   {
  674.     print(i-1,s_c-1,attr,"⌐º");
  675.     print(i-1,e_c-1,attr,"⌐º");
  676.   }
  677.   print(e_r-1,s_c-1,attr,"⌐╗");
  678.   print(e_r-1,s_c+1,attr,"%-.*s",e_c-s_c-2,line);
  679.   print(e_r-1,e_c-1,attr,"⌐┐");
  680. }
  681.