source: filezilla/trunk/fuentes/src/putty/unix/unix.h @ 3185

Last change on this file since 3185 was 3185, checked in by jrpelegrina, 2 years ago

Update new version: 3.15.02

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