Logo Search packages:      
Sourcecode: rapple version File versions  Download package

rpl_wk_status rpl_mod_link_cleanup ( void   ) 

Release resources (and transform XML report into HTML) held during processing.

Definition at line 329 of file mod_link.c.

References rpl_cfg_get_linkchecker_html_report(), rpl_cfg_get_linkchecker_xml_report(), rpl_cfg_get_linkchecker_xslt(), rpl_cfg_get_trf_catalog(), rpl_fs_f2str(), rpl_fs_str2f(), rpl_log_error(), rpl_log_fatal(), rpl_log_warn(), rpl_me_free(), and rpl_message_get().

Referenced by rpl_mod_link_configure().

{
      rpl_wk_status status = RPL_WK_OK;
      rpl_str_t xslt = NULL, input;

#if SUPPORT_XSLT_PROC == 1
      /* define Sablot variables */
      SablotSituation situation;
      SablotHandle proc;
      SDOM_Document xml, xsl;
      int sablotronFlags;
      rpl_str_t output;
#elif SUPPORT_XSLT_PROC == 2
      static xsltStylesheetPtr cur;
      rpl_c_str_t catalog_loc;
      xmlDocPtr doc, res = NULL;
      rpl_str_t msg;
      FILE *fp;
#endif

      if(process_flag) 
      {
            /* acquire XSLT file and input */
            fprintf(xml_rpt_fp,"%s", RPL_MOD_LINK_TRL);
            fclose(xml_rpt_fp);
            input = rpl_fs_f2str(rpl_cfg_get_linkchecker_xml_report());

#if SUPPORT_XSLT_PROC == 1
            xslt = rpl_fs_f2str(rpl_cfg_get_linkchecker_xslt());
            /* prepare input and stylehseet for processing */
            SablotCreateSituation(&situation);
            SablotParseStylesheetBuffer(situation, xslt, &xsl);
            SablotParseBuffer(situation, input, &xml);
            SablotCreateProcessorForSituation(situation,&proc);
            SablotAddArgTree(situation, proc, RPL_MOD_LINK_SABLOT_XSLT, xsl);
            SablotAddArgTree(situation, proc, RPL_MOD_LINK_SABLOT_DATA, xml);

            sablotronFlags = SablotGetOptions (situation);
            sablotronFlags |= SAB_PARSE_PUBLIC_ENTITIES;
            SablotSetOptions (situation, sablotronFlags);

            /* perform transformation */
            SablotRunProcessorGen(situation, proc, RPL_MOD_LINK_SABLOT_ARG_XSLT, RPL_MOD_LINK_SABLOT_ARG_DATA, 
                                                      RPL_MOD_LINK_SABLOT_ARG_OUT);
            SablotGetResultArg(proc, RPL_MOD_LINK_SABLOT_ARG_OUT, &output);
            rpl_fs_str2f(output, rpl_cfg_get_linkchecker_html_report());

            /* free resources */
            SablotDestroyDocument(situation, xml);
            SablotDestroyDocument(situation, xsl);
            SablotDestroyProcessor(proc);
            SablotDestroySituation(situation);
            rpl_me_free(output);

#elif SUPPORT_XSLT_PROC == 2

            /* attempt to identify the catalog location */
            catalog_loc = (rpl_cfg_get_trf_catalog()) ?  rpl_cfg_get_trf_catalog() : getenv("XML_CATALOG_FILES");
            if(catalog_loc == NULL)
            {
                  msg = rpl_message_get("XML_CATALOG_DEFAULT", RPL_EOM);
                  rpl_log_warn(msg);
            } else {
                  xmlLoadCatalogs(catalog_loc);
            }

            /* set up libxslt internals */
            xmlSubstituteEntitiesDefault(1);
            xmlLoadExtDtdDefaultValue = 1;

            /* perform xsltlib operations */
            if((cur = xsltParseStylesheetFile((const xmlChar *) rpl_cfg_get_linkchecker_xslt())) == NULL)
            {
                  msg = rpl_message_get("XSLT_STYLESHEET_PARSE_FAILED", xslt, RPL_EOM);
                  rpl_log_fatal(msg);
            }

            if((doc = xmlParseMemory(input, strlen(input))) == NULL)
            {
                  msg = rpl_message_get("XSLT_INPUT_PARSE_FAILED", input, RPL_EOM);
                  rpl_log_error(msg);

                  return -1;
            }
            res = xsltApplyStylesheet(cur, doc, NULL);
            /* xsltSaveResultToString((xmlChar **)&output, &out_size, res, cur); */
            if((fp = fopen(rpl_cfg_get_linkchecker_html_report(), "wb")) == NULL)
                  return RPL_WK_ERR;
            xsltSaveResultToFile(fp, res, cur);

            /*
               xmlFreeDoc(res);
               xmlFreeDoc(doc);
             */
            xsltFreeStylesheet(cur);
            xsltCleanupGlobals();
            xmlCleanupParser();
#endif

            /* release string resources 
               rpl_me_free(rpl_link_base_dir);
             */
      }

      return status;
}


Generated by  Doxygen 1.6.0   Back to index