X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=fuzzterm.c;h=15b5d63546616fab90c76e5d9f5713d6189e767c;hb=3f29d939ee6d20789eff0fb779592f64fc4bf892;hp=f1dcb1ab698700f44465ffdfe6fa0ffccaa687dc;hpb=1a009ab2e9d9f0baa5ff98d295d4ec7afd9ff2f9;p=PuTTY.git diff --git a/fuzzterm.c b/fuzzterm.c index f1dcb1ab..15b5d635 100644 --- a/fuzzterm.c +++ b/fuzzterm.c @@ -6,6 +6,9 @@ #include "putty.h" #include "terminal.h" +/* For Unix in particular, but harmless if this main() is reused elsewhere */ +const int buildinfo_gtk_relevant = FALSE; + int main(int argc, char **argv) { char blk[512]; @@ -23,10 +26,15 @@ int main(int argc, char **argv) term = term_init(conf, &ucsdata, NULL); term_size(term, 24, 80, 10000); term->ldisc = NULL; + /* Tell american fuzzy lop that this is a good place to fork. */ +#ifdef __AFL_HAVE_MANUAL_CONTROL + __AFL_INIT(); +#endif while (!feof(stdin)) { len = fread(blk, 1, sizeof(blk), stdin); term_data(term, 0, blk, len); } + term_update(term); return 0; } @@ -36,8 +44,28 @@ int from_backend(void *frontend, int is_stderr, const char *data, int len) /* 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) { } +void do_text(Context ctx, int x, int y, wchar_t * text, int len, + unsigned long attr, int lattr) +{ + int i; + + printf("TEXT[attr=%08lx,lattr=%02x]@(%d,%d):", attr, lattr, x, y); + for (i = 0; i < len; i++) { + printf(" %x", (unsigned)text[i]); + } + printf("\n"); +} +void do_cursor(Context ctx, int x, int y, wchar_t * text, int len, + unsigned long attr, int lattr) +{ + int i; + + printf("CURS[attr=%08lx,lattr=%02x]@(%d,%d):", attr, lattr, x, y); + for (i = 0; i < len; i++) { + printf(" %x", (unsigned)text[i]); + } + printf("\n"); +} int char_width(Context ctx, int uc) { return 1; } void set_title(void *frontend, char *t) { } void set_icon(void *frontend, char *t) { } @@ -45,7 +73,11 @@ 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; } +Context get_ctx(void *frontend) { + static char x; + + return &x; +} void free_ctx(Context ctx) { } void palette_set(void *frontend, int a, int b, int c, int d) { } void palette_reset(void *frontend) { } @@ -68,6 +100,7 @@ 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"; } +int frontend_is_utf8(void *frontend) { return TRUE; } /* needed by timing.c */ void timer_change_notify(unsigned long next) { }