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