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