]> asedeno.scripts.mit.edu Git - PuTTY.git/blob - fuzzterm.c
fuzzterm: add some output to allow this to be used for testing.
[PuTTY.git] / fuzzterm.c
1 #include <stddef.h>
2 #include <stdlib.h>
3 #include <stdio.h>
4
5 #define PUTTY_DO_GLOBALS
6 #include "putty.h"
7 #include "terminal.h"
8
9 int main(int argc, char **argv)
10 {
11         char blk[512];
12         size_t len;
13         Terminal *term;
14         Conf *conf;
15         struct unicode_data ucsdata;
16
17         conf = conf_new();
18         do_defaults(NULL, conf);
19         init_ucs(&ucsdata, conf_get_str(conf, CONF_line_codepage),
20                  conf_get_int(conf, CONF_utf8_override),
21                  CS_NONE, conf_get_int(conf, CONF_vtmode));
22
23         term = term_init(conf, &ucsdata, NULL);
24         term_size(term, 24, 80, 10000);
25         term->ldisc = NULL;
26         /* Tell american fuzzy lop that this is a good place to fork. */
27 #ifdef __AFL_HAVE_MANUAL_CONTROL
28         __AFL_INIT();
29 #endif
30         while (!feof(stdin)) {
31                 len = fread(blk, 1, sizeof(blk), stdin);
32                 term_data(term, 0, blk, len);
33         }
34         term_update(term);
35         return 0;
36 }
37
38 int from_backend(void *frontend, int is_stderr, const char *data, int len)
39 { return 0; }
40
41 /* functions required by terminal.c */
42
43 void request_resize(void *frontend, int x, int y) { }
44 void do_text(Context ctx, int x, int y, wchar_t * text, int len,
45              unsigned long attr, int lattr)
46 {
47     printf("TEXT[attr=%08lx,lattr=%02x]@(%d,%d): %d\n", attr, lattr, x, y, len);
48 }
49 void do_cursor(Context ctx, int x, int y, wchar_t * text, int len,
50              unsigned long attr, int lattr)
51 {
52     printf("CURS[attr=%08lx,lattr=%02x]@(%d,%d): %d\n", attr, lattr, x, y, len);
53 }
54 int char_width(Context ctx, int uc) { return 1; }
55 void set_title(void *frontend, char *t) { }
56 void set_icon(void *frontend, char *t) { }
57 void set_sbar(void *frontend, int a, int b, int c) { }
58
59 void ldisc_send(void *handle, const char *buf, int len, int interactive) {}
60 void ldisc_echoedit_update(void *handle) {}
61 Context get_ctx(void *frontend) { 
62     static char x;
63
64     return &x;
65 }
66 void free_ctx(Context ctx) { }
67 void palette_set(void *frontend, int a, int b, int c, int d) { }
68 void palette_reset(void *frontend) { }
69 void write_clip(void *frontend, wchar_t *a, int *b, int c, int d) { }
70 void get_clip(void *frontend, wchar_t **w, int *i) { }
71 void set_raw_mouse_mode(void *frontend, int m) { }
72 void request_paste(void *frontend) { }
73 void do_beep(void *frontend, int a) { }
74 void sys_cursor(void *frontend, int x, int y) { }
75 void fatalbox(const char *fmt, ...) { exit(0); }
76 void modalfatalbox(const char *fmt, ...) { exit(0); }
77 void nonfatal(const char *fmt, ...) { }
78
79 void set_iconic(void *frontend, int iconic) { }
80 void move_window(void *frontend, int x, int y) { }
81 void set_zorder(void *frontend, int top) { }
82 void refresh_window(void *frontend) { }
83 void set_zoomed(void *frontend, int zoomed) { }
84 int is_iconic(void *frontend) { return 0; }
85 void get_window_pos(void *frontend, int *x, int *y) { *x = 0; *y = 0; }
86 void get_window_pixels(void *frontend, int *x, int *y) { *x = 0; *y = 0; }
87 char *get_window_title(void *frontend, int icon) { return "moo"; }
88
89 /* needed by timing.c */
90 void timer_change_notify(unsigned long next) { }
91
92 /* needed by config.c and sercfg.c */
93
94 void dlg_radiobutton_set(union control *ctrl, void *dlg, int whichbutton) { }
95 int dlg_radiobutton_get(union control *ctrl, void *dlg) { return 0; }
96 void dlg_checkbox_set(union control *ctrl, void *dlg, int checked) { }
97 int dlg_checkbox_get(union control *ctrl, void *dlg) { return 0; }
98 void dlg_editbox_set(union control *ctrl, void *dlg, char const *text) { }
99 char *dlg_editbox_get(union control *ctrl, void *dlg) { return dupstr("moo"); }
100 void dlg_listbox_clear(union control *ctrl, void *dlg) { }
101 void dlg_listbox_del(union control *ctrl, void *dlg, int index) { }
102 void dlg_listbox_add(union control *ctrl, void *dlg, char const *text) { }
103 void dlg_listbox_addwithid(union control *ctrl, void *dlg,
104                            char const *text, int id) { }
105 int dlg_listbox_getid(union control *ctrl, void *dlg, int index) { return 0; }
106 int dlg_listbox_index(union control *ctrl, void *dlg) { return -1; }
107 int dlg_listbox_issel(union control *ctrl, void *dlg, int index) { return 0; }
108 void dlg_listbox_select(union control *ctrl, void *dlg, int index) { }
109 void dlg_text_set(union control *ctrl, void *dlg, char const *text) { }
110 void dlg_filesel_set(union control *ctrl, void *dlg, Filename *fn) { }
111 Filename *dlg_filesel_get(union control *ctrl, void *dlg) { return NULL; }
112 void dlg_fontsel_set(union control *ctrl, void *dlg, FontSpec *fn) { }
113 FontSpec *dlg_fontsel_get(union control *ctrl, void *dlg) { return NULL; }
114 void dlg_update_start(union control *ctrl, void *dlg) { }
115 void dlg_update_done(union control *ctrl, void *dlg) { }
116 void dlg_set_focus(union control *ctrl, void *dlg) { }
117 void dlg_label_change(union control *ctrl, void *dlg, char const *text) { }
118 union control *dlg_last_focused(union control *ctrl, void *dlg) { return NULL; }
119 void dlg_beep(void *dlg) { }
120 void dlg_error_msg(void *dlg, const char *msg) { }
121 void dlg_end(void *dlg, int value) { }
122 void dlg_coloursel_start(union control *ctrl, void *dlg,
123                          int r, int g, int b) { }
124 int dlg_coloursel_results(union control *ctrl, void *dlg,
125                           int *r, int *g, int *b) { return 0; }
126 void dlg_refresh(union control *ctrl, void *dlg) { }
127
128 /* miscellany */
129 void logevent(void *frontend, const char *msg) { }
130 int askappend(void *frontend, Filename *filename,
131               void (*callback)(void *ctx, int result), void *ctx) { return 0; }
132
133 const char *const appname = "FuZZterm";
134 const int ngsslibs = 0;
135 const char *const gsslibnames[0] = { };
136 const struct keyvalwhere gsslibkeywords[0] = { };
137
138 /*
139  * Default settings that are specific to Unix plink.
140  */
141 char *platform_default_s(const char *name)
142 {
143     if (!strcmp(name, "TermType"))
144         return dupstr(getenv("TERM"));
145     if (!strcmp(name, "SerialLine"))
146         return dupstr("/dev/ttyS0");
147     return NULL;
148 }
149
150 int platform_default_i(const char *name, int def)
151 {
152     return def;
153 }
154
155 FontSpec *platform_default_fontspec(const char *name)
156 {
157     return fontspec_new("");
158 }
159
160 Filename *platform_default_filename(const char *name)
161 {
162     if (!strcmp(name, "LogFileName"))
163         return filename_from_str("putty.log");
164     else
165         return filename_from_str("");
166 }
167
168 char *x_get_default(const char *key)
169 {
170     return NULL;                       /* this is a stub */
171 }
172
173