dbb28d6f23c8ce0420cb099aba133e7d35017dc8
[u/mdw/putty] / unix / unix.h
1 #ifndef PUTTY_UNIX_H
2 #define PUTTY_UNIX_H
3
4 #include <stdio.h> /* for FILENAME_MAX */
5 #include "charset.h"
6
7 struct Filename {
8 char path[FILENAME_MAX];
9 };
10 #define f_open(filename, mode) ( fopen((filename).path, (mode)) )
11
12 struct FontSpec {
13 char name[256];
14 };
15
16 typedef void *Context; /* FIXME: probably needs changing */
17
18 typedef int OSSocket;
19 #define OSSOCKET_DEFINED /* stop network.h using its default */
20
21 extern Backend pty_backend;
22
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 /*
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 /*
36 * Under X, selection data must not be NUL-terminated.
37 */
38 #define SELECTION_NUL_TERMINATED 0
39
40 /*
41 * Under X, copying to the clipboard terminates lines with just LF.
42 */
43 #define SEL_NL { 10 }
44
45 /* Simple wraparound timer function */
46 unsigned long getticks(void); /* based on gettimeofday(2) */
47 #define GETTICKCOUNT getticks
48 #define TICKSPERSEC 1000000 /* gettimeofday returns microseconds */
49 #define CURSORBLINK 450000 /* no standard way to set this */
50
51 #define WCHAR wchar_t
52 #define BYTE unsigned char
53
54 GLOBAL void *logctx;
55
56 /* Things pty.c needs from pterm.c */
57 char *get_x_display(void *frontend);
58 int font_dimension(void *frontend, int which);/* 0 for width, 1 for height */
59 long get_windowid(void *frontend);
60
61 /* Things gtkdlg.c needs from pterm.c */
62 void *get_window(void *frontend); /* void * to avoid depending on gtk.h */
63
64 /* Things pterm.c needs from gtkdlg.c */
65 int do_config_box(const char *title, Config *cfg, int midsession);
66 void fatal_message_box(void *window, char *msg);
67 void about_box(void *window);
68 void *eventlogstuff_new(void);
69 void showeventlog(void *estuff, void *parentwin);
70 void logevent_dlg(void *estuff, const char *string);
71 int reallyclose(void *frontend);
72
73 /* Things pterm.c needs from {ptermm,uxputty}.c */
74 char *make_default_wintitle(char *hostname);
75 int process_nonoption_arg(char *arg, Config *cfg);
76
77 /* pterm.c needs this special function in xkeysym.c */
78 int keysym_to_unicode(int keysym);
79
80 /* Things uxstore.c needs from pterm.c */
81 char *x_get_default(const char *key);
82
83 /* Things uxstore.c provides to pterm.c */
84 void provide_xrm_string(char *string);
85
86 /* The interface used by uxsel.c */
87 void uxsel_init(void);
88 typedef int (*uxsel_callback_fn)(int fd, int event);
89 void uxsel_set(int fd, int rwx, uxsel_callback_fn callback);
90 void uxsel_del(int fd);
91 int select_result(int fd, int event);
92 int first_fd(int *state, int *rwx);
93 int next_fd(int *state, int *rwx);
94 /* The following are expected to be provided _to_ uxsel.c by the frontend */
95 int uxsel_input_add(int fd, int rwx); /* returns an id */
96 void uxsel_input_remove(int id);
97
98 /* uxcfg.c */
99 struct controlbox;
100 void unix_setup_config_box(struct controlbox *b, int midsession, void *window);
101
102 /*
103 * In the Unix Unicode layer, DEFAULT_CODEPAGE is a special value
104 * which causes mb_to_wc and wc_to_mb to call _libc_ rather than
105 * libcharset. That way, we can interface the various charsets
106 * supported by libcharset with the one supported by mbstowcs and
107 * wcstombs (which will be the character set in which stuff read
108 * from the command line or config files is assumed to be encoded).
109 */
110 #define DEFAULT_CODEPAGE 0xFFFF
111 #define CP_UTF8 CS_UTF8 /* from libcharset */
112
113 #define strnicmp strncasecmp
114 #define stricmp strcasecmp
115
116 /* BSD-semantics version of signal() */
117 void (*putty_signal(int sig, void (*func)(int)))(int);
118
119 /*
120 * Exports from unicode.c.
121 */
122 struct unicode_data;
123 int init_ucs(struct unicode_data *ucsdata,
124 char *line_codepage, int font_charset, int vtmode);
125
126 /*
127 * Spare function exported directly from uxnet.c.
128 */
129 int sk_getxdmdata(void *sock, unsigned long *ip, int *port);
130
131 #endif