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