/* BINDINGS BETWEEN MEDIA TYPES AND EXTERNAL VIEWERS/PRESENTERS ** ------------------------------------------------------------ ** Not done automaticly - may be done by application! ** The data objects are stored in temporary files before the external ** program is called */ PUBLIC void HTPresenterInit (HTList * c) { /* ** First we set the special "presenter" stream that writes to a ** temporary file before executing the external presenter */ HTPresentation_setConverter(HTSaveAndExecute); #ifdef NeXT HTPresentation_add(c,"application/postscript", "open %s", NULL, 1.0, 2.0, 0.0); /* The following needs the GIF previewer -- you might not have it. */ HTPresentation_add(c,"image/gif", "open %s", NULL, 0.3, 2.0, 0.0); HTPresentation_add(c,"image/tiff", "open %s", NULL, 1.0, 2.0, 0.0); HTPresentation_add(c,"audio/basic", "open %s", NULL, 1.0, 2.0, 0.0); HTPresentation_add(c,"*/*", "open %s", NULL, 0.05, 0.0, 0.0); #else if (getenv("DISPLAY")) { /* Must have X11 */ HTPresentation_add(c,"application/postscript", "ghostview %s", NULL, 1.0, 3.0, 0.0); HTPresentation_add(c,"image/gif", "xv %s", NULL, 1.0, 3.0, 0.0); HTPresentation_add(c,"image/tiff", "xv %s", NULL, 1.0, 3.0, 0.0); HTPresentation_add(c,"image/jpeg", "xv %s", NULL, 1.0, 3.0, 0.0); HTPresentation_add(c,"image/png", "xv %s", NULL, 1.0, 3.0, 0.0); } #endif }
/* 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; }