]> asedeno.scripts.mit.edu Git - PuTTY.git/blob - fuzzterm.c
21e7b12aa5a041ace211a6cda4315b2496a29314
[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     int i;
48
49     printf("TEXT[attr=%08lx,lattr=%02x]@(%d,%d):", attr, lattr, x, y);
50     for (i = 0; i < len; i++) {
51         printf(" %x", (unsigned)text[i]);
52     }
53     printf("\n");
54 }
55 void do_cursor(Context ctx, int x, int y, wchar_t * text, int len,
56              unsigned long attr, int lattr)
57 {
58     int i;
59
60     printf("CURS[attr=%08lx,lattr=%02x]@(%d,%d):", attr, lattr, x, y);
61     for (i = 0; i < len; i++) {
62         printf(" %x", (unsigned)text[i]);
63     }
64     printf("\n");
65 }
66 int char_width(Context ctx, int uc) { return 1; }
67 void set_title(void *frontend, char *t) { }
68 void set_icon(void *frontend, char *t) { }
69 void set_sbar(void *frontend, int a, int b, int c) { }
70
71 void ldisc_send(void *handle, const char *buf, int len, int interactive) {}
72 void ldisc_echoedit_update(void *handle) {}
73 Context get_ctx(void *frontend) { 
74     static char x;
75
76     return &x;
77 }
78 void free_ctx(Context ctx) { }
79 void palette_set(void *frontend, int a, int b, int c, int d) { }
80 void palette_reset(void *frontend) { }
81 void write_clip(void *frontend, wchar_t *a, int *b, int c, int d) { }
82 void get_clip(void *frontend, wchar_t **w, int *i) { }
83 void set_raw_mouse_mode(void *frontend, int m) { }
84 void request_paste(void *frontend) { }
85 void do_beep(void *frontend, int a) { }
86 void sys_cursor(void *frontend, int x, int y) { }
87 void fatalbox(const char *fmt, ...) { exit(0); }
88 void modalfatalbox(const char *fmt, ...) { exit(0); }
89 void nonfatal(const char *fmt, ...) { }
90
91 void set_iconic(void *frontend, int iconic) { }
92 void move_window(void *frontend, int x, int y) { }
93 void set_zorder(void *frontend, int top) { }
94 void refresh_window(void *frontend) { }
95 void set_zoomed(void *frontend, int zoomed) { }
96 int is_iconic(void *frontend) { return 0; }
97 void get_window_pos(void *frontend, int *x, int *y) { *x = 0; *y = 0; }
98 void get_window_pixels(void *frontend, int *x, int *y) { *x = 0; *y = 0; }
99 char *get_window_title(void *frontend, int icon) { return "moo"; }
100 int frontend_is_utf8(void *frontend) { return TRUE; }
101
102 /* needed by timing.c */
103 void timer_change_notify(unsigned long next) { }
104
105 /* needed by config.c and sercfg.c */
106
107 void dlg_radiobutton_set(union control *ctrl, void *dlg, int whichbutton) { }
108 int dlg_radiobutton_get(union control *ctrl, void *dlg) { return 0; }
109 void dlg_checkbox_set(union control *ctrl, void *dlg, int checked) { }
110 int dlg_checkbox_get(union control *ctrl, void *dlg) { return 0; }
111 void dlg_editbox_set(union control *ctrl, void *dlg, char const *text) { }
112 char *dlg_editbox_get(union control *ctrl, void *dlg) { return dupstr("moo"); }
113 void dlg_listbox_clear(union control *ctrl, void *dlg) { }
114 void dlg_listbox_del(union control *ctrl, void *dlg, int index) { }
115 void dlg_listbox_add(union control *ctrl, void *dlg, char const *text) { }
116 void dlg_listbox_addwithid(union control *ctrl, void *dlg,
117                            char const *text, int id) { }
118 int dlg_listbox_getid(union control *ctrl, void *dlg, int index) { return 0; }
119 int dlg_listbox_index(union control *ctrl, void *dlg) { return -1; }
120 int dlg_listbox_issel(union control *ctrl, void *dlg, int index) { return 0; }
121 void dlg_listbox_select(union control *ctrl, void *dlg, int index) { }
122 void dlg_text_set(union control *ctrl, void *dlg, char const *text) { }
123 void dlg_filesel_set(union control *ctrl, void *dlg, Filename *fn) { }
124 Filename *dlg_filesel_get(union control *ctrl, void *dlg) { return NULL; }
125 void dlg_fontsel_set(union control *ctrl, void *dlg, FontSpec *fn) { }
126 FontSpec *dlg_fontsel_get(union control *ctrl, void *dlg) { return NULL; }
127 void dlg_update_start(union control *ctrl, void *dlg) { }
128 void dlg_update_done(union control *ctrl, void *dlg) { }
129 void dlg_set_focus(union control *ctrl, void *dlg) { }
130 void dlg_label_change(union control *ctrl, void *dlg, char const *text) { }
131 union control *dlg_last_focused(union control *ctrl, void *dlg) { return NULL; }
132 void dlg_beep(void *dlg) { }
133 void dlg_error_msg(void *dlg, const char *msg) { }
134 void dlg_end(void *dlg, int value) { }
135 void dlg_coloursel_start(union control *ctrl, void *dlg,
136                          int r, int g, int b) { }
137 int dlg_coloursel_results(union control *ctrl, void *dlg,
138                           int *r, int *g, int *b) { return 0; }
139 void dlg_refresh(union control *ctrl, void *dlg) { }
140
141 /* miscellany */
142 void logevent(void *frontend, const char *msg) { }
143 int askappend(void *frontend, Filename *filename,
144               void (*callback)(void *ctx, int result), void *ctx) { return 0; }
145
146 const char *const appname = "FuZZterm";
147 const int ngsslibs = 0;
148 const char *const gsslibnames[0] = { };
149 const struct keyvalwhere gsslibkeywords[0] = { };
150
151 /*
152  * Default settings that are specific to Unix plink.
153  */
154 char *platform_default_s(const char *name)
155 {
156     if (!strcmp(name, "TermType"))
157         return dupstr(getenv("TERM"));
158     if (!strcmp(name, "SerialLine"))
159         return dupstr("/dev/ttyS0");
160     return NULL;
161 }
162
163 int platform_default_i(const char *name, int def)
164 {
165     return def;
166 }
167
168 FontSpec *platform_default_fontspec(const char *name)
169 {
170     return fontspec_new("");
171 }
172
173 Filename *platform_default_filename(const char *name)
174 {
175     if (!strcmp(name, "LogFileName"))
176         return filename_from_str("putty.log");
177     else
178         return filename_from_str("");
179 }
180
181 char *x_get_default(const char *key)
182 {
183     return NULL;                       /* this is a stub */
184 }
185
186