Annotation of parser3/src/main/pa_stylesheet_connection.C, revision 1.14
1.1 paf 1: /** @file
2: Parser: Stylesheet connection implementation.
3:
1.14 ! moko 4: Copyright (c) 2001-2023 Art. Lebedev Studio (http://www.artlebedev.com)
! 5: Authors: Konstantin Morshnev <moko@design.ru>, Alexandr Petrosian <paf@design.ru>
1.1 paf 6: */
7:
1.2 paf 8: #include "pa_config_includes.h"
9: #ifdef XML
1.1 paf 10:
11: #include "pa_stylesheet_connection.h"
12: #include "pa_xml_exception.h"
13:
1.14 ! moko 14: volatile const char * IDENT_PA_STYLESHEET_CONNECTION_C="$Id: pa_stylesheet_connection.C,v 1.13 2020/12/15 17:10:37 moko Exp $" IDENT_PA_STYLESHEET_CONNECTION_H;
1.7 moko 15:
1.1 paf 16: void Stylesheet_connection::load(time_t new_disk_time) {
17: xsltStylesheet *nstylesheet;
18: {
1.12 moko 19: dependencies=pa_xmlStartMonitoringDependencies(); // just to reference TLS variable
1.1 paf 20: {
1.12 moko 21: int saved=xmlDoValidityCheckingDefaultValue;
22: xmlDoValidityCheckingDefaultValue=0;
1.1 paf 23: nstylesheet=xsltParseStylesheetFile(BAD_CAST ffile_spec.cstr());
1.12 moko 24: xmlDoValidityCheckingDefaultValue = saved;
1.1 paf 25: }
26: dependencies=pa_xmlGetDependencies();
27: }
1.4 paf 28: if(xmlHaveGenericErrors())
1.8 moko 29: throw XmlException(new String(ffile_spec, String::L_TAINTED), pa_thread_request());
1.1 paf 30: if(!nstylesheet)
1.12 moko 31: throw Exception("file.missing", new String(ffile_spec, String::L_TAINTED), "stylesheet failed to load");
1.1 paf 32:
1.12 moko 33: xsltFreeStylesheet(fstylesheet);
1.1 paf 34: fstylesheet=nstylesheet;
1.12 moko 35: prev_disk_time=new_disk_time; // note: 0 for the first fime, cache works only from second hit
1.1 paf 36: }
37:
1.6 misha 38: static void update_max_mtime(HashStringValue::key_type stat_file_spec_cstr, bool /*value*/, time_t* max) {
1.10 moko 39: uint64_t size;
1.1 paf 40: time_t atime, mtime, ctime;
1.10 moko 41: file_stat(*new String(stat_file_spec_cstr, String::L_AS_IS), size, atime, mtime, ctime, true/*exception on error*/);
1.1 paf 42:
43: if(mtime>*max)
44: *max=mtime;
45: }
46:
47: time_t Stylesheet_connection::get_disk_time() {
48: assert(dependencies);
49:
50: time_t result=0;
1.5 paf 51: dependencies->for_each<time_t*>(update_max_mtime, &result);
1.1 paf 52: return result;
53: }
1.2 paf 54:
55: #endif
E-mail: