The latest unfix.org IPv6 patch contains these apparently
[sgt/putty] / unix / unix.h
... / ...
CommitLineData
1#ifndef PUTTY_UNIX_H
2#define PUTTY_UNIX_H
3
4#include <stdio.h> /* for FILENAME_MAX */
5#include "charset.h"
6
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
16typedef void *Context; /* FIXME: probably needs changing */
17
18typedef int OSSocket;
19#define OSSOCKET_DEFINED /* stop network.h using its default */
20
21extern 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 */
46unsigned long getticks(void); /* based on gettimeofday(2) */
47#define GETTICKCOUNT getticks
48#define TICKSPERSEC 1000 /* we choose to use milliseconds */
49#define CURSORBLINK 450 /* no standard way to set this */
50
51#define WCHAR wchar_t
52#define BYTE unsigned char
53
54/* Things pty.c needs from pterm.c */
55char *get_x_display(void *frontend);
56int font_dimension(void *frontend, int which);/* 0 for width, 1 for height */
57long get_windowid(void *frontend);
58
59/* Things gtkdlg.c needs from pterm.c */
60void *get_window(void *frontend); /* void * to avoid depending on gtk.h */
61
62/* Things pterm.c needs from gtkdlg.c */
63int do_config_box(const char *title, Config *cfg, int midsession);
64void fatal_message_box(void *window, char *msg);
65void about_box(void *window);
66void *eventlogstuff_new(void);
67void showeventlog(void *estuff, void *parentwin);
68void logevent_dlg(void *estuff, const char *string);
69int reallyclose(void *frontend);
70
71/* Things pterm.c needs from {ptermm,uxputty}.c */
72char *make_default_wintitle(char *hostname);
73int process_nonoption_arg(char *arg, Config *cfg);
74
75/* pterm.c needs this special function in xkeysym.c */
76int keysym_to_unicode(int keysym);
77
78/* Things uxstore.c needs from pterm.c */
79char *x_get_default(const char *key);
80
81/* Things uxstore.c provides to pterm.c */
82void provide_xrm_string(char *string);
83
84/* The interface used by uxsel.c */
85void uxsel_init(void);
86typedef int (*uxsel_callback_fn)(int fd, int event);
87void uxsel_set(int fd, int rwx, uxsel_callback_fn callback);
88void uxsel_del(int fd);
89int select_result(int fd, int event);
90int first_fd(int *state, int *rwx);
91int next_fd(int *state, int *rwx);
92/* The following are expected to be provided _to_ uxsel.c by the frontend */
93int uxsel_input_add(int fd, int rwx); /* returns an id */
94void uxsel_input_remove(int id);
95
96/* uxcfg.c */
97struct controlbox;
98void unix_setup_config_box(struct controlbox *b, int midsession, void *window);
99
100/*
101 * In the Unix Unicode layer, DEFAULT_CODEPAGE is a special value
102 * which causes mb_to_wc and wc_to_mb to call _libc_ rather than
103 * libcharset. That way, we can interface the various charsets
104 * supported by libcharset with the one supported by mbstowcs and
105 * wcstombs (which will be the character set in which stuff read
106 * from the command line or config files is assumed to be encoded).
107 */
108#define DEFAULT_CODEPAGE 0xFFFF
109#define CP_UTF8 CS_UTF8 /* from libcharset */
110
111#define strnicmp strncasecmp
112#define stricmp strcasecmp
113
114/* BSD-semantics version of signal(), and another helpful function */
115void (*putty_signal(int sig, void (*func)(int)))(int);
116void block_signal(int sig, int block_it);
117
118/*
119 * Exports from unicode.c.
120 */
121struct unicode_data;
122int init_ucs(struct unicode_data *ucsdata, char *line_codepage,
123 int utf8_override, int font_charset, int vtmode);
124
125/*
126 * Spare function exported directly from uxnet.c.
127 */
128int sk_getxdmdata(void *sock, unsigned long *ip, int *port);
129
130/*
131 * General helpful Unix stuff: more helpful version of the FD_SET
132 * macro, which also handles maxfd.
133 */
134#define FD_SET_MAX(fd, max, set) do { \
135 FD_SET(fd, &set); \
136 if (max < fd + 1) max = fd + 1; \
137} while (0)
138
139#endif