PUBLIC BOOL HTBind_addLanguage (const char * suffix, const char * language, double value) { return HTBind_add(suffix, NULL, NULL, NULL, language, value); }
PUBLIC BOOL HTBind_addTransfer (const char * suffix, const char * transfer, double value) { return HTBind_add(suffix, NULL, NULL, transfer, NULL, value); }
/* Define the representation associated with a file suffix ** ------------------------------------------------------- ** ** Calling this with suffix set to "*" will set the default ** representation. ** Calling this with suffix set to "*.*" will set the default ** representation for unknown suffix files which contain a "." ** ** If filename suffix is already defined its previous ** definition is overridden (or modified) */ PUBLIC BOOL HTBind_addType (const char * suffix, const char * representation, double value) { return HTBind_add(suffix, representation, NULL, NULL, NULL, value); }
PUBLIC BOOL HTBind_addEncoding (const char * suffix, const char * encoding, double value) { return HTBind_add(suffix, NULL, encoding, NULL, NULL, value); }
/* Load one line of configuration ** ------------------------------ ** Call this, for example, to load a X resource with config info. ** Returns YES if line OK, else NO */ PUBLIC BOOL HTRule_parseLine (HTList * list, const char * config) { HTRuleOp op; char * line = NULL; char * ptr; char * word1, * word2, * word3; int status; if (!config) return NO; if ((ptr = strchr(config, '#'))) *ptr = '\0'; StrAllocCopy(line, config); /* Get our own copy */ ptr = line; HTTRACE(APP_TRACE, "Rule Parse.. `%s\'\n" _ config ? config : "<null>"); if ((word1 = HTNextField(&ptr)) == NULL) { /* Empty line */ HT_FREE(line); return YES; } if ((word2 = HTNextField(&ptr)) == NULL) { HTTRACE(APP_TRACE, "Rule Parse.. Insufficient operands: `%s\'\n" _ line); HT_FREE(line); return NO; } word3 = HTNextField(&ptr); /* Look for things we recognize */ if (!strcasecomp(word1, "addtype")) { double quality; char * encoding = HTNextField(&ptr); status = ptr ? sscanf(ptr, "%lf", &quality) : 0; HTBind_add(word2, /* suffix */ word3, /* type */ encoding ? encoding : "binary", /* encoding */ NULL, /* cte */ NULL, /* language */ status >= 1? quality : 1.0); /* quality */ } else if (!strcasecomp(word1, "addencoding")) { double quality; status = ptr ? sscanf(ptr, "%lf", &quality) : 0; HTBind_addEncoding(word2, word3, status >= 1 ? quality : 1.0); } else if (!strcasecomp(word1, "addlanguage")) { double quality; status = ptr ? sscanf(ptr, "%lf", &quality) : 0; HTBind_addLanguage(word2, word3, status >= 1 ? quality : 1.0); } else if (!strcasecomp(word1, "presentation")) { HTList * converters = HTFormat_conversion(); double quality, secs, secs_per_byte; status = ptr ? sscanf(ptr,"%lf%lf%lf",&quality,&secs,&secs_per_byte):0; HTPresentation_add(converters, word2, word3, NULL, status >= 1 ? quality : 1.0, status >= 2 ? secs : 0.0, status >= 3 ? secs_per_byte : 0.0); } else if (!strcasecomp(word1, "proxy")) { HTProxy_add(word2, word3); } else if (!strcasecomp(word1, "noproxy")) { int port = 0; status = ptr ? sscanf(ptr, "%d", &port) : 0; HTNoProxy_add(word2, word3, port); } else if (!strcasecomp(word1, "gateway")) { HTGateway_add(word2, word3); } else { op = 0==strcasecomp(word1, "map") ? HT_Map : 0==strcasecomp(word1, "pass") ? HT_Pass : 0==strcasecomp(word1, "fail") ? HT_Fail : HT_Invalid; if (op == HT_Invalid) { HTTRACE(APP_TRACE, "Rule Parse.. Bad or unknown: `%s'\n" _ config); } else HTRule_add(list, op, word2, word3); } HT_FREE(line); return YES; }