Patch from Alejandro Sedeno, somewhat modified by me, which
[u/mdw/putty] / unix / unix.h
1 #ifndef PUTTY_UNIX_H
2 #define PUTTY_UNIX_H
3
4 #ifdef HAVE_CONFIG_H
5 # include "uxconfig.h" /* Space to hide it from mkfiles.pl */
6 #endif
7
8 #include <stdio.h> /* for FILENAME_MAX */
9 #include <stdint.h> /* C99 int types */
10 #ifndef NO_LIBDL
11 #include <dlfcn.h> /* Dynamic library loading */
12 #endif /* NO_LIBDL */
13 #include "charset.h"
14
15 struct Filename {
16 char path[FILENAME_MAX];
17 };
18 FILE *f_open(struct Filename, char const *, int);
19
20 struct FontSpec {
21 char name[256];
22 };
23
24 typedef void *Context; /* FIXME: probably needs changing */
25
26 typedef int OSSocket;
27 #define OSSOCKET_DEFINED /* stop network.h using its default */
28
29 extern Backend pty_backend;
30
31 typedef uint32_t uint32; /* C99: uint32_t defined in stdint.h */
32 #define PUTTY_UINT32_DEFINED
33
34 /*
35 * Under GTK, we send MA_CLICK _and_ MA_2CLK, or MA_CLICK _and_
36 * MA_3CLK, when a button is pressed for the second or third time.
37 */
38 #define MULTICLICK_ONLY_EVENT 0
39
40 /*
41 * Under GTK, there is no context help available.
42 */
43 #define HELPCTX(x) P(NULL)
44 #define FILTER_KEY_FILES NULL /* FIXME */
45
46 /*
47 * Under X, selection data must not be NUL-terminated.
48 */
49 #define SELECTION_NUL_TERMINATED 0
50
51 /*
52 * Under X, copying to the clipboard terminates lines with just LF.
53 */
54 #define SEL_NL { 10 }
55
56 /* Simple wraparound timer function */
57 unsigned long getticks(void); /* based on gettimeofday(2) */
58 #define GETTICKCOUNT getticks
59 #define TICKSPERSEC 1000 /* we choose to use milliseconds */
60 #define CURSORBLINK 450 /* no standard way to set this */
61 /* getticks() works using gettimeofday(), so it's vulnerable to system clock
62 * changes causing chaos. Therefore, we provide a compensation mechanism. */
63 #define TIMING_SYNC
64 #define TIMING_SYNC_ANOW
65 extern long tickcount_offset;
66
67 #define WCHAR wchar_t
68 #define BYTE unsigned char
69
70 /*
71 * Unix-specific global flag
72 *
73 * FLAG_STDERR_TTY indicates that standard error might be a terminal and
74 * might get its configuration munged, so anything trying to output plain
75 * text (i.e. with newlines in it) will need to put it back into cooked
76 * mode first. Applications setting this flag should also call
77 * stderr_tty_init() before messing with any terminal modes, and can call
78 * premsg() before outputting text to stderr and postmsg() afterwards.
79 */
80 #define FLAG_STDERR_TTY 0x1000
81
82 /* Things pty.c needs from pterm.c */
83 char *get_x_display(void *frontend);
84 int font_dimension(void *frontend, int which);/* 0 for width, 1 for height */
85 long get_windowid(void *frontend);
86
87 /* Things gtkdlg.c needs from pterm.c */
88 void *get_window(void *frontend); /* void * to avoid depending on gtk.h */
89
90 /* Things pterm.c needs from gtkdlg.c */
91 int do_config_box(const char *title, Config *cfg,
92 int midsession, int protcfginfo);
93 void fatal_message_box(void *window, char *msg);
94 void about_box(void *window);
95 void *eventlogstuff_new(void);
96 void showeventlog(void *estuff, void *parentwin);
97 void logevent_dlg(void *estuff, const char *string);
98 int reallyclose(void *frontend);
99
100 /* Things pterm.c needs from {ptermm,uxputty}.c */
101 char *make_default_wintitle(char *hostname);
102 int process_nonoption_arg(char *arg, Config *cfg, int *allow_launch);
103
104 /* pterm.c needs this special function in xkeysym.c */
105 int keysym_to_unicode(int keysym);
106
107 /* Things uxstore.c needs from pterm.c */
108 char *x_get_default(const char *key);
109
110 /* Things uxstore.c provides to pterm.c */
111 void provide_xrm_string(char *string);
112
113 /* Things provided by uxcons.c */
114 struct termios;
115 void stderr_tty_init(void);
116 void premsg(struct termios *);
117 void postmsg(struct termios *);
118
119 /* The interface used by uxsel.c */
120 void uxsel_init(void);
121 typedef int (*uxsel_callback_fn)(int fd, int event);
122 void uxsel_set(int fd, int rwx, uxsel_callback_fn callback);
123 void uxsel_del(int fd);
124 int select_result(int fd, int event);
125 int first_fd(int *state, int *rwx);
126 int next_fd(int *state, int *rwx);
127 /* The following are expected to be provided _to_ uxsel.c by the frontend */
128 int uxsel_input_add(int fd, int rwx); /* returns an id */
129 void uxsel_input_remove(int id);
130
131 /* uxcfg.c */
132 struct controlbox;
133 void unix_setup_config_box(struct controlbox *b, int midsession, int protocol);
134
135 /* gtkcfg.c */
136 void gtk_setup_config_box(struct controlbox *b, int midsession, void *window);
137
138 /*
139 * In the Unix Unicode layer, DEFAULT_CODEPAGE is a special value
140 * which causes mb_to_wc and wc_to_mb to call _libc_ rather than
141 * libcharset. That way, we can interface the various charsets
142 * supported by libcharset with the one supported by mbstowcs and
143 * wcstombs (which will be the character set in which stuff read
144 * from the command line or config files is assumed to be encoded).
145 */
146 #define DEFAULT_CODEPAGE 0xFFFF
147 #define CP_UTF8 CS_UTF8 /* from libcharset */
148
149 #define strnicmp strncasecmp
150 #define stricmp strcasecmp
151
152 /* BSD-semantics version of signal(), and another helpful function */
153 void (*putty_signal(int sig, void (*func)(int)))(int);
154 void block_signal(int sig, int block_it);
155
156 /* uxmisc.c */
157 int cloexec(int);
158
159 /*
160 * Exports from unicode.c.
161 */
162 struct unicode_data;
163 int init_ucs(struct unicode_data *ucsdata, char *line_codepage,
164 int utf8_override, int font_charset, int vtmode);
165
166 /*
167 * Spare function exported directly from uxnet.c.
168 */
169 void *sk_getxdmdata(void *sock, int *lenp);
170
171 /*
172 * General helpful Unix stuff: more helpful version of the FD_SET
173 * macro, which also handles maxfd.
174 */
175 #define FD_SET_MAX(fd, max, set) do { \
176 FD_SET(fd, &set); \
177 if (max < fd + 1) max = fd + 1; \
178 } while (0)
179
180 /*
181 * Exports from winser.c.
182 */
183 extern Backend serial_backend;
184
185 #endif