% gopher2mime.c -- gopher2mime function % % 21 Feb '94 Translating Gopher types to MIME types [[gopher2mime() converts a 1-letter gopher type to a MIME type. The arguments are: [[type]] = the Gopher type; [[mime]] = returns a MIME type, e.g., [["text/plain"]]; [[selector]] = in case of doubt, try heuristic rules on the selector. <<*>>= #include #include #include EXPORT void gopher2mime(char type, char *selector, char **mime) { char *hint, *encoding; Bool binary; switch (type) { case '0': *mime = "text/plain"; break; case '1': case '7': (*mime) = "text/html"; /* Gopher menu is translated */ break; case '2': *mime = "application/x-cso-server"; break; case '4': *mime = "application/x-mac-hqx"; break; case '8': *mime = "application/x-telnet"; break; case '9': if (URL_infer_type(selector, TRUE, &hint, &encoding, &binary)) *mime = hint; else *mime = "application/x-unknown"; break; case 's': if (URL_infer_type(selector, TRUE, &hint, &encoding, &binary)) *mime = hint; else *mime = "audio/basic"; break; case 'I': if (URL_infer_type(selector, TRUE, &hint, &encoding, &binary)) *mime = hint; else *mime = "image/gif"; break; case 'G': case 'g': *mime = "image/gif"; break; case 'h': *mime = "text/html"; break; default: if (URL_infer_type(selector, TRUE, &hint, &encoding, &binary)) *mime = hint; else *mime = "application/x-unknown"; } }