47 explicit MimeIcon(
const char *aName);
68 const char *aContentType,
69 const char *aContentEncoding,
const char *aTransferMode,
70 bool optionViewEnable,
bool optionDownloadEnable,
71 const char *anIconName);
104 else if (m ==
nullptr)
112 if ((t = strrchr(name,
'.'))) {
172 mb.
append(
"/squid-internal-static/icons/");
250 if (filename ==
nullptr)
253 if ((fp = fopen(filename,
"r")) ==
nullptr) {
260 setmode(fileno(fp),
O_TEXT);
265 while (fgets(buf,
BUFSIZ, fp)) {
269 if ((t = strchr(buf,
'#')))
272 if ((t = strchr(buf,
'\r')))
275 if ((t = strchr(buf,
'\n')))
283 const auto pattern =
SBuf(strtok(chopbuf,
w_space));
284 if (pattern.isEmpty()) {
289 if ((type = strtok(
nullptr,
w_space)) ==
nullptr) {
294 if ((icon = strtok(
nullptr,
w_space)) ==
nullptr) {
299 if ((encoding = strtok(
nullptr,
w_space)) ==
nullptr) {
304 if ((mode = strtok(
nullptr,
w_space)) ==
nullptr) {
312 while ((option = strtok(
nullptr,
w_space)) !=
nullptr) {
313 if (!strcmp(option,
"+download"))
315 else if (!strcmp(option,
"+view"))
318 debugs(25,
DBG_IMPORTANT,
"ERROR: mimeInit: unknown option: '" << buf <<
"' (" << option <<
")");
321 m =
new MimeEntry(
SBuf(pattern),type,encoding,mode,view_option,download_option,icon);
327 debugs(25, 5,
"mimeInit: added '" << buf <<
"'");
361 fatal(
"Unknown icon format while reading mime.conf\n");
365 e->abandon(__func__);
400 e->
lock(
"MimeIcon::created");
407 const auto mx = MasterXaction::MakePortless<XactionInitiator::initIcon>();
410 fatalf(
"mimeLoadIcon: cannot parse internal URL: %s",
url_);
419 reply->
setHeaders(status,
nullptr,
nullptr, 0, -1, -1);
430 std::array<char, 4096> buf;
459 const char *aContentType,
const char *aContentEncoding,
460 const char *aTransferMode,
bool optionViewEnable,
461 bool optionDownloadEnable,
const char *anIconName) :
462 pattern(aPattern, REG_EXTENDED|REG_NOSUB|REG_ICASE),
463 content_type(
xstrdup(aContentType)),
464 content_encoding(
xstrdup(aContentEncoding)),
465 view_option(optionViewEnable),
466 download_option(optionDownloadEnable),
467 theIcon(anIconName), next(nullptr)
469 if (!strcasecmp(aTransferMode,
"ascii"))
471 else if (!strcasecmp(aTransferMode,
"text"))
#define SQUIDSBUFPRINT(s)
std::ostream & CurrentException(std::ostream &os)
prints active (i.e., thrown but not yet handled) exception
void setHeaders(Http::StatusCode status, const char *reason, const char *ctype, int64_t clen, time_t lmt, time_t expires)
static HttpRequest * FromUrlXXX(const char *url, const MasterXaction::Pointer &, const HttpRequestMethod &method=Http::METHOD_GET)
HttpHdrCc * cache_control
HttpRequestPointer request
const char * content_type
MimeEntry(const SBuf &aPattern, const char *aContentType, const char *aContentEncoding, const char *aTransferMode, bool optionViewEnable, bool optionDownloadEnable, const char *anIconName)
MEMPROXY_CLASS(MimeEntry)
const char * content_encoding
MimeIcon(const char *aName)
void setName(char const *)
void fillChecklist(ACLFilledChecklist &) const override
configure the given checklist (to reflect the current transaction state)
LogTags * loggingTags() const override
bool match(const char *str) const
int cmp(const SBuf &S, const size_type n) const
shorthand version for compare()
SBuf & append(const SBuf &S)
struct SquidConfig::@93 icons
a storeGetPublic*() caller
void lock(const char *context)
void replaceHttpReply(const HttpReplyPointer &, const bool andStartWriting=true)
void append(char const *, int) override
Appends a c-string to existing packed data.
bool setPublicKey(const KeyScope keyScope=ksDefault)
#define debugs(SECTION, LEVEL, CONTENT)
#define EBIT_SET(flag, bit)
void fatal(const char *message)
void fatalf(const char *fmt,...)
int FD_READ_METHOD(int fd, char *buf, int len)
int file_open(const char *path, int mode)
char * internalLocalUri(const char *dir, const SBuf &name)
static void mimeFreeMemory(void)
const char * mimeGetIconURL(const char *fn)
static MimeEntry * MimeTable
static MimeEntry ** MimeTableTail
static const SBuf mimeGetIcon(const char *fn)
const char * mimeGetContentEncoding(const char *fn)
static MimeEntry * mimeGetEntry(const char *fn, int skip_encodings)
char mimeGetTransferMode(const char *fn)
void mimeInit(char *filename)
bool mimeGetViewOption(const char *fn)
const char * mimeGetContentType(const char *fn)
bool mimeGetDownloadOption(const char *fn)
StoreEntry * storeGetPublic(const char *uri, const HttpRequestMethod &method)
StoreEntry * storeCreatePureEntry(const char *url, const char *log_url, const HttpRequestMethod &method)
const char * xstrerr(int error)
char * xstrncpy(char *dst, const char *src, size_t n)