Reorganise setup_fonts_ucs so that in case of error it does nothing
[u/mdw/putty] / unix / unix.h
... / ...
CommitLineData
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
15struct Filename {
16 char *path;
17};
18FILE *f_open(const struct Filename *, char const *, int);
19
20struct FontSpec {
21 char *name; /* may be "" to indicate no selected font at all */
22};
23struct FontSpec *fontspec_new(const char *name);
24
25typedef void *Context; /* FIXME: probably needs changing */
26
27typedef int OSSocket;
28#define OSSOCKET_DEFINED /* stop network.h using its default */
29
30extern Backend pty_backend;
31
32typedef uint32_t uint32; /* C99: uint32_t defined in stdint.h */
33#define PUTTY_UINT32_DEFINED
34
35/*
36 * Under GTK, we send MA_CLICK _and_ MA_2CLK, or MA_CLICK _and_
37 * MA_3CLK, when a button is pressed for the second or third time.
38 */
39#define MULTICLICK_ONLY_EVENT 0
40
41/*
42 * Under GTK, there is no context help available.
43 */
44#define HELPCTX(x) P(NULL)
45#define FILTER_KEY_FILES NULL /* FIXME */
46#define FILTER_DYNLIB_FILES NULL /* FIXME */
47
48/*
49 * Under X, selection data must not be NUL-terminated.
50 */
51#define SELECTION_NUL_TERMINATED 0
52
53/*
54 * Under X, copying to the clipboard terminates lines with just LF.
55 */
56#define SEL_NL { 10 }
57
58/* Simple wraparound timer function */
59unsigned long getticks(void); /* based on gettimeofday(2) */
60#define GETTICKCOUNT getticks
61#define TICKSPERSEC 1000 /* we choose to use milliseconds */
62#define CURSORBLINK 450 /* no standard way to set this */
63
64#define WCHAR wchar_t
65#define BYTE unsigned char
66
67/*
68 * Unix-specific global flag
69 *
70 * FLAG_STDERR_TTY indicates that standard error might be a terminal and
71 * might get its configuration munged, so anything trying to output plain
72 * text (i.e. with newlines in it) will need to put it back into cooked
73 * mode first. Applications setting this flag should also call
74 * stderr_tty_init() before messing with any terminal modes, and can call
75 * premsg() before outputting text to stderr and postmsg() afterwards.
76 */
77#define FLAG_STDERR_TTY 0x1000
78
79/* Things pty.c needs from pterm.c */
80char *get_x_display(void *frontend);
81int font_dimension(void *frontend, int which);/* 0 for width, 1 for height */
82long get_windowid(void *frontend);
83
84/* Things gtkdlg.c needs from pterm.c */
85void *get_window(void *frontend); /* void * to avoid depending on gtk.h */
86
87/* Things pterm.c needs from gtkdlg.c */
88int do_config_box(const char *title, Conf *conf,
89 int midsession, int protcfginfo);
90void fatal_message_box(void *window, char *msg);
91void about_box(void *window);
92void *eventlogstuff_new(void);
93void showeventlog(void *estuff, void *parentwin);
94void logevent_dlg(void *estuff, const char *string);
95int reallyclose(void *frontend);
96#ifdef MAY_REFER_TO_GTK_IN_HEADERS
97int messagebox(GtkWidget *parentwin, char *title, char *msg, int minwid, ...);
98int string_width(char *text);
99#endif
100
101/* Things pterm.c needs from {ptermm,uxputty}.c */
102char *make_default_wintitle(char *hostname);
103int process_nonoption_arg(char *arg, Conf *conf, int *allow_launch);
104
105/* pterm.c needs this special function in xkeysym.c */
106int keysym_to_unicode(int keysym);
107
108/* Things uxstore.c needs from pterm.c */
109char *x_get_default(const char *key);
110
111/* Things uxstore.c provides to pterm.c */
112void provide_xrm_string(char *string);
113
114/* Things provided by uxcons.c */
115struct termios;
116void stderr_tty_init(void);
117void premsg(struct termios *);
118void postmsg(struct termios *);
119
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);
125int select_result(int fd, int event);
126int first_fd(int *state, int *rwx);
127int next_fd(int *state, int *rwx);
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);
131
132/* uxcfg.c */
133struct controlbox;
134void unix_setup_config_box(struct controlbox *b, int midsession, int protocol);
135
136/* gtkcfg.c */
137void gtk_setup_config_box(struct controlbox *b, int midsession, void *window);
138
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 */
149
150#define strnicmp strncasecmp
151#define stricmp strcasecmp
152
153/* BSD-semantics version of signal(), and another helpful function */
154void (*putty_signal(int sig, void (*func)(int)))(int);
155void block_signal(int sig, int block_it);
156
157/* uxmisc.c */
158int cloexec(int);
159
160/*
161 * Exports from unicode.c.
162 */
163struct unicode_data;
164int init_ucs(struct unicode_data *ucsdata, char *line_codepage,
165 int utf8_override, int font_charset, int vtmode);
166
167/*
168 * Spare function exported directly from uxnet.c.
169 */
170void *sk_getxdmdata(void *sock, int *lenp);
171
172/*
173 * Function provided by front ends, and called by uxnet.c to indicate
174 * that net_pending_errors() would like to be called back when the
175 * front end has a spare moment and isn't deep in any other recursion.
176 */
177void frontend_net_error_pending(void);
178
179/*
180 * General helpful Unix stuff: more helpful version of the FD_SET
181 * macro, which also handles maxfd.
182 */
183#define FD_SET_MAX(fd, max, set) do { \
184 FD_SET(fd, &set); \
185 if (max < fd + 1) max = fd + 1; \
186} while (0)
187
188/*
189 * Exports from winser.c.
190 */
191extern Backend serial_backend;
192
193#endif