* \brief Activate the selected language for this session.
*/
void go_selected_language(void) {
+#ifdef HAVE_USELOCALE
if (WC->selected_language < 0) return;
uselocale(wc_locales[WC->selected_language]); /** switch locales */
textdomain(textdomain(NULL)); /** clear the cache */
+#endif
}
/**
* \brief Deactivate the selected language for this session.
*/
void stop_selected_language(void) {
+#ifdef HAVE_USELOCALE
uselocale(LC_GLOBAL_LOCALE); /** switch locales */
textdomain(textdomain(NULL)); /** clear the cache */
+#endif
}
-
+void preset_locale(void)
+{
+#ifndef HAVE_USELOCALE
+#ifdef HAVE_GETTEXT
+ char *language;
+
+ language = getenv("LANG");
+ setlocale(LC_MESSAGES, language);
+#endif
+#endif
+}
/**
* \brief Create a locale_t for each available language
*/
void stop_selected_language(void) {
}
+void preset_locale(void)
+{
+}
#endif /* ENABLE_NLS */
/**
* \brief Output a piece of content to the web browser
*/
-void http_transmit_thing(char *thing, size_t length, char *content_type,
+void http_transmit_thing(char *thing, size_t length, const char *content_type,
int is_static) {
output_headers(0, 0, 0, 0, 0, is_static);
}
+
+typedef struct _MimeGuess {
+ const char *Pattern;
+ size_t PatternLen;
+ long PatternOffset;
+ const char *MimeString;
+} MimeGuess;
+
+MimeGuess MyMimes [] = {
+ {
+ "GIF",
+ 3,
+ 0,
+ "image/gif"
+ },
+ {
+ "\xff\xd8",
+ 2,
+ 0,
+ "image/jpeg"
+ },
+ {
+ "\x89PNG",
+ 4,
+ 0,
+ "image/png"
+ },
+ { // last...
+ "",
+ 0,
+ 0,
+ ""
+ }
+};
+
+
+
/**
* \brief When the browser requests an image file from the Citadel server,
* this function is called to transmit it.
char buf[SIZ];
char *xferbuf = NULL;
off_t bytes;
+ int MimeIndex = 0;
serv_printf("OIMG %s|%s", bstr("name"), bstr("parm"));
serv_getln(buf, sizeof buf);
serv_puts("CLOS");
serv_getln(buf, sizeof buf);
+ while (MyMimes[MimeIndex].PatternLen != 0)
+ {
+ if (strncmp(MyMimes[MimeIndex].Pattern,
+ &xferbuf[MyMimes[MimeIndex].PatternOffset],
+ MyMimes[MimeIndex].PatternLen) == 0)
+ break;
+ MimeIndex ++;
+ }
+
/** Write it to the browser */
- http_transmit_thing(xferbuf, (size_t)bytes, "image/gif", 0);
+ if (MyMimes[MimeIndex].PatternLen != 0)
+ {
+ http_transmit_thing(xferbuf,
+ (size_t)bytes,
+ MyMimes[MimeIndex].MimeString,
+ 0);
+ free(xferbuf);
+ return;
+ }
+ /* hm... unknown mimetype? fallback to blank gif */
free(xferbuf);
+ }
- } else {
- /**
- * Instead of an ugly 404, send a 1x1 transparent GIF
- * when there's no such image on the server.
- */
- char blank_gif[SIZ];
- snprintf (blank_gif, SIZ, "%s%s", static_dirs[0], "/blank.gif");
- output_static(blank_gif);
- }
-
-
-
+
+ /**
+ * Instead of an ugly 404, send a 1x1 transparent GIF
+ * when there's no such image on the server.
+ */
+ char blank_gif[SIZ];
+ snprintf (blank_gif, SIZ, "%s%s", static_dirs[0], "/blank.gif");
+ output_static(blank_gif);
}
/**
int goto_config_room(void);
long locate_user_vcard(char *username, long usernum);
void sleeeeeeeeeep(int);
-void http_transmit_thing(char *thing, size_t length, char *content_type,
+void http_transmit_thing(char *thing, size_t length, const char *content_type,
int is_static);
void unescape_input(char *buf);
void do_iconbar(void);
void set_selected_language(char *);
void go_selected_language(void);
void stop_selected_language(void);
+void preset_locale(void);
void httplang_to_locale(char *LocaleString);
void tabbed_dialog(int num_tabs, char *tabnames[]);
void begin_tab(int tabnum, int num_tabs);