]> asedeno.scripts.mit.edu Git - PuTTY.git/blob - fuzzterm.c
Fuzzable terminal emulator.
[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         while (!feof(stdin)) {
27                 len = fread(blk, 1, sizeof(blk), stdin);
28                 term_data(term, 0, blk, len);
29         }
30         return 0;
31 }
32
33 int from_backend(void *frontend, int is_stderr, const char *data, int len)
34 { return 0; }
35
36 /* functions required by terminal.c */
37
38 void request_resize(void *frontend, int x, int y) { }
39 void do_text(Context a, int b, int c, wchar_t * d, int e, unsigned long f, int g) { }
40 void do_cursor(Context a, int b, int c, wchar_t * d, int e, unsigned long f, int g) { }
41 int char_width(Context ctx, int uc) { return 1; }
42 void set_title(void *frontend, char *t) { }
43 void set_icon(void *frontend, char *t) { }
44 void set_sbar(void *frontend, int a, int b, int c) { }
45
46 void ldisc_send(void *handle, const char *buf, int len, int interactive) {}
47 void ldisc_echoedit_update(void *handle) {}
48 Context get_ctx(void *frontend) { return NULL; }
49 void free_ctx(Context ctx) { }
50 void palette_set(void *frontend, int a, int b, int c, int d) { }
51 void palette_reset(void *frontend) { }
52 void write_clip(void *frontend, wchar_t *a, int *b, int c, int d) { }
53 void get_clip(void *frontend, wchar_t **w, int *i) { }
54 void set_raw_mouse_mode(void *frontend, int m) { }
55 void request_paste(void *frontend) { }
56 void do_beep(void *frontend, int a) { }
57 void sys_cursor(void *frontend, int x, int y) { }
58 void fatalbox(const char *fmt, ...) { exit(0); }
59 void modalfatalbox(const char *fmt, ...) { exit(0); }
60 void nonfatal(const char *fmt, ...) { }
61
62 void set_iconic(void *frontend, int iconic) { }
63 void move_window(void *frontend, int x, int y) { }
64 void set_zorder(void *frontend, int top) { }
65 void refresh_window(void *frontend) { }
66 void set_zoomed(void *frontend, int zoomed) { }
67 int is_iconic(void *frontend) { return 0; }
68 void get_window_pos(void *frontend, int *x, int *y) { *x = 0; *y = 0; }
69 void get_window_pixels(void *frontend, int *x, int *y) { *x = 0; *y = 0; }
70 char *get_window_title(void *frontend, int icon) { return "moo"; }
71
72 /* needed by timing.c */
73 void timer_change_notify(unsigned long next) { }
74
75 /* needed by config.c and sercfg.c */
76
77 void dlg_radiobutton_set(union control *ctrl, void *dlg, int whichbutton) { }
78 int dlg_radiobutton_get(union control *ctrl, void *dlg) { return 0; }
79 void dlg_checkbox_set(union control *ctrl, void *dlg, int checked) { }
80 int dlg_checkbox_get(union control *ctrl, void *dlg) { return 0; }
81 void dlg_editbox_set(union control *ctrl, void *dlg, char const *text) { }
82 char *dlg_editbox_get(union control *ctrl, void *dlg) { return dupstr("moo"); }
83 void dlg_listbox_clear(union control *ctrl, void *dlg) { }
84 void dlg_listbox_del(union control *ctrl, void *dlg, int index) { }
85 void dlg_listbox_add(union control *ctrl, void *dlg, char const *text) { }
86 void dlg_listbox_addwithid(union control *ctrl, void *dlg,
87                            char const *text, int id) { }
88 int dlg_listbox_getid(union control *ctrl, void *dlg, int index) { return 0; }
89 int dlg_listbox_index(union control *ctrl, void *dlg) { return -1; }
90 int dlg_listbox_issel(union control *ctrl, void *dlg, int index) { return 0; }
91 void dlg_listbox_select(union control *ctrl, void *dlg, int index) { }
92 void dlg_text_set(union control *ctrl, void *dlg, char const *text) { }
93 void dlg_filesel_set(union control *ctrl, void *dlg, Filename *fn) { }
94 Filename *dlg_filesel_get(union control *ctrl, void *dlg) { return NULL; }
95 void dlg_fontsel_set(union control *ctrl, void *dlg, FontSpec *fn) { }
96 FontSpec *dlg_fontsel_get(union control *ctrl, void *dlg) { return NULL; }
97 void dlg_update_start(union control *ctrl, void *dlg) { }
98 void dlg_update_done(union control *ctrl, void *dlg) { }
99 void dlg_set_focus(union control *ctrl, void *dlg) { }
100 void dlg_label_change(union control *ctrl, void *dlg, char const *text) { }
101 union control *dlg_last_focused(union control *ctrl, void *dlg) { return NULL; }
102 void dlg_beep(void *dlg) { }
103 void dlg_error_msg(void *dlg, const char *msg) { }
104 void dlg_end(void *dlg, int value) { }
105 void dlg_coloursel_start(union control *ctrl, void *dlg,
106                          int r, int g, int b) { }
107 int dlg_coloursel_results(union control *ctrl, void *dlg,
108                           int *r, int *g, int *b) { return 0; }
109 void dlg_refresh(union control *ctrl, void *dlg) { }
110
111 /* miscellany */
112 void logevent(void *frontend, const char *msg) { }
113 int askappend(void *frontend, Filename *filename,
114               void (*callback)(void *ctx, int result), void *ctx) { return 0; }
115
116 const char *const appname = "FuZZterm";
117 const int ngsslibs = 0;
118 const char *const gsslibnames[0] = { };
119 const struct keyvalwhere gsslibkeywords[0] = { };
120
121 /*
122  * Default settings that are specific to Unix plink.
123  */
124 char *platform_default_s(const char *name)
125 {
126     if (!strcmp(name, "TermType"))
127         return dupstr(getenv("TERM"));
128     if (!strcmp(name, "SerialLine"))
129         return dupstr("/dev/ttyS0");
130     return NULL;
131 }
132
133 int platform_default_i(const char *name, int def)
134 {
135     return def;
136 }
137
138 FontSpec *platform_default_fontspec(const char *name)
139 {
140     return fontspec_new("");
141 }
142
143 Filename *platform_default_filename(const char *name)
144 {
145     if (!strcmp(name, "LogFileName"))
146         return filename_from_str("putty.log");
147     else
148         return filename_from_str("");
149 }
150
151 char *x_get_default(const char *key)
152 {
153     return NULL;                       /* this is a stub */
154 }
155
156