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