/*
- * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
+ * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
*
* Squid software is distributed under GPLv2+ license and includes
* contributions from numerous individuals and organizations.
#include "squid.h"
#include "anyp/UriScheme.h"
-char const *
-AnyP::UriScheme::c_str() const
+AnyP::UriScheme::UriScheme(AnyP::ProtocolType const aScheme, const char *img) :
+ theScheme_(aScheme)
{
- if (theScheme_ == AnyP::PROTO_UNKNOWN)
- return "(unknown)";
-
- static char out[BUFSIZ];
- int p = 0;
-
- if (theScheme_ > AnyP::PROTO_NONE && theScheme_ < AnyP::PROTO_MAX) {
- const char *in = AnyP::ProtocolType_str[theScheme_];
- for (; p < (BUFSIZ-1) && in[p] != '\0'; ++p)
- out[p] = xtolower(in[p]);
+ if (img)
+ // image could be provided explicitly (case-sensitive)
+ image_ = img;
+
+ else if (theScheme_ == AnyP::PROTO_UNKNOWN)
+ // image could be actually unknown and not provided
+ image_ = "(unknown)";
+
+ else if (theScheme_ > AnyP::PROTO_NONE && theScheme_ < AnyP::PROTO_MAX) {
+ // image could be implied by a registered transfer protocol
+ // which use upper-case labels, so down-case for scheme image
+ image_ = AnyP::ProtocolType_str[theScheme_];
+ image_.toLower();
}
- out[p] = '\0';
- return out;
+ // else, image is an empty string ("://example.com/")
}
unsigned short