home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 24 / CD_ASCQ_24_0995.iso / dos / tools / inter47 / int2hlp / int2hm.c < prev    next >
Text File  |  1995-03-30  |  13KB  |  402 lines

  1. /********************************
  2.  **                                   **
  3.  **  INT2HM.C                      **
  4.  **  (INT list TO HelpMake)    **
  5.  **                                   **
  6.  **  by Giorgio Caimi             **
  7.  **                                   **
  8.  ********************************/
  9.  
  10. #include <stdio.h>
  11. #include <stdlib.h>
  12. #include <string.h>
  13. #include <ctype.h>
  14.  
  15.  /* Formats definition */
  16.  
  17. char intlist[]=
  18. ".context h.title\nINTERRUPTS,PORTS,MEMORY and CMOS Help\n"
  19. ".context h.default\n.topic INTERRUPTS LIST (copyrights)\n\n\n\n"
  20. "               \\bINT2HM (INTerrupts list TO HelpMake converter)\\p\n"
  21. "                 \\bby GIORGIO CAIMI (caimi@zeus.csr.unibo.it)\\p\n\n\n"
  22. "       All documentation files except INTERRUPTS LIST, PORTS LIST and\n"
  23. "       CATEGORY LIST  are  copied  into  the  data-base  as  they are\n"
  24. "       provided.  Copyrights  and other restrictions applied from the\n"
  25. "       authors are contained into those files.\n\n"
  26. "       Copyrights for INTERRUPTS LIST,  PORTS LIST  and CATEGORY LIST\n"
  27. "       belong  to the  respective authors;  copyright information had\n"
  28. "       to be  removed  from the  original files  due to  the indexing\n"
  29. "       process requirements.\n\n\n"
  30. "                                                                 "
  31. "\\u[\\u\\aOK\\vh.contents\\v\\u]\\u\n"
  32. ".context h.contents\n.topic INTERRUPTS LIST (files index)\n"
  33. "    \\u[\\u\\aINTERRUPTS\\vis\\v\\u]\\u"
  34. "  \\u[\\u\\aFAR CALLS\\vft\\v\\u]\\u"
  35. "  \\u[\\u\\aMEMORY\\vmt\\v\\u]\\u"
  36. "  \\u[\\u\\aPORTS\\vpi\\v\\u]\\u"
  37. "  \\u[\\u\\aCMOS\\vct\\v\\u]\\u"
  38. "          \\u[\\u\\aBACK\\v!B\\v\\u]\\u\n"
  39. "  ──────────────────────────────────────────────────────────────────────\n\n"
  40. " ████ ██   ██ ██████ ███████ ██████  ██████  ██  ██ ██████  ██████  ████ \n"
  41. "  ██  ███  ██ █ ██ █  ██   █  ██  ██  ██  ██ ██  ██  ██  ██ █ ██ █ ██  ██\n"
  42. "  ██  ████ ██   ██    ██ █    ██  ██  ██  ██ ██  ██  ██  ██   ██   ███\n"
  43. "  ██  ██ ████   ██    ████    █████   █████  ██  ██  █████    ██    ███\n"
  44. "  ██  ██  ███   ██    ██ █    ██ ██   ██ ██  ██  ██  ██       ██      ███\n"
  45. "  ██  ██   ██   ██    ██   █  ██  ██  ██  ██ ██  ██  ██       ██   ██  ██\n"
  46. " ████ ██   ██  ████  ███████ ███  ██ ███  ██ ██████ ████     ████   ████\n\n"
  47.  
  48. "                       ████    ████  ████  ██████\n"
  49. "                        ██      ██  ██  ██ █ ██ █\n"
  50. "                        ██      ██  ███      ██\n"
  51. "                        ██      ██   ███     ██\n"
  52. "                        ██   █  ██     ███   ██\n"
  53. "                        ██  ██  ██  ██  ██   ██\n"
  54. "                       ███████ ████  ████   ████\n\n"
  55. "  ──────────────────────────────────────────────────────────────────────\n"
  56. "                                   HelpMake converter by Giorgio Caimi\n",
  57. fcall[]=".context ft\n.topic FARCALL.LST\n",
  58. mem[]=".context mt\n.topic MEMORY.LST\n",
  59. cmos[]=".context ct\n.topic CMOS.LST\n",
  60. gloss[]=".context gt\n.topic GLOSSARY.LST\n",
  61. keys[]=".context kt\n.topic CATEGORY.KEY\n",
  62. klink[]="  \\u\\aSEARCHING KEYS\\vkt\\v\\u\n\n",
  63. port[]=".context pi\n",
  64. port_a[]=".context pt####\n",
  65. port_b[]=".topic PORTS.LST\n",
  66. intlst[]=".context is\n",
  67. intlst_a[]=".context ii####\n",
  68. intlst_b[]=".context it####\n",
  69. intlst_c[]=".topic INTERRUP.LST\n",
  70. intlst_d[]="\\bCATEGORY :\\p ##\n\\bKEY      :\\p #"
  71. "                                                  ", /* filler[50] */
  72. line[]=
  73. "  ──────────────────────────────────────────────────────────────────────\n",
  74. menu[]=
  75. ".freeze 2\n"
  76. "    \\u[\\u\\aBACK\\v!B\\v\\u]\\u"
  77. "  \\u[\\u\\aFILES INDEX\\vh.contents\\v\\u]\\u"
  78. "                                 "
  79. "  \\u[\\u\\aGLOSSARY\\vgt\\v\\u]\\u\n",
  80. menuglo[]=
  81. ".freeze 2\n"
  82. "    \\u[\\u\\aBACK\\v!B\\v\\u]\\u"
  83. "  \\u[\\u\\aFILES INDEX\\vh.contents\\v\\u]\\u\n",
  84. menuglo1[]=
  85. ".freeze 2\n"
  86. "    \\u[\\u\\aFILES INDEX\\vh.contents\\v\\u]\\u"
  87. "                                         "
  88. "  \\u[\\u\\aGLOSSARY\\vgt\\v\\u]\\u\n",
  89. menubas[]=
  90. ".freeze 2\n"
  91. "    \\u[\\u\\aFILES INDEX\\vh.contents\\v\\u]\\u\n";
  92.  
  93. char *checkslash(char *str)
  94. /* converts backslash into double-backslash */
  95. {
  96.     int i,h;
  97.  
  98.     for (i=0;str[i];i++) {
  99.         if (str[i]=='\\') {
  100.             for (h=strlen(str)+1;h>i;h--) str[h]=str[h-1];
  101.             ++i;
  102.         }
  103.     }
  104.     return str;
  105. }
  106.  
  107. void main(void)
  108. {
  109.     FILE *fs,*fd,*fi;
  110.     char str[150],str1[150],str2[150],str3[10],str4[10],*error,hmfname[13];
  111.     unsigned cnt,cnt1;
  112.     int i,j,k,comp,intno,destno=0,ctxcont=0;
  113.  
  114.     printf("\n INT-list to HelpMake converter\n"
  115.                 " (c) 1994-95 by Giorgio Caimi\n\n"
  116.             "Checking archives...");
  117.       if ((fopen("PORTS.LST","rb")==NULL)||
  118.        (fopen("CMOS.LST","rb")==NULL)||
  119.        (fopen("FARCALL.LST","rb")==NULL)||
  120.          (fopen("MEMORY.LST","rb")==NULL)||
  121.          (fopen("GLOSSARY.LST","rb")==NULL)||
  122.          (fopen("CATEGORY.KEY","rb")==NULL)) {
  123.       fcloseall();
  124.         printf("NEED 'PORTS.LST','MEMORY.LST','CMOS.LST',\n"
  125.                  "                         "
  126.                  "'GLOSSARY.LST','CATEGORY.KEY' AND 'FARCALL.LST'\n");
  127.         putchar(7);
  128.       exit(1);
  129.    }
  130.    fcloseall();
  131.  
  132.     if (fopen("INTERRUP.LST","rb")==NULL) {
  133.        fcloseall();
  134.         printf("RUN 'COMBINE.BAT' FIRST\n");
  135.         putchar(7);
  136.       exit(2);
  137.     }
  138.     fcloseall();
  139.  
  140.     printf("OK\nWriting banner...");
  141.  
  142.    sprintf(hmfname,"INTLST%02X.HM",++destno);
  143.     fd=fopen(hmfname,"wt");
  144.     fputs(intlist,fd);
  145.  
  146.    printf("OK\nConverting 'FARCALL.LST'...");
  147.     fs=fopen("FARCALL.LST","rt");
  148.     fputs(fcall,fd); /* put context */
  149.     fputs(menuglo1,fd); /* put menu */
  150.    fputs(line,fd);
  151.     while (fgets(str,95,fs)) fputs(checkslash(str),fd);
  152.     fclose(fs);
  153.  
  154.       printf("OK\nConverting 'MEMORY.LST'...");
  155.    fs=fopen("MEMORY.LST","rt");
  156.    fputs(mem,fd); /* put context */
  157.     fputs(menuglo1,fd); /* put menu */
  158.    fputs(line,fd);
  159.     while (fgets(str,95,fs)) fputs(checkslash(str),fd);
  160.     fclose(fs);
  161.  
  162.     printf("OK\nConverting 'CMOS.LST'...");
  163.     fs=fopen("CMOS.LST","rt");
  164.     fputs(cmos,fd); /* put context */
  165.     fputs(menuglo1,fd); /* put menu */
  166.    fputs(line,fd);
  167.     while (fgets(str,95,fs)) fputs(checkslash(str),fd);
  168.     fclose(fs);
  169.  
  170.     printf("OK\nConverting 'GLOSSARY.LST'...");
  171.     fs=fopen("GLOSSARY.LST","rt");
  172.     fputs(gloss,fd); /* put context */
  173.     fputs(menuglo,fd); /* put menu */
  174.    fputs(line,fd);
  175.     while (fgets(str,95,fs)) fputs(checkslash(str),fd);
  176.     fclose(fs);
  177.  
  178.    printf("OK\nConverting 'PORTS.LST'...");
  179.     fs=fopen("PORTS.LST","rt");
  180.     fi=fopen("PORTS.IDX","wt");
  181.     cnt=0;str2[0]='\0';
  182.     do {
  183.         do {
  184.             while (str2[0]!='-')
  185.                 fgets(str2,95,fs);
  186.             comp=strncmp(str2,"-------------CREDITS",20);
  187.             fgets(str2,95,fs);
  188.         } while ((str2[0]=='\n')&&(comp));
  189.         if (comp) {
  190.  
  191.          strcpy(str,str2);
  192.          str2[0]='\0';  /* topic formatting */
  193.          i=j=0;
  194.          while (str[i]&&(str[i]!=' ')&&(str[i]!='\t')) {
  195.             str2[j]=str[i];
  196.             ++i;
  197.             if (toupper(str2[j])!='H') ++j;
  198.          }
  199.          for (;j<10;j++) str2[j]=' ';
  200.          while ((str[i]==' ')||(str[i]=='\t')) i++;
  201.          if (((str[i]=='r')||(str[i]=='w'))&&
  202.              ((str[i+1]==' ')||(str[i+1]=='\t')||(str[i+1]=='/')))
  203.             for (;(str[i]!=' ')&&(str[i]!='\t');i++) str2[j++]=str[i];
  204.          else while (str[i]=='-') i++;
  205.          while ((str[i]==' ')||(str[i]=='\t')) ++i;
  206.          for (;j<14;j++) str2[j]=' ';
  207.          if (str2[j-1]!=' ') str2[j++]=' ';
  208.          for (;str[i];i++) {
  209.             str2[j]=str[i];
  210.             if (str2[j]=='\t') str2[j]=' ';
  211.             ++j;
  212.          }
  213.          str2[j]='\0';
  214.          checkslash(str2);
  215.  
  216.          fputs(str2,fi);   /* add entry to index */
  217.             fgets(str,95,fs);
  218.             if (!strcmp(str,"\n")) fgets(str,95,fs); /* search text */
  219.             if (str[0]!='-') {  /* Is there any description? */
  220.                 sprintf(str1,"%04u\n",cnt++);
  221.                 strncpy(port_a+11,str1,4);
  222.             fputs(port_a,fd);fputs(port_b,fd);/* put context */
  223.                 fputs(menu,fd);fputs(line,fd); /* put menu */
  224.                 fputs("\\b",fd); /* bold on */
  225.                 str2[strlen(str2)-1]='\0';fputs(str2,fd);
  226.                 fputs("\\p\n\n",fd); /* bold off */
  227.                 do fputs(checkslash(str),fd); while (fgets(str,95,fs),*str!='-');
  228.                 fputs(str1,fi);
  229.                 ++ctxcont;
  230.             } else fputs("\n",fi);
  231.          strcpy(str2,str);
  232.         }
  233.     } while (comp);
  234.     fclose(fi);fclose(fs);
  235.  
  236.     printf("OK\nIndexing 'PORTS.LST'...");
  237.     fs=fopen("PORTS.IDX","rt");
  238.    fputs(port,fd);fputs(port_b,fd);
  239.     fputs(menubas,fd);fputs(line,fd);
  240.     while (fgets(str,95,fs)) {
  241.         fgets(str1,95,fs);
  242.         if ((k=strcmp(str1,"\n"))!=0) fputs("\\u\\a",fd);
  243.       str[strlen(str)-1]='\0';  /* del newline */
  244.         fputs(str,fd);
  245.       if (k) {
  246.             fputs("\\v",fd);
  247.             strncpy(port_a+11,str1,4);
  248.             strcpy(str1,port_a+9);
  249.             str1[strlen(str1)-1]='\0';
  250.             fputs(str1,fd);
  251.             fputs("\\v\\u",fd);
  252.             ++ctxcont;
  253.       }
  254.       putc('\n',fd);
  255.     }
  256.    fclose(fs);
  257.    unlink("PORTS.IDX");
  258.  
  259.     printf("OK\nConverting 'CATEGORY.KEY'...");
  260.     fs=fopen("CATEGORY.KEY","rt");
  261.     fputs(keys,fd); /* put context */
  262.     fputs(menuglo,fd); /* put menu */
  263.    fputs(line,fd);
  264.     while (*fgets(str,95,fs)!='-') ;
  265.    while (fgets(str,95,fs)) {
  266.       error=str;
  267.       while ((*error=='\t')||(*error==' ')) ++error;
  268.       fputs(checkslash(error),fd);
  269.    }
  270.     fclose(fs);
  271.  
  272.     printf("OK\nConverting 'INTERRUP.LST'...");
  273.     fs=fopen("INTERRUP.LST","rt");
  274.     fi=fopen("INTERRUP.IDX","wt");
  275.     cnt=cnt1=str[0]=0;intno=-1;
  276.     do {
  277.         do {
  278.             strcpy(str2,str);
  279.           while (strncmp(str2,"--------",8))
  280.                 fgets(str2,95,fs);
  281.             comp=strncmp(str2,"--------!---Admin",17);
  282.             if ((comp)&&(str2[8]=='!')) fgets(str,95,fs);
  283.         } while ((comp)&&(str2[8]=='!'));
  284.         if (comp) {
  285.             intlst_d[15]=str2[8]; /* category (main) */
  286.             i=10;j=33;
  287.             for (;str2[i];i++) {  /* key */
  288.                 intlst_d[j]=str2[i];
  289.                 if (intlst_d[j]!='-') ++j;
  290.             }
  291.             intlst_d[j]='\0';
  292.             str[0]=str2[10];str[1]=str2[11]; /* int no. */
  293.             str[2]='\0';
  294.             k=(int)strtol(str,&error,16);
  295.             if ((k!=intno)||(cnt1==500)) {
  296.             if (intno>=0) fputs("\n\n",fi);
  297.             fputs(str,fi);  /* put int no. */
  298.                 putc('\n',fi);
  299.                 intno=k;cnt1=0;
  300.             } else ++cnt1;
  301.             fgets(str2,95,fs);
  302.             intlst_d[16]=str2[7]; /* category (flag) */
  303.             if (str2[7]=='-') i=9; else i=11;
  304.             strcpy(str,str2+i); /* description */
  305.             checkslash(str);
  306.             sprintf(str1,"%04u\n",cnt++);
  307.          fputs(str,fi);fputs(str1,fi);
  308.             strncpy(intlst_b+11,str1,5);
  309.             fputs(intlst_b,fd);fputs(intlst_c,fd);/* put context */
  310.             fputs(menu,fd);fputs(line,fd); /* put menu */
  311.             fputs("\\b",fd); /* bold on */
  312.             str[strlen(str)-1]='\0';fputs(str,fd);
  313.             fputs("\\p\n",fd); /* bold off */
  314.             fputs(intlst_d,fd);
  315.             putc('\n',fd);
  316.             while (fgets(str2,95,fs),strncmp(str2,"--------",8))
  317.                 fputs(checkslash(str2),fd);
  318.             strcpy(str,str2);
  319.             ++ctxcont;
  320.             if (ctxcont==600) {
  321.                 ctxcont=0;
  322.             sprintf(hmfname,"INTLST%02X.HM",++destno);
  323.                 freopen(hmfname,"wt",fd);
  324.             }
  325.         }
  326.     } while (comp);
  327.    fputs("\n\n",fi);
  328.     fclose(fi);fclose(fs);
  329.  
  330.     printf("OK\nIndexing 'INTERRUP.LST'...");
  331.     fs=fopen("INTERRUP.IDX","rt");
  332.     fi=fopen("INTERRUP.CNT","wb");
  333.     fputs(intlst,fd);fputs(intlst_c,fd); /* put context */
  334.    fputs(menubas,fd);fputs(line,fd); /* put menu */
  335.    fputs(klink,fd); /* put searching keys link */
  336.    cnt=0;
  337.    while (fgets(str,95,fs)) {
  338.         str3[0]=str1[0]=cnt1=0;
  339.         do {
  340.             strcpy(str4,str3);
  341.          fgets(str1,95,fs);
  342.             fgets(str3,9,fs);
  343.             ++cnt1;
  344.         } while (*str1!='\n');
  345.         fputs("  \\u\\aINT ",fd);
  346.         str[strlen(str)-1]='\0';  /* del newline */
  347.         fputs(str,fd);
  348.         fputs("\\v",fd);
  349.         if (cnt1==2) { /* put text */
  350.             strncpy(intlst_b+11,str4,5);
  351.             strcpy(str1,intlst_b+9);
  352.         } else { /* put index */
  353.             sprintf(str4,"%04u",cnt++);
  354.             strncpy(intlst_a+11,str4,4);
  355.             strcpy(str1,intlst_a+9);
  356.         }
  357.       str1[strlen(str1)-1]='\0';
  358.         fputs(str1,fd);
  359.         putw(cnt1-1,fi);
  360.         fputs("\\v\\u\n",fd);
  361.     }
  362.     fclose(fs);fclose(fi);
  363.  
  364.    fs=fopen("INTERRUP.IDX","rt");
  365.     fi=fopen("INTERRUP.CNT","rb");
  366.     cnt=0;
  367.     while ((k=getw(fi))!=EOF) {
  368.         fgets(str,95,fs);
  369.         if (k>1) {
  370.             sprintf(str3,"%04u",cnt++);
  371.             strncpy(intlst_a+11,str3,4);
  372.             fputs(intlst_a,fd);fputs(intlst_c,fd); /* put context */
  373.             fputs(menu,fd);fputs(line,fd); /* put menu */
  374.         }
  375.         for (i=0;i<k;i++) {
  376.             fgets(str,95,fs);
  377.          fgets(str3,9,fs);
  378.             if (k>1) {
  379.                 fputs("\\u\\a",fd);
  380.                 str[strlen(str)-1]='\0';  /* del newline */
  381.                 fputs(str,fd);
  382.                 fputs("\\v",fd);
  383.                 strncpy(intlst_b+11,str3,5);
  384.                 strcpy(str1,intlst_b+9);
  385.                 str1[strlen(str1)-1]='\0';  /* del newline */
  386.                 fputs(str1,fd);
  387.             fputs("\\v\\u\n",fd);
  388.             }
  389.         }
  390.       fgets(str3,9,fs);
  391.         fgets(str3,9,fs);
  392.     }
  393.  
  394.     fclose(fs);fclose(fi);
  395.     unlink("INTERRUP.IDX");unlink("INTERRUP.CNT");
  396.  
  397.    fclose(fd);
  398.  
  399.     printf("OK\n\nDONE.\n");
  400.     putchar(7);
  401. }
  402.