From 950d8f4593e0d3b4802dd0db39fcc8fe5872e7a6 Mon Sep 17 00:00:00 2001 From: Amos Jeffries Date: Tue, 10 Dec 2013 07:02:19 -0800 Subject: [PATCH] Add parser/libsquid-parser.la Also, basic class CharacterSet definition --- configure.ac | 1 + src/Makefile.am | 5 +++-- src/parser/CharacterSet.h | 40 +++++++++++++++++++++++++++++++++++++++ src/parser/Makefile.am | 6 ++++++ 4 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 src/parser/CharacterSet.h create mode 100644 src/parser/Makefile.am diff --git a/configure.ac b/configure.ac index d238d694bc..2e956d232a 100644 --- a/configure.ac +++ b/configure.ac @@ -3425,6 +3425,7 @@ AC_CONFIG_FILES([\ src/ipc/Makefile \ src/ssl/Makefile \ src/mgr/Makefile \ + src/parser/Makefile \ src/snmp/Makefile \ contrib/Makefile \ snmplib/Makefile \ diff --git a/src/Makefile.am b/src/Makefile.am index 12f19f1352..fee975dd54 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -30,8 +30,8 @@ LOADABLE_MODULES_SOURCES = \ LoadableModules.h \ LoadableModules.cc -SUBDIRS = base anyp comm eui acl format fs repl -DIST_SUBDIRS = base anyp comm eui acl format fs repl +SUBDIRS = base anyp parser comm eui acl format fs repl +DIST_SUBDIRS = base anyp parser comm eui acl format fs repl if ENABLE_AUTH SUBDIRS += auth @@ -636,6 +636,7 @@ squid_LDADD = \ $(ESI_LIBS) \ $(SSL_LIBS) \ $(SNMP_LIBS) \ + parser/libsquid-parser.la \ $(top_builddir)/lib/libmisccontainers.la \ $(top_builddir)/lib/libmiscencoding.la \ $(top_builddir)/lib/libmiscutil.la \ diff --git a/src/parser/CharacterSet.h b/src/parser/CharacterSet.h new file mode 100644 index 0000000000..0b0207ef7c --- /dev/null +++ b/src/parser/CharacterSet.h @@ -0,0 +1,40 @@ +#ifndef _SQUID_SRC_PARSER_CHARACTERSET_H +#define _SQUID_SRC_PARSER_CHARACTERSET_H + +#include + +namespace Parser { + +class CharacterSet +{ +public: + CharacterSet(const char *label, const char * const c) : name_(label) { + memset(match_, 0, sizeof(match_)); + const size_t = strlen(c); + for (size_t i = 0; i < len; ++i) { + match_[static_cast(c)] = true; + } + } + + /// whether a given character exists in the set + bool operator[](char t) const {return match_[static_cast(c)];} + + void add(const char c) {match_[static_cast(c)] = true;} + + /// add all characters from the given CharacterSet to this one + const CharacterSet &operator +=(const CharacterSet &src) { + for (size_t i = 0; i < 256; ++i) { + if(src.match_[i]) + match_[i] = true; + } + return *this; + } + +private: + char * name_; + std::map chars_; +}; + +} // namespace Parser + +#endif /* _SQUID_SRC_PARSER_CHARACTERSET_H */ diff --git a/src/parser/Makefile.am b/src/parser/Makefile.am new file mode 100644 index 0000000000..e877f0bece --- /dev/null +++ b/src/parser/Makefile.am @@ -0,0 +1,6 @@ +include $(top_srcdir)/src/Common.am + +noinst_LTLIBRARIES = libsquid-parser.la + +libsquid_parser_la_SOURCES = \ + CharacterSet.h -- 2.47.3