]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Cleanup: Split some enums into their own files. auto-generate their text name arrays.
authorAmos Jeffries <squid3@treenet.co.nz>
Sun, 23 Aug 2009 05:13:09 +0000 (17:13 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Sun, 23 Aug 2009 05:13:09 +0000 (17:13 +1200)
Also updates the enum strings generator to work with any given header file.
The header does however need to be named identical to the enum and not pull
in any other definitions that require .cc content. The generated .cc will
only contain the minimal includes and enum string array global.

24 files changed:
configure.in
src/HierarchyLogEntry.h
src/Makefile.am
src/StoreSwapLogData.cc
src/access_log.cc
src/acl/Gadgets.h
src/acl/HierCodeData.cc
src/enums.h
src/err_type.h [new file with mode: 0644]
src/fs/ufs/store_dir_ufs.cc
src/fs/ufs/ufscommon.cc
src/globals.h
src/hier_code.cc [deleted file]
src/hier_code.h
src/icp_opcode.h [new file with mode: 0644]
src/mk-string-arrays.awk
src/neighbors.cc
src/peer_select.cc
src/protos.h
src/store.cc
src/store_dir.cc
src/store_swapout.cc
src/structs.h
src/swap_log_op.h [new file with mode: 0644]

index 27fc8ab765cb861c1c5ddcc3a08fe80efc00ba7b..1fbd66d2af535733542b8fca661e28121778d6ce 100644 (file)
@@ -34,7 +34,7 @@ new_configure_args="$ac_configure_args --with-squid=$ac_abs_confdir"
 ac_configure_args="$new_configure_args"
 
 
-use_loadable_modules=1
+use_loadable_modules=0
 AC_MSG_CHECKING(whether to use loadable modules)
 AC_ARG_ENABLE(loadable-modules,
     AS_HELP_STRING([--disable-loadable-modules],[do not support loadable modules]) ,
@@ -51,6 +51,7 @@ AC_ARG_ENABLE(loadable-modules,
         AC_MSG_RESULT([$use_loadable_modules, implicitly])
     ]
 )
+use_loadable_modules=0
 
 AM_CONDITIONAL(USE_LOADABLE_MODULES, test $use_loadable_modules = yes)
 
index 4617b26d384cb822579898a56ad2a87c0e5d5aeb..9284c69955aba2e59203b8a48cad97cf8189b06a 100644 (file)
 #define SQUID_HTTPHIERARCHYLOGENTRY_H
 
 #include "hier_code.h"
+#include "lookup_t.h"
 #include "rfc2181.h"
 #include "PingData.h"
 
-/* for lookup_t and http_status */
+/* for http_status */
 #include "enums.h"
 
 class HierarchyLogEntry
index 906cfc7ae515b3dcb5cde63ac11820ec834528ae..ecc1e1038e61018b64c724aa4a0171008bacee93 100644 (file)
@@ -229,31 +229,6 @@ DiskIO/DiskIOModules_gen.cc: Makefile
        $(SHELL) $(srcdir)/DiskIO/modules.sh $(DISK_MODULES) > DiskIO/DiskIOModules_gen.cc
 
 
-EXTRA_squid_SOURCES = \
-       $(AIO_WIN32_ALL_SOURCES) \
-       $(all_AUTHMODULES) \
-       ConfigOption.h \
-       $(DELAY_POOL_ALL_SOURCE) \
-       dns.cc \
-       dnsserver.cc \
-       dns_internal.cc \
-       DnsLookupDetails.cc \
-       DnsLookupDetails.h \
-       htcp.cc \
-       htcp.h \
-       ipc.cc \
-       ipc_win32.cc \
-       ProfStats.cc \
-       LeakFinder.cc \
-       LeakFinder.h \
-       $(SNMP_ALL_SOURCE) \
-       $(UNLINKDSOURCE) \
-       $(SSL_ALL_SOURCE) \
-       $(WIN32_ALL_SOURCE) \
-       $(LOADABLE_MODULES_SOURCES) \
-       DiskIO/DiskThreads/aiops.cc \
-       DiskIO/DiskThreads/aiops_win32.cc
-
 squid_COMMSOURCES = \
        comm_select.cc \
        comm_select.h \
@@ -330,6 +305,7 @@ squid_SOURCES = \
        dlink.cc \
        $(DNSSOURCE) \
        enums.h \
+       err_type.h \
        errorpage.cc \
        errorpage.h \
        ETag.cc \
@@ -355,7 +331,6 @@ squid_SOURCES = \
        helper.cc \
        helper.h \
        hier_code.h \
-       hier_code.cc \
        HierarchyLogEntry.h \
        $(HTCPSOURCE) \
        http.cc \
@@ -386,6 +361,7 @@ squid_SOURCES = \
        HttpRequestMethod.h \
        HttpVersion.h \
        ICP.h \
+       icp_opcode.h \
        icp_v2.cc \
        icp_v3.cc \
        int.cc \
@@ -395,6 +371,7 @@ squid_SOURCES = \
        $(LEAKFINDERSOURCE) \
        list.cc \
        logfile.cc \
+       lookup_t.h \
        main.cc \
        mem.cc \
        mem_node.cc \
@@ -477,6 +454,7 @@ squid_SOURCES = \
        Server.cc \
        Server.h \
        structs.h \
+       swap_log_op.h \
        SwapDir.cc \
        SwapDir.h \
        time.cc \
@@ -498,6 +476,31 @@ squid_SOURCES = \
        $(WIN32_SOURCE) \
        $(WINSVC_SOURCE)
 
+EXTRA_squid_SOURCES = \
+       $(AIO_WIN32_ALL_SOURCES) \
+       $(all_AUTHMODULES) \
+       ConfigOption.h \
+       $(DELAY_POOL_ALL_SOURCE) \
+       dns.cc \
+       dnsserver.cc \
+       dns_internal.cc \
+       DnsLookupDetails.cc \
+       DnsLookupDetails.h \
+       htcp.cc \
+       htcp.h \
+       ipc.cc \
+       ipc_win32.cc \
+       ProfStats.cc \
+       LeakFinder.cc \
+       LeakFinder.h \
+       $(SNMP_ALL_SOURCE) \
+       $(UNLINKDSOURCE) \
+       $(SSL_ALL_SOURCE) \
+       $(WIN32_ALL_SOURCE) \
+       $(LOADABLE_MODULES_SOURCES) \
+       DiskIO/DiskThreads/aiops.cc \
+       DiskIO/DiskThreads/aiops_win32.cc
+
 noinst_HEADERS = \
        client_side_request.cci \
        MemBuf.cci \
@@ -508,12 +511,22 @@ noinst_HEADERS = \
        SquidString.h \
        SquidTime.h
 
-nodist_squid_SOURCES = \
-       $(DISKIO_GEN_SOURCE) \
-       repl_modules.cc \
+BUILT_SOURCES = \
+       cf_gen_defines.h \
        cf_parser.h \
+       err_type.cc \
        globals.cc \
-       string_arrays.c
+       hier_code.cc \
+       icp_opcode.cc \
+       lookup_t.cc \
+       repl_modules.cc \
+       swap_log_op.cc
+
+CLEANFILES += $(BUILT_SOURCES)
+
+nodist_squid_SOURCES = \
+       $(DISKIO_GEN_SOURCE) \
+       $(BUILT_SOURCES)
 
 squid_LDADD = \
        $(COMMON_LIBS) \
@@ -629,13 +642,6 @@ ufsdump_DEPENDENCIES = $(top_builddir)/lib/libmiscutil.a \
 nodist_ufsdump_SOURCES = \
        globals.cc
 
-BUILT_SOURCES = \
-       cf_gen_defines.h \
-       cf_parser.h \
-       globals.cc \
-       string_arrays.c \
-       repl_modules.cc
-
 sysconf_DATA = \
        squid.conf.default \
        squid.conf.documented \
@@ -728,11 +734,27 @@ DEFS += -DDEFAULT_CONFIG_FILE=\"$(DEFAULT_CONFIG_FILE)\" -DDEFAULT_SQUID_DATA_DI
 
 snmp_core.o snmp_agent.o: ../snmplib/libsnmp.a $(top_srcdir)/include/cache_snmp.h
 
-globals.cc: globals.h mk-globals-c.pl
+globals.cc: globals.h mk-globals-c.awk
        $(AWK) -f $(srcdir)/mk-globals-c.awk < $(srcdir)/globals.h > $@
 
-string_arrays.c: enums.h mk-string-arrays.pl
-       $(AWK) -f $(srcdir)/mk-string-arrays.awk < $(srcdir)/enums.h > $@
+## Generate files containing strng arrays for various enums....
+hier_code.cc: hier_code.h mk-string-arrays.awk
+       $(AWK) -f $(srcdir)/mk-string-arrays.awk < $(srcdir)/hier_code.h > $@
+
+err_type.cc: err_type.h mk-string-arrays.awk
+       $(AWK) -f $(srcdir)/mk-string-arrays.awk < $(srcdir)/err_type.h > $@
+
+lookup_t.cc: lookup_t.h mk-string-arrays.awk
+       $(AWK) -f $(srcdir)/mk-string-arrays.awk < $(srcdir)/lookup_t.h > $@
+
+icp_opcode.cc: icp_opcode.h mk-string-arrays.awk
+       $(AWK) -f $(srcdir)/mk-string-arrays.awk < $(srcdir)/icp_opcode.h > $@
+
+swap_log_op.cc: swap_log_op.h mk-string-arrays.awk
+       $(AWK) -f $(srcdir)/mk-string-arrays.awk < $(srcdir)/swap_log_op.h > $@
+
+
+## other generated files...
 
 cache_diff: cache_diff.o debug.o globals.o store_key_md5.o
        $(CC) -o $@ $(LDFLAGS) $@.o debug.o globals.o store_key_md5.o $(STD_APP_LIBS)
@@ -810,8 +832,8 @@ uninstall-local:
        @$(SHELL) $(top_srcdir)/scripts/remove-cfg.sh "$(RM)" $(DESTDIR)$(DEFAULT_MIME_TABLE)
        @$(SHELL) $(top_srcdir)/scripts/remove-cfg.sh "$(RM)" $(DESTDIR)$(DEFAULT_CONFIG_FILE)
 
-CLEANFILES += cf_gen_defines.h cf.data cf_parser.h squid.conf.default squid.conf.documented \
-       globals.cc string_arrays.c repl_modules.cc DiskIO/DiskIOModules_gen.cc \
+CLEANFILES += cf.data squid.conf.default squid.conf.documented \
+       DiskIO/DiskIOModules_gen.cc \
        test_tools.cc *.a
 
 test_tools.cc: $(top_srcdir)/test-suite/test_tools.cc
@@ -1091,7 +1113,6 @@ tests_testCacheManager_SOURCES = \
        ftp.cc \
        gopher.cc \
        hier_code.h \
-       hier_code.cc \
        helper.cc \
        $(HTCPSOURCE) \
        http.cc \
@@ -1172,9 +1193,7 @@ tests_testCacheManager_SOURCES = \
        $(WIN32_SOURCE) \
        wordlist.cc
 nodist_tests_testCacheManager_SOURCES = \
-       globals.cc \
-       repl_modules.cc \
-       string_arrays.c
+       $(BUILT_SOURCES)
 tests_testCacheManager_LDADD = \
        $(COMMON_LIBS) \
        icmp/libicmp.la icmp/libicmp-core.la \
@@ -1200,7 +1219,8 @@ tests_testDiskIO_SOURCES = \
        tests/testMain.cc \
        tests/stub_cache_manager.cc
 nodist_tests_testDiskIO_SOURCES= \
-       $(SWAP_TEST_GEN_SOURCES)
+       $(SWAP_TEST_GEN_SOURCES) \
+       swap_log_op.cc
 tests_testDiskIO_LDADD = \
        $(SWAP_TEST_LDADD) \
        @DISK_LIBS@ \
@@ -1263,7 +1283,6 @@ tests_testEvent_SOURCES = \
        ftp.cc \
        gopher.cc \
        hier_code.h \
-       hier_code.cc \
        helper.cc \
        $(HTCPSOURCE) \
        http.cc \
@@ -1343,9 +1362,7 @@ tests_testEvent_SOURCES = \
        $(WIN32_SOURCE) \
        wordlist.cc
 nodist_tests_testEvent_SOURCES = \
-       globals.cc \
-       repl_modules.cc \
-       string_arrays.c
+       $(BUILT_SOURCES)
 tests_testEvent_LDADD = \
        $(COMMON_LIBS) \
        icmp/libicmp.la icmp/libicmp-core.la \
@@ -1414,7 +1431,6 @@ tests_testEventLoop_SOURCES = \
        gopher.cc \
        helper.cc \
        hier_code.h \
-       hier_code.cc \
        $(HTCPSOURCE) \
        http.cc \
        HttpBody.cc \
@@ -1493,9 +1509,7 @@ tests_testEventLoop_SOURCES = \
        $(WIN32_SOURCE) \
        wordlist.cc
 nodist_tests_testEventLoop_SOURCES = \
-       globals.cc \
-       repl_modules.cc \
-       string_arrays.c
+       $(BUILT_SOURCES)
 tests_testEventLoop_LDADD = \
        $(COMMON_LIBS) \
        icmp/libicmp.la icmp/libicmp-core.la \
@@ -1553,7 +1567,6 @@ tests_test_http_range_SOURCES = \
        gopher.cc \
        helper.cc \
        hier_code.h \
-       hier_code.cc \
        $(HTCPSOURCE) \
        http.cc \
        HttpBody.cc \
@@ -1638,9 +1651,7 @@ tests_test_http_range_SOURCES = \
        Packer.cc \
        MemBuf.cc
 nodist_tests_test_http_range_SOURCES = \
-       globals.cc \
-       repl_modules.cc \
-       string_arrays.c
+       $(BUILT_SOURCES)
 tests_test_http_range_LDADD = \
        $(COMMON_LIBS) \
        icmp/libicmp.la icmp/libicmp-core.la \
@@ -1708,7 +1719,6 @@ tests_testHttpRequest_SOURCES = \
        gopher.cc \
        helper.cc \
        hier_code.h \
-       hier_code.cc \
        $(HTCPSOURCE) \
        http.cc \
        HttpBody.cc \
@@ -1788,9 +1798,7 @@ tests_testHttpRequest_SOURCES = \
        $(WIN32_SOURCE) \
        wordlist.cc
 nodist_tests_testHttpRequest_SOURCES = \
-       globals.cc \
-       repl_modules.cc \
-       string_arrays.c
+       $(BUILT_SOURCES)
 tests_testHttpRequest_LDADD = \
        $(COMMON_LIBS) \
        icmp/libicmp.la icmp/libicmp-core.la \
@@ -1849,10 +1857,6 @@ STORE_TEST_SOURCES=\
        URLScheme.cc \
        wordlist.cc
 
-STORE_TEST_GEN_SOURCES = \
-       $(TESTSOURCES) \
-       string_arrays.c
-
 ## why so many sources? well httpHeaderTools requites ACLChecklist & friends.
 ## first line - what we are testing.
 tests_testStore_SOURCES= \
@@ -1876,7 +1880,8 @@ tests_testStore_SOURCES= \
        $(STORE_TEST_SOURCES)
 
 nodist_tests_testStore_SOURCES= \
-       $(STORE_TEST_GEN_SOURCES)
+       $(TESTSOURCES) \
+       swap_log_op.cc
 
 tests_testStore_LDADD= \
        $(COMMON_LIBS) \
@@ -1944,7 +1949,7 @@ SWAP_TEST_SOURCES = \
        $(DISKIO_SOURCE)
 
 SWAP_TEST_GEN_SOURCES = \
-       $(STORE_TEST_GEN_SOURCES) \
+       $(TESTSOURCES) \
        $(DISKIO_GEN_SOURCE)
 
 SWAP_TEST_LDADD = \
@@ -1970,7 +1975,8 @@ tests_testUfs_SOURCES = \
        tests/stub_cache_manager.cc \
        $(SWAP_TEST_SOURCES)
 nodist_tests_testUfs_SOURCES = \
-       $(SWAP_TEST_GEN_SOURCES)
+       $(SWAP_TEST_GEN_SOURCES) \
+       swap_log_op.cc
 tests_testUfs_LDADD = \
        $(SWAP_TEST_LDADD) \
        $(COMMON_LIBS) \
@@ -2062,7 +2068,6 @@ tests_testURL_SOURCES = \
        gopher.cc \
        helper.cc \
        hier_code.h \
-       hier_code.cc \
        $(HTCPSOURCE) \
        http.cc \
        HttpBody.cc \
@@ -2139,9 +2144,7 @@ tests_testURL_SOURCES = \
        $(WIN32_SOURCE) \
        wordlist.cc
 nodist_tests_testURL_SOURCES = \
-       globals.cc \
-       repl_modules.cc \
-       string_arrays.c
+       $(BUILT_SOURCES)
 tests_testURL_LDADD = \
        $(COMMON_LIBS) \
        icmp/libicmp.la icmp/libicmp-core.la \
index 1892cb53d3dfe637a8d54e0fb26917c4ca17ae76..91a2362bf6200ad2f7007edc01ea5203ab6ff8a3 100644 (file)
@@ -33,6 +33,7 @@
  */
 
 #include "StoreSwapLogData.h"
+#include "swap_log_op.h"
 
 StoreSwapLogData::StoreSwapLogData(): op(0), swap_filen (0), timestamp (0), lastref (0), expires (0), lastmod(0), swap_file_sz (0), refcount (0), flags (0)
 {
index 9ecb48b3a972735ee297935cf827f64f6b4facdb..15e497e391cb0e606958d4df98ada72f1ac659bf 100644 (file)
@@ -1033,7 +1033,7 @@ accessLogCustom(AccessLogEntry * al, customlog * log)
             if (al->hier.ping.timedout)
                 mb.append("TIMEOUT_", 8);
 
-            out = hier_strings[al->hier.code];
+            out = hier_code_str[al->hier.code];
 
             break;
 
@@ -1664,7 +1664,7 @@ accessLogSquid(AccessLogEntry * al, Logfile * logfile)
                       al->url,
                       user ? user : dash_str,
                       al->hier.ping.timedout ? "TIMEOUT_" : "",
-                      hier_strings[al->hier.code],
+                      hier_code_str[al->hier.code],
                       al->hier.host,
                       al->http.content_type);
     } else {
@@ -1682,7 +1682,7 @@ accessLogSquid(AccessLogEntry * al, Logfile * logfile)
                       al->url,
                       user ? user : dash_str,
                       al->hier.ping.timedout ? "TIMEOUT_" : "",
-                      hier_strings[al->hier.code],
+                      hier_code_str[al->hier.code],
                       al->hier.host,
                       al->http.content_type,
                       ereq,
@@ -1723,7 +1723,7 @@ accessLogCommon(AccessLogEntry * al, Logfile * logfile)
                   al->http.code,
                   al->cache.replySize,
                   log_tags[al->cache.code],
-                  hier_strings[al->hier.code]);
+                  hier_code_str[al->hier.code]);
 
     safe_free(user1);
 
index 6c913b1a2b9fa4193c90eed13086351cc332f421..f6a8956c8b593aba5c57fb8a3322459bdbb16e95 100644 (file)
@@ -2,7 +2,7 @@
 #define SQUID_ACL_GADGETS_H
 
 #include "config.h"
-#include "enums.h" /* for err_type */
+#include "err_type.h"
 
 struct dlink_list;
 class StoreEntry;
index de8f9847951037c7ec6fdda29d4c86c83fca3c5b..3e5e17cdea1274994344ee43e67be746634333cb 100644 (file)
@@ -31,7 +31,7 @@ ACLHierCodeData::dump()
 
     for (hier_code iter=HIER_NONE; iter<HIER_MAX; ++iter) {
         if (!values[iter]) continue;
-        wordlistAdd(&W, hier_strings[iter]);
+        wordlistAdd(&W, hier_code_str[iter]);
     }
 
     return W;
@@ -48,7 +48,7 @@ ACLHierCodeData::parse()
                 fatalf("ERROR: No such hier_code '%s'",t);
                 return;
             }
-            if (strcmp(hier_strings[iter],t) == 0) {
+            if (strcmp(hier_code_str[iter],t) == 0) {
                 values[iter] = true;
                 break; // back to while-loop
             }
index e6bb8ca1a32acd603c1bf2d220bf718c8d483f6e..ee36d8ba93532f38520051e088e75dcdd3ae3c80 100644 (file)
@@ -61,47 +61,6 @@ typedef enum {
     LOG_TYPE_MAX
 } log_type;
 
-typedef enum {
-    ERR_NONE,
-    ERR_READ_TIMEOUT,
-    ERR_LIFETIME_EXP,
-    ERR_READ_ERROR,
-    ERR_WRITE_ERROR,
-    ERR_SHUTTING_DOWN,
-    ERR_CONNECT_FAIL,
-    ERR_SECURE_CONNECT_FAIL,
-    ERR_INVALID_REQ,
-    ERR_UNSUP_REQ,
-    ERR_INVALID_URL,
-    ERR_SOCKET_FAILURE,
-    ERR_DNS_FAIL,
-    ERR_CANNOT_FORWARD,
-    ERR_FORWARDING_DENIED,
-    ERR_NO_RELAY,
-    ERR_ZERO_SIZE_OBJECT,
-    ERR_FTP_DISABLED,
-    ERR_FTP_FAILURE,
-    ERR_URN_RESOLVE,
-    ERR_ACCESS_DENIED,
-    ERR_CACHE_ACCESS_DENIED,
-    ERR_CACHE_MGR_ACCESS_DENIED,
-    ERR_SQUID_SIGNATURE,       /* not really an error */
-    ERR_FTP_PUT_CREATED,       /* !error,a note that the file was created */
-    ERR_FTP_PUT_MODIFIED,      /* modified, !created */
-    ERR_FTP_PUT_ERROR,
-    ERR_FTP_NOT_FOUND,
-    ERR_FTP_FORBIDDEN,
-    ERR_FTP_UNAVAILABLE,
-    ERR_ONLY_IF_CACHED_MISS,   /* failure to satisfy only-if-cached request */
-    ERR_TOO_BIG,
-    TCP_RESET,
-    ERR_ESI,                    /* Failure to perform ESI processing */
-    ERR_INVALID_RESP,
-    ERR_ICAP_FAILURE,
-    ERR_UNSUP_HTTPVERSION,     /* HTTP version is not supported */
-    ERR_MAX
-} err_type;
-
 enum fd_type {
     FD_NONE,
     FD_LOG,
@@ -123,12 +82,6 @@ typedef enum {
     PEER_MULTICAST
 } peer_t;
 
-typedef enum {
-    LOOKUP_NONE,
-    LOOKUP_HIT,
-    LOOKUP_MISS
-} lookup_t;
-
 typedef enum {
     CC_BADHDR = -1,
     CC_PUBLIC = 0,
@@ -156,35 +109,6 @@ typedef enum {
 } http_hdr_sc_type;
 
 
-/// \ingroup ServerProtocolICPAPI
-typedef enum {
-    ICP_INVALID,
-    ICP_QUERY,
-    ICP_HIT,
-    ICP_MISS,
-    ICP_ERR,
-    ICP_SEND,
-    ICP_SENDA,
-    ICP_DATABEG,
-    ICP_DATA,
-    ICP_DATAEND,
-    ICP_SECHO,
-    ICP_DECHO,
-    ICP_NOTIFY,
-    ICP_INVALIDATE,
-    ICP_DELETE,
-    ICP_UNUSED15,
-    ICP_UNUSED16,
-    ICP_UNUSED17,
-    ICP_UNUSED18,
-    ICP_UNUSED19,
-    ICP_UNUSED20,
-    ICP_MISS_NOFETCH,
-    ICP_DENIED,
-    ICP_HIT_OBJ,
-    ICP_END
-} icp_opcode;
-
 typedef enum _mem_status_t {
     NOT_IN_MEMORY,
     IN_MEMORY
@@ -398,15 +322,6 @@ enum {
     STORE_LOG_SWAPOUTFAIL
 };
 
-typedef enum {
-    SWAP_LOG_NOP,
-    SWAP_LOG_ADD,
-    SWAP_LOG_DEL,
-    SWAP_LOG_VERSION,
-    SWAP_LOG_MAX
-} swap_log_op;
-
-
 /* parse state of HttpReply or HttpRequest */
 typedef enum {
     psReadyToParseStartLine = 0,
diff --git a/src/err_type.h b/src/err_type.h
new file mode 100644 (file)
index 0000000..a14bf25
--- /dev/null
@@ -0,0 +1,64 @@
+#ifndef _SQUID_ERR_TYPE_H
+#define _SQUID_ERR_TYPE_H
+
+typedef enum {
+    ERR_NONE,
+
+/* Access Permission Errors.  Prefix new with ERR_ACCESS_ */
+    ERR_ACCESS_DENIED,
+    ERR_CACHE_ACCESS_DENIED,
+    ERR_CACHE_MGR_ACCESS_DENIED,
+    ERR_FORWARDING_DENIED,
+    ERR_NO_RELAY,
+    ERR_CANNOT_FORWARD,
+
+/* TCP Errors. */
+    ERR_READ_TIMEOUT,
+    ERR_LIFETIME_EXP,
+    ERR_READ_ERROR,
+    ERR_WRITE_ERROR,
+    ERR_CONNECT_FAIL,
+    ERR_SECURE_CONNECT_FAIL,
+    ERR_SOCKET_FAILURE,
+
+/* DNS Errors */
+    ERR_DNS_FAIL,
+    ERR_URN_RESOLVE,
+
+/* HTTP Errors */
+    ERR_ONLY_IF_CACHED_MISS,    /* failure to satisfy only-if-cached request */
+    ERR_TOO_BIG,
+    ERR_INVALID_RESP,
+    ERR_UNSUP_HTTPVERSION,     /* HTTP version is not supported */
+    ERR_INVALID_REQ,
+    ERR_UNSUP_REQ,
+    ERR_INVALID_URL,
+    ERR_ZERO_SIZE_OBJECT,
+
+/* FTP Errors */
+    ERR_FTP_DISABLED,
+    ERR_FTP_UNAVAILABLE,
+    ERR_FTP_FAILURE,
+    ERR_FTP_PUT_ERROR,
+    ERR_FTP_NOT_FOUND,
+    ERR_FTP_FORBIDDEN,
+    ERR_FTP_PUT_CREATED,        /* !error,a note that the file was created */
+    ERR_FTP_PUT_MODIFIED,       /* modified, !created */
+
+/* ESI Errors */
+    ERR_ESI,                    /* Failure to perform ESI processing */
+
+/* ICAP Errors */
+    ERR_ICAP_FAILURE,
+
+/* Special Cases */
+    ERR_SQUID_SIGNATURE,        /* not really an error */
+    ERR_SHUTTING_DOWN,
+    TCP_RESET,
+
+    ERR_MAX
+} err_type;
+
+extern const char *err_type_str[];
+
+#endif /* _SQUID_ERR_TYPE_H */
index 3273547d4eed4338d160f9ba31cd150eff4fc7bf..6ba640b3786ea803f436bc857233de57421eb82e 100644 (file)
@@ -44,6 +44,7 @@
 #include "Parsing.h"
 #include "SquidTime.h"
 #include "SwapDir.h"
+#include "swap_log_op.h"
 
 int UFSSwapDir::NumberOfUFSDirs = 0;
 int *UFSSwapDir::UFSDirToGlobalDirMapping = NULL;
index 558410e68b1febb8eab41f7e417b7aeccba5aa84..20fe3679c5487d1eef56fd289a203cdc11a3b504 100644 (file)
@@ -1,6 +1,5 @@
 /*
  * $Id$
- * vim: set et :
  *
  * DEBUG: section 47    Store Directory Routines
  * AUTHOR: Robert Collins
@@ -34,6 +33,7 @@
  * Copyright (c) 2003, Robert Collins <robertc@squid-cache.org>
  */
 
+#include "config.h"
 #include "ufscommon.h"
 #include "Store.h"
 #include "fde.h"
@@ -42,6 +42,8 @@
 #include "StoreMetaUnpacker.h"
 #include "RefCount.h"
 #include "StoreSwapLogData.h"
+#include "swap_log_op.h"
+
 
 CBDATA_CLASS_INIT(RebuildState);
 
index dfd234bb1f2dd17fb91e1fc4f212b4d161c17c5a..e3e926c63b011fc67eadf250011fd246772352ab 100644 (file)
@@ -124,10 +124,6 @@ extern "C"
     extern unsigned long store_swap_size;      /* 0 */
     extern time_t hit_only_mode_until; /* 0 */
     extern StatCounters statCounter;
-    extern char *err_type_str[];
-    extern char *icp_opcode_str[];
-    extern char *swap_log_op_str[];
-    extern char *lookup_t_str[];
     extern double request_failure_ratio;       /* 0.0 */
     extern int store_hash_buckets;     /* 0 */
     extern hash_table *store_table;    /* NULL */
diff --git a/src/hier_code.cc b/src/hier_code.cc
deleted file mode 100644 (file)
index 4a5157e..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-#include "config.h"
-#include "hier_code.h"
-
-const char *hier_strings[] = {
-    "NONE",          /* HIER_NONE */
-    "DIRECT",        /* HIER_DIRECT */
-    "SIBLING_HIT",
-    "PARENT_HIT",
-    "DEFAULT_PARENT",
-    "SINGLE_PARENT",
-    "FIRSTUP_PARENT",
-    "FIRST_PARENT_MISS",
-    "CLOSEST_PARENT_MISS",
-    "CLOSEST_PARENT",
-    "CLOSEST_DIRECT",
-    "NO_DIRECT_FAIL",
-    "SOURCE_FASTEST",
-    "ROUNDROBIN_PARENT",
-#if USE_CACHE_DIGESTS
-    "CD_PARENT_HIT",
-    "CD_SIBLING_HIT",
-#endif
-    "CARP",
-    "ANY_PARENT",
-    "USERHASH",
-    "SOURCEHASH",
-    "PINNED",
-    "HIER_MAX"
-};
index 5b91d24eeda17b5fef5fe919dbcc94d1837bf5e7..38adaac798208f35d235b2d76f2387a961104231 100644 (file)
@@ -28,7 +28,7 @@ typedef enum {
     HIER_MAX
 } hier_code;
 
-extern const char *hier_strings[];
+extern const char *hier_code_str[];
 
 inline const hier_code operator++(hier_code &i) { return (hier_code)(i+1); }
 
diff --git a/src/icp_opcode.h b/src/icp_opcode.h
new file mode 100644 (file)
index 0000000..84e74fa
--- /dev/null
@@ -0,0 +1,35 @@
+#ifndef _SQUID_ICP_OPCODE_H
+#define _SQUID_ICP_OPCODE_H
+
+/// \ingroup ServerProtocolICPAPI
+typedef enum {
+    ICP_INVALID,
+    ICP_QUERY,
+    ICP_HIT,
+    ICP_MISS,
+    ICP_ERR,
+    ICP_SEND,
+    ICP_SENDA,
+    ICP_DATABEG,
+    ICP_DATA,
+    ICP_DATAEND,
+    ICP_SECHO,
+    ICP_DECHO,
+    ICP_NOTIFY,
+    ICP_INVALIDATE,
+    ICP_DELETE,
+    ICP_UNUSED15,
+    ICP_UNUSED16,
+    ICP_UNUSED17,
+    ICP_UNUSED18,
+    ICP_UNUSED19,
+    ICP_UNUSED20,
+    ICP_MISS_NOFETCH,
+    ICP_DENIED,
+    ICP_HIT_OBJ,
+    ICP_END
+} icp_opcode;
+
+extern const char *icp_opcode_str[];
+
+#endif /* _SQUID_ICP_OPCODE_H */
index 72995a58cc6494e170c670e25e1337b2f17fa7e8..d4b5ec37518cbe76da0a069dbfcf905345a9e70a 100644 (file)
@@ -5,17 +5,23 @@
 #              -->  awk -f mk-string-arrays.awk enum.h
 #
 # 2006 by Christopher Kerr.
+#
+# 2009 modified by Amos Jeffries
+#   Adapted to convert individual enum headers
+#
 
-BEGIN { # converted to "const char *"TypedefEnum[?]"_str[]"
-       TypedefEnum["err_type"] = 1
-       TypedefEnum["lookup_t"] = 1
-       TypedefEnum["icp_opcode"] = 1
-       TypedefEnum["swap_log_op"] = 1
+BEGIN {
+       print "/*"
+       print " * Auto-Generated File. Changes will be destroyed."
+       print " */"
+       print "#include \"squid.h\""
+        codeSkip = 1
+        e = 0
 }
 
-/^ \*\/$/ && Copyright != 1    { Copyright = 1; print; next }
-Copyright != 1                 {                print; next }
-/^typedef/                     { e = 0;                next }
+# Skip all lines outside of typedef {}
+/^typedef/             { codeSkip = 0; next }
+codeSkip == 1          { next }
 
 /^[ \t]*[A-Z]/ {
        split($1, t, ",")                       # remove ,
@@ -26,13 +32,13 @@ Copyright != 1                      {                print; next }
 /^} / {
        split($2, t, ";")                       # remove ;
        type = t[1]
-       if (TypedefEnum[type]) {
-               print "\nconst char *" type "_str[] = {"
-               for ( i = 1; i < e; ++i)
-                       print "\t\"" Element[i] "\","
-               print "\t\"" Element[i] "\""
-               print "};"
-       }
+        codeSkip = 1
+
+       print "#include \"" type ".h\""
+       print "\nconst char *" type "_str[] = {"
+       for ( i = 1; i < e; ++i)
+               print "\t\"" Element[i] "\","
+       print "\t\"" Element[i] "\""
+       print "};"
        next
 }
-
index 00ef0165c745fd89acb9d18015522a754976411f..834d656ecb909b100bd6f3da791c5de498ea078b 100644 (file)
@@ -877,18 +877,13 @@ void
 peerNoteDigestLookup(HttpRequest * request, peer * p, lookup_t lookup)
 {
 #if USE_CACHE_DIGESTS
-
     if (p)
         strncpy(request->hier.cd_host, p->host, sizeof(request->hier.cd_host));
     else
         *request->hier.cd_host = '\0';
 
     request->hier.cd_lookup = lookup;
-
-    debugs(15, 4, "peerNoteDigestLookup: peer " <<
-           (p ? p->host : "<none>") << ", lookup: " <<
-           lookup_t_str[lookup]  );
-
+    debugs(15, 4, "peerNoteDigestLookup: peer " << (p? p->host : "<none>") << ", lookup: " << lookup_t_str[lookup]  );
 #endif
 }
 
@@ -1007,21 +1002,20 @@ ignoreMulticastReply(peer * p, MemObject * mem)
     return 1;
 }
 
-/* I should attach these records to the entry.  We take the first
+/**
+ * I should attach these records to the entry.  We take the first
  * hit we get our wait until everyone misses.  The timeout handler
  * call needs to nip this shopping list or call one of the misses.
  *
  * If a hit process is already started, then sobeit
  */
 void
-
 neighborsUdpAck(const cache_key * key, icp_common_t * header, const IpAddress &from)
 {
     peer *p = NULL;
     StoreEntry *entry;
     MemObject *mem = NULL;
     peer_t ntype = PEER_NONE;
-    char *opcode_d;
     icp_opcode opcode = (icp_opcode) header->opcode;
 
     debugs(15, 6, "neighborsUdpAck: opcode " << opcode << " '" << storeKeyText(key) << "'");
@@ -1035,7 +1029,7 @@ neighborsUdpAck(const cache_key * key, icp_common_t * header, const IpAddress &f
     if (opcode > ICP_END)
         return;
 
-    opcode_d = icp_opcode_str[opcode];
+    const char *opcode_d = icp_opcode_str[opcode];
 
     if (p)
         neighborUpdateRtt(p, mem);
index 72e9eea8a3056c504e5e8f451aaf04b232f7d839..b7ebe8f65b27ca8b4f117191df4ed26d888a6aee 100644 (file)
@@ -438,7 +438,7 @@ peerGetSomeNeighbor(ps_state * ps)
 
     if (code != HIER_NONE) {
         assert(p);
-        debugs(44, 3, "peerSelect: " << hier_strings[code] << "/" << p->host);
+        debugs(44, 3, "peerSelect: " << hier_code_str[code] << "/" << p->host);
         peerAddFwdServer(&ps->servers, p, code);
     }
 
@@ -461,7 +461,7 @@ peerGetSomeNeighborReplies(ps_state * ps)
 
     if (peerCheckNetdbDirect(ps)) {
         code = CLOSEST_DIRECT;
-        debugs(44, 3, "peerSelect: " << hier_strings[code] << "/" << request->GetHost());
+        debugs(44, 3, "peerSelect: " << hier_code_str[code] << "/" << request->GetHost());
         peerAddFwdServer(&ps->servers, NULL, code);
         return;
     }
@@ -478,7 +478,7 @@ peerGetSomeNeighborReplies(ps_state * ps)
         }
     }
     if (p && code != HIER_NONE) {
-        debugs(44, 3, "peerSelect: " << hier_strings[code] << "/" << p->host);
+        debugs(44, 3, "peerSelect: " << hier_code_str[code] << "/" << p->host);
         peerAddFwdServer(&ps->servers, p, code);
     }
 }
@@ -533,7 +533,7 @@ peerGetSomeParent(ps_state * ps)
     }
 
     if (code != HIER_NONE) {
-        debugs(44, 3, "peerSelect: " << hier_strings[code] << "/" << p->host);
+        debugs(44, 3, "peerSelect: " << hier_code_str[code] << "/" << p->host);
         peerAddFwdServer(&ps->servers, p, code);
     }
 }
@@ -765,7 +765,7 @@ peerAddFwdServer(FwdServer ** FSVR, peer * p, hier_code code)
     FwdServer *fs = (FwdServer *)memAllocate(MEM_FWD_SERVER);
     debugs(44, 5, "peerAddFwdServer: adding " <<
            (p ? p->host : "DIRECT")  << " " <<
-           hier_strings[code]  );
+           hier_code_str[code]  );
     fs->_peer = cbdataReference(p);
     fs->code = code;
 
index 8d63ce34fbfd9eb8eec9be15df18155d24df3edf..f694a07ad9da56a15449c8b8857710d87baf4be2 100644 (file)
 /* some parameters stil need this */
 #include "wordlist.h"
 
+/* for parameters that still need these */
+#include "lookup_t.h"
+
+
 class HttpRequestMethod;
 
 
@@ -355,10 +359,6 @@ SQUIDCEXTERN int mimeGetViewOption(const char *fn);
 SQUIDCEXTERN int mcastSetTtl(int, int);
 SQUIDCEXTERN IPH mcastJoinGroups;
 
-/* Labels for hierachical log file */
-/* put them all here for easier reference when writing a logfile analyzer */
-
-
 SQUIDCEXTERN peer *getFirstPeer(void);
 SQUIDCEXTERN peer *getFirstUpParent(HttpRequest *);
 SQUIDCEXTERN peer *getNextPeer(peer *);
index 29c097384a6631b3f7100c7ce7b292dcbaf1c3f0..99531ef196d7074ef9c5c3cebe60996f7310c2d1 100644 (file)
@@ -50,6 +50,7 @@
 #endif
 #include "Stack.h"
 #include "SquidTime.h"
+#include "swap_log_op.h"
 
 static STMCB storeWriteComplete;
 
@@ -57,6 +58,9 @@ static STMCB storeWriteComplete;
 
 #define STORE_IN_MEM_BUCKETS            (229)
 
+
+/** \todo Convert these string constants to enum string-arrays generated */
+
 const char *memStatusStr[] = {
     "NOT_IN_MEMORY",
     "IN_MEMORY"
index b9f60a105f6f64fa9dd3ce6d767504cb7d44b8ae..5bfc9636c84d7eee6f711ad342454af51a8bdbbc 100644 (file)
@@ -38,6 +38,7 @@
 #include "MemObject.h"
 #include "SquidTime.h"
 #include "SwapDir.h"
+#include "swap_log_op.h"
 
 #if HAVE_STATVFS
 #if HAVE_SYS_STATVFS_H
index b415a92e8883874c29520befaeb7a0e25cf14769..6e049a6dc5f93054fe5fe0bca2ddee04552f459c 100644 (file)
@@ -41,6 +41,7 @@
 #include "mem_node.h"
 #include "MemObject.h"
 #include "SwapDir.h"
+#include "swap_log_op.h"
 
 static void storeSwapOutStart(StoreEntry * e);
 static StoreIOState::STIOCB storeSwapOutFileClosed;
index fd9941d9ec34cec5b63387cba84d8acca6d2191b..e807b09d1784f6e45025c6f63bcfabed388159ae 100644 (file)
 #include "config.h"
 #include "RefCount.h"
 #include "cbdata.h"
-
-/* needed for various structures still in structs.h */
 #include "dlink.h"
+#include "err_type.h"
+
 /* needed for the global config */
 #include "HttpHeader.h"
 
+/* for ICP_END */
+#include "icp_opcode.h"
+
 struct acl_name_list {
     char name[ACL_NAME_SZ];
     acl_name_list *next;
diff --git a/src/swap_log_op.h b/src/swap_log_op.h
new file mode 100644 (file)
index 0000000..0fde233
--- /dev/null
@@ -0,0 +1,14 @@
+#ifndef _SQUID_SWAP_LOG_OP_H
+#define _SQUID_SWAP_LOG_OP_H
+
+typedef enum {
+    SWAP_LOG_NOP,
+    SWAP_LOG_ADD,
+    SWAP_LOG_DEL,
+    SWAP_LOG_VERSION,
+    SWAP_LOG_MAX
+} swap_log_op;
+
+extern const char *swap_log_op_str[];
+
+#endif /* _SQUID_SWAP_LOG_OP_H */