home *** CD-ROM | disk | FTP | other *** search
/ Resource Library: Multimedia / Resource Library: Multimedia.iso / sgml / unix / rexxsgml / sgmlapir.c < prev   
Encoding:
Text File  |  1991-07-03  |  37.8 KB  |  988 lines

  1. /*****************************************************************************/
  2. /* SGMLAPIR: SGML API for REXX                                               */
  3. /* Author: Roy Engehausen                                                    */
  4. /* Mods:   Jack Steitz         1. Bring code to ANSI standard                */
  5. /* Mods:   Charles F. Goldfarb 2. Convert to Borland C                       */
  6. /*                                                                           */
  7. /******************************************************************************/
  8. /* Secret public variable for use by markup validator (not in SGMLAPI.H). */
  9. int TPisVM = 0;               /* Set to 1 by TP if it is markup validator. */
  10. /*****************************************************************************/
  11.  
  12. /*===========================================================================*/
  13. /* External files                                                            */
  14. /*===========================================================================*/
  15.  
  16. #include "sgmlapi.h"          /* Text processor header for SGML interfacing. */
  17. #include "vmincl.h"           /* Include files for VM.                       */
  18. #include "vmxtrn.h"           /* Declarations for VM public variables.       */
  19.  
  20. /*---------------------------------------------------------------------------*/
  21. /* Global structures                                                         */
  22. /*---------------------------------------------------------------------------*/
  23.  
  24. struct rcbde de = {0};        /* RCB for current data entity information.    */
  25. struct rcbte te = {0};        /* RCB for calls to SGMLAPI (TP+ENV).          */
  26. UNCH sgmlomsg[] =             /* Text for invalid option error message.      */
  27.      "/d /e /f /g /mSGML.MSG /p1 /r /t3";
  28. /*===========================================================================*/
  29. /* Subroutine forwards                                                       */
  30. /*===========================================================================*/
  31.  
  32. static void rexx_attr(int, char*); /* Put attribute list into rexx           */
  33.        void alset(struct ad *);  /* Set up to start processing att list.     */
  34.        void setndata(PNE);   /* Build ext data entity rcbde with entity text.*/
  35. static void rexx_set(char *, char *, int);
  36. static void rexx_drop(char *);
  37.  
  38. /*===========================================================================*/
  39. /* Global variables                                                          */
  40. /*===========================================================================*/
  41.  
  42. int  tag_stack;
  43. int  drop_pending;
  44. char drop_me[30];
  45. char alist[200];
  46.  
  47. /*===========================================================================*/
  48. /* Main routine                                                              */
  49. /*===========================================================================*/
  50.  
  51. void sgmlapir(int argc, char **argv)
  52. {
  53.  
  54.     /*-----------------------------------------------------------------------*/
  55.     /* Local variables                                                       */
  56.     /*-----------------------------------------------------------------------*/
  57.  
  58.     char buffer[10];
  59.     UNCH *fileid = NULL;
  60.     char *funct  = NULL;
  61.     int i;
  62.  
  63.     /*-----------------------------------------------------------------------*/
  64.     /* Check parameter count                                                 */
  65.     /*-----------------------------------------------------------------------*/
  66.  
  67.     if (argc < 2)
  68.     {
  69.         printf("\nFunction parameter is missing -- %d\n", argc);
  70.         exit(1);
  71.     }
  72.  
  73.     /*-----------------------------------------------------------------------*/
  74.     /* The function name is the first item.                                  */
  75.     /*-----------------------------------------------------------------------*/
  76.  
  77.     funct = argv[1];
  78.  
  79.     /*-----------------------------------------------------------------------*/
  80.     /* Execute proper function                                               */
  81.     /*-----------------------------------------------------------------------*/
  82.  
  83.     /*-----------------------------------------------------------------------*/
  84.     /* NEXT                                                                  */
  85.     /*-----------------------------------------------------------------------*/
  86.  
  87.     if (strcmp(funct, "NEXT") == 0)
  88.     {
  89.  
  90.         if (drop_pending)
  91.         {
  92.             rexx_drop(drop_me);
  93.             drop_pending = 0;
  94.         }
  95.  
  96.         sgmlnext();
  97.  
  98.         return;
  99.  
  100.     }
  101.  
  102.     /*-----------------------------------------------------------------------*/
  103.     /* INIT                                                                  */
  104.     /*-----------------------------------------------------------------------*/
  105.  
  106.     if (strcmp(funct, "INIT") == 0)
  107.     {
  108.  
  109.         /*-------------------------------------------------------------------*/
  110.         /* Set the options back to defaults                                  */
  111.         /*-------------------------------------------------------------------*/
  112.  
  113.         drop_pending = 0;
  114.  
  115.         sgmloset();
  116.  
  117.         /*-------------------------------------------------------------------*/
  118.         /* Now loop thru processing the options                              */
  119.         /*-------------------------------------------------------------------*/
  120.  
  121.         for (i = 1; ++i<argc;)
  122.         {
  123.  
  124.             /*---------------------------------------------------------------*/
  125.             /* It must start with a "/".  If not, assume its the file name   */
  126.             /*---------------------------------------------------------------*/
  127.  
  128.             if (argv[i][0]!='/')
  129.               fileid = argv[i];
  130.             else
  131.               if (sgmlopt(argv[i])!=0)
  132.               {
  133.                   printf("\nTP001-> \"%s\" option switch is"
  134.                          " incorrect; usage is: %s", argv[i], sgmlomsg);
  135.                   exit(001);
  136.               }
  137.  
  138.         } /*----- End argument process loop -------------------------------*/
  139.  
  140.         /*-------------------------------------------------------------------*/
  141.         /* Check to make sure a fileid is present                            */
  142.         /*-------------------------------------------------------------------*/
  143.  
  144.         if (fileid==NULL || *fileid=='?')
  145.         {
  146.             printf("\nTP002-> No primary file specified; usage is:"
  147.                    "  INIT %s [profile;]file", sgmlomsg);
  148.             exit(002);
  149.         }
  150.  
  151.         /*-------------------------------------------------------------------*/
  152.         /* Now process the file name                                         */
  153.         /*-------------------------------------------------------------------*/
  154.  
  155.         if (docent(fileid))
  156.         {
  157.             printf("\nTP005-> SGML document entity system ID"
  158.                    " (%s) exceeds 240 characters.", fileid);
  159.             exit(005);
  160.         }
  161.  
  162.         /*-------------------------------------------------------------------*/
  163.         /* Initialize the parser and return                                  */
  164.         /*-------------------------------------------------------------------*/
  165.  
  166.         sgmlset();
  167.  
  168.         /*-------------------------------------------------------------------*/
  169.         /* Initialize the interface                                          */
  170.         /*-------------------------------------------------------------------*/
  171.  
  172.         te.pass   = 0;
  173.  
  174.         return;
  175.     }
  176.  
  177.     /*-----------------------------------------------------------------------*/
  178.     /* START_PASS                                                            */
  179.     /*-----------------------------------------------------------------------*/
  180.  
  181.     if (strcmp(funct, "START_PASS") == 0)
  182.     {
  183.  
  184.         /*-------------------------------------------------------------------*/
  185.         /* Initialize the interface                                          */
  186.         /*-------------------------------------------------------------------*/
  187.  
  188.         drop_pending = 0;
  189.         tag_stack    = 0;
  190.  
  191.         rexx_set("SGML_TAG_LEVEL", "0", 1);
  192.  
  193.         /*-------------------------------------------------------------------*/
  194.         /* Count the pass                                                    */
  195.         /*-------------------------------------------------------------------*/
  196.  
  197.         ++te.pass;
  198.  
  199.         /*-------------------------------------------------------------------*/
  200.         /* Tell user                                                         */
  201.         /*-------------------------------------------------------------------*/
  202.  
  203.         printf("\nTP105-> Pass %d of %d.", te.pass, te.passes);
  204.  
  205.         /*-------------------------------------------------------------------*/
  206.         /* Initialize the pass                                               */
  207.         /*-------------------------------------------------------------------*/
  208.  
  209.         if (sgmlpset())
  210.         {
  211.             printf("\nTP006-> Could not open SGML document entity in file: %s",
  212.                    fileid);
  213.                    exit(006);
  214.         }
  215.         return;
  216.     }
  217.  
  218.     /*-----------------------------------------------------------------------*/
  219.     /* END_RUN                                                               */
  220.     /*-----------------------------------------------------------------------*/
  221.  
  222.     if (strcmp(funct, "END_RUN") == 0)
  223.     {
  224.  
  225.         i = sgmlend();
  226.  
  227.         sprintf(buffer,"%d", i);
  228.         rexx_set("SGML_DATA", buffer, strlen(buffer));
  229.  
  230.         return;
  231.  
  232.     }
  233.  
  234.     /*-----------------------------------------------------------------------*/
  235.     /* If we reach here, the function code is INVALID                        */
  236.     /*-----------------------------------------------------------------------*/
  237.  
  238.     printf("\nInvalid function code -- %s\n", funct);
  239.     return;
  240.  
  241. }
  242.  
  243. /*===========================================================================*/
  244. /* SGML NEXT                                                                 */
  245. /*===========================================================================*/
  246.  
  247. int sgmlnext(void)
  248. {
  249.  
  250.     char buffer[10];
  251.     char composite_name[30];
  252.     char composite_temp1[30];
  253.  
  254.     /*-----------------------------------------------------------------------*/
  255.     /* Main scan loop!                                                       */
  256.     /*-----------------------------------------------------------------------*/
  257.  
  258.     do
  259.     {
  260.       /*-----------------------------------------------------------------------*/
  261.       /* Get next item                                                         */
  262.       /*-----------------------------------------------------------------------*/
  263.  
  264.       sgml((struct ipbt *)NULL);
  265.       getscbs(SGMLSCBS, SGMLES);
  266.  
  267.       /*-----------------------------------------------------------------------*/
  268.       /* Handle the response                                                   */
  269.       /*-----------------------------------------------------------------------*/
  270.  
  271.       switch (RCBTYPE)
  272.       {
  273.  
  274.           /*===================================================================*/
  275.           /* Data found                                                        */
  276.           /*===================================================================*/
  277.  
  278.           case SGMLDAF:
  279.  
  280.             /*-----------------------------------------------------------------*/
  281.             /* Set the common data                                             */
  282.             /*-----------------------------------------------------------------*/
  283.  
  284.             te.datalen = CDATALEN;
  285.             te.data = CDATA;
  286.             rexx_set("SGML_DATA", te.data, te.datalen);
  287.  
  288.             /*-----------------------------------------------------------------*/
  289.             /* Regular data                                                    */
  290.             /*-----------------------------------------------------------------*/
  291.  
  292.             if (CDESW)
  293.             {
  294.                 rexx_set("SGML_EVENT", "CDATA", 4);
  295.                 return (TPCDATA);
  296.             }
  297.  
  298.             /*-----------------------------------------------------------------*/
  299.             /* System data                                                     */
  300.             /*-----------------------------------------------------------------*/
  301.  
  302.             if (SDESW)
  303.             {
  304.                 rexx_set("SGML_EVENT", "SDATA", 5);
  305.                 return (TPSDATA);
  306.             }
  307.  
  308.             /*-----------------------------------------------------------------*/
  309.             /* NDATA -- Requires lots of work since it can have its own list   */
  310.             /*-----------------------------------------------------------------*/
  311.  
  312.             if (NDESW)
  313.             {
  314.  
  315.                 /*-------------------------------------------------------------*/
  316.                 /* Set event type                                              */
  317.                 /*-------------------------------------------------------------*/
  318.  
  319.                 rexx_set("SGML_EVENT", "NDATA", 5);
  320.  
  321.                 /*-------------------------------------------------------------*/
  322.                 /* Initialize control blocks                                   */
  323.                 /*-------------------------------------------------------------*/
  324.  
  325.                 setndata(NEPTR);
  326.  
  327.                 /*-------------------------------------------------------------*/
  328.                 /* Set REXX stuff                                              */
  329.                 /*-------------------------------------------------------------*/
  330.  
  331.                 rexx_set("SGML_NDATA.ENAME", de.ename, de.enamelen);
  332.                 rexx_set("SGML_NDATA.SYSID", de.detxt, de.detxtlen);
  333.                 rexx_set("SGML_NDATA.DCNNM", de.dcnnm, de.dcnnmlen);
  334.                 rexx_set("SGML_NDATA.NSYS" , de.dcnid, de.dcnidlen);
  335.  
  336.                 sprintf(buffer,"%d", de.alcnt);
  337.                 rexx_set("SGML_NDATA.ALCNT", buffer, strlen(buffer));
  338.  
  339.                 /*-------------------------------------------------------------*/
  340.                 /* Build the tag stack name "SGML_NDATA.                       */
  341.                 /*-------------------------------------------------------------*/
  342.  
  343.                 strcpy(composite_name, "SGML_NDATA.");
  344.  
  345.                 /*-------------------------------------------------------------*/
  346.                 /* Set the attributes (if any)                                 */
  347.                 /*-------------------------------------------------------------*/
  348.  
  349.                 rexx_attr(te.alcnt, composite_name);
  350.  
  351.                 /*-------------------------------------------------------------*/
  352.                 /* Setup for drop                                              */
  353.                 /*-------------------------------------------------------------*/
  354.  
  355.                 strcpy(drop_me, "SGML_NDATA.");
  356.                 drop_pending = 1;
  357.  
  358.                 /*-------------------------------------------------------------*/
  359.                 /* Done                                                        */
  360.                 /*-------------------------------------------------------------*/
  361.  
  362.                 return(TPNDATA);
  363.  
  364.             }
  365.  
  366.             /*-----------------------------------------------------------------*/
  367.             /* Non GML character                                               */
  368.             /*-----------------------------------------------------------------*/
  369.  
  370.             if (*te.data==tpsw.delnonch)
  371.             {
  372.                 rexx_set("SGML_EVENT", "NON_SGML", 8);
  373.  
  374.                 te.data[0] = te.data[1] - tpsw.addnonch;
  375.                 te.data[1] = 0;
  376.  
  377.                 rexx_set("SGML_DATA", te.data, te.datalen);
  378.  
  379.                 return(TPNSGML);
  380.             }
  381.  
  382.             /*-----------------------------------------------------------------*/
  383.             /* Anything left is DATA                                           */
  384.             /*-----------------------------------------------------------------*/
  385.  
  386.             rexx_set("SGML_EVENT", "DATA", 5);
  387.             return(TPPCDATA);
  388.  
  389.           /*===================================================================*/
  390.           /* Start tag found                                                   */
  391.           /*===================================================================*/
  392.  
  393.           case SGMLSTG:
  394.  
  395.             /*-----------------------------------------------------------------*/
  396.             /* Set the event type                                              */
  397.             /*-----------------------------------------------------------------*/
  398.  
  399.             rexx_set("SGML_EVENT", "START_TAG", 9);
  400.  
  401.             /*-----------------------------------------------------------------*/
  402.             /* Left over code                                                  */
  403.             /*-----------------------------------------------------------------*/
  404.  
  405.             memcpy( &tptags[++tpts][0] , GI, (UNS)*(GI-1) ); /* Stack the GI. */
  406.  
  407.             te.data = GI;
  408.             te.datalen = *(GI-1)-2;
  409.  
  410.             /*-----------------------------------------------------------------*/
  411.             /* Set the data                                                    */
  412.             /*-----------------------------------------------------------------*/
  413.  
  414.             rexx_set("SGML_DATA", te.data, te.datalen);
  415.  
  416.             /*-----------------------------------------------------------------*/
  417.             /* Push the tag stack                                              */
  418.             /*-----------------------------------------------------------------*/
  419.  
  420.             ++tag_stack;
  421.  
  422.             /*-----------------------------------------------------------------*/
  423.             /* Tell user what level we are at                                  */
  424.             /*-----------------------------------------------------------------*/
  425.  
  426.             sprintf(buffer,"%d", tag_stack);
  427.             rexx_set("SGML_TAG_LEVEL", buffer, strlen(buffer));
  428.  
  429.             /*-----------------------------------------------------------------*/
  430.             /* Build the tag stack name "SGML_TAG.n.                           */
  431.             /*-----------------------------------------------------------------*/
  432.  
  433.             strcpy(composite_name, "SGML_TAG.");
  434.             strcat(composite_name, buffer);
  435.             strcat(composite_name, ".");
  436.  
  437.             /*-----------------------------------------------------------------*/
  438.             /* Now set the ".GI"                                               */
  439.             /*-----------------------------------------------------------------*/
  440.  
  441.             strcpy(composite_temp1, composite_name);
  442.             strcat(composite_temp1, "GI");
  443.  
  444.             rexx_set(composite_temp1, te.data, te.datalen);
  445.  
  446.             te.gidata = GIDATA;
  447.   #ifdef V2
  448.             te.format = FORMAT;
  449.   #endif
  450.  
  451.             /*-----------------------------------------------------------------*/
  452.             /* Ready the attribute stuff                                       */
  453.             /*-----------------------------------------------------------------*/
  454.  
  455.             if (ALPTR)
  456.             {                        /* Tag attributes will be processed. */
  457.                  alptr = ALPTR;      /* Tag attributes are active att list. */
  458.                  te.alcnt = AN;      /* Indicate number of attributes in list. */
  459.                  te.pca = &te.ca;    /* Current attribute structure in rcbte. */
  460.                  alset((struct ad *)0); /* Initialize for alnext processing. */
  461.             }
  462.             else
  463.                  te.alcnt = 0;
  464.  
  465.             /*-----------------------------------------------------------------*/
  466.             /* Set the attributes (if any)                                     */
  467.             /*-----------------------------------------------------------------*/
  468.  
  469.             rexx_attr(te.alcnt, composite_name);
  470.  
  471.             /*-----------------------------------------------------------------*/
  472.             /* Done with start tag                                             */
  473.             /*-----------------------------------------------------------------*/
  474.  
  475.             return(TPSTAG);
  476.  
  477.           /*===================================================================*/
  478.           /* End tag found                                                     */
  479.           /*===================================================================*/
  480.  
  481.           case SGMLETG:
  482.  
  483.             /*-----------------------------------------------------------------*/
  484.             /* Set the event type                                              */
  485.             /*-----------------------------------------------------------------*/
  486.  
  487.             rexx_set("SGML_EVENT", "END_TAG", 7);
  488.  
  489.             /*-----------------------------------------------------------------*/
  490.             /* Left over code                                                  */
  491.             /*-----------------------------------------------------------------*/
  492.  
  493.             --tpts;             /* Destack the GI. */
  494.             te.data = GI;
  495.             te.datalen = *(GI-1)-2;
  496.             te.gidata = GIDATA;
  497.   #ifdef V2
  498.             te.format = FORMAT;
  499.   #endif
  500.  
  501.             /*-----------------------------------------------------------------*/
  502.             /* Set the data                                                    */
  503.             /*-----------------------------------------------------------------*/
  504.  
  505.             rexx_set("SGML_DATA", te.data, te.datalen);
  506.  
  507.             /*-----------------------------------------------------------------*/
  508.             /* Pop the REXX tag stack                                          */
  509.             /*-----------------------------------------------------------------*/
  510.  
  511.             --tag_stack;
  512.  
  513.             /*-----------------------------------------------------------------*/
  514.             /* Tell user what level we are at                                  */
  515.             /*-----------------------------------------------------------------*/
  516.  
  517.             sprintf(buffer,"%d", tag_stack);
  518.             rexx_set("SGML_TAG_LEVEL", buffer, strlen(buffer));
  519.  
  520.             /*-----------------------------------------------------------------*/
  521.             /* Build the tag stack name "SGML_TAG.n.                           */
  522.             /*-----------------------------------------------------------------*/
  523.  
  524.             strcpy(drop_me, "SGML_TAG.");
  525.             strcat(drop_me, buffer);
  526.             strcat(drop_me, ".");
  527.  
  528.             /*-----------------------------------------------------------------*/
  529.             /* Set drop pending                                                */
  530.             /*-----------------------------------------------------------------*/
  531.  
  532.             drop_pending = 1;
  533.  
  534.             /*-----------------------------------------------------------------*/
  535.             /* Done                                                            */
  536.             /*-----------------------------------------------------------------*/
  537.  
  538.             return(TPETAG);
  539.  
  540.           /*===================================================================*/
  541.           /* Processing instruction: string                                    */
  542.           /*===================================================================*/
  543.  
  544.           case SGMLPIS:
  545.  
  546.             rexx_set("SGML_EVENT", "PI", 2);
  547.  
  548.             te.datalen = PDATALEN;
  549.             te.data = PDATA;
  550.  
  551.             rexx_set("SGML_DATA", te.data, te.datalen);
  552.  
  553.             return(PIESW ? TPPIENT : TPPI);
  554.  
  555.           /*===================================================================*/
  556.           /* Record end                                                        */
  557.           /*===================================================================*/
  558.  
  559.           case SGMLREF:
  560.  
  561.             rexx_set("SGML_EVENT", "RE", 2);
  562.  
  563.             return(TPRE);
  564.  
  565.           /*===================================================================*/
  566.           /* Document type definition started                                  */
  567.           /* Document type definition ended                                    */
  568.           /* Markup validator info                                             */
  569.           /*      These are all ignored                                        */
  570.           /*===================================================================*/
  571.  
  572.           case SGMLSDTD:
  573.           case SGMLEDTD:
  574.           case SGMLMV:
  575.                 break;  /* Ignore'em */
  576.           /*===================================================================*/
  577.           /* End document                                                      */
  578.           /*===================================================================*/
  579.  
  580.        case SGMLEOD:
  581.  
  582.             rexx_set("SGML_EVENT", "EOD", 3);
  583.  
  584.      }
  585.  
  586.    } while (RCBTYPE != SGMLEOD);
  587.      return(TPEOD);           /* Avoid lint and TurboC warnings. */
  588. }
  589.  
  590. /*===========================================================================*/
  591. /* REXX_ATTR -- Put an attribute list to REXX                                */
  592. /*===========================================================================*/
  593.  
  594. VOID rexx_attr(int at_counter,
  595.                char *root_name)
  596. {
  597.  
  598.     char buffer[10];
  599.     char composite_temp[50];
  600.     int  composite_reset;
  601.     int  end_root;
  602.     int  i;
  603.     int  j;
  604.     char *blank_me;
  605.  
  606.     end_root = strlen(root_name);
  607.  
  608.     /*-----------------------------------------------------------------------*/
  609.     /* Set the attribute count                                               */
  610.     /*-----------------------------------------------------------------------*/
  611.  
  612.     strcpy(composite_temp, root_name);
  613.     strcat(composite_temp, "ALCNT");
  614.  
  615.     sprintf(buffer,"%d", at_counter);
  616.     rexx_set(composite_temp, buffer, strlen(buffer));
  617.  
  618.     composite_temp[end_root] = '\0';
  619.  
  620.     /*-----------------------------------------------------------------------*/
  621.     /* Clear attribute list                                                  */
  622.     /*-----------------------------------------------------------------------*/
  623.  
  624.     alist[0] = '\0';
  625.  
  626.     /*-----------------------------------------------------------------------*/
  627.     /* Attribute loop                                                        */
  628.     /*-----------------------------------------------------------------------*/
  629.  
  630.     while (at_counter > 0)
  631.     {
  632.  
  633.         /*-------------------------------------------------------------------*/
  634.         /* Decrement the counter                                             */
  635.         /*-------------------------------------------------------------------*/
  636.  
  637.         --at_counter;
  638.  
  639.         /*-------------------------------------------------------------------*/
  640.         /* Get the attribute data                                            */
  641.         /*-------------------------------------------------------------------*/
  642.  
  643.         alnext();
  644.  
  645.         /*-------------------------------------------------------------------*/
  646.         /* Stick name on the end of the attribute list                       */
  647.         /*-------------------------------------------------------------------*/
  648.  
  649.         strncat(alist, CA.aname, CA.anamelen);
  650.         strncat(alist, " ", 1);
  651.  
  652.         /*-------------------------------------------------------------------*/
  653.         /* Build the composite name                                          */
  654.         /*-------------------------------------------------------------------*/
  655.  
  656.         composite_temp[end_root] = '\0';
  657.         strncat(composite_temp, CA.aname, CA.anamelen);
  658.  
  659.         /*-------------------------------------------------------------------*/
  660.         /* Save end of the composite name.  Makes it easy to clean up        */
  661.         /*-------------------------------------------------------------------*/
  662.  
  663.         composite_reset = strlen(composite_temp);
  664.  
  665.         /*-------------------------------------------------------------------*/
  666.         /* Fix up value if a list                                            */
  667.         /*-------------------------------------------------------------------*/
  668.  
  669.         if (CA.atype == TPALIST)
  670.         {
  671.  
  672.             blank_me  = CA.aval;
  673.  
  674.             i = CA.avallen;
  675.  
  676.             while (i > 0)
  677.             {
  678.                 j = *blank_me + 1;
  679.                 *blank_me = ' ';
  680.                 blank_me = blank_me + j;
  681.                 i = i - j;
  682.             }
  683.  
  684.             ++CA.aval;
  685.             --CA.avallen;
  686.  
  687.         }
  688.  
  689.         /*-------------------------------------------------------------------*/
  690.         /* Set the VALUE                                                     */
  691.         /*-------------------------------------------------------------------*/
  692.  
  693.         strcat(composite_temp, ".VALUE");
  694.  
  695.         rexx_set(composite_temp, CA.aval, CA.avallen);
  696.  
  697.         composite_temp[composite_reset] = 0;
  698.  
  699.         /*-------------------------------------------------------------------*/
  700.         /* Set the DATA                                                      */
  701.         /*-------------------------------------------------------------------*/
  702.  
  703.         switch(CA.adata)
  704.         {
  705.  
  706.             case TPANOTE:
  707.               strcpy(buffer, "NOTE");
  708.               break;
  709.  
  710.             case TPAENTIT:
  711.               strcpy(buffer, "ENTITY");
  712.               break;
  713.  
  714.             case TPAIDREF:
  715.               strcpy(buffer, "IDREF");
  716.               break;
  717.  
  718.             case TPANONE:
  719.               strcpy(buffer, "NONE");
  720.               break;
  721.  
  722.             default:
  723.               strcpy(buffer, "?");
  724.               break;
  725.  
  726.         }
  727.  
  728.         strcat(composite_temp, ".DATA");
  729.  
  730.         rexx_set(composite_temp, buffer, strlen(buffer));
  731.  
  732.         composite_temp[composite_reset] = '\0';
  733.  
  734.         /*-------------------------------------------------------------------*/
  735.         /* Set the TYPE                                                      */
  736.         /*-------------------------------------------------------------------*/
  737.  
  738.         switch(CA.atype)
  739.         {
  740.             case TPACDATA:
  741.               strcpy(buffer, "CDATA");
  742.               break;
  743.  
  744.             case TPATOKEN:
  745.               strcpy(buffer, "TOKEN");
  746.               break;
  747.  
  748.             case TPALIST:
  749.               strcpy(buffer, "LIST");
  750.               break;
  751.  
  752.             default:
  753.               strcpy(buffer, "?");
  754.               break;
  755.  
  756.         }
  757.  
  758.         strcat(composite_temp, ".TYPE");
  759.  
  760.         rexx_set(composite_temp, buffer, strlen(buffer));
  761.  
  762.         composite_temp[composite_reset] = '\0';
  763.  
  764.         /*-------------------------------------------------------------------*/
  765.         /* Set the status                                                    */
  766.         /*-------------------------------------------------------------------*/
  767.  
  768.         switch(CA.astatus)
  769.         {
  770.             case TPANOREQ:
  771.               strcpy(buffer, "NOREQ");
  772.               break;
  773.  
  774.             case TPAIMPLY:
  775.               strcpy(buffer, "IMPLY");
  776.               break;
  777.  
  778.             case TPAINVAL:
  779.               strcpy(buffer, "INVAL");
  780.               break;
  781.  
  782.             case TPAERROR:
  783.               strcpy(buffer, "ERROR");
  784.               break;
  785.  
  786.             case TPAOK:
  787.               strcpy(buffer, "OK");
  788.               break;
  789.  
  790.             default:
  791.               strcpy(buffer, "?");
  792.               break;
  793.  
  794.         }
  795.  
  796.         strcat(composite_temp, ".STATUS");
  797.  
  798.         rexx_set(composite_temp, buffer, strlen(buffer));
  799.  
  800.         composite_temp[composite_reset] = '\0';
  801.  
  802.         /*-------------------------------------------------------------------*/
  803.         /* Set the DCNID                                                     */
  804.         /*-------------------------------------------------------------------*/
  805.  
  806.         if (CA.atype == TPANOTE)
  807.         {
  808.             strcat(composite_temp, ".DCNID");
  809.  
  810.             rexx_set(composite_temp, CA.dcnid, CA.dcnidlen);
  811.  
  812.             composite_temp[composite_reset] = '\0';
  813.         }
  814.  
  815.     }   /*----- End attribute loop ------------------------------------------*/
  816.  
  817.     /*-----------------------------------------------------------------------*/
  818.     /* set the attribute list                                                */
  819.     /*-----------------------------------------------------------------------*/
  820.  
  821.     composite_temp[end_root] = '\0';
  822.  
  823.     strcat(composite_temp, "ALIST");
  824.  
  825.     i = strlen(alist);
  826.     if (i > 0)
  827.       --i;
  828.  
  829.     rexx_set(composite_temp, alist, i);
  830.  
  831. }
  832.  
  833. /*****************************************************************************/
  834. /* Set a rexx variable                                                       */
  835. /* Drop a rexx variable                                                      */
  836. /*                                                                           */
  837. /* Author:  Roy Engehausen                                                   */
  838. /* Mods:    Jack Steitz      1. Bring code to ANSI Standard                  */
  839. /*                                                                           */
  840. /*                                                                           */
  841. /*****************************************************************************/
  842.  
  843. /*===========================================================================*/
  844. /* External files                                                            */
  845. /*===========================================================================*/
  846.  
  847. #include <dos.h>
  848. #pragma option -a-            /* Borland C: force byte alignment */
  849. #include "rexxcall.h"
  850. #pragma option -a.            /* Borland C: restore previous alignment */
  851.  
  852. #ifdef __SMALL__  /* small model */
  853. #define FINDINT findints
  854. #endif
  855. #ifdef __MEDIUM__  /* medium model */
  856. #define FINDINT findintm
  857. #endif
  858. #ifdef __LARGE__  /* large model */
  859. #define FINDINT findintl
  860. #endif
  861.  
  862. int FINDINT(int *);
  863.  
  864. void error_rexx(char *);
  865.  
  866. /*===========================================================================*/
  867. /* REXX_SET                                                                  */
  868. /*===========================================================================*/
  869.  
  870. void rexx_set(char * var_name,
  871.               char * var_value,
  872.               int    var_length)
  873.  
  874.   {
  875.  
  876.     /*-----------------------------------------------------------------------*/
  877.     /* Local Variables                                                       */
  878.     /*-----------------------------------------------------------------------*/
  879.  
  880.     struct shvblock   sb, *sbp = &sb;
  881.     union   REGS  inregs, outregs;
  882.     struct  SREGS segregs;
  883.     int     interrupt_status;
  884.     int     rexx_interrupt;
  885.  
  886.     rexx_interrupt = FINDINT(&interrupt_status);
  887.     if (interrupt_status != 0) error_rexx("RXINTMGR not installed.\n");
  888.  
  889.     inregs.h.ah = REXX_VERSION;
  890.     inregs.h.al = 0;
  891.     int86(rexx_interrupt, &inregs, &outregs);
  892.     if (outregs.h.al == 0) error_rexx("REXX not loaded\n");
  893.  
  894.     segread(&segregs);
  895.  
  896.     /*-----------------------------------------------------------------------*/
  897.     /* Initialize block                                                      */
  898.     /*-----------------------------------------------------------------------*/
  899.  
  900.     memset(&sb, 0, sizeof(struct shvblock));
  901.  
  902.     sb.shvcode = SHVSET;
  903.  
  904.     sb.shvnext_addr = 0;
  905.  
  906.     sb.shvnam_addr = var_name;
  907.     sb.shvnaml     = strlen(var_name);
  908.  
  909.     sb.shvvall = var_length;
  910.     sb.shvbufl = var_length;
  911.  
  912.     sb.shvval_addr = var_value;
  913.  
  914.     inregs.h.ah = REXX_SHV;
  915. #ifdef __LARGE__    /* predefined by Borland c if large model */
  916.     inregs.x.bx = FP_SEG(sbp);
  917.     inregs.x.dx = FP_OFF(sbp);
  918. #else       /* medium or small model */
  919.     inregs.x.bx = segregs.ds;
  920.     inregs.x.dx = (unsigned) sbp;
  921. #endif
  922.     int86x(rexx_interrupt, &inregs, &outregs, &segregs);
  923.  
  924.   }
  925.  
  926. /*===========================================================================*/
  927. /* REXX_DROP                                                                 */
  928. /*===========================================================================*/
  929.  
  930. void rexx_drop(char * var_name)
  931.  
  932.   {
  933.  
  934.     /*-----------------------------------------------------------------------*/
  935.     /* Local Variables                                                       */
  936.     /*-----------------------------------------------------------------------*/
  937.  
  938.     struct shvblock   sb, *sbp = &sb;
  939.     union   REGS  inregs, outregs;
  940.     struct  SREGS segregs;
  941.     int     interrupt_status;
  942.     int     rexx_interrupt;
  943.  
  944.     rexx_interrupt = FINDINT(&interrupt_status);
  945.     if (interrupt_status != 0) error_rexx("RXINTMGR not installed.\n");
  946.  
  947.     inregs.h.ah = REXX_VERSION;
  948.     inregs.h.al = 0;
  949.     int86(rexx_interrupt, &inregs, &outregs);
  950.     if (outregs.h.al == 0) error_rexx("REXX not loaded\n");
  951.  
  952.     segread(&segregs);
  953.  
  954.     /*-----------------------------------------------------------------------*/
  955.     /* Initialize block                                                      */
  956.     /*-----------------------------------------------------------------------*/
  957.  
  958.     memset(&sb, 0, sizeof(struct shvblock));
  959.  
  960.     sb.shvcode = SHVDROPV;
  961.  
  962.     sb.shvnext_addr = 0;
  963.  
  964.     sb.shvnam_addr = var_name;
  965.     sb.shvnaml     = strlen(var_name);
  966.  
  967.     inregs.h.ah = REXX_SHV;
  968. #ifdef __LARGE__    /* predefined by Borland C if large model */
  969.     inregs.x.bx = FP_SEG(sbp);
  970.     inregs.x.dx = FP_OFF(sbp);
  971. #else       /* medium or small model */
  972.     inregs.x.bx = segregs.ds;
  973.     inregs.x.dx = (unsigned) sbp;
  974. #endif
  975.     int86x(rexx_interrupt, &inregs, &outregs, &segregs);
  976.  
  977.   }
  978.  
  979. /* Display error message and exit (similar to CI 86 abort() function) */
  980. void error_rexx(char *s)
  981.   {
  982.     printf("ABORT:- %s\n",s);
  983.     exit(255);
  984.   }
  985. /******************************************************************************/
  986. #include "sgmlsubs.c"         /* Subroutines for SGML API. */
  987. /******************************************************************************/
  988.