| 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 | |
| 11 | struct Filename { |
| 12 | char path[FILENAME_MAX]; |
| 13 | }; |
| 14 | FILE *f_open(struct Filename, char const *, int); |
| 15 | |
| 16 | struct FontSpec { |
| 17 | char name[256]; |
| 18 | }; |
| 19 | |
| 20 | typedef void *Context; /* FIXME: probably needs changing */ |
| 21 | |
| 22 | typedef int OSSocket; |
| 23 | #define OSSOCKET_DEFINED /* stop network.h using its default */ |
| 24 | |
| 25 | extern 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 */ |
| 50 | unsigned 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 |
| 58 | extern long tickcount_offset; |
| 59 | |
| 60 | #define WCHAR wchar_t |
| 61 | #define BYTE unsigned char |
| 62 | |
| 63 | #ifndef NO_GSSAPI |
| 64 | /* |
| 65 | * GSS-API stuff |
| 66 | */ |
| 67 | #include <gssapi/gssapi.h> |
| 68 | typedef gss_buffer_desc Ssh_gss_buf; |
| 69 | #define SSH_GSS_EMPTY_BUF GSS_C_EMPTY_BUFFER |
| 70 | typedef gss_name_t Ssh_gss_name; |
| 71 | #endif |
| 72 | |
| 73 | /* |
| 74 | * Unix-specific global flag |
| 75 | * |
| 76 | * FLAG_STDERR_TTY indicates that standard error might be a terminal and |
| 77 | * might get its configuration munged, so anything trying to output plain |
| 78 | * text (i.e. with newlines in it) will need to put it back into cooked |
| 79 | * mode first. Applications setting this flag should also call |
| 80 | * stderr_tty_init() before messing with any terminal modes, and can call |
| 81 | * premsg() before outputting text to stderr and postmsg() afterwards. |
| 82 | */ |
| 83 | #define FLAG_STDERR_TTY 0x1000 |
| 84 | |
| 85 | /* Things pty.c needs from pterm.c */ |
| 86 | char *get_x_display(void *frontend); |
| 87 | int font_dimension(void *frontend, int which);/* 0 for width, 1 for height */ |
| 88 | long get_windowid(void *frontend); |
| 89 | |
| 90 | /* Things gtkdlg.c needs from pterm.c */ |
| 91 | void *get_window(void *frontend); /* void * to avoid depending on gtk.h */ |
| 92 | |
| 93 | /* Things pterm.c needs from gtkdlg.c */ |
| 94 | int do_config_box(const char *title, Config *cfg, |
| 95 | int midsession, int protcfginfo); |
| 96 | void fatal_message_box(void *window, char *msg); |
| 97 | void about_box(void *window); |
| 98 | void *eventlogstuff_new(void); |
| 99 | void showeventlog(void *estuff, void *parentwin); |
| 100 | void logevent_dlg(void *estuff, const char *string); |
| 101 | int reallyclose(void *frontend); |
| 102 | |
| 103 | /* Things pterm.c needs from {ptermm,uxputty}.c */ |
| 104 | char *make_default_wintitle(char *hostname); |
| 105 | int process_nonoption_arg(char *arg, Config *cfg, int *allow_launch); |
| 106 | |
| 107 | /* pterm.c needs this special function in xkeysym.c */ |
| 108 | int keysym_to_unicode(int keysym); |
| 109 | |
| 110 | /* Things uxstore.c needs from pterm.c */ |
| 111 | char *x_get_default(const char *key); |
| 112 | |
| 113 | /* Things uxstore.c provides to pterm.c */ |
| 114 | void provide_xrm_string(char *string); |
| 115 | |
| 116 | /* Things provided by uxcons.c */ |
| 117 | struct termios; |
| 118 | void stderr_tty_init(void); |
| 119 | void premsg(struct termios *); |
| 120 | void postmsg(struct termios *); |
| 121 | |
| 122 | /* The interface used by uxsel.c */ |
| 123 | void uxsel_init(void); |
| 124 | typedef int (*uxsel_callback_fn)(int fd, int event); |
| 125 | void uxsel_set(int fd, int rwx, uxsel_callback_fn callback); |
| 126 | void uxsel_del(int fd); |
| 127 | int select_result(int fd, int event); |
| 128 | int first_fd(int *state, int *rwx); |
| 129 | int next_fd(int *state, int *rwx); |
| 130 | /* The following are expected to be provided _to_ uxsel.c by the frontend */ |
| 131 | int uxsel_input_add(int fd, int rwx); /* returns an id */ |
| 132 | void uxsel_input_remove(int id); |
| 133 | |
| 134 | /* uxcfg.c */ |
| 135 | struct controlbox; |
| 136 | void unix_setup_config_box(struct controlbox *b, int midsession, int protocol); |
| 137 | |
| 138 | /* gtkcfg.c */ |
| 139 | void gtk_setup_config_box(struct controlbox *b, int midsession, void *window); |
| 140 | |
| 141 | /* |
| 142 | * In the Unix Unicode layer, DEFAULT_CODEPAGE is a special value |
| 143 | * which causes mb_to_wc and wc_to_mb to call _libc_ rather than |
| 144 | * libcharset. That way, we can interface the various charsets |
| 145 | * supported by libcharset with the one supported by mbstowcs and |
| 146 | * wcstombs (which will be the character set in which stuff read |
| 147 | * from the command line or config files is assumed to be encoded). |
| 148 | */ |
| 149 | #define DEFAULT_CODEPAGE 0xFFFF |
| 150 | #define CP_UTF8 CS_UTF8 /* from libcharset */ |
| 151 | |
| 152 | #define strnicmp strncasecmp |
| 153 | #define stricmp strcasecmp |
| 154 | |
| 155 | /* BSD-semantics version of signal(), and another helpful function */ |
| 156 | void (*putty_signal(int sig, void (*func)(int)))(int); |
| 157 | void block_signal(int sig, int block_it); |
| 158 | |
| 159 | /* uxmisc.c */ |
| 160 | int cloexec(int); |
| 161 | |
| 162 | /* |
| 163 | * Exports from unicode.c. |
| 164 | */ |
| 165 | struct unicode_data; |
| 166 | int init_ucs(struct unicode_data *ucsdata, char *line_codepage, |
| 167 | int utf8_override, int font_charset, int vtmode); |
| 168 | |
| 169 | /* |
| 170 | * Spare function exported directly from uxnet.c. |
| 171 | */ |
| 172 | void *sk_getxdmdata(void *sock, int *lenp); |
| 173 | |
| 174 | /* |
| 175 | * General helpful Unix stuff: more helpful version of the FD_SET |
| 176 | * macro, which also handles maxfd. |
| 177 | */ |
| 178 | #define FD_SET_MAX(fd, max, set) do { \ |
| 179 | FD_SET(fd, &set); \ |
| 180 | if (max < fd + 1) max = fd + 1; \ |
| 181 | } while (0) |
| 182 | |
| 183 | /* |
| 184 | * Exports from winser.c. |
| 185 | */ |
| 186 | extern Backend serial_backend; |
| 187 | |
| 188 | #endif |