Annotation of parser3/src/include/pa_charset_connection.h, revision 1.1
1.1 ! parser 1: /** @file
! 2: Parser: Charset connection decl.
! 3:
! 4: Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
! 5: Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
! 6:
! 7: $Id: pa_stylesheet_connection.h,v 1.6 2001/09/28 15:58:26 parser Exp $
! 8: */
! 9:
! 10: #ifndef PA_CHARSET_CONNECTION_H
! 11: #define PA_CHARSET_CONNECTION_H
! 12:
! 13: #include "pcre.h"
! 14: # include "internal.h"
! 15:
! 16: #include "pa_config_includes.h"
! 17: #include "pa_pool.h"
! 18: #include "pa_exception.h"
! 19: #include "pa_common.h"
! 20:
! 21: // defines
! 22:
! 23: /** Connection with charset file:
! 24: remembers time and can figure out that it needs recompilation
! 25: */
! 26: class Charset_connection : public Pooled {
! 27: public:
! 28:
! 29: Charset_connection(Pool& pool, const String& aname, const String& afile_spec) : Pooled(pool),
! 30: fname(aname),
! 31: ffile_spec(afile_spec),
! 32: prev_disk_time(0) {
! 33: }
! 34:
! 35: // const String& file_spec() { return ffile_spec; }
! 36:
! 37: void up_to_date(Pool& pool) {
! 38: time_t new_disk_time=get_new_disk_time();
! 39: if(new_disk_time)
! 40: load(pool, new_disk_time);
! 41: }
! 42:
! 43: unsigned char *pcre_tables() { return fpcre_tables; }
! 44:
! 45: private:
! 46:
! 47: time_t get_new_disk_time() {
! 48: time_t now_disk_time=get_disk_time();
! 49: return now_disk_time>prev_disk_time?now_disk_time:0;
! 50: }
! 51:
! 52: void load(Pool& pool, time_t new_disk_time);
! 53:
! 54: time_t get_disk_time() {
! 55: size_t size;
! 56: time_t atime, mtime, ctime;
! 57: // {file_spec} modification time
! 58: if(!file_stat(ffile_spec,
! 59: size,
! 60: atime, mtime, ctime,
! 61: false/*no exception on global pool[ffile_spec], please*/))
! 62: mtime=1; //no file=pseudo non-zero time, see get_new_disk_time
! 63: return mtime;
! 64: }
! 65:
! 66: private:
! 67:
! 68: const String& fname;
! 69: const String& ffile_spec;
! 70: time_t prev_disk_time;
! 71:
! 72: unsigned char fpcre_tables[tables_length];
! 73: };
! 74:
! 75: #endif
E-mail: