2002-10-07 16:45:23 +00:00
|
|
|
#ifndef PUTTY_UNIX_H
|
|
|
|
#define PUTTY_UNIX_H
|
|
|
|
|
2005-04-25 15:55:06 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "uxconfig.h" /* Space to hide it from mkfiles.pl */
|
|
|
|
#endif
|
|
|
|
|
2003-02-01 12:54:40 +00:00
|
|
|
#include <stdio.h> /* for FILENAME_MAX */
|
2010-05-19 18:22:17 +00:00
|
|
|
#include <stdint.h> /* C99 int types */
|
|
|
|
#ifndef NO_LIBDL
|
|
|
|
#include <dlfcn.h> /* Dynamic library loading */
|
|
|
|
#endif /* NO_LIBDL */
|
2002-12-31 12:20:34 +00:00
|
|
|
#include "charset.h"
|
|
|
|
|
2015-08-31 12:05:51 +00:00
|
|
|
#ifdef OSX_GTK
|
|
|
|
/*
|
|
|
|
* Assorted tweaks to various parts of the GTK front end which all
|
|
|
|
* need to be enabled when compiling on OS X. Because I might need the
|
|
|
|
* same tweaks on other systems in future, I don't want to
|
|
|
|
* conditionalise all of them on OSX_GTK directly, so instead, each
|
|
|
|
* one has its own name and we enable them all centrally here if
|
|
|
|
* OSX_GTK is defined at configure time.
|
|
|
|
*/
|
|
|
|
#define NOT_X_WINDOWS /* of course, all the X11 stuff should be disabled */
|
|
|
|
#define NO_PTY_PRE_INIT /* OS X gets very huffy if we try to set[ug]id */
|
|
|
|
#define SET_NONBLOCK_VIA_OPENPT /* work around missing fcntl functionality */
|
|
|
|
#endif
|
|
|
|
|
2003-02-01 12:54:40 +00:00
|
|
|
struct Filename {
|
2011-10-02 11:01:57 +00:00
|
|
|
char *path;
|
2003-02-01 12:54:40 +00:00
|
|
|
};
|
2011-10-02 11:01:57 +00:00
|
|
|
FILE *f_open(const struct Filename *, char const *, int);
|
2003-02-01 12:54:40 +00:00
|
|
|
|
|
|
|
struct FontSpec {
|
2011-10-01 17:38:59 +00:00
|
|
|
char *name; /* may be "" to indicate no selected font at all */
|
2003-02-01 12:54:40 +00:00
|
|
|
};
|
2011-10-01 17:38:59 +00:00
|
|
|
struct FontSpec *fontspec_new(const char *name);
|
2003-02-01 12:54:40 +00:00
|
|
|
|
2002-10-07 16:45:23 +00:00
|
|
|
typedef void *Context; /* FIXME: probably needs changing */
|
|
|
|
|
2002-10-09 18:09:42 +00:00
|
|
|
extern Backend pty_backend;
|
|
|
|
|
2010-05-19 18:22:17 +00:00
|
|
|
typedef uint32_t uint32; /* C99: uint32_t defined in stdint.h */
|
|
|
|
#define PUTTY_UINT32_DEFINED
|
|
|
|
|
2002-10-13 11:24:25 +00:00
|
|
|
/*
|
|
|
|
* Under GTK, we send MA_CLICK _and_ MA_2CLK, or MA_CLICK _and_
|
|
|
|
* MA_3CLK, when a button is pressed for the second or third time.
|
|
|
|
*/
|
|
|
|
#define MULTICLICK_ONLY_EVENT 0
|
|
|
|
|
2003-03-13 19:52:28 +00:00
|
|
|
/*
|
|
|
|
* Under GTK, there is no context help available.
|
|
|
|
*/
|
|
|
|
#define HELPCTX(x) P(NULL)
|
|
|
|
#define FILTER_KEY_FILES NULL /* FIXME */
|
2010-09-25 07:16:56 +00:00
|
|
|
#define FILTER_DYNLIB_FILES NULL /* FIXME */
|
2003-03-13 19:52:28 +00:00
|
|
|
|
2002-10-13 11:24:25 +00:00
|
|
|
/*
|
|
|
|
* Under X, selection data must not be NUL-terminated.
|
|
|
|
*/
|
|
|
|
#define SELECTION_NUL_TERMINATED 0
|
|
|
|
|
2002-10-14 09:06:31 +00:00
|
|
|
/*
|
|
|
|
* Under X, copying to the clipboard terminates lines with just LF.
|
|
|
|
*/
|
|
|
|
#define SEL_NL { 10 }
|
|
|
|
|
2002-10-07 16:45:23 +00:00
|
|
|
/* Simple wraparound timer function */
|
|
|
|
unsigned long getticks(void); /* based on gettimeofday(2) */
|
|
|
|
#define GETTICKCOUNT getticks
|
2004-11-27 13:20:21 +00:00
|
|
|
#define TICKSPERSEC 1000 /* we choose to use milliseconds */
|
|
|
|
#define CURSORBLINK 450 /* no standard way to set this */
|
2002-10-07 16:45:23 +00:00
|
|
|
|
|
|
|
#define WCHAR wchar_t
|
|
|
|
#define BYTE unsigned char
|
|
|
|
|
2007-09-29 12:27:45 +00:00
|
|
|
/*
|
|
|
|
* Unix-specific global flag
|
|
|
|
*
|
|
|
|
* FLAG_STDERR_TTY indicates that standard error might be a terminal and
|
|
|
|
* might get its configuration munged, so anything trying to output plain
|
|
|
|
* text (i.e. with newlines in it) will need to put it back into cooked
|
|
|
|
* mode first. Applications setting this flag should also call
|
|
|
|
* stderr_tty_init() before messing with any terminal modes, and can call
|
|
|
|
* premsg() before outputting text to stderr and postmsg() afterwards.
|
|
|
|
*/
|
|
|
|
#define FLAG_STDERR_TTY 0x1000
|
|
|
|
|
2002-10-15 15:16:21 +00:00
|
|
|
/* Things pty.c needs from pterm.c */
|
2015-08-22 13:07:02 +00:00
|
|
|
const char *get_x_display(void *frontend);
|
2002-10-26 12:58:13 +00:00
|
|
|
int font_dimension(void *frontend, int which);/* 0 for width, 1 for height */
|
2003-03-06 12:57:37 +00:00
|
|
|
long get_windowid(void *frontend);
|
2015-09-01 17:35:38 +00:00
|
|
|
int frontend_is_utf8(void *frontend);
|
2002-10-15 12:29:52 +00:00
|
|
|
|
2003-03-31 11:21:07 +00:00
|
|
|
/* Things gtkdlg.c needs from pterm.c */
|
|
|
|
void *get_window(void *frontend); /* void * to avoid depending on gtk.h */
|
2015-08-09 10:33:43 +00:00
|
|
|
void post_main(void); /* called after any subsidiary gtk_main() */
|
2003-03-31 11:21:07 +00:00
|
|
|
|
2003-04-01 18:10:25 +00:00
|
|
|
/* Things pterm.c needs from gtkdlg.c */
|
Post-release destabilisation! Completely remove the struct type
'Config' in putty.h, which stores all PuTTY's settings and includes an
arbitrary length limit on every single one of those settings which is
stored in string form. In place of it is 'Conf', an opaque data type
everywhere outside the new file conf.c, which stores a list of (key,
value) pairs in which every key contains an integer identifying a
configuration setting, and for some of those integers the key also
contains extra parts (so that, for instance, CONF_environmt is a
string-to-string mapping). Everywhere that a Config was previously
used, a Conf is now; everywhere there was a Config structure copy,
conf_copy() is called; every lookup, adjustment, load and save
operation on a Config has been rewritten; and there's a mechanism for
serialising a Conf into a binary blob and back for use with Duplicate
Session.
User-visible effects of this change _should_ be minimal, though I
don't doubt I've introduced one or two bugs here and there which will
eventually be found. The _intended_ visible effects of this change are
that all arbitrary limits on configuration strings and lists (e.g.
limit on number of port forwardings) should now disappear; that list
boxes in the configuration will now be displayed in a sorted order
rather than the arbitrary order in which they were added to the list
(since the underlying data structure is now a sorted tree234 rather
than an ad-hoc comma-separated string); and one more specific change,
which is that local and dynamic port forwardings on the same port
number are now mutually exclusive in the configuration (putting 'D' in
the key rather than the value was a mistake in the first place).
One other reorganisation as a result of this is that I've moved all
the dialog.c standard handlers (dlg_stdeditbox_handler and friends)
out into config.c, because I can't really justify calling them generic
any more. When they took a pointer to an arbitrary structure type and
the offset of a field within that structure, they were independent of
whether that structure was a Config or something completely different,
but now they really do expect to talk to a Conf, which can _only_ be
used for PuTTY configuration, so I've renamed them all things like
conf_editbox_handler and moved them out of the nominally independent
dialog-box management module into the PuTTY-specific config.c.
[originally from svn r9214]
2011-07-14 18:52:21 +00:00
|
|
|
int do_config_box(const char *title, Conf *conf,
|
2004-12-29 12:32:25 +00:00
|
|
|
int midsession, int protcfginfo);
|
2015-05-15 10:15:42 +00:00
|
|
|
void fatal_message_box(void *window, const char *msg);
|
|
|
|
void nonfatal_message_box(void *window, const char *msg);
|
2003-04-10 08:53:43 +00:00
|
|
|
void about_box(void *window);
|
2003-04-09 18:46:45 +00:00
|
|
|
void *eventlogstuff_new(void);
|
|
|
|
void showeventlog(void *estuff, void *parentwin);
|
2003-05-04 14:18:18 +00:00
|
|
|
void logevent_dlg(void *estuff, const char *string);
|
2003-04-11 18:15:47 +00:00
|
|
|
int reallyclose(void *frontend);
|
2013-01-13 21:59:10 +00:00
|
|
|
#ifdef MAY_REFER_TO_GTK_IN_HEADERS
|
2015-05-15 10:15:42 +00:00
|
|
|
int messagebox(GtkWidget *parentwin, const char *title,
|
|
|
|
const char *msg, int minwid, ...);
|
2013-01-13 21:59:10 +00:00
|
|
|
#endif
|
2003-04-01 18:10:25 +00:00
|
|
|
|
2003-03-31 11:42:45 +00:00
|
|
|
/* Things pterm.c needs from {ptermm,uxputty}.c */
|
|
|
|
char *make_default_wintitle(char *hostname);
|
2015-05-15 10:15:42 +00:00
|
|
|
int process_nonoption_arg(const char *arg, Conf *conf, int *allow_launch);
|
2003-03-31 11:42:45 +00:00
|
|
|
|
2003-04-27 11:10:48 +00:00
|
|
|
/* pterm.c needs this special function in xkeysym.c */
|
|
|
|
int keysym_to_unicode(int keysym);
|
|
|
|
|
2002-10-16 14:32:06 +00:00
|
|
|
/* Things uxstore.c needs from pterm.c */
|
2003-01-14 18:43:45 +00:00
|
|
|
char *x_get_default(const char *key);
|
2002-10-16 14:32:06 +00:00
|
|
|
|
2002-10-16 22:54:58 +00:00
|
|
|
/* Things uxstore.c provides to pterm.c */
|
|
|
|
void provide_xrm_string(char *string);
|
|
|
|
|
2007-09-29 12:27:45 +00:00
|
|
|
/* Things provided by uxcons.c */
|
|
|
|
struct termios;
|
|
|
|
void stderr_tty_init(void);
|
|
|
|
void premsg(struct termios *);
|
|
|
|
void postmsg(struct termios *);
|
|
|
|
|
2003-03-29 16:47:06 +00:00
|
|
|
/* The interface used by uxsel.c */
|
2015-08-16 11:50:46 +00:00
|
|
|
typedef struct uxsel_id uxsel_id;
|
2003-03-29 16:47:06 +00:00
|
|
|
void uxsel_init(void);
|
|
|
|
typedef int (*uxsel_callback_fn)(int fd, int event);
|
|
|
|
void uxsel_set(int fd, int rwx, uxsel_callback_fn callback);
|
|
|
|
void uxsel_del(int fd);
|
2002-10-31 19:49:52 +00:00
|
|
|
int select_result(int fd, int event);
|
2003-03-29 16:47:06 +00:00
|
|
|
int first_fd(int *state, int *rwx);
|
|
|
|
int next_fd(int *state, int *rwx);
|
2003-03-29 18:30:14 +00:00
|
|
|
/* The following are expected to be provided _to_ uxsel.c by the frontend */
|
2015-08-16 11:50:46 +00:00
|
|
|
uxsel_id *uxsel_input_add(int fd, int rwx); /* returns an id */
|
|
|
|
void uxsel_input_remove(uxsel_id *id);
|
2002-10-31 19:49:52 +00:00
|
|
|
|
2003-03-14 18:35:01 +00:00
|
|
|
/* uxcfg.c */
|
|
|
|
struct controlbox;
|
2006-08-29 09:18:09 +00:00
|
|
|
void unix_setup_config_box(struct controlbox *b, int midsession, int protocol);
|
2003-03-14 18:35:01 +00:00
|
|
|
|
2005-02-14 07:41:41 +00:00
|
|
|
/* gtkcfg.c */
|
|
|
|
void gtk_setup_config_box(struct controlbox *b, int midsession, void *window);
|
|
|
|
|
2002-12-31 12:20:34 +00:00
|
|
|
/*
|
|
|
|
* In the Unix Unicode layer, DEFAULT_CODEPAGE is a special value
|
|
|
|
* which causes mb_to_wc and wc_to_mb to call _libc_ rather than
|
|
|
|
* libcharset. That way, we can interface the various charsets
|
|
|
|
* supported by libcharset with the one supported by mbstowcs and
|
|
|
|
* wcstombs (which will be the character set in which stuff read
|
|
|
|
* from the command line or config files is assumed to be encoded).
|
|
|
|
*/
|
|
|
|
#define DEFAULT_CODEPAGE 0xFFFF
|
|
|
|
#define CP_UTF8 CS_UTF8 /* from libcharset */
|
2002-10-07 16:45:23 +00:00
|
|
|
|
2002-10-30 17:57:31 +00:00
|
|
|
#define strnicmp strncasecmp
|
|
|
|
#define stricmp strcasecmp
|
|
|
|
|
2004-12-17 14:25:53 +00:00
|
|
|
/* BSD-semantics version of signal(), and another helpful function */
|
2002-11-02 14:35:57 +00:00
|
|
|
void (*putty_signal(int sig, void (*func)(int)))(int);
|
2004-12-17 14:25:53 +00:00
|
|
|
void block_signal(int sig, int block_it);
|
2002-11-02 14:35:57 +00:00
|
|
|
|
2006-12-09 15:44:31 +00:00
|
|
|
/* uxmisc.c */
|
2013-07-19 18:10:02 +00:00
|
|
|
void cloexec(int);
|
|
|
|
void noncloexec(int);
|
|
|
|
int nonblock(int);
|
|
|
|
int no_nonblock(int);
|
2015-05-05 19:16:22 +00:00
|
|
|
char *make_dir_and_check_ours(const char *dirname);
|
2006-12-09 15:44:31 +00:00
|
|
|
|
2003-01-01 22:25:25 +00:00
|
|
|
/*
|
|
|
|
* Exports from unicode.c.
|
|
|
|
*/
|
2003-01-14 18:28:23 +00:00
|
|
|
struct unicode_data;
|
2004-10-16 14:17:58 +00:00
|
|
|
int init_ucs(struct unicode_data *ucsdata, char *line_codepage,
|
|
|
|
int utf8_override, int font_charset, int vtmode);
|
2003-01-01 22:25:25 +00:00
|
|
|
|
2003-01-11 09:31:54 +00:00
|
|
|
/*
|
|
|
|
* Spare function exported directly from uxnet.c.
|
|
|
|
*/
|
2005-01-28 11:39:45 +00:00
|
|
|
void *sk_getxdmdata(void *sock, int *lenp);
|
2003-01-11 09:31:54 +00:00
|
|
|
|
2003-08-24 13:22:17 +00:00
|
|
|
/*
|
|
|
|
* General helpful Unix stuff: more helpful version of the FD_SET
|
|
|
|
* macro, which also handles maxfd.
|
|
|
|
*/
|
|
|
|
#define FD_SET_MAX(fd, max, set) do { \
|
|
|
|
FD_SET(fd, &set); \
|
|
|
|
if (max < fd + 1) max = fd + 1; \
|
|
|
|
} while (0)
|
|
|
|
|
2006-08-28 14:29:02 +00:00
|
|
|
/*
|
|
|
|
* Exports from winser.c.
|
|
|
|
*/
|
|
|
|
extern Backend serial_backend;
|
|
|
|
|
2015-05-18 12:57:45 +00:00
|
|
|
/*
|
|
|
|
* uxpeer.c, wrapping getsockopt(SO_PEERCRED).
|
|
|
|
*/
|
|
|
|
int so_peercred(int fd, int *pid, int *uid, int *gid);
|
|
|
|
|
2015-08-31 12:24:09 +00:00
|
|
|
/*
|
|
|
|
* Default font setting, which can vary depending on NOT_X_WINDOWS.
|
|
|
|
*/
|
|
|
|
#ifdef NOT_X_WINDOWS
|
|
|
|
#define DEFAULT_GTK_FONT "client:Monospace 12"
|
|
|
|
#else
|
|
|
|
#define DEFAULT_GTK_FONT "server:fixed"
|
|
|
|
#endif
|
|
|
|
|
2002-10-07 16:45:23 +00:00
|
|
|
#endif
|