]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/acl/Acl.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / acl / Acl.h
index 6e8c83a96651cb0884c0ea519b3dab7d196d9261..89eb9094575c84241b9a815e18c46684e64fc282 100644 (file)
 
 #include "Array.h"
 #include "cbdata.h"
+#include "defines.h"
 #include "dlink.h"
+#include "MemPool.h"
+#include "structs.h"
+
+#if HAVE_OSTREAM
+#include <ostream>
+#endif
 
 class ConfigParser;
 class ACLChecklist;
@@ -112,9 +119,53 @@ typedef enum {
 
     // Authentication ACL result states
     ACCESS_AUTH_REQUIRED,    // Missing Credentials
-    ACCESS_AUTH_EXPIRED_OK,  // Expired now. Were Okay.
-    ACCESS_AUTH_EXPIRED_BAD  // Expired now. Were Failed.
-} allow_t;
+} aclMatchCode;
+
+/// \ingroup ACLAPI
+/// ACL check answer; TODO: Rename to Acl::Answer
+class allow_t
+{
+public:
+    // not explicit: allow "aclMatchCode to allow_t" conversions (for now)
+    allow_t(const aclMatchCode aCode): code(aCode), kind(0) {}
+
+    allow_t(): code(ACCESS_DUNNO), kind(0) {}
+
+    bool operator ==(const aclMatchCode aCode) const {
+        return code == aCode;
+    }
+
+    bool operator !=(const aclMatchCode aCode) const {
+        return !(*this == aCode);
+    }
+
+    operator aclMatchCode() const {
+        return code;
+    }
+
+    aclMatchCode code; ///< ACCESS_* code
+    int kind; ///< which custom access list verb matched
+};
+
+inline std::ostream &
+operator <<(std::ostream &o, const allow_t a)
+{
+    switch (a) {
+    case ACCESS_DENIED:
+        o << "DENIED";
+        break;
+    case ACCESS_ALLOWED:
+        o << "ALLOWED";
+        break;
+    case ACCESS_DUNNO:
+        o << "DUNNO";
+        break;
+    case ACCESS_AUTH_REQUIRED:
+        o << "AUTH_REQUIRED";
+        break;
+    }
+    return o;
+}
 
 /// \ingroup ACLAPI
 class acl_access
@@ -162,7 +213,6 @@ public:
 
 MEMPROXY_CLASS_INLINE(acl_proxy_auth_match_cache);
 
-
 /// \ingroup ACLAPI
 extern const char *AclMatchedName;     /* NULL */