Render timing.c robust in the face of strangeness. The strangenesses
[u/mdw/putty] / unix / unix.h
CommitLineData
f7f27309 1#ifndef PUTTY_UNIX_H
2#define PUTTY_UNIX_H
3
9a30e26b 4#include <stdio.h> /* for FILENAME_MAX */
2dc6356a 5#include "charset.h"
6
9a30e26b 7struct Filename {
8 char path[FILENAME_MAX];
9};
10#define f_open(filename, mode) ( fopen((filename).path, (mode)) )
11
12struct FontSpec {
13 char name[256];
14};
15
f7f27309 16typedef void *Context; /* FIXME: probably needs changing */
17
f7f9fb5c 18typedef int OSSocket;
19#define OSSOCKET_DEFINED /* stop network.h using its default */
20
1709795f 21extern Backend pty_backend;
22
e6346999 23/*
24 * Under GTK, we send MA_CLICK _and_ MA_2CLK, or MA_CLICK _and_
25 * MA_3CLK, when a button is pressed for the second or third time.
26 */
27#define MULTICLICK_ONLY_EVENT 0
28
29/*
d9b15094 30 * Under GTK, there is no context help available.
31 */
32#define HELPCTX(x) P(NULL)
33#define FILTER_KEY_FILES NULL /* FIXME */
34
35/*
e6346999 36 * Under X, selection data must not be NUL-terminated.
37 */
38#define SELECTION_NUL_TERMINATED 0
39
0f351587 40/*
41 * Under X, copying to the clipboard terminates lines with just LF.
42 */
43#define SEL_NL { 10 }
44
f7f27309 45/* Simple wraparound timer function */
46unsigned long getticks(void); /* based on gettimeofday(2) */
47#define GETTICKCOUNT getticks
39934deb 48#define TICKSPERSEC 1000 /* we choose to use milliseconds */
49#define CURSORBLINK 450 /* no standard way to set this */
2ac3322e 50/* getticks() works using gettimeofday(), so it's vulnerable to system clock
51 * changes causing chaos. Therefore, we provide a compensation mechanism. */
52#define TIMING_SYNC
53#define TIMING_SYNC_ANOW
54extern long tickcount_offset;
f7f27309 55
56#define WCHAR wchar_t
57#define BYTE unsigned char
58
e9aef757 59/* Things pty.c needs from pterm.c */
a8327734 60char *get_x_display(void *frontend);
61int font_dimension(void *frontend, int which);/* 0 for width, 1 for height */
7af753e6 62long get_windowid(void *frontend);
755a6d84 63
5bf9955d 64/* Things gtkdlg.c needs from pterm.c */
65void *get_window(void *frontend); /* void * to avoid depending on gtk.h */
66
3f935d5b 67/* Things pterm.c needs from gtkdlg.c */
f89c3294 68int do_config_box(const char *title, Config *cfg,
69 int midsession, int protcfginfo);
3f935d5b 70void fatal_message_box(void *window, char *msg);
7718480a 71void about_box(void *window);
8eed910d 72void *eventlogstuff_new(void);
73void showeventlog(void *estuff, void *parentwin);
cbe2d68f 74void logevent_dlg(void *estuff, const char *string);
abb6895f 75int reallyclose(void *frontend);
3f935d5b 76
10705014 77/* Things pterm.c needs from {ptermm,uxputty}.c */
78char *make_default_wintitle(char *hostname);
46a3419b 79int process_nonoption_arg(char *arg, Config *cfg);
10705014 80
f5dd8adb 81/* pterm.c needs this special function in xkeysym.c */
82int keysym_to_unicode(int keysym);
83
faec60ed 84/* Things uxstore.c needs from pterm.c */
c85623f9 85char *x_get_default(const char *key);
faec60ed 86
0ac15bdc 87/* Things uxstore.c provides to pterm.c */
88void provide_xrm_string(char *string);
89
0ff9ea38 90/* The interface used by uxsel.c */
91void uxsel_init(void);
92typedef int (*uxsel_callback_fn)(int fd, int event);
93void uxsel_set(int fd, int rwx, uxsel_callback_fn callback);
94void uxsel_del(int fd);
c5e438ec 95int select_result(int fd, int event);
0ff9ea38 96int first_fd(int *state, int *rwx);
97int next_fd(int *state, int *rwx);
74aca06d 98/* The following are expected to be provided _to_ uxsel.c by the frontend */
99int uxsel_input_add(int fd, int rwx); /* returns an id */
100void uxsel_input_remove(int id);
c5e438ec 101
1d0d4a3b 102/* uxcfg.c */
103struct controlbox;
4838c7c6 104void unix_setup_config_box(struct controlbox *b, int midsession);
1d0d4a3b 105
8d68f26a 106/* gtkcfg.c */
107void gtk_setup_config_box(struct controlbox *b, int midsession, void *window);
108
2dc6356a 109/*
110 * In the Unix Unicode layer, DEFAULT_CODEPAGE is a special value
111 * which causes mb_to_wc and wc_to_mb to call _libc_ rather than
112 * libcharset. That way, we can interface the various charsets
113 * supported by libcharset with the one supported by mbstowcs and
114 * wcstombs (which will be the character set in which stuff read
115 * from the command line or config files is assumed to be encoded).
116 */
117#define DEFAULT_CODEPAGE 0xFFFF
118#define CP_UTF8 CS_UTF8 /* from libcharset */
f7f27309 119
68a49acb 120#define strnicmp strncasecmp
121#define stricmp strcasecmp
122
15b5d988 123/* BSD-semantics version of signal(), and another helpful function */
0f33f9d1 124void (*putty_signal(int sig, void (*func)(int)))(int);
15b5d988 125void block_signal(int sig, int block_it);
0f33f9d1 126
facd762c 127/*
128 * Exports from unicode.c.
129 */
21d2b241 130struct unicode_data;
6ac7f054 131int init_ucs(struct unicode_data *ucsdata, char *line_codepage,
132 int utf8_override, int font_charset, int vtmode);
facd762c 133
2f92b717 134/*
135 * Spare function exported directly from uxnet.c.
136 */
0a4022a1 137void *sk_getxdmdata(void *sock, int *lenp);
2f92b717 138
b51259f6 139/*
140 * General helpful Unix stuff: more helpful version of the FD_SET
141 * macro, which also handles maxfd.
142 */
143#define FD_SET_MAX(fd, max, set) do { \
144 FD_SET(fd, &set); \
145 if (max < fd + 1) max = fd + 1; \
146} while (0)
147
f7f27309 148#endif