+/* GUI Adaptation - Sept 2000 */
+static void tell_char(FILE *stream, char c);
+static void tell_str(FILE *stream, char *str);
+static void tell_user(FILE *stream, char *fmt, ...);
+static void send_char_msg(unsigned int msg_id, char c);
+static void send_str_msg(unsigned int msg_id, char *str);
+static void gui_update_stats(char *name, unsigned long size, int percentage, time_t elapsed);
+
+/*
+ * These functions are needed to link with ssh.c, but never get called.
+ */
+void term_out(void)
+{
+ abort();
+}
+void begin_session(void) {
+}
+
+/* GUI Adaptation - Sept 2000 */
+void send_msg(HWND h, UINT message, WPARAM wParam)
+{
+ while (!PostMessage( h, message, wParam, 0))
+ SleepEx(1000,TRUE);
+}
+
+void tell_char(FILE *stream, char c)
+{
+ if (!gui_mode)
+ fputc(c, stream);
+ else
+ {
+ unsigned int msg_id = WM_STD_OUT_CHAR;
+ if (stream = stderr) msg_id = WM_STD_ERR_CHAR;
+ send_msg( (HWND)atoi(gui_hwnd), msg_id, (WPARAM)c );
+ }
+}
+
+void tell_str(FILE *stream, char *str)
+{
+ unsigned int i;
+
+ for( i = 0; i < strlen(str); ++i )
+ tell_char(stream, str[i]);
+}
+
+void tell_user(FILE *stream, char *fmt, ...)
+{
+ char str[0x100]; /* Make the size big enough */
+ va_list ap;
+ va_start(ap, fmt);
+ vsprintf(str, fmt, ap);
+ va_end(ap);
+ strcat(str, "\n");
+ tell_str(stream, str);
+}
+
+void gui_update_stats(char *name, unsigned long size, int percentage, time_t elapsed)
+{
+ unsigned int i;
+
+ if (strcmp(name,statname) != 0)
+ {
+ for( i = 0; i < strlen(name); ++i )
+ send_msg( (HWND)atoi(gui_hwnd), WM_STATS_CHAR, (WPARAM)name[i]);
+ send_msg( (HWND)atoi(gui_hwnd), WM_STATS_CHAR, (WPARAM)'\n' );
+ strcpy(statname,name);
+ }
+ if (statsize != size)
+ {
+ send_msg( (HWND)atoi(gui_hwnd), WM_STATS_SIZE, (WPARAM)size );
+ statsize = size;
+ }
+ if (statelapsed != elapsed)
+ {
+ send_msg( (HWND)atoi(gui_hwnd), WM_STATS_ELAPSED, (WPARAM)elapsed );
+ statelapsed = elapsed;
+ }
+ if (statperct != percentage)
+ {
+ send_msg( (HWND)atoi(gui_hwnd), WM_STATS_PERCENT, (WPARAM)percentage );
+ statperct = percentage;
+ }
+}