]> asedeno.scripts.mit.edu Git - PuTTY.git/blob - unix/unix.h
Unix buildinfo: stop saying 'GTK' in pure CLI utilities.
[PuTTY.git] / 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 #include <sys/types.h>         /* for mode_t */
15
16 #ifdef OSX_GTK
17 /*
18  * Assorted tweaks to various parts of the GTK front end which all
19  * need to be enabled when compiling on OS X. Because I might need the
20  * same tweaks on other systems in future, I don't want to
21  * conditionalise all of them on OSX_GTK directly, so instead, each
22  * one has its own name and we enable them all centrally here if
23  * OSX_GTK is defined at configure time.
24  */
25 #define NOT_X_WINDOWS /* of course, all the X11 stuff should be disabled */
26 #define NO_PTY_PRE_INIT /* OS X gets very huffy if we try to set[ug]id */
27 #define SET_NONBLOCK_VIA_OPENPT /* work around missing fcntl functionality */
28 #define OSX_META_KEY_CONFIG /* two possible Meta keys to choose from */
29 /* this potential one of the Meta keys needs manual handling */
30 #define META_MANUAL_MASK (GDK_MOD1_MASK)
31 #define JUST_USE_GTK_CLIPBOARD_UTF8 /* low-level gdk_selection_* fails */
32 #define DEFAULT_CLIPBOARD GDK_SELECTION_CLIPBOARD /* OS X has no PRIMARY */
33
34 #define BUILDINFO_PLATFORM_GTK "OS X (GTK)"
35 #define BUILDINFO_GTK
36
37 #elif defined NOT_X_WINDOWS
38
39 #define BUILDINFO_PLATFORM_GTK "Unix (pure GTK)"
40 #define BUILDINFO_GTK
41
42 #else
43
44 #define BUILDINFO_PLATFORM_GTK "Unix (GTK + X11)"
45 #define BUILDINFO_GTK
46
47 #endif
48
49 /* BUILDINFO_PLATFORM varies its expansion between the GTK and
50  * pure-CLI utilities, so that Unix Plink, PSFTP etc don't announce
51  * themselves incongruously as having something to do with GTK. */
52 #define BUILDINFO_PLATFORM_CLI "Unix"
53 extern const int buildinfo_gtk_relevant;
54 #define BUILDINFO_PLATFORM (buildinfo_gtk_relevant ? \
55                             BUILDINFO_PLATFORM_GTK : BUILDINFO_PLATFORM_CLI)
56
57 char *buildinfo_gtk_version(void);
58
59 struct Filename {
60     char *path;
61 };
62 FILE *f_open(const struct Filename *, char const *, int);
63
64 struct FontSpec {
65     char *name;    /* may be "" to indicate no selected font at all */
66 };
67 struct FontSpec *fontspec_new(const char *name);
68
69 typedef void *Context;                 /* FIXME: probably needs changing */
70
71 extern Backend pty_backend;
72
73 #define BROKEN_PIPE_ERROR_CODE EPIPE   /* used in sshshare.c */
74
75 typedef uint32_t uint32; /* C99: uint32_t defined in stdint.h */
76 #define PUTTY_UINT32_DEFINED
77
78 /*
79  * Under GTK, we send MA_CLICK _and_ MA_2CLK, or MA_CLICK _and_
80  * MA_3CLK, when a button is pressed for the second or third time.
81  */
82 #define MULTICLICK_ONLY_EVENT 0
83
84 /*
85  * Under GTK, there is no context help available.
86  */
87 #define HELPCTX(x) P(NULL)
88 #define FILTER_KEY_FILES NULL          /* FIXME */
89 #define FILTER_DYNLIB_FILES NULL       /* FIXME */
90
91 /*
92  * Under X, selection data must not be NUL-terminated.
93  */
94 #define SELECTION_NUL_TERMINATED 0
95
96 /*
97  * Under X, copying to the clipboard terminates lines with just LF.
98  */
99 #define SEL_NL { 10 }
100
101 /* Simple wraparound timer function */
102 unsigned long getticks(void);
103 #define GETTICKCOUNT getticks
104 #define TICKSPERSEC    1000            /* we choose to use milliseconds */
105 #define CURSORBLINK     450            /* no standard way to set this */
106
107 #define WCHAR wchar_t
108 #define BYTE unsigned char
109
110 /*
111  * Unix-specific global flag
112  *
113  * FLAG_STDERR_TTY indicates that standard error might be a terminal and
114  * might get its configuration munged, so anything trying to output plain
115  * text (i.e. with newlines in it) will need to put it back into cooked
116  * mode first.  Applications setting this flag should also call
117  * stderr_tty_init() before messing with any terminal modes, and can call
118  * premsg() before outputting text to stderr and postmsg() afterwards.
119  */
120 #define FLAG_STDERR_TTY 0x1000
121
122 /* The per-session frontend structure managed by gtkwin.c */
123 struct gui_data;
124 struct gui_data *new_session_window(Conf *conf, const char *geometry_string);
125
126 /* Defined in gtkmain.c */
127 void launch_duplicate_session(Conf *conf);
128 void launch_new_session(void);
129 void launch_saved_session(const char *str);
130 #ifdef MAY_REFER_TO_GTK_IN_HEADERS
131 GtkWidget *make_gtk_toplevel_window(void *frontend);
132 #endif
133
134 /* Defined in gtkcomm.c */
135 void gtkcomm_setup(void);
136
137 /* Things pty.c needs from pterm.c */
138 const char *get_x_display(void *frontend);
139 int font_dimension(void *frontend, int which);/* 0 for width, 1 for height */
140 long get_windowid(void *frontend);
141
142 /* Things gtkdlg.c needs from pterm.c */
143 void *get_window(void *frontend);      /* void * to avoid depending on gtk.h */
144 void post_main(void);     /* called after any subsidiary gtk_main() */
145
146 /* Things pterm.c needs from gtkdlg.c */
147 int do_config_box(const char *title, Conf *conf,
148                   int midsession, int protcfginfo);
149 void fatal_message_box(void *window, const char *msg);
150 void nonfatal_message_box(void *window, const char *msg);
151 void about_box(void *window);
152 void *eventlogstuff_new(void);
153 void showeventlog(void *estuff, void *parentwin);
154 void logevent_dlg(void *estuff, const char *string);
155 int reallyclose(void *frontend);
156 #ifdef MAY_REFER_TO_GTK_IN_HEADERS
157 int messagebox(GtkWidget *parentwin, const char *title,
158                const char *msg, int minwid, int selectable, ...);
159 #endif
160
161 /* Things pterm.c needs from {ptermm,uxputty}.c */
162 char *make_default_wintitle(char *hostname);
163 int process_nonoption_arg(const char *arg, Conf *conf, int *allow_launch);
164
165 /* pterm.c needs this special function in xkeysym.c */
166 int keysym_to_unicode(int keysym);
167
168 /* Things uxstore.c needs from pterm.c */
169 char *x_get_default(const char *key);
170
171 /* Things uxstore.c provides to pterm.c */
172 void provide_xrm_string(char *string);
173
174 /* Things provided by uxcons.c */
175 struct termios;
176 void stderr_tty_init(void);
177 void premsg(struct termios *);
178 void postmsg(struct termios *);
179
180 /* The interface used by uxsel.c */
181 typedef struct uxsel_id uxsel_id;
182 void uxsel_init(void);
183 typedef int (*uxsel_callback_fn)(int fd, int event);
184 void uxsel_set(int fd, int rwx, uxsel_callback_fn callback);
185 void uxsel_del(int fd);
186 int select_result(int fd, int event);
187 int first_fd(int *state, int *rwx);
188 int next_fd(int *state, int *rwx);
189 /* The following are expected to be provided _to_ uxsel.c by the frontend */
190 uxsel_id *uxsel_input_add(int fd, int rwx);  /* returns an id */
191 void uxsel_input_remove(uxsel_id *id);
192
193 /* uxcfg.c */
194 struct controlbox;
195 void unix_setup_config_box(struct controlbox *b, int midsession, int protocol);
196
197 /* gtkcfg.c */
198 void gtk_setup_config_box(struct controlbox *b, int midsession, void *window);
199
200 /*
201  * In the Unix Unicode layer, DEFAULT_CODEPAGE is a special value
202  * which causes mb_to_wc and wc_to_mb to call _libc_ rather than
203  * libcharset. That way, we can interface the various charsets
204  * supported by libcharset with the one supported by mbstowcs and
205  * wcstombs (which will be the character set in which stuff read
206  * from the command line or config files is assumed to be encoded).
207  */
208 #define DEFAULT_CODEPAGE 0xFFFF
209 #define CP_UTF8 CS_UTF8                /* from libcharset */
210
211 #define strnicmp strncasecmp
212 #define stricmp strcasecmp
213
214 /* BSD-semantics version of signal(), and another helpful function */
215 void (*putty_signal(int sig, void (*func)(int)))(int);
216 void block_signal(int sig, int block_it);
217
218 /* uxmisc.c */
219 void cloexec(int);
220 void noncloexec(int);
221 int nonblock(int);
222 int no_nonblock(int);
223 char *make_dir_and_check_ours(const char *dirname);
224 char *make_dir_path(const char *path, mode_t mode);
225
226 /*
227  * Exports from unicode.c.
228  */
229 struct unicode_data;
230 int init_ucs(struct unicode_data *ucsdata, char *line_codepage,
231              int utf8_override, int font_charset, int vtmode);
232
233 /*
234  * Spare function exported directly from uxnet.c.
235  */
236 void *sk_getxdmdata(void *sock, int *lenp);
237
238 /*
239  * General helpful Unix stuff: more helpful version of the FD_SET
240  * macro, which also handles maxfd.
241  */
242 #define FD_SET_MAX(fd, max, set) do { \
243     FD_SET(fd, &set); \
244     if (max < fd + 1) max = fd + 1; \
245 } while (0)
246
247 /*
248  * Exports from winser.c.
249  */
250 extern Backend serial_backend;
251
252 /*
253  * uxpeer.c, wrapping getsockopt(SO_PEERCRED).
254  */
255 int so_peercred(int fd, int *pid, int *uid, int *gid);
256
257 /*
258  * Default font setting, which can vary depending on NOT_X_WINDOWS.
259  */
260 #ifdef NOT_X_WINDOWS
261 #define DEFAULT_GTK_FONT "client:Monospace 12"
262 #else
263 #define DEFAULT_GTK_FONT "server:fixed"
264 #endif
265
266 #endif