]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
Fuzzable terminal emulator.
authorBen Harris <bjh21@bjh21.me.uk>
Tue, 6 Oct 2015 10:02:52 +0000 (11:02 +0100)
committerBen Harris <bjh21@bjh21.me.uk>
Wed, 28 Oct 2015 21:46:30 +0000 (21:46 +0000)
Recipe
fuzzterm.c [new file with mode: 0644]
terminal.c

diff --git a/Recipe b/Recipe
index 89609df68c4d3313c6c431c1df190b71edc0327d..bba63a9c2dd89792e890a0154d90219eeedc4fdc 100644 (file)
--- a/Recipe
+++ b/Recipe
@@ -310,3 +310,6 @@ pageant  : [X] uxpgnt uxagentc pageant sshrsa sshpubk sshdes sshbn sshmd5
 
 PuTTY    : [MX] osxmain OSXTERM OSXMISC CHARSET U_BE_ALL NONSSH UXSSH
          + ux_x11 uxpty uxsignal testback putty.icns info.plist
+
+fuzzterm : [U] UXTERM CHARSET misc uxmisc uxucs fuzzterm time settings
+        + uxstore be_none
diff --git a/fuzzterm.c b/fuzzterm.c
new file mode 100644 (file)
index 0000000..f1dcb1a
--- /dev/null
@@ -0,0 +1,156 @@
+#include <stddef.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#define PUTTY_DO_GLOBALS
+#include "putty.h"
+#include "terminal.h"
+
+int main(int argc, char **argv)
+{
+       char blk[512];
+       size_t len;
+       Terminal *term;
+       Conf *conf;
+       struct unicode_data ucsdata;
+
+       conf = conf_new();
+       do_defaults(NULL, conf);
+       init_ucs(&ucsdata, conf_get_str(conf, CONF_line_codepage),
+                conf_get_int(conf, CONF_utf8_override),
+                CS_NONE, conf_get_int(conf, CONF_vtmode));
+
+       term = term_init(conf, &ucsdata, NULL);
+       term_size(term, 24, 80, 10000);
+       term->ldisc = NULL;
+       while (!feof(stdin)) {
+               len = fread(blk, 1, sizeof(blk), stdin);
+               term_data(term, 0, blk, len);
+       }
+       return 0;
+}
+
+int from_backend(void *frontend, int is_stderr, const char *data, int len)
+{ return 0; }
+
+/* functions required by terminal.c */
+
+void request_resize(void *frontend, int x, int y) { }
+void do_text(Context a, int b, int c, wchar_t * d, int e, unsigned long f, int g) { }
+void do_cursor(Context a, int b, int c, wchar_t * d, int e, unsigned long f, int g) { }
+int char_width(Context ctx, int uc) { return 1; }
+void set_title(void *frontend, char *t) { }
+void set_icon(void *frontend, char *t) { }
+void set_sbar(void *frontend, int a, int b, int c) { }
+
+void ldisc_send(void *handle, const char *buf, int len, int interactive) {}
+void ldisc_echoedit_update(void *handle) {}
+Context get_ctx(void *frontend) { return NULL; }
+void free_ctx(Context ctx) { }
+void palette_set(void *frontend, int a, int b, int c, int d) { }
+void palette_reset(void *frontend) { }
+void write_clip(void *frontend, wchar_t *a, int *b, int c, int d) { }
+void get_clip(void *frontend, wchar_t **w, int *i) { }
+void set_raw_mouse_mode(void *frontend, int m) { }
+void request_paste(void *frontend) { }
+void do_beep(void *frontend, int a) { }
+void sys_cursor(void *frontend, int x, int y) { }
+void fatalbox(const char *fmt, ...) { exit(0); }
+void modalfatalbox(const char *fmt, ...) { exit(0); }
+void nonfatal(const char *fmt, ...) { }
+
+void set_iconic(void *frontend, int iconic) { }
+void move_window(void *frontend, int x, int y) { }
+void set_zorder(void *frontend, int top) { }
+void refresh_window(void *frontend) { }
+void set_zoomed(void *frontend, int zoomed) { }
+int is_iconic(void *frontend) { return 0; }
+void get_window_pos(void *frontend, int *x, int *y) { *x = 0; *y = 0; }
+void get_window_pixels(void *frontend, int *x, int *y) { *x = 0; *y = 0; }
+char *get_window_title(void *frontend, int icon) { return "moo"; }
+
+/* needed by timing.c */
+void timer_change_notify(unsigned long next) { }
+
+/* needed by config.c and sercfg.c */
+
+void dlg_radiobutton_set(union control *ctrl, void *dlg, int whichbutton) { }
+int dlg_radiobutton_get(union control *ctrl, void *dlg) { return 0; }
+void dlg_checkbox_set(union control *ctrl, void *dlg, int checked) { }
+int dlg_checkbox_get(union control *ctrl, void *dlg) { return 0; }
+void dlg_editbox_set(union control *ctrl, void *dlg, char const *text) { }
+char *dlg_editbox_get(union control *ctrl, void *dlg) { return dupstr("moo"); }
+void dlg_listbox_clear(union control *ctrl, void *dlg) { }
+void dlg_listbox_del(union control *ctrl, void *dlg, int index) { }
+void dlg_listbox_add(union control *ctrl, void *dlg, char const *text) { }
+void dlg_listbox_addwithid(union control *ctrl, void *dlg,
+                          char const *text, int id) { }
+int dlg_listbox_getid(union control *ctrl, void *dlg, int index) { return 0; }
+int dlg_listbox_index(union control *ctrl, void *dlg) { return -1; }
+int dlg_listbox_issel(union control *ctrl, void *dlg, int index) { return 0; }
+void dlg_listbox_select(union control *ctrl, void *dlg, int index) { }
+void dlg_text_set(union control *ctrl, void *dlg, char const *text) { }
+void dlg_filesel_set(union control *ctrl, void *dlg, Filename *fn) { }
+Filename *dlg_filesel_get(union control *ctrl, void *dlg) { return NULL; }
+void dlg_fontsel_set(union control *ctrl, void *dlg, FontSpec *fn) { }
+FontSpec *dlg_fontsel_get(union control *ctrl, void *dlg) { return NULL; }
+void dlg_update_start(union control *ctrl, void *dlg) { }
+void dlg_update_done(union control *ctrl, void *dlg) { }
+void dlg_set_focus(union control *ctrl, void *dlg) { }
+void dlg_label_change(union control *ctrl, void *dlg, char const *text) { }
+union control *dlg_last_focused(union control *ctrl, void *dlg) { return NULL; }
+void dlg_beep(void *dlg) { }
+void dlg_error_msg(void *dlg, const char *msg) { }
+void dlg_end(void *dlg, int value) { }
+void dlg_coloursel_start(union control *ctrl, void *dlg,
+                        int r, int g, int b) { }
+int dlg_coloursel_results(union control *ctrl, void *dlg,
+                         int *r, int *g, int *b) { return 0; }
+void dlg_refresh(union control *ctrl, void *dlg) { }
+
+/* miscellany */
+void logevent(void *frontend, const char *msg) { }
+int askappend(void *frontend, Filename *filename,
+             void (*callback)(void *ctx, int result), void *ctx) { return 0; }
+
+const char *const appname = "FuZZterm";
+const int ngsslibs = 0;
+const char *const gsslibnames[0] = { };
+const struct keyvalwhere gsslibkeywords[0] = { };
+
+/*
+ * Default settings that are specific to Unix plink.
+ */
+char *platform_default_s(const char *name)
+{
+    if (!strcmp(name, "TermType"))
+       return dupstr(getenv("TERM"));
+    if (!strcmp(name, "SerialLine"))
+       return dupstr("/dev/ttyS0");
+    return NULL;
+}
+
+int platform_default_i(const char *name, int def)
+{
+    return def;
+}
+
+FontSpec *platform_default_fontspec(const char *name)
+{
+    return fontspec_new("");
+}
+
+Filename *platform_default_filename(const char *name)
+{
+    if (!strcmp(name, "LogFileName"))
+       return filename_from_str("putty.log");
+    else
+       return filename_from_str("");
+}
+
+char *x_get_default(const char *key)
+{
+    return NULL;                      /* this is a stub */
+}
+
+
index ca47c8335f79eabaf581bd71b8b55f28b8718ee6..8e5c07bf0fe594d12c45d845e196f446c89a38c0 100644 (file)
@@ -4688,7 +4688,7 @@ static void term_out(Terminal *term)
     }
 
     term_print_flush(term);
-    if (term->logflush)
+    if (term->logflush && term->logctx)
        logflush(term->logctx);
 }