Post-release destabilisation! Completely remove the struct type
[u/mdw/putty] / unix / unix.h
CommitLineData
f7f27309 1#ifndef PUTTY_UNIX_H
2#define PUTTY_UNIX_H
3
76d3a838 4#ifdef HAVE_CONFIG_H
5# include "uxconfig.h" /* Space to hide it from mkfiles.pl */
6#endif
7
9a30e26b 8#include <stdio.h> /* for FILENAME_MAX */
b3d375b2 9#include <stdint.h> /* C99 int types */
10#ifndef NO_LIBDL
11#include <dlfcn.h> /* Dynamic library loading */
12#endif /* NO_LIBDL */
2dc6356a 13#include "charset.h"
14
9a30e26b 15struct Filename {
16 char path[FILENAME_MAX];
17};
c6940f12 18FILE *f_open(struct Filename, char const *, int);
9a30e26b 19
20struct FontSpec {
21 char name[256];
22};
23
f7f27309 24typedef void *Context; /* FIXME: probably needs changing */
25
f7f9fb5c 26typedef int OSSocket;
27#define OSSOCKET_DEFINED /* stop network.h using its default */
28
1709795f 29extern Backend pty_backend;
30
b3d375b2 31typedef uint32_t uint32; /* C99: uint32_t defined in stdint.h */
32#define PUTTY_UINT32_DEFINED
33
e6346999 34/*
35 * Under GTK, we send MA_CLICK _and_ MA_2CLK, or MA_CLICK _and_
36 * MA_3CLK, when a button is pressed for the second or third time.
37 */
38#define MULTICLICK_ONLY_EVENT 0
39
40/*
d9b15094 41 * Under GTK, there is no context help available.
42 */
43#define HELPCTX(x) P(NULL)
44#define FILTER_KEY_FILES NULL /* FIXME */
1e00c92b 45#define FILTER_DYNLIB_FILES NULL /* FIXME */
d9b15094 46
47/*
e6346999 48 * Under X, selection data must not be NUL-terminated.
49 */
50#define SELECTION_NUL_TERMINATED 0
51
0f351587 52/*
53 * Under X, copying to the clipboard terminates lines with just LF.
54 */
55#define SEL_NL { 10 }
56
f7f27309 57/* Simple wraparound timer function */
58unsigned long getticks(void); /* based on gettimeofday(2) */
59#define GETTICKCOUNT getticks
39934deb 60#define TICKSPERSEC 1000 /* we choose to use milliseconds */
61#define CURSORBLINK 450 /* no standard way to set this */
2ac3322e 62/* getticks() works using gettimeofday(), so it's vulnerable to system clock
63 * changes causing chaos. Therefore, we provide a compensation mechanism. */
64#define TIMING_SYNC
65#define TIMING_SYNC_ANOW
66extern long tickcount_offset;
f7f27309 67
68#define WCHAR wchar_t
69#define BYTE unsigned char
70
f7397dc6 71/*
72 * Unix-specific global flag
73 *
74 * FLAG_STDERR_TTY indicates that standard error might be a terminal and
75 * might get its configuration munged, so anything trying to output plain
76 * text (i.e. with newlines in it) will need to put it back into cooked
77 * mode first. Applications setting this flag should also call
78 * stderr_tty_init() before messing with any terminal modes, and can call
79 * premsg() before outputting text to stderr and postmsg() afterwards.
80 */
81#define FLAG_STDERR_TTY 0x1000
82
e9aef757 83/* Things pty.c needs from pterm.c */
a8327734 84char *get_x_display(void *frontend);
85int font_dimension(void *frontend, int which);/* 0 for width, 1 for height */
7af753e6 86long get_windowid(void *frontend);
755a6d84 87
5bf9955d 88/* Things gtkdlg.c needs from pterm.c */
89void *get_window(void *frontend); /* void * to avoid depending on gtk.h */
90
3f935d5b 91/* Things pterm.c needs from gtkdlg.c */
4a693cfc 92int do_config_box(const char *title, Conf *conf,
f89c3294 93 int midsession, int protcfginfo);
3f935d5b 94void fatal_message_box(void *window, char *msg);
7718480a 95void about_box(void *window);
8eed910d 96void *eventlogstuff_new(void);
97void showeventlog(void *estuff, void *parentwin);
cbe2d68f 98void logevent_dlg(void *estuff, const char *string);
abb6895f 99int reallyclose(void *frontend);
3f935d5b 100
10705014 101/* Things pterm.c needs from {ptermm,uxputty}.c */
102char *make_default_wintitle(char *hostname);
4a693cfc 103int process_nonoption_arg(char *arg, Conf *conf, int *allow_launch);
10705014 104
f5dd8adb 105/* pterm.c needs this special function in xkeysym.c */
106int keysym_to_unicode(int keysym);
107
faec60ed 108/* Things uxstore.c needs from pterm.c */
c85623f9 109char *x_get_default(const char *key);
faec60ed 110
0ac15bdc 111/* Things uxstore.c provides to pterm.c */
112void provide_xrm_string(char *string);
113
f7397dc6 114/* Things provided by uxcons.c */
115struct termios;
116void stderr_tty_init(void);
117void premsg(struct termios *);
118void postmsg(struct termios *);
119
0ff9ea38 120/* The interface used by uxsel.c */
121void uxsel_init(void);
122typedef int (*uxsel_callback_fn)(int fd, int event);
123void uxsel_set(int fd, int rwx, uxsel_callback_fn callback);
124void uxsel_del(int fd);
c5e438ec 125int select_result(int fd, int event);
0ff9ea38 126int first_fd(int *state, int *rwx);
127int next_fd(int *state, int *rwx);
74aca06d 128/* The following are expected to be provided _to_ uxsel.c by the frontend */
129int uxsel_input_add(int fd, int rwx); /* returns an id */
130void uxsel_input_remove(int id);
c5e438ec 131
1d0d4a3b 132/* uxcfg.c */
133struct controlbox;
8a7f1392 134void unix_setup_config_box(struct controlbox *b, int midsession, int protocol);
1d0d4a3b 135
8d68f26a 136/* gtkcfg.c */
137void gtk_setup_config_box(struct controlbox *b, int midsession, void *window);
138
2dc6356a 139/*
140 * In the Unix Unicode layer, DEFAULT_CODEPAGE is a special value
141 * which causes mb_to_wc and wc_to_mb to call _libc_ rather than
142 * libcharset. That way, we can interface the various charsets
143 * supported by libcharset with the one supported by mbstowcs and
144 * wcstombs (which will be the character set in which stuff read
145 * from the command line or config files is assumed to be encoded).
146 */
147#define DEFAULT_CODEPAGE 0xFFFF
148#define CP_UTF8 CS_UTF8 /* from libcharset */
f7f27309 149
68a49acb 150#define strnicmp strncasecmp
151#define stricmp strcasecmp
152
15b5d988 153/* BSD-semantics version of signal(), and another helpful function */
0f33f9d1 154void (*putty_signal(int sig, void (*func)(int)))(int);
15b5d988 155void block_signal(int sig, int block_it);
0f33f9d1 156
db9b7dce 157/* uxmisc.c */
158int cloexec(int);
159
facd762c 160/*
161 * Exports from unicode.c.
162 */
21d2b241 163struct unicode_data;
6ac7f054 164int init_ucs(struct unicode_data *ucsdata, char *line_codepage,
165 int utf8_override, int font_charset, int vtmode);
facd762c 166
2f92b717 167/*
168 * Spare function exported directly from uxnet.c.
169 */
0a4022a1 170void *sk_getxdmdata(void *sock, int *lenp);
2f92b717 171
b51259f6 172/*
173 * General helpful Unix stuff: more helpful version of the FD_SET
174 * macro, which also handles maxfd.
175 */
176#define FD_SET_MAX(fd, max, set) do { \
177 FD_SET(fd, &set); \
178 if (max < fd + 1) max = fd + 1; \
179} while (0)
180
aef05b78 181/*
182 * Exports from winser.c.
183 */
184extern Backend serial_backend;
185
f7f27309 186#endif