7 | #include "putty.h"
8 |
9 | struct printer_job_tag {
10 | FILE *fp;
11 | };
12 |
13 | printer_job *printer_start_job(char *printer)
14 | {
15 | printer_job *ret = snew(printer_job);
16 | /*
17 | * On Unix, we treat the printer string as the name of a
18 | * command to pipe to - typically lpr, of course.
19 | */
20 | ret->fp = popen(printer, "w");
21 | if (!ret->fp) {
22 | sfree(ret);
23 | ret = NULL;
24 | }
25 | return ret;
26 | }
27 |
28 | void printer_job_data(printer_job *pj, void *data, int len)
29 | {
30 | if (!pj)
31 | return;
32 |
33 | if (fwrite(data, 1, len, pj->fp) < len)
34 | /* ignore */;
35 | }
36 |
37 | void printer_finish_job(printer_job *pj)
38 | {
39 | if (!pj)
40 | return;
41 |
42 | pclose(pj->fp);
43 | sfree(pj);
44 | }
45 |
46 | /*
47 | * There's no sensible way to enumerate printers under Unix, since
48 | * practically any valid Unix command is a valid printer :-) So
49 | * these are useless stub functions, and uxcfg.c will disable the
50 | * drop-down list in the printer configurer.
51 | */
52 | printer_enum *printer_start_enum(int *nprinters_ptr) {
53 | *nprinters_ptr = 0;
54 | return NULL;
55 | }
56 | char *printer_get_name(printer_enum *pe, int i) { return NULL;
57 | }
58 | void printer_finish_enum(printer_enum *pe) { }
59 |
--------------------------------------------------------------------------------
/windows/win_res.h:
--------------------------------------------------------------------------------
1 | /*
2 | * win_res.h - constants shared between win_res.rc2 and the C code.
3 | */
4 |
5 | #ifndef PUTTY_WIN_RES_H
6 | #define PUTTY_WIN_RES_H
7 |
8 | #define IDI_MAINICON 200
9 | #define IDI_CFGICON 201
10 | #define IDI_DUP_SESS 202
11 | #define IDI_SESS_CFG 203
12 | #define IDI_RESET_SESS 204
13 | #define IDI_SFTP 205
14 | #define IDI_SHOW_LOG 206
15 | #define IDI_COYP_ALL 207
16 | #define IDI_PASTE 208
17 | #define IDI_CLEAR_SB 209
18 | #define IDI_FULL_SCREEN 210
19 | #define IDI_ABOUT 211
20 | #define IDI_SEARCH_PRE 212
21 | #define IDI_SEARCH_NEXT 213
22 | #define IDI_SEARCH_RESET 214
23 | #define IDI_TAB_SHORTCUT 215
24 | #define IDI_START_LOG 216
25 |
26 | #define IDD_MAINBOX 102
27 | #define IDD_LOGBOX 110
28 | #define IDD_ABOUTBOX 111
29 | #define IDD_RECONF 112
30 | #define IDD_LICENCEBOX 113
31 |
32 | #define IDN_LIST 1001
33 | #define IDN_COPY 1002
34 |
35 | #define IDA_ICON 1001
36 | #define IDA_TEXT1 1002
37 | #define IDA_VERSION 1003
38 | #define IDA_TEXT2 1004
39 | #define IDA_LICENCE 1005
40 | #define IDA_WEB 1006
41 |
42 | #define IDC_TAB 1001
43 | #define IDC_TABSTATIC1 1002
44 | #define IDC_TABSTATIC2 1003
45 | #define IDC_TABLIST 1004
46 | #define IDC_HELPBTN 1005
47 | #define IDC_ABOUT 1006
48 |
49 | #define IDB_TREE 2001
50 |
51 | #endif
52 |
--------------------------------------------------------------------------------
/LICENCE:
--------------------------------------------------------------------------------
1 | PuTTY is copyright 1997-2011 Simon Tatham.
2 |
3 | Portions copyright Robert de Bath, Joris van Rantwijk, Delian
4 | Delchev, Andreas Schultz, Jeroen Massar, Wez Furlong, Nicolas Barry,
5 | Justin Bradford, Ben Harris, Malcolm Smith, Ahmad Khalifa, Markus
6 | Kuhn, Colin Watson, and CORE SDI S.A.
7 |
8 | Portions copyright Lu Dong, Lokesh for the putty-nd's changes.
9 |
10 | Permission is hereby granted, free of charge, to any person
11 | obtaining a copy of this software and associated documentation files
12 | (the "Software"), to deal in the Software without restriction,
13 | including without limitation the rights to use, copy, modify, merge,
14 | publish, distribute, sublicense, and/or sell copies of the Software,
15 | and to permit persons to whom the Software is furnished to do so,
16 | subject to the following conditions:
17 |
18 | The above copyright notice and this permission notice shall be
19 | included in all copies or substantial portions of the Software.
20 |
21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 | NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE
25 | FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
26 | CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 |
--------------------------------------------------------------------------------
/doc/licence.but:
--------------------------------------------------------------------------------
1 | \define{versionidlicence} \versionid $Id$
2 |
3 | \A{licence} PuTTY \ii{Licence}
4 |
5 | PuTTY is \i{copyright} 1997-2011 Simon Tatham.
6 |
7 | Portions copyright Robert de Bath, Joris van Rantwijk, Delian
8 | Delchev, Andreas Schultz, Jeroen Massar, Wez Furlong, Nicolas Barry,
9 | Justin Bradford, Ben Harris, Malcolm Smith, Ahmad Khalifa, Markus
10 | Kuhn, Colin Watson, and CORE SDI S.A.
11 |
12 | Permission is hereby granted, free of charge, to any person
13 | obtaining a copy of this software and associated documentation files
14 | (the \q{Software}), to deal in the Software without restriction,
15 | including without limitation the rights to use, copy, modify, merge,
16 | publish, distribute, sublicense, and/or sell copies of the Software,
17 | and to permit persons to whom the Software is furnished to do so,
18 | subject to the following conditions:
19 |
20 | The above copyright notice and this permission notice shall be
21 | included in all copies or substantial portions of the Software.
22 |
23 | THE SOFTWARE IS PROVIDED \q{AS IS}, WITHOUT WARRANTY OF ANY KIND,
24 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 | NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE
27 | FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
28 | CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 |
--------------------------------------------------------------------------------
/doc/blurb.but:
--------------------------------------------------------------------------------
1 | \define{versionidblurb} \versionid $Id$
2 |
3 | \title PuTTY User Manual
4 |
5 | \cfg{xhtml-leaf-level}{1}
6 | \cfg{xhtml-leaf-smallest-contents}{2}
7 | \cfg{xhtml-leaf-contains-contents}{true}
8 | \cfg{xhtml-body-end}{If you want to provide feedback on this manual
9 | or on the PuTTY tools themselves, see the
10 | Feedback
11 | page.
}
12 |
13 | \cfg{html-template-fragment}{%k}{%b}
14 |
15 | \cfg{info-max-file-size}{0}
16 |
17 | \cfg{xhtml-contents-filename}{index.html}
18 | \cfg{text-filename}{puttydoc.txt}
19 | \cfg{winhelp-filename}{putty.hlp}
20 | \cfg{info-filename}{putty.info}
21 |
22 | PuTTY is a free (MIT-licensed) Win32 Telnet and SSH client. This
23 | manual documents PuTTY, and its companion utilities PSCP, PSFTP,
24 | Plink, Pageant and PuTTYgen.
25 |
26 | \e{Note to Unix users:} this manual currently primarily documents the
27 | Windows versions of the PuTTY utilities. Some options are therefore
28 | mentioned that are absent from the \i{Unix version}; the Unix version has
29 | features not described here; and the \i\cw{pterm} and command-line
30 | \cw{puttygen} utilities are not described at all. The only
31 | Unix-specific documentation that currently exists is the
32 | \I{man pages for PuTTY tools}man pages.
33 |
34 | \copyright This manual is copyright 2001-2011 Simon Tatham. All
35 | rights reserved. You may distribute this documentation under the MIT
36 | licence. See \k{licence} for the licence text in full.
37 |
--------------------------------------------------------------------------------
/puttymem.h:
--------------------------------------------------------------------------------
1 | /*
2 | * PuTTY memory-handling header.
3 | */
4 |
5 | #ifndef PUTTY_PUTTYMEM_H
6 | #define PUTTY_PUTTYMEM_H
7 |
8 | #include /* for size_t */
9 | #include /* for memcpy() */
10 |
11 |
12 | /* #define MALLOC_LOG do this if you suspect putty of leaking memory */
13 | #ifdef MALLOC_LOG
14 | #define smalloc(z) (mlog(__FILE__,__LINE__), safemalloc(z,1))
15 | #define snmalloc(z,s) (mlog(__FILE__,__LINE__), safemalloc(z,s))
16 | #define srealloc(y,z) (mlog(__FILE__,__LINE__), saferealloc(y,z,1))
17 | #define snrealloc(y,z,s) (mlog(__FILE__,__LINE__), saferealloc(y,z,s))
18 | #define sfree(z) (mlog(__FILE__,__LINE__), safefree(z))
19 | void mlog(char *, int);
20 | #else
21 | #define smalloc(z) safemalloc(z,1)
22 | #define snmalloc safemalloc
23 | #define srealloc(y,z) saferealloc(y,z,1)
24 | #define snrealloc saferealloc
25 | #define sfree safefree
26 | #endif
27 |
28 | void *safemalloc(size_t, size_t);
29 | void *saferealloc(void *, size_t, size_t);
30 | void safefree(void *);
31 |
32 | /*
33 | * Direct use of smalloc within the code should be avoided where
34 | * possible, in favour of these type-casting macros which ensure
35 | * you don't mistakenly allocate enough space for one sort of
36 | * structure and assign it to a different sort of pointer.
37 | */
38 | #define snew(type) ((type *)snmalloc(1, sizeof(type)))
39 | #define snewn(n, type) ((type *)snmalloc((n), sizeof(type)))
40 | #define sresize(ptr, n, type) ((type *)snrealloc((ptr), (n), sizeof(type)))
41 |
42 | #endif
43 |
--------------------------------------------------------------------------------
/mkauto.sh:
--------------------------------------------------------------------------------
1 | #! /bin/sh
2 | # This script makes the autoconf mechanism for the Unix port work.
3 | # It's separate from mkfiles.pl because it won't work (and isn't needed)
4 | # on a non-Unix system.
5 |
6 | # It's nice to be able to run this from inside the unix subdir as
7 | # well as from outside.
8 | test -f unix.h && cd ..
9 |
10 | # Persuade automake to give us a copy of its install-sh. This is a
11 | # pain because I don't actually want to have to _use_ automake.
12 | # Instead, I construct a trivial unrelated automake project in a
13 | # temporary subdirectory, run automake so that it'll copy
14 | # install-sh into that directory, then copy it back out again.
15 | # Hideous, but it should work.
16 |
17 | mkdir automake-grievous-hack
18 | cat > automake-grievous-hack/hello.c << EOF
19 | #include
20 | int main(int argc, char **argv)
21 | {
22 | printf("hello, world\n");
23 | return 0;
24 | }
25 | EOF
26 | cat > automake-grievous-hack/Makefile.am << EOF
27 | bin_PROGRAMS = hello
28 | hello_SOURCES = hello.c
29 | EOF
30 | cat > automake-grievous-hack/configure.ac << EOF
31 | AC_INIT
32 | AM_INIT_AUTOMAKE(hello, 1.0)
33 | AC_CONFIG_FILES([Makefile])
34 | AC_PROG_CC
35 | AC_OUTPUT
36 | EOF
37 | echo Some news > automake-grievous-hack/NEWS
38 | echo Some text > automake-grievous-hack/README
39 | echo Some people > automake-grievous-hack/AUTHORS
40 | echo Some changes > automake-grievous-hack/ChangeLog
41 | rm -f install-sh # this won't work if we accidentally have one _here_
42 | (cd automake-grievous-hack && autoreconf -i && \
43 | cp install-sh ../unix/install-sh)
44 | rm -rf automake-grievous-hack
45 |
46 | # That was the hard bit. Now run autoconf on our real configure.in.
47 | (cd unix && autoreconf && rm -rf aclocal.m4 autom4te.cache)
48 |
--------------------------------------------------------------------------------
/windows/README.txt:
--------------------------------------------------------------------------------
1 | PuTTY README
2 | ============
3 |
4 | This is the README file for the PuTTY installer distribution. If
5 | you're reading this, you've probably just run our installer and
6 | installed PuTTY on your system.
7 |
8 | What should I do next?
9 | ----------------------
10 |
11 | If you want to use PuTTY to connect to other computers, or use PSFTP
12 | to transfer files, you should just be able to run them from the
13 | Start menu.
14 |
15 | If you want to use the command-line-only file transfer utility PSCP,
16 | you will probably want to put the PuTTY installation directory on
17 | your PATH. How you do this depends on your version of Windows. On
18 | Windows NT, 2000, and XP, you can set it using Control Panel > System;
19 | on Windows 95, 98, and Me, you will need to edit AUTOEXEC.BAT. Consult
20 | your Windows manuals for details.
21 |
22 | Some versions of Windows will refuse to run HTML Help files (.CHM)
23 | if they are installed on a network drive. If you have installed
24 | PuTTY on a network drive, you might want to check that the help file
25 | works properly. If not, see http://support.microsoft.com/kb/896054
26 | for information on how to solve this problem.
27 |
28 | What do I do if it doesn't work?
29 | --------------------------------
30 |
31 | The PuTTY home web site is
32 |
33 | http://www.chiark.greenend.org.uk/~sgtatham/putty/
34 |
35 | Here you will find our list of known bugs and pending feature
36 | requests. If your problem is not listed in there, or in the FAQ, or
37 | in the manuals, read the Feedback page to find out how to report
38 | bugs to us. PLEASE read the Feedback page carefully: it is there to
39 | save you time as well as us. Do not send us one-line bug reports
40 | telling us `it doesn't work'.
41 |
--------------------------------------------------------------------------------
/pinger.c:
--------------------------------------------------------------------------------
1 | /*
2 | * pinger.c: centralised module that deals with sending TS_PING
3 | * keepalives, to avoid replicating this code in multiple backends.
4 | */
5 |
6 | #include "putty.h"
7 |
8 | struct pinger_tag {
9 | int interval;
10 | int pending;
11 | long next;
12 | Backend *back;
13 | void *backhandle;
14 | };
15 |
16 | static void pinger_schedule(Pinger pinger);
17 |
18 | static void pinger_timer(void *ctx, long now)
19 | {
20 | Pinger pinger = (Pinger)ctx;
21 |
22 | if (pinger->pending && now - pinger->next >= 0) {
23 | pinger->back->special(pinger->backhandle, TS_PING);
24 | pinger->pending = FALSE;
25 | pinger_schedule(pinger);
26 | }
27 | }
28 |
29 | static void pinger_schedule(Pinger pinger)
30 | {
31 | int next;
32 |
33 | if (!pinger->interval) {
34 | pinger->pending = FALSE; /* cancel any pending ping */
35 | return;
36 | }
37 |
38 | next = schedule_timer(pinger->interval * TICKSPERSEC,
39 | pinger_timer, pinger);
40 | if (!pinger->pending || next < pinger->next) {
41 | pinger->next = next;
42 | pinger->pending = TRUE;
43 | }
44 | }
45 |
46 | Pinger pinger_new(Config *cfg, Backend *back, void *backhandle)
47 | {
48 | Pinger pinger = snew(struct pinger_tag);
49 |
50 | pinger->interval = cfg->ping_interval;
51 | pinger->pending = FALSE;
52 | pinger->back = back;
53 | pinger->backhandle = backhandle;
54 | pinger_schedule(pinger);
55 |
56 | return pinger;
57 | }
58 |
59 | void pinger_reconfig(Pinger pinger, Config *oldcfg, Config *newcfg)
60 | {
61 | if (oldcfg->ping_interval != newcfg->ping_interval) {
62 | pinger->interval = newcfg->ping_interval;
63 | pinger_schedule(pinger);
64 | }
65 | }
66 |
67 | void pinger_free(Pinger pinger)
68 | {
69 | expire_timer_context(pinger);
70 | sfree(pinger);
71 | }
72 |
--------------------------------------------------------------------------------
/mkunxarc.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # Build a Unix source distribution from the PuTTY CVS area.
4 | #
5 | # Pass an argument of the form `2004-02-08' to have the archive
6 | # tagged as a development snapshot; of the form `0.54' to have it
7 | # tagged as a release; of the form `r1234' to have it tagged as a
8 | # custom build. Otherwise it'll be tagged as unidentified.
9 |
10 | case "$1" in
11 | ????-??-??)
12 | case "$1" in *[!-0-9]*) echo "Malformed snapshot ID '$1'" >&2;exit 1;;esac
13 | arcsuffix="-`cat LATEST.VER`-$1"
14 | ver="-DSNAPSHOT=$1"
15 | docver=
16 | ;;
17 | r*)
18 | arcsuffix="-$1"
19 | ver="-DSVN_REV=$1"
20 | docver=
21 | ;;
22 | '')
23 | arcsuffix=
24 | ver=
25 | docver=
26 | ;;
27 | *)
28 | case "$1" in *[!.0-9a-z]*) echo "Malformed release ID '$1'">&2;exit 1;;esac
29 | arcsuffix="-$1"
30 | ver="-DRELEASE=$1"
31 | docver="VERSION=\"PuTTY release $1\""
32 | ;;
33 | esac
34 |
35 | perl mkfiles.pl
36 | (cd doc && make -s ${docver:+"$docver"})
37 | sh mkauto.sh 2>/dev/null
38 |
39 | relver=`cat LATEST.VER`
40 | arcname="putty$arcsuffix"
41 | mkdir uxarc
42 | mkdir uxarc/$arcname
43 | find . -name uxarc -prune -o \
44 | -name CVS -prune -o \
45 | -name .svn -prune -o \
46 | -name . -o \
47 | -type d -exec mkdir uxarc/$arcname/{} \;
48 | find . -name uxarc -prune -o \
49 | -name CVS -prune -o \
50 | -name .cvsignore -prune -o \
51 | -name .svn -prune -o \
52 | -name '*.zip' -prune -o \
53 | -name '*.tar.gz' -prune -o \
54 | -type f -exec ln -s $PWD/{} uxarc/$arcname/{} \;
55 | if test "x$ver" != "x"; then
56 | (cd uxarc/$arcname;
57 | md5sum `find . -name '*.[ch]' -print` > manifest;
58 | echo "$ver" > version.def)
59 | fi
60 | tar -C uxarc -chzof $arcname.tar.gz $arcname
61 | rm -rf uxarc
62 |
--------------------------------------------------------------------------------
/windows/wintabdraw.h:
--------------------------------------------------------------------------------
1 | #ifndef WINTABDRAW_H
2 | #define WINTABDRAW_H
3 |
4 | typedef enum{
5 | SIDE_LEFT, SIDE_TOP, SIDE_RIGHT, SIDE_BOTTOM
6 | }SIDE;
7 |
8 | int DrawMinButton(HDC hdc, RECT *pRect, COLORREF clrBorder, COLORREF clrBack, COLORREF clrBtn);
9 | int DrawMaxButton(HDC hdc, RECT *pRect, COLORREF clrBorder, COLORREF clrBack, COLORREF clrBtn, int isZoomed);
10 | int DrawClsButton(HDC hdc, RECT *pRect, COLORREF clrBorder, COLORREF clrBack, COLORREF clrBtn);
11 | HRGN DrawChromeFrame(HDC hdc, RECT *pRect, COLORREF clrBorder, COLORREF clrBack);
12 | int DrawSysButtonFrame(HDC hdc, RECT *pRect, COLORREF clrBorder, COLORREF clrBack, HRGN* hRgns);
13 | int DrawSysButton(HDC hdc, RECT *pRect, COLORREF clrBorder);
14 | HRGN DrawCloseButton(HDC hdc, const int x, const int y,
15 | COLORREF clrBorder, COLORREF clrBack );
16 | void DrawHalfRoundFrame(HDC hdc, RECT const *pRect, SIDE side,
17 | int radius, COLORREF clrBorder, COLORREF clrBack);
18 | void DrawFrame(HDC hdc, POINT const *pPoints, int iCount,
19 | COLORREF clrBorder, COLORREF clrBack);
20 | void _DrawFrame(HDC hdc, POINT const *pPoints, int iCount, COLORREF clrLine);
21 | void DrawGradient(HDC hdc, RECT const *pRect, char horz, COLORREF clrTopLeft, COLORREF clrBottomRight);
22 | void DrawLinec(HDC hdc, int x1, int y1, int x2, int y2, COLORREF clrLine);
23 | void DrawLine(HDC hdc, int x1, int y1, int x2, int y2);
24 | void DrawRect4c(HDC hdc, int x1, int y1, int x2, int y2, COLORREF clrLine);
25 | void DrawRect1c(HDC hdc, RECT const *pRect, COLORREF clrLine);
26 | void DrawRect4(HDC hdc, int x1, int y1, int x2, int y2);
27 | void DrawRect1(HDC hdc, RECT const *pRect);
28 | void DrawBeveledRect(HDC hdc, RECT const *pRect, int bevel);
29 | COLORREF PixelAlpha(COLORREF src, COLORREF dst, int percent);
30 | void FillSolidRect(HDC hdc, RECT const *rc, COLORREF color);
31 | int DrawMarker(HDC hdc, RECT const *pRect, HBITMAP hbmpMask, COLORREF color);
32 | int CorrectFitSpaceString(HDC hdc, char const *strSrc, int maxLength, char *strDst);
33 |
34 |
35 | #endif /* WINTABDRAW_H */
36 |
37 |
--------------------------------------------------------------------------------
/unix/gtkcols.h:
--------------------------------------------------------------------------------
1 | /*
2 | * gtkcols.h - header file for a columns-based widget container
3 | * capable of supporting the PuTTY portable dialog box layout
4 | * mechanism.
5 | */
6 |
7 | #ifndef COLUMNS_H
8 | #define COLUMNS_H
9 |
10 | #include
11 | #include
12 |
13 | #ifdef __cplusplus
14 | extern "C" {
15 | #endif /* __cplusplus */
16 |
17 | #define TYPE_COLUMNS (columns_get_type())
18 | #define COLUMNS(obj) (GTK_CHECK_CAST((obj), TYPE_COLUMNS, Columns))
19 | #define COLUMNS_CLASS(klass) \
20 | (GTK_CHECK_CLASS_CAST((klass), TYPE_COLUMNS, ColumnsClass))
21 | #define IS_COLUMNS(obj) (GTK_CHECK_TYPE((obj), TYPE_COLUMNS))
22 | #define IS_COLUMNS_CLASS(klass) (GTK_CHECK_CLASS_TYPE((klass), TYPE_COLUMNS))
23 |
24 | typedef struct Columns_tag Columns;
25 | typedef struct ColumnsClass_tag ColumnsClass;
26 | typedef struct ColumnsChild_tag ColumnsChild;
27 |
28 | struct Columns_tag {
29 | GtkContainer container;
30 | /* private after here */
31 | GList *children; /* this holds ColumnsChild structures */
32 | GList *taborder; /* this just holds GtkWidgets */
33 | gint spacing;
34 | };
35 |
36 | struct ColumnsClass_tag {
37 | GtkContainerClass parent_class;
38 | };
39 |
40 | struct ColumnsChild_tag {
41 | /* If `widget' is non-NULL, this entry represents an actual widget. */
42 | GtkWidget *widget;
43 | gint colstart, colspan;
44 | gboolean force_left; /* for recalcitrant GtkLabels */
45 | /* Otherwise, this entry represents a change in the column setup. */
46 | gint ncols;
47 | gint *percentages;
48 | };
49 |
50 | GtkType columns_get_type(void);
51 | GtkWidget *columns_new(gint spacing);
52 | void columns_set_cols(Columns *cols, gint ncols, const gint *percentages);
53 | void columns_add(Columns *cols, GtkWidget *child,
54 | gint colstart, gint colspan);
55 | void columns_taborder_last(Columns *cols, GtkWidget *child);
56 | void columns_force_left_align(Columns *cols, GtkWidget *child);
57 |
58 | #ifdef __cplusplus
59 | }
60 | #endif /* __cplusplus */
61 |
62 | #endif /* COLUMNS_H */
63 |
--------------------------------------------------------------------------------
/charset/toucs.c:
--------------------------------------------------------------------------------
1 | /*
2 | * toucs.c - convert charsets to Unicode.
3 | */
4 |
5 | #include "charset.h"
6 | #include "internal.h"
7 |
8 | struct unicode_emit_param {
9 | wchar_t *output;
10 | int outlen;
11 | const wchar_t *errstr;
12 | int errlen;
13 | int stopped;
14 | };
15 |
16 | static void unicode_emit(void *ctx, long int output)
17 | {
18 | struct unicode_emit_param *param = (struct unicode_emit_param *)ctx;
19 | wchar_t outval;
20 | wchar_t const *p;
21 | int outlen;
22 |
23 | if (output == ERROR) {
24 | if (param->errstr) {
25 | p = param->errstr;
26 | outlen = param->errlen;
27 | } else {
28 | outval = 0xFFFD; /* U+FFFD REPLACEMENT CHARACTER */
29 | p = &outval;
30 | outlen = 1;
31 | }
32 | } else {
33 | outval = output;
34 | p = &outval;
35 | outlen = 1;
36 | }
37 |
38 | if (param->outlen >= outlen) {
39 | while (outlen > 0) {
40 | *param->output++ = *p++;
41 | param->outlen--;
42 | outlen--;
43 | }
44 | } else {
45 | param->stopped = 1;
46 | }
47 | }
48 |
49 | int charset_to_unicode(char **input, int *inlen, wchar_t *output, int outlen,
50 | int charset, charset_state *state,
51 | const wchar_t *errstr, int errlen)
52 | {
53 | charset_spec const *spec = charset_find_spec(charset);
54 | charset_state localstate;
55 | struct unicode_emit_param param;
56 |
57 | param.output = output;
58 | param.outlen = outlen;
59 | param.errstr = errstr;
60 | param.errlen = errlen;
61 | param.stopped = 0;
62 |
63 | if (!state) {
64 | localstate.s0 = 0;
65 | } else {
66 | localstate = *state; /* structure copy */
67 | }
68 |
69 | while (*inlen > 0) {
70 | int lenbefore = param.output - output;
71 | spec->read(spec, (unsigned char)**input, &localstate,
72 | unicode_emit, ¶m);
73 | if (param.stopped) {
74 | /*
75 | * The emit function has _tried_ to output some
76 | * characters, but ran up against the end of the
77 | * buffer. Leave immediately, and return what happened
78 | * _before_ attempting to process this character.
79 | */
80 | return lenbefore;
81 | }
82 | if (state)
83 | *state = localstate; /* structure copy */
84 | (*input)++;
85 | (*inlen)--;
86 | }
87 |
88 | return param.output - output;
89 | }
90 |
--------------------------------------------------------------------------------
/unix/gtkfont.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Header file for gtkfont.c. Has to be separate from unix.h
3 | * because it depends on GTK data types, hence can't be included
4 | * from cross-platform code (which doesn't go near GTK).
5 | */
6 |
7 | #ifndef PUTTY_GTKFONT_H
8 | #define PUTTY_GTKFONT_H
9 |
10 | /*
11 | * Exports from gtkfont.c.
12 | */
13 | struct unifont_vtable; /* contents internal to gtkfont.c */
14 | typedef struct unifont {
15 | const struct unifont_vtable *vt;
16 | /*
17 | * `Non-static data members' of the `class', accessible to
18 | * external code.
19 | */
20 |
21 | /*
22 | * public_charset is the charset used when the user asks for
23 | * `Use font encoding'.
24 | *
25 | * real_charset is the charset used when translating text into
26 | * a form suitable for sending to unifont_draw_text().
27 | *
28 | * They can differ. For example, public_charset might be
29 | * CS_ISO8859_1 while real_charset is CS_ISO8859_1_X11.
30 | */
31 | int public_charset, real_charset;
32 |
33 | /*
34 | * Font dimensions needed by clients.
35 | */
36 | int width, height, ascent, descent;
37 | } unifont;
38 |
39 | unifont *unifont_create(GtkWidget *widget, const char *name,
40 | int wide, int bold,
41 | int shadowoffset, int shadowalways);
42 | void unifont_destroy(unifont *font);
43 | void unifont_draw_text(GdkDrawable *target, GdkGC *gc, unifont *font,
44 | int x, int y, const char *string, int len,
45 | int wide, int bold, int cellwidth);
46 |
47 | /*
48 | * Unified font selector dialog. I can't be bothered to do a
49 | * proper GTK subclassing today, so this will just be an ordinary
50 | * data structure with some useful members.
51 | *
52 | * (Of course, these aren't the only members; this structure is
53 | * contained within a bigger one which holds data visible only to
54 | * the implementation.)
55 | */
56 | typedef struct unifontsel {
57 | void *user_data; /* settable by the user */
58 | GtkWindow *window;
59 | GtkWidget *ok_button, *cancel_button;
60 | } unifontsel;
61 |
62 | unifontsel *unifontsel_new(const char *wintitle);
63 | void unifontsel_destroy(unifontsel *fontsel);
64 | void unifontsel_set_name(unifontsel *fontsel, const char *fontname);
65 | char *unifontsel_get_name(unifontsel *fontsel);
66 |
67 | #endif /* PUTTY_GTKFONT_H */
68 |
--------------------------------------------------------------------------------
/charset/fromucs.c:
--------------------------------------------------------------------------------
1 | /*
2 | * fromucs.c - convert Unicode to other character sets.
3 | */
4 |
5 | #include "charset.h"
6 | #include "internal.h"
7 |
8 | struct charset_emit_param {
9 | char *output;
10 | int outlen;
11 | const char *errstr;
12 | int errlen;
13 | int stopped;
14 | };
15 |
16 | static void charset_emit(void *ctx, long int output)
17 | {
18 | struct charset_emit_param *param = (struct charset_emit_param *)ctx;
19 | char outval;
20 | char const *p;
21 | int outlen;
22 |
23 | if (output == ERROR) {
24 | p = param->errstr;
25 | outlen = param->errlen;
26 | } else {
27 | outval = output;
28 | p = &outval;
29 | outlen = 1;
30 | }
31 |
32 | if (param->outlen >= outlen) {
33 | while (outlen > 0) {
34 | *param->output++ = *p++;
35 | param->outlen--;
36 | outlen--;
37 | }
38 | } else {
39 | param->stopped = 1;
40 | }
41 | }
42 |
43 | int charset_from_unicode(wchar_t **input, int *inlen, char *output, int outlen,
44 | int charset, charset_state *state,
45 | const char *errstr, int errlen)
46 | {
47 | charset_spec const *spec = charset_find_spec(charset);
48 | charset_state localstate;
49 | struct charset_emit_param param;
50 |
51 | param.output = output;
52 | param.outlen = outlen;
53 | param.stopped = 0;
54 |
55 | /*
56 | * charset_emit will expect a valid errstr.
57 | */
58 | if (!errstr) {
59 | /* *shrug* this is good enough, and consistent across all SBCS... */
60 | param.errstr = ".";
61 | param.errlen = 1;
62 | }
63 | param.errstr = errstr;
64 | param.errlen = errlen;
65 |
66 | if (!state) {
67 | localstate.s0 = 0;
68 | } else {
69 | localstate = *state; /* structure copy */
70 | }
71 | state = &localstate;
72 |
73 | while (*inlen > 0) {
74 | int lenbefore = param.output - output;
75 | spec->write(spec, **input, &localstate, charset_emit, ¶m);
76 | if (param.stopped) {
77 | /*
78 | * The emit function has _tried_ to output some
79 | * characters, but ran up against the end of the
80 | * buffer. Leave immediately, and return what happened
81 | * _before_ attempting to process this character.
82 | */
83 | return lenbefore;
84 | }
85 | if (state)
86 | *state = localstate; /* structure copy */
87 | (*input)++;
88 | (*inlen)--;
89 | }
90 | return param.output - output;
91 | }
92 |
--------------------------------------------------------------------------------
/doc/Makefile:
--------------------------------------------------------------------------------
1 | all: man index.html
2 |
3 | # Decide on the versionid policy.
4 | #
5 | # If the user has passed in $(VERSION) on the command line (`make
6 | # VERSION="Release 0.56"'), we use that as an explicit version
7 | # string. Otherwise, we use `svnversion' to examine the checked-out
8 | # documentation source, and if that returns a single revision
9 | # number then we invent a version string reflecting just that
10 | # number. Failing _that_, we resort to versionids.but which shows a
11 | # $Id for each individual file.
12 | #
13 | # So here, we define VERSION using svnversion if it isn't already
14 | # defined ...
15 | ifndef VERSION
16 | SVNVERSION=$(shell test -d .svn && svnversion .)
17 | BADCHARS=$(findstring :,$(SVNVERSION))$(findstring S,$(SVNVERSION))
18 | ifeq ($(BADCHARS),)
19 | ifneq ($(SVNVERSION),)
20 | ifneq ($(SVNVERSION),exported)
21 | VERSION=Built from revision $(patsubst M,,$(SVNVERSION))
22 | endif
23 | endif
24 | endif
25 | endif
26 | # ... and now, we condition our build behaviour on whether or not
27 | # VERSION _is_ defined.
28 | ifdef VERSION
29 | VERSIONIDS=vstr
30 | vstr.but: FORCE
31 | echo \\versionid $(VERSION) > vstr.but
32 | FORCE:;
33 | else
34 | VERSIONIDS=vids
35 | endif
36 |
37 | CHAPTERS := $(SITE) blurb intro gs using config pscp psftp plink pubkey
38 | CHAPTERS += pageant errors faq feedback licence udp pgpkeys sshnames
39 | CHAPTERS += index $(VERSIONIDS)
40 |
41 | INPUTS = $(patsubst %,%.but,$(CHAPTERS))
42 |
43 | # This is temporary. Hack it locally or something.
44 | HALIBUT = halibut
45 |
46 | index.html: $(INPUTS)
47 | $(HALIBUT) --text --html --winhelp $(INPUTS)
48 |
49 | # During formal builds it's useful to be able to build this one alone.
50 | putty.hlp: $(INPUTS)
51 | $(HALIBUT) --winhelp $(INPUTS)
52 |
53 | putty.info: $(INPUTS)
54 | $(HALIBUT) --info $(INPUTS)
55 |
56 | chm: putty.hhp
57 | putty.hhp: $(INPUTS) chm.but
58 | $(HALIBUT) --html $(INPUTS) chm.but
59 |
60 | MKMAN = $(HALIBUT) --man=$@ mancfg.but $<
61 | MANPAGES = putty.1 puttygen.1 plink.1 pscp.1 psftp.1 puttytel.1 pterm.1
62 | man: $(MANPAGES)
63 |
64 | putty.1: man-putt.but mancfg.but; $(MKMAN)
65 | puttygen.1: man-pg.but mancfg.but; $(MKMAN)
66 | plink.1: man-pl.but mancfg.but; $(MKMAN)
67 | pscp.1: man-pscp.but mancfg.but; $(MKMAN)
68 | psftp.1: man-psft.but mancfg.but; $(MKMAN)
69 | puttytel.1: man-ptel.but mancfg.but; $(MKMAN)
70 | pterm.1: man-pter.but mancfg.but; $(MKMAN)
71 |
72 | mostlyclean:
73 | rm -f *.html *.txt *.hlp *.cnt *.1 *.info vstr.but *.hh[pck]
74 | clean: mostlyclean
75 | rm -f *.chm
76 |
--------------------------------------------------------------------------------
/doc/man-psft.but:
--------------------------------------------------------------------------------
1 | \cfg{man-identity}{psftp}{1}{2004-03-24}{PuTTY tool suite}{PuTTY tool suite}
2 |
3 | \H{psftp-manpage} Man page for PSFTP
4 |
5 | \S{psftp-manpage-name} NAME
6 |
7 | \cw{psftp} \- interactive SFTP (secure file transfer protocol) client
8 |
9 | \S{psftp-manpage-synopsis} SYNOPSIS
10 |
11 | \c psftp [options] [user@]host
12 | \e bbbbb iiiiiii iiiib iiii
13 |
14 | \S{psftp-manpage-description} DESCRIPTION
15 |
16 | \cw{psftp} is an interactive text-based client for the SSH-based SFTP
17 | (secure file transfer) protocol.
18 |
19 | \S{psftp-manpage-options} OPTIONS
20 |
21 | The command-line options supported by \cw{psftp} are:
22 |
23 | \dt \cw{-V}
24 |
25 | \dd Show version information and exit.
26 |
27 | \dt \cw{-pgpfp}
28 |
29 | \dd Display the fingerprints of the PuTTY PGP Master Keys and exit,
30 | to aid in verifying new files released by the PuTTY team.
31 |
32 | \dt \cw{-b} \e{batchfile}
33 |
34 | \dd Use specified batchfile.
35 |
36 | \dt \cw{-bc}
37 |
38 | \dd Output batchfile commands.
39 |
40 | \dt \cw{-be}
41 |
42 | \dd Don't stop batchfile processing on errors.
43 |
44 | \dt \cw{-v}
45 |
46 | \dd Show verbose messages.
47 |
48 | \dt \cw{-load} \e{session}
49 |
50 | \dd Load settings from saved session.
51 |
52 | \dt \cw{-P} \e{port}
53 |
54 | \dd Connect to port \e{port}.
55 |
56 | \dt \cw{-l} \e{user}
57 |
58 | \dd Set remote username to \e{user}.
59 |
60 | \dt \cw{-batch}
61 |
62 | \dd Disable interactive prompts.
63 |
64 | \dt \cw{-pw} \e{password}
65 |
66 | \dd Set remote password to \e{password}. \e{CAUTION:} this will likely
67 | make the password visible to other users of the local machine (via
68 | commands such as \q{\c{w}}).
69 |
70 | \dt \cw{-1}
71 |
72 | \dd Force use of SSH protocol version 1.
73 |
74 | \dt \cw{-2}
75 |
76 | \dd Force use of SSH protocol version 2.
77 |
78 | \dt \cw{-C}
79 |
80 | \dd Enable SSH compression.
81 |
82 | \dt \cw{-i} \e{path}
83 |
84 | \dd Private key file for authentication.
85 |
86 | \S{psftp-manpage-commands} COMMANDS
87 |
88 | For a list of commands available inside \cw{psftp}, type \cw{help}
89 | at the \cw{psftp>} prompt.
90 |
91 | \S{psftp-manpage-more-information} MORE INFORMATION
92 |
93 | For more information on \cw{psftp} it's probably best to go and look at
94 | the manual on the PuTTY web page:
95 |
96 | \cw{http://www.chiark.greenend.org.uk/~sgtatham/putty/}
97 |
98 | \S{psftp-manpage-bugs} BUGS
99 |
100 | This man page isn't terribly complete. See the above web link for
101 | better documentation.
102 |
--------------------------------------------------------------------------------
/doc/sshnames.but:
--------------------------------------------------------------------------------
1 | \define{versionidsshnames} \versionid $Id$
2 |
3 | \A{sshnames} SSH-2 names specified for PuTTY
4 |
5 | There are various parts of the SSH-2 protocol where things are specified
6 | using a textual name. Names ending in \cw{@putty.projects.tartarus.org}
7 | are reserved for allocation by the PuTTY team. Allocated names are
8 | documented here.
9 |
10 | \H{sshnames-channel} Connection protocol channel request names
11 |
12 | These names can be sent in a \cw{SSH_MSG_CHANNEL_REQUEST} message.
13 |
14 | \dt \cw{simple@putty.projects.tartarus.org}
15 |
16 | \dd This is sent by a client to announce that it will not have more than
17 | one channel open at a time in the current connection (that one being
18 | the one the request is sent on). The intention is that the server,
19 | knowing this, can set the window on that one channel to something very
20 | large, and leave flow control to TCP. There is no message-specific data.
21 |
22 | \dt \cw{winadj@putty.projects.tartarus.org}
23 |
24 | \dd PuTTY sends this request along with some
25 | \cw{SSH_MSG_CHANNEL_WINDOW_ADJUST} messages as part of its window-size
26 | tuning. It can be sent on any type of channel. There is no
27 | message-specific data. Servers MUST treat it as an unrecognised request
28 | and respond with \cw{SSH_MSG_CHANNEL_FAILURE}.
29 |
30 | \H{sshnames-kex} Key exchange method names
31 |
32 | \dt \cw{rsa-sha1-draft-00@putty.projects.tartarus.org}
33 |
34 | \dt \cw{rsa-sha256-draft-00@putty.projects.tartarus.org}
35 |
36 | \dt \cw{rsa1024-sha1-draft-01@putty.projects.tartarus.org}
37 |
38 | \dt \cw{rsa1024-sha256-draft-01@putty.projects.tartarus.org}
39 |
40 | \dt \cw{rsa2048-sha256-draft-01@putty.projects.tartarus.org}
41 |
42 | \dt \cw{rsa1024-sha1-draft-02@putty.projects.tartarus.org}
43 |
44 | \dt \cw{rsa2048-sha512-draft-02@putty.projects.tartarus.org}
45 |
46 | \dt \cw{rsa1024-sha1-draft-03@putty.projects.tartarus.org}
47 |
48 | \dt \cw{rsa2048-sha256-draft-03@putty.projects.tartarus.org}
49 |
50 | \dt \cw{rsa1024-sha1-draft-04@putty.projects.tartarus.org}
51 |
52 | \dt \cw{rsa2048-sha256-draft-04@putty.projects.tartarus.org}
53 |
54 | \dd These appeared in various drafts of what eventually became RFC\_4432.
55 | They have been superseded by \cw{rsa1024-sha1} and \cw{rsa2048-sha256}.
56 |
57 | \H{sshnames-encrypt} Encryption algorithm names
58 |
59 | \dt \cw{arcfour128-draft-00@putty.projects.tartarus.org}
60 |
61 | \dt \cw{arcfour256-draft-00@putty.projects.tartarus.org}
62 |
63 | \dd These were used in drafts of what eventually became RFC\_4345.
64 | They have been superseded by \cw{arcfour128} and \cw{arcfour256}.
65 |
--------------------------------------------------------------------------------
/unix/uxcfg.c:
--------------------------------------------------------------------------------
1 | /*
2 | * uxcfg.c - the Unix-specific parts of the PuTTY configuration
3 | * box.
4 | */
5 |
6 | #include
7 | #include
8 |
9 | #include "putty.h"
10 | #include "dialog.h"
11 | #include "storage.h"
12 |
13 | void unix_setup_config_box(struct controlbox *b, int midsession, int protocol)
14 | {
15 | struct controlset *s;
16 | union control *c;
17 |
18 | /*
19 | * The Config structure contains two Unix-specific elements
20 | * which are not configured in here: stamp_utmp and
21 | * login_shell. This is because pterm does not put up a
22 | * configuration box right at the start, which is the only time
23 | * when these elements would be useful to configure.
24 | */
25 |
26 | /*
27 | * On Unix, we don't have a drop-down list for the printer
28 | * control.
29 | */
30 | s = ctrl_getset(b, "Terminal", "printing", "Remote-controlled printing");
31 | assert(s->ncontrols == 1 && s->ctrls[0]->generic.type == CTRL_EDITBOX);
32 | s->ctrls[0]->editbox.has_list = 0;
33 |
34 | /*
35 | * Unix supports a local-command proxy. This also means we must
36 | * adjust the text on the `Telnet command' control.
37 | */
38 | if (!midsession) {
39 | int i;
40 | s = ctrl_getset(b, "Connection/Proxy", "basics", NULL);
41 | for (i = 0; i < s->ncontrols; i++) {
42 | c = s->ctrls[i];
43 | if (c->generic.type == CTRL_RADIO &&
44 | c->generic.context.i == offsetof(Config, proxy_type)) {
45 | assert(c->generic.handler == dlg_stdradiobutton_handler);
46 | c->radio.nbuttons++;
47 | c->radio.buttons =
48 | sresize(c->radio.buttons, c->radio.nbuttons, char *);
49 | c->radio.buttons[c->radio.nbuttons-1] =
50 | dupstr("Local");
51 | c->radio.buttondata =
52 | sresize(c->radio.buttondata, c->radio.nbuttons, intorptr);
53 | c->radio.buttondata[c->radio.nbuttons-1] = I(PROXY_CMD);
54 | break;
55 | }
56 | }
57 |
58 | for (i = 0; i < s->ncontrols; i++) {
59 | c = s->ctrls[i];
60 | if (c->generic.type == CTRL_EDITBOX &&
61 | c->generic.context.i ==
62 | offsetof(Config, proxy_telnet_command)) {
63 | assert(c->generic.handler == dlg_stdeditbox_handler);
64 | sfree(c->generic.label);
65 | c->generic.label = dupstr("Telnet command, or local"
66 | " proxy command");
67 | break;
68 | }
69 | }
70 | }
71 |
72 | /*
73 | * Serial back end is available on Unix. However, we have to
74 | * mask out a couple of the configuration options: mark and
75 | * space parity are not conveniently supported, and neither is
76 | * DSR/DTR flow control.
77 | */
78 | if (!midsession || (protocol == PROT_SERIAL))
79 | ser_setup_config_box(b, midsession, 0x07, 0x07);
80 | }
81 |
--------------------------------------------------------------------------------
/charset/xenc.c:
--------------------------------------------------------------------------------
1 | /*
2 | * xenc.c - translate our internal character set codes to and from
3 | * X11 character encoding names.
4 | *
5 | */
6 |
7 | #include
8 | #include "charset.h"
9 | #include "internal.h"
10 |
11 | static const struct {
12 | const char *name;
13 | int charset;
14 | } xencs[] = {
15 | /*
16 | * Officially registered encoding names. This list is derived
17 | * from the font encodings section of
18 | *
19 | * http://ftp.x.org/pub/DOCS/registry
20 | *
21 | * Where multiple encoding names map to the same encoding id
22 | * (such as iso8859-15 and fcd8859-15), the first is considered
23 | * canonical and will be returned when translating the id to a
24 | * string.
25 | */
26 | { "iso8859-1", CS_ISO8859_1 },
27 | { "iso8859-2", CS_ISO8859_2 },
28 | { "iso8859-3", CS_ISO8859_3 },
29 | { "iso8859-4", CS_ISO8859_4 },
30 | { "iso8859-5", CS_ISO8859_5 },
31 | { "iso8859-6", CS_ISO8859_6 },
32 | { "iso8859-7", CS_ISO8859_7 },
33 | { "iso8859-8", CS_ISO8859_8 },
34 | { "iso8859-9", CS_ISO8859_9 },
35 | { "iso8859-10", CS_ISO8859_10 },
36 | { "iso8859-13", CS_ISO8859_13 },
37 | { "iso8859-14", CS_ISO8859_14 },
38 | { "iso8859-15", CS_ISO8859_15 },
39 | { "fcd8859-15", CS_ISO8859_15 },
40 | { "hp-roman8", CS_HP_ROMAN8 },
41 | { "koi8-r", CS_KOI8_R },
42 | /*
43 | * Unofficial encoding names found in the wild.
44 | */
45 | { "iso8859-16", CS_ISO8859_16 },
46 | { "koi8-u", CS_KOI8_U },
47 | { "ibm-cp437", CS_CP437 },
48 | { "ibm-cp850", CS_CP850 },
49 | { "ibm-cp866", CS_CP866 },
50 | { "microsoft-cp1250", CS_CP1250 },
51 | { "microsoft-cp1251", CS_CP1251 },
52 | { "microsoft-cp1252", CS_CP1252 },
53 | { "microsoft-cp1253", CS_CP1253 },
54 | { "microsoft-cp1254", CS_CP1254 },
55 | { "microsoft-cp1255", CS_CP1255 },
56 | { "microsoft-cp1256", CS_CP1256 },
57 | { "microsoft-cp1257", CS_CP1257 },
58 | { "microsoft-cp1258", CS_CP1258 },
59 | { "mac-roman", CS_MAC_ROMAN },
60 | { "viscii1.1-1", CS_VISCII },
61 | { "viscii1-1", CS_VISCII },
62 | };
63 |
64 | const char *charset_to_xenc(int charset)
65 | {
66 | int i;
67 |
68 | for (i = 0; i < (int)lenof(xencs); i++)
69 | if (charset == xencs[i].charset)
70 | return xencs[i].name;
71 |
72 | return NULL; /* not found */
73 | }
74 |
75 | int charset_from_xenc(const char *name)
76 | {
77 | int i;
78 |
79 | for (i = 0; i < (int)lenof(xencs); i++) {
80 | const char *p, *q;
81 | p = name;
82 | q = xencs[i].name;
83 | while (*p || *q) {
84 | if (tolower((unsigned char)*p) != tolower((unsigned char)*q))
85 | break;
86 | p++; q++;
87 | }
88 | if (!*p && !*q)
89 | return xencs[i].charset;
90 | }
91 |
92 | return CS_NONE; /* not found */
93 | }
94 |
--------------------------------------------------------------------------------
/ldiscucs.c:
--------------------------------------------------------------------------------
1 | /*
2 | * ldisc.c: PuTTY line discipline. Sits between the input coming
3 | * from keypresses in the window, and the output channel leading to
4 | * the back end. Implements echo and/or local line editing,
5 | * depending on what's currently configured.
6 | */
7 |
8 | #include
9 | #include
10 |
11 | #include "putty.h"
12 | #include "terminal.h"
13 | #include "ldisc.h"
14 |
15 | void lpage_send(void *handle,
16 | int codepage, char *buf, int len, int interactive)
17 | {
18 | Ldisc ldisc = (Ldisc)handle;
19 | wchar_t *widebuffer = 0;
20 | int widesize = 0;
21 | int wclen;
22 |
23 | if (codepage < 0) {
24 | ldisc_send(ldisc, buf, len, interactive);
25 | return;
26 | }
27 |
28 | widesize = len * 2;
29 | widebuffer = snewn(widesize, wchar_t);
30 |
31 | wclen = mb_to_wc(codepage, 0, buf, len, widebuffer, widesize);
32 | luni_send(ldisc, widebuffer, wclen, interactive);
33 |
34 | sfree(widebuffer);
35 | }
36 |
37 | void luni_send(void *handle, wchar_t * widebuf, int len, int interactive)
38 | {
39 | Ldisc ldisc = (Ldisc)handle;
40 | int ratio = (in_utf(ldisc->term))?3:1;
41 | char *linebuffer;
42 | int linesize;
43 | int i;
44 | char *p;
45 |
46 | linesize = len * ratio * 2;
47 | linebuffer = snewn(linesize, char);
48 |
49 | if (in_utf(ldisc->term)) {
50 | /* UTF is a simple algorithm */
51 | for (p = linebuffer, i = 0; i < len; i++) {
52 | unsigned long ch = widebuf[i];
53 |
54 | if ((ch & 0xF800) == 0xD800) {
55 | #ifdef PLATFORM_IS_UTF16
56 | if (i+1 < len) {
57 | unsigned long ch2 = widebuf[i+1];
58 | if ((ch & 0xFC00) == 0xD800 &&
59 | (ch2 & 0xFC00) == 0xDC00) {
60 | ch = 0x10000 + ((ch & 0x3FF) << 10) + (ch2 & 0x3FF);
61 | i++;
62 | }
63 | } else
64 | #endif
65 | {
66 | /* Unrecognised UTF-16 sequence */
67 | ch = '.';
68 | }
69 | }
70 |
71 | if (ch < 0x80) {
72 | *p++ = (char) (ch);
73 | } else if (ch < 0x800) {
74 | *p++ = (0xC0 | (ch >> 6));
75 | *p++ = (0x80 | (ch & 0x3F));
76 | } else if (ch < 0x10000) {
77 | *p++ = (0xE0 | (ch >> 12));
78 | *p++ = (0x80 | ((ch >> 6) & 0x3F));
79 | *p++ = (0x80 | (ch & 0x3F));
80 | } else {
81 | *p++ = (0xF0 | (ch >> 18));
82 | *p++ = (0x80 | ((ch >> 12) & 0x3F));
83 | *p++ = (0x80 | ((ch >> 6) & 0x3F));
84 | *p++ = (0x80 | (ch & 0x3F));
85 | }
86 | }
87 | } else {
88 | int rv;
89 | rv = wc_to_mb(ldisc->term->ucsdata->line_codepage, 0, widebuf, len,
90 | linebuffer, linesize, NULL, NULL, ldisc->term->ucsdata);
91 | if (rv >= 0)
92 | p = linebuffer + rv;
93 | else
94 | p = linebuffer;
95 | }
96 | if (p > linebuffer)
97 | ldisc_send(ldisc, linebuffer, p - linebuffer, interactive);
98 |
99 | sfree(linebuffer);
100 | }
101 |
--------------------------------------------------------------------------------
/doc/man-pscp.but:
--------------------------------------------------------------------------------
1 | \cfg{man-identity}{pscp}{1}{2004-03-24}{PuTTY tool suite}{PuTTY tool suite}
2 |
3 | \H{pscp-manpage} Man page for PSCP
4 |
5 | \S{pscp-manpage-name} NAME
6 |
7 | \cw{pscp} \- command-line SCP (secure copy) / SFTP client
8 |
9 | \S{pscp-manpage-synopsis} SYNOPSIS
10 |
11 | \c pscp [options] [user@]host:source target
12 | \e bbbb iiiiiii iiiib iiiibiiiiii iiiiii
13 | \c pscp [options] source [source...] [user@]host:target
14 | \e bbbb iiiiiii iiiiii iiiiii iiiib iiiibiiiiii
15 | \c pscp [options] -ls [user@]host:filespec
16 | \e bbbb iiiiiii bbb iiiib iiiibiiiiiiii
17 |
18 | \S{pscp-manpage-description} DESCRIPTION
19 |
20 | \cw{pscp} is a command-line client for the SSH-based SCP (secure
21 | copy) and SFTP (secure file transfer protocol) protocols.
22 |
23 | \S{pscp-manpage-options} OPTIONS
24 |
25 | The command-line options supported by \e{pscp} are:
26 |
27 | \dt \cw{-V}
28 |
29 | \dd Show version information and exit.
30 |
31 | \dt \cw{-pgpfp}
32 |
33 | \dd Display the fingerprints of the PuTTY PGP Master Keys and exit,
34 | to aid in verifying new files released by the PuTTY team.
35 |
36 | \dt \cw{-ls}
37 |
38 | \dd Remote directory listing.
39 |
40 | \dt \cw{-p}
41 |
42 | \dd Preserve file attributes.
43 |
44 | \dt \cw{-q}
45 |
46 | \dd Quiet, don't show statistics.
47 |
48 | \dt \cw{-r}
49 |
50 | \dd Copy directories recursively.
51 |
52 | \dt \cw{-unsafe}
53 |
54 | \dd Allow server-side wildcards (DANGEROUS).
55 |
56 | \dt \cw{-v}
57 |
58 | \dd Show verbose messages.
59 |
60 | \dt \cw{-load} \e{session}
61 |
62 | \dd Load settings from saved session.
63 |
64 | \dt \cw{-P} \e{port}
65 |
66 | \dd Connect to port \e{port}.
67 |
68 | \dt \cw{-l} \e{user}
69 |
70 | \dd Set remote username to \e{user}.
71 |
72 | \dt \cw{-batch}
73 |
74 | \dd Disable interactive prompts.
75 |
76 | \dt \cw{-pw} \e{password}
77 |
78 | \dd Set remote password to \e{password}. \e{CAUTION:} this will likely
79 | make the password visible to other users of the local machine (via
80 | commands such as \q{\c{w}}).
81 |
82 | \dt \cw{-1}
83 |
84 | \dd Force use of SSH protocol version 1.
85 |
86 | \dt \cw{-2}
87 |
88 | \dd Force use of SSH protocol version 2.
89 |
90 | \dt \cw{-C}
91 |
92 | \dd Enable SSH compression.
93 |
94 | \dt \cw{-i} \e{path}
95 |
96 | \dd Private key file for authentication.
97 |
98 | \dt \cw{-scp}
99 |
100 | \dd Force use of SCP protocol.
101 |
102 | \dt \cw{-sftp}
103 |
104 | \dd Force use of SFTP protocol.
105 |
106 | \S{pscp-manpage-more-information} MORE INFORMATION
107 |
108 | For more information on \cw{pscp} it's probably best to go and look at
109 | the manual on the PuTTY web page:
110 |
111 | \W{http://www.chiark.greenend.org.uk/~sgtatham/putty/}\cw{http://www.chiark.greenend.org.uk/~sgtatham/putty/}
112 |
113 | \S{pscp-manpage-bugs} BUGS
114 |
115 | This man page isn't terribly complete. See the above web link for
116 | better documentation.
117 |
--------------------------------------------------------------------------------
/unix/configure.ac:
--------------------------------------------------------------------------------
1 | # To compile this into a configure script, you need:
2 | # * Autoconf 2.50 or newer
3 | # * Gtk (for $prefix/share/aclocal/gtk.m4)
4 | # * Automake (for aclocal)
5 | # If you've got them, running "autoreconf" should work.
6 |
7 | AC_INIT
8 | AC_CONFIG_FILES([Makefile])
9 | AC_CONFIG_HEADERS([uxconfig.h:uxconfig.in])
10 |
11 | AC_PROG_INSTALL
12 | AC_PROG_CC
13 | if test "X$GCC" = Xyes; then
14 | PUTTYCFLAGS="-Wall -Werror"
15 | else
16 | PUTTYCFLAGS=""
17 | fi
18 | AC_SUBST(PUTTYCFLAGS)
19 |
20 | AC_ARG_WITH([gssapi],
21 | [AS_HELP_STRING([--without-gssapi],
22 | [disable GSSAPI support])],
23 | [],
24 | [with_gssapi=yes])
25 |
26 | WITH_GSSAPI=
27 | AS_IF([test "x$with_gssapi" != xno],
28 | [AC_DEFINE([WITH_GSSAPI], [1], [Define if building with GSSAPI support.])])
29 |
30 | AC_CHECK_HEADERS([utmpx.h sys/select.h],,,[
31 | #include
32 | #include ])
33 |
34 | # Look for both GTK 1 and GTK 2.
35 | AM_PATH_GTK([1.2.0], [gtk=1], [gtk=none])
36 | AM_PATH_GTK_2_0([2.0.0], [gtk=2], [])
37 | if test "$gtk" = "none"; then
38 | all_targets="all-cli"
39 | else
40 | all_targets="all-cli all-gtk"
41 | fi
42 | if test "$gtk" = "2"; then
43 | ac_save_CFLAGS="$CFLAGS"
44 | ac_save_LIBS="$LIBS"
45 | CFLAGS="$CFLAGS $GTK_CFLAGS"
46 | LIBS="$GTK_LIBS $LIBS"
47 | AC_CHECK_FUNCS([pango_font_family_is_monospace pango_font_map_list_families])
48 | CFLAGS="$ac_save_CFLAGS"
49 | LIBS="$ac_save_LIBS"
50 | fi
51 | AC_SUBST([all_targets])
52 |
53 | AC_SEARCH_LIBS([socket], [xnet])
54 |
55 | AS_IF([test "x$with_gssapi" != xno],
56 | [AC_SEARCH_LIBS(
57 | [dlopen],[dl],
58 | [],
59 | [AC_DEFINE([NO_LIBDL], [1], [Define if we could not find libdl.])
60 | AC_CHECK_HEADERS([gssapi/gssapi.h])
61 | AC_SEARCH_LIBS(
62 | [gss_init_sec_context],[gssapi gssapi_krb5 gss],
63 | [],
64 | [AC_DEFINE([NO_GSSAPI_LIB], [1], [Define if we could not find a gssapi library])])])])
65 |
66 | AC_CHECK_LIB(X11, XOpenDisplay)
67 |
68 | AC_CHECK_FUNCS([getaddrinfo ptsname setresuid strsignal updwtmpx])
69 |
70 | AC_OUTPUT
71 |
72 | AH_BOTTOM([
73 | /* Convert autoconf definitions to ones that PuTTY wants. */
74 |
75 | #ifndef HAVE_GETADDRINFO
76 | # define NO_IPV6
77 | #endif
78 | #ifndef HAVE_SETRESUID
79 | # define HAVE_NO_SETRESUID
80 | #endif
81 | #ifndef HAVE_STRSIGNAL
82 | # define HAVE_NO_STRSIGNAL
83 | #endif
84 | #if !defined(HAVE_UTMPX_H) || !defined(HAVE_UPDWTMPX)
85 | # define OMIT_UTMP
86 | #endif
87 | #ifndef HAVE_PTSNAME
88 | # define BSD_PTYS
89 | #endif
90 | #ifndef HAVE_SYS_SELECT_H
91 | # define HAVE_NO_SYS_SELECT_H
92 | #endif
93 | #ifndef HAVE_PANGO_FONT_FAMILY_IS_MONOSPACE
94 | # define PANGO_PRE_1POINT4
95 | #endif
96 | #ifndef HAVE_PANGO_FONT_MAP_LIST_FAMILIES
97 | # define PANGO_PRE_1POINT6
98 | #endif
99 | #if !defined(WITH_GSSAPI)
100 | # define NO_GSSAPI
101 | #endif
102 | #if !defined(NO_GSSAPI) && defined(NO_LIBDL)
103 | # if !defined(HAVE_GSSAPI_GSSAPI_H) || defined(NO_GSSAPI_LIB)
104 | # define NO_GSSAPI
105 | # endif
106 | #endif
107 | ])
108 |
--------------------------------------------------------------------------------
/macosx/README.OSX:
--------------------------------------------------------------------------------
1 | This directory contains a Mac OS X port of PuTTY/pterm, running as a
2 | native Aqua GUI application.
3 |
4 | THIS PORT IS CURRENTLY UNFINISHED AND EXPERIMENTAL. It is _not_
5 | considered to be of release quality, even if you've found it (and
6 | are reading this) in a PuTTY release source archive. You are welcome
7 | to try using it, but don't be surprised at unexpected behaviour. I'm
8 | not kidding.
9 |
10 | In particular, I have not yet decided where OS X PuTTY should store
11 | its configuration data. Options include storing it in ~/.putty to be
12 | compatible with Unix PuTTY, storing it wherever is compatible with
13 | Mac Classic PuTTY, storing it in a natively OS X location, or
14 | sorting out the `config-locations' wishlist item and doing all
15 | three. Therefore, if you start using this port and create a whole
16 | load of saved sessions, you should not be surprised if a future
17 | version of the port decides to look somewhere completely different
18 | for the data and therefore loses them all. If that happens, don't
19 | say you weren't warned!
20 |
21 | Other ways in which the port is currently unfinished include:
22 |
23 | Missing terminal window features
24 | --------------------------------
25 |
26 | - terminal display is horribly slow
27 |
28 | - fonts aren't configurable
29 |
30 | - several features are unimplemented in the terminal display:
31 | underlining, non-solid-block cursors, double-width and
32 | double-height line attributes, bold as font rather than as
33 | colour, wide (CJK) characters, combining characters.
34 |
35 | - there's no scrollbar
36 |
37 | - terminal window resizing isn't implemented yet
38 |
39 | - proper window placement (cascading down and right from the
40 | starting position, plus remembering previous window positions per
41 | the Apple HIG) is not implemented
42 |
43 | Missing alert box features
44 | --------------------------
45 |
46 | - warn-on-close isn't implemented
47 |
48 | Missing input features
49 | ----------------------
50 |
51 | - use of Alt+numberpad to enter arbitrary numeric character codes
52 | is not yet supported
53 |
54 | - there's no Meta key yet. (I'd like to at least have the
55 | possibility of using Command rather than Option as the Meta key,
56 | since the latter is necessary to send some characters, including
57 | the rather important # on Apple UK keyboards; but trapping
58 | Command- and sending it to the window rather than the
59 | application menu requires me to make a positive effort of some
60 | sort and I haven't got round to it yet. For those Mac users who
61 | consider their Command key sacrosanct, don't worry, this option
62 | _will_ be configurable and _will_ be off by default.)
63 |
64 | - there's no specials menu
65 |
66 | - mouse activity isn't supported (neither cut-and-paste nor xterm
67 | mouse tracking)
68 |
69 | Missing terminal emulation features
70 | -----------------------------------
71 |
72 | - currently no support for server-side window management requests
73 | (i.e. escape sequences to minimise or maximise the window,
74 | request or change its position and size, change its title etc)
75 |
76 | - window title is currently fixed
77 |
78 | Other missing features
79 | ----------------------
80 |
81 | - no Event Log
82 |
83 | - no mid-session Change Settings
84 |
--------------------------------------------------------------------------------
/charset/sbcsgen.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env perl -w
2 |
3 | # This script generates sbcsdat.c (the data for all the SBCSes) from its
4 | # source form sbcs.dat.
5 |
6 | $infile = "sbcs.dat";
7 | $outfile = "sbcsdat.c";
8 |
9 | open FOO, $infile;
10 | open BAR, ">$outfile";
11 | select BAR;
12 |
13 | print "/*\n";
14 | print " * sbcsdat.c - data definitions for single-byte character sets.\n";
15 | print " *\n";
16 | print " * Generated by sbcsgen.pl from sbcs.dat.\n";
17 | print " * You should edit those files rather than editing this one.\n";
18 | print " */\n";
19 | print "\n";
20 | print "#ifndef ENUM_CHARSETS\n";
21 | print "\n";
22 | print "#include \"charset.h\"\n";
23 | print "#include \"internal.h\"\n";
24 | print "\n";
25 |
26 | my $charsetname = undef;
27 | my @vals = ();
28 |
29 | my @charsetnames = ();
30 | my @sortpriority = ();
31 |
32 | while () {
33 | chomp;
34 | if (/^charset (.*)$/) {
35 | $charsetname = $1;
36 | @vals = ();
37 | @sortpriority = map { 0 } 0..255;
38 | } elsif (/^sortpriority ([^-]*)-([^-]*) (.*)$/) {
39 | for ($i = hex $1; $i <= hex $2; $i++) {
40 | $sortpriority[$i] += $3;
41 | }
42 | } elsif (/^[0-9a-fA-FX]/) {
43 | push @vals, map { $_ eq "XXXX" ? -1 : hex $_ } split / +/, $_;
44 | if (scalar @vals > 256) {
45 | die "$infile:$.: charset $charsetname has more than 256 values\n";
46 | } elsif (scalar @vals == 256) {
47 | &outcharset($charsetname, \@vals, \@sortpriority);
48 | push @charsetnames, $charsetname;
49 | $charsetname = undef;
50 | @vals = ();
51 | @sortpriority = map { 0 } 0..255;
52 | }
53 | }
54 | }
55 |
56 | print "#else /* ENUM_CHARSETS */\n";
57 | print "\n";
58 |
59 | foreach $i (@charsetnames) {
60 | print "ENUM_CHARSET($i)\n";
61 | }
62 |
63 | print "\n";
64 | print "#endif /* ENUM_CHARSETS */\n";
65 |
66 | sub outcharset($$$) {
67 | my ($name, $vals, $sortpriority) = @_;
68 | my ($prefix, $i, @sorted);
69 |
70 | print "static const sbcs_data data_$name = {\n";
71 | print " {\n";
72 | $prefix = " ";
73 | @sorted = ();
74 | for ($i = 0; $i < 256; $i++) {
75 | if ($vals->[$i] < 0) {
76 | printf "%sERROR ", $prefix;
77 | } else {
78 | printf "%s0x%04x", $prefix, $vals->[$i];
79 | die "ooh? $i\n" unless defined $sortpriority->[$i];
80 | push @sorted, [$i, $vals->[$i], 0+$sortpriority->[$i]];
81 | }
82 | if ($i % 8 == 7) {
83 | $prefix = ",\n ";
84 | } else {
85 | $prefix = ", ";
86 | }
87 | }
88 | print "\n },\n {\n";
89 | @sorted = sort { ($a->[1] == $b->[1] ?
90 | $b->[2] <=> $a->[2] :
91 | $a->[1] <=> $b->[1]) ||
92 | $a->[0] <=> $b->[0] } @sorted;
93 | $prefix = " ";
94 | $uval = -1;
95 | for ($i = $j = 0; $i < scalar @sorted; $i++) {
96 | next if ($uval == $sorted[$i]->[1]); # low-priority alternative
97 | $uval = $sorted[$i]->[1];
98 | printf "%s0x%02x", $prefix, $sorted[$i]->[0];
99 | if ($j % 8 == 7) {
100 | $prefix = ",\n ";
101 | } else {
102 | $prefix = ", ";
103 | }
104 | $j++;
105 | }
106 | printf "\n },\n %d\n", $j;
107 | print "};\n";
108 | print "const charset_spec charset_$name = {\n" .
109 | " $name, read_sbcs, write_sbcs, &data_$name\n};\n\n";
110 | }
111 |
--------------------------------------------------------------------------------
/unix/uxsel.c:
--------------------------------------------------------------------------------
1 | /*
2 | * uxsel.c
3 | *
4 | * This module is a sort of all-purpose interchange for file
5 | * descriptors. At one end it talks to uxnet.c and pty.c and
6 | * anything else which might have one or more fds that need
7 | * select()-type things doing to them during an extended program
8 | * run; at the other end it talks to pterm.c or uxplink.c or
9 | * anything else which might have its own means of actually doing
10 | * those select()-type things.
11 | */
12 |
13 | #include
14 |
15 | #include "putty.h"
16 | #include "tree234.h"
17 |
18 | struct fd {
19 | int fd;
20 | int rwx; /* 4=except 2=write 1=read */
21 | uxsel_callback_fn callback;
22 | int id; /* for uxsel_input_remove */
23 | };
24 |
25 | static tree234 *fds;
26 |
27 | static int uxsel_fd_cmp(void *av, void *bv)
28 | {
29 | struct fd *a = (struct fd *)av;
30 | struct fd *b = (struct fd *)bv;
31 | if (a->fd < b->fd)
32 | return -1;
33 | if (a->fd > b->fd)
34 | return +1;
35 | return 0;
36 | }
37 | static int uxsel_fd_findcmp(void *av, void *bv)
38 | {
39 | int *a = (int *)av;
40 | struct fd *b = (struct fd *)bv;
41 | if (*a < b->fd)
42 | return -1;
43 | if (*a > b->fd)
44 | return +1;
45 | return 0;
46 | }
47 |
48 | void uxsel_init(void)
49 | {
50 | fds = newtree234(uxsel_fd_cmp);
51 | }
52 |
53 | /*
54 | * Here is the interface to fd-supplying modules. They supply an
55 | * fd, a set of read/write/execute states, and a callback function
56 | * for when the fd satisfies one of those states. Repeated calls to
57 | * uxsel_set on the same fd are perfectly legal and serve to change
58 | * the rwx state (typically you only want to select an fd for
59 | * writing when you actually have pending data you want to write to
60 | * it!).
61 | */
62 |
63 | void uxsel_set(int fd, int rwx, uxsel_callback_fn callback)
64 | {
65 | struct fd *newfd;
66 |
67 | uxsel_del(fd);
68 |
69 | if (rwx) {
70 | newfd = snew(struct fd);
71 | newfd->fd = fd;
72 | newfd->rwx = rwx;
73 | newfd->callback = callback;
74 | newfd->id = uxsel_input_add(fd, rwx);
75 | add234(fds, newfd);
76 | }
77 | }
78 |
79 | void uxsel_del(int fd)
80 | {
81 | struct fd *oldfd = find234(fds, &fd, uxsel_fd_findcmp);
82 | if (oldfd) {
83 | uxsel_input_remove(oldfd->id);
84 | del234(fds, oldfd);
85 | sfree(oldfd);
86 | }
87 | }
88 |
89 | /*
90 | * And here is the interface to select-functionality-supplying
91 | * modules.
92 | */
93 |
94 | int next_fd(int *state, int *rwx)
95 | {
96 | struct fd *fd;
97 | fd = index234(fds, (*state)++);
98 | if (fd) {
99 | *rwx = fd->rwx;
100 | return fd->fd;
101 | } else
102 | return -1;
103 | }
104 |
105 | int first_fd(int *state, int *rwx)
106 | {
107 | *state = 0;
108 | return next_fd(state, rwx);
109 | }
110 |
111 | int select_result(int fd, int event)
112 | {
113 | struct fd *fdstruct = find234(fds, &fd, uxsel_fd_findcmp);
114 | /*
115 | * Apparently this can sometimes be NULL. Can't see how, but I
116 | * assume it means I need to ignore the event since it's on an
117 | * fd I've stopped being interested in. Sigh.
118 | */
119 | if (fdstruct)
120 | return fdstruct->callback(fd, event);
121 | else
122 | return 1;
123 | }
124 |
--------------------------------------------------------------------------------
/macosx/osxclass.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Header file for the Objective-C parts of Mac OS X PuTTY. This
3 | * file contains the class definitions, which would cause compile
4 | * failures in the pure C modules if they appeared in osx.h.
5 | */
6 |
7 | #ifndef PUTTY_OSXCLASS_H
8 | #define PUTTY_OSXCLASS_H
9 |
10 | #include "putty.h"
11 |
12 | /*
13 | * The application controller class, defined in osxmain.m.
14 | */
15 | @interface AppController : NSObject
16 | {
17 | NSTimer *timer;
18 | }
19 | - (void)newSessionConfig:(id)sender;
20 | - (void)newTerminal:(id)sender;
21 | - (void)newSessionWithConfig:(id)cfg;
22 | - (void)setTimer:(long)next;
23 | @end
24 | extern AppController *controller;
25 |
26 | /*
27 | * The SessionWindow class, defined in osxwin.m.
28 | */
29 |
30 | struct alert_queue {
31 | struct alert_queue *next;
32 | NSAlert *alert;
33 | void (*callback)(void *, int);
34 | void *ctx;
35 | };
36 |
37 | @class SessionWindow;
38 | @class TerminalView;
39 |
40 | @interface SessionWindow : NSWindow
41 | {
42 | Terminal *term;
43 | TerminalView *termview;
44 | struct unicode_data ucsdata;
45 | void *logctx;
46 | Config cfg;
47 | void *ldisc;
48 | Backend *back;
49 | void *backhandle;
50 | int exited;
51 | /*
52 | * The following two members relate to the currently active
53 | * alert sheet, if any. They are NULL if there isn't one.
54 | */
55 | void (*alert_callback)(void *, int);
56 | void *alert_ctx;
57 | /* This queues future alerts that need to be shown. */
58 | struct alert_queue *alert_qhead, *alert_qtail;
59 | }
60 | - (id)initWithConfig:(Config)cfg;
61 | - (void)drawStartFinish:(BOOL)start;
62 | - (void)setColour:(int)n r:(float)r g:(float)g b:(float)b;
63 | - (Config *)cfg;
64 | - (void)doText:(wchar_t *)text len:(int)len x:(int)x y:(int)y
65 | attr:(unsigned long)attr lattr:(int)lattr;
66 | - (int)fromBackend:(const char *)data len:(int)len isStderr:(int)is_stderr;
67 | - (int)fromBackendUntrusted:(const char *)data len:(int)len;
68 | - (void)startAlert:(NSAlert *)alert
69 | withCallback:(void (*)(void *, int))callback andCtx:(void *)ctx;
70 | - (void)endSession:(int)clean;
71 | - (void)notifyRemoteExit;
72 | - (Terminal *)term;
73 | @end
74 |
75 | /*
76 | * The ConfigWindow class, defined in osxdlg.m.
77 | */
78 |
79 | @class ConfigWindow;
80 |
81 | @interface ConfigWindow : NSWindow
82 | {
83 | NSOutlineView *treeview;
84 | struct controlbox *ctrlbox;
85 | void *dv;
86 | Config cfg;
87 | }
88 | - (id)initWithConfig:(Config)cfg;
89 | @end
90 |
91 | /*
92 | * Functions exported by osxctrls.m. (They have to go in this
93 | * header file and not osx.h, because some of them have Cocoa class
94 | * types in their prototypes.)
95 | */
96 | #define HSPACING 12 /* needed in osxdlg.m and osxctrls.m */
97 | #define VSPACING 8
98 |
99 | void *fe_dlg_init(void *data, NSWindow *window, NSObject *target, SEL action);
100 | void fe_dlg_free(void *dv);
101 | void create_ctrls(void *dv, NSView *parent, struct controlset *s,
102 | int *minw, int *minh);
103 | int place_ctrls(void *dv, struct controlset *s, int leftx, int topy,
104 | int width); /* returns height used */
105 | void select_panel(void *dv, struct controlbox *b, const char *name);
106 |
107 | #endif /* PUTTY_OSXCLASS_H */
108 |
--------------------------------------------------------------------------------
/charset/internal.h:
--------------------------------------------------------------------------------
1 | /*
2 | * internal.h - internal header stuff for the charset library.
3 | */
4 |
5 | #ifndef charset_internal_h
6 | #define charset_internal_h
7 |
8 | /* This invariably comes in handy */
9 | #define lenof(x) ( sizeof((x)) / sizeof(*(x)) )
10 |
11 | /* This is an invalid Unicode value used to indicate an error. */
12 | #define ERROR 0xFFFFL /* Unicode value representing error */
13 |
14 | typedef struct charset_spec charset_spec;
15 | typedef struct sbcs_data sbcs_data;
16 |
17 | struct charset_spec {
18 | int charset; /* numeric identifier */
19 |
20 | /*
21 | * A function to read the character set and output Unicode
22 | * characters. The `emit' function expects to get Unicode chars
23 | * passed to it; it should be sent ERROR for any encoding error
24 | * on the input.
25 | */
26 | void (*read)(charset_spec const *charset, long int input_chr,
27 | charset_state *state,
28 | void (*emit)(void *ctx, long int output), void *emitctx);
29 | /*
30 | * A function to read Unicode characters and output in this
31 | * character set. The `emit' function expects to get byte
32 | * values passed to it; it should be sent ERROR for any
33 | * non-representable characters on the input.
34 | */
35 | void (*write)(charset_spec const *charset, long int input_chr,
36 | charset_state *state,
37 | void (*emit)(void *ctx, long int output), void *emitctx);
38 | void const *data;
39 | };
40 |
41 | /*
42 | * This is the format of `data' used by the SBCS read and write
43 | * functions; so it's the format used in all SBCS definitions.
44 | */
45 | struct sbcs_data {
46 | /*
47 | * This is a simple mapping table converting each SBCS position
48 | * to a Unicode code point. Some positions may contain ERROR,
49 | * indicating that that byte value is not defined in the SBCS
50 | * in question and its occurrence in input is an error.
51 | */
52 | unsigned long sbcs2ucs[256];
53 |
54 | /*
55 | * This lookup table is used to convert Unicode back to the
56 | * SBCS. It consists of the valid byte values in the SBCS,
57 | * sorted in order of their Unicode translation. So given a
58 | * Unicode value U, you can do a binary search on this table
59 | * using the above table as a lookup: when testing the Xth
60 | * position in this table, you branch according to whether
61 | * sbcs2ucs[ucs2sbcs[X]] is less than, greater than, or equal
62 | * to U.
63 | *
64 | * Note that since there may be fewer than 256 valid byte
65 | * values in a particular SBCS, we must supply the length of
66 | * this table as well as the contents.
67 | */
68 | unsigned char ucs2sbcs[256];
69 | int nvalid;
70 | };
71 |
72 | /*
73 | * Prototypes for internal library functions.
74 | */
75 | charset_spec const *charset_find_spec(int charset);
76 | void read_sbcs(charset_spec const *charset, long int input_chr,
77 | charset_state *state,
78 | void (*emit)(void *ctx, long int output), void *emitctx);
79 | void write_sbcs(charset_spec const *charset, long int input_chr,
80 | charset_state *state,
81 | void (*emit)(void *ctx, long int output), void *emitctx);
82 |
83 | /*
84 | * Placate compiler warning about unused parameters, of which we
85 | * expect to have some in this library.
86 | */
87 | #define UNUSEDARG(x) ( (x) = (x) )
88 |
89 | #endif /* charset_internal_h */
90 |
--------------------------------------------------------------------------------
/ssharcf.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Arcfour (RC4) implementation for PuTTY.
3 | *
4 | * Coded from Schneier.
5 | */
6 |
7 | #include
8 | #include "ssh.h"
9 |
10 | typedef struct {
11 | unsigned char i, j, s[256];
12 | } ArcfourContext;
13 |
14 | static void arcfour_block(void *handle, unsigned char *blk, int len)
15 | {
16 | ArcfourContext *ctx = (ArcfourContext *)handle;
17 | unsigned k;
18 | unsigned char tmp, i, j, *s;
19 |
20 | s = ctx->s;
21 | i = ctx->i; j = ctx->j;
22 | for (k = 0; (int)k < len; k++) {
23 | i = (i + 1) & 0xff;
24 | j = (j + s[i]) & 0xff;
25 | tmp = s[i]; s[i] = s[j]; s[j] = tmp;
26 | blk[k] ^= s[(s[i]+s[j]) & 0xff];
27 | }
28 | ctx->i = i; ctx->j = j;
29 | }
30 |
31 | static void arcfour_setkey(ArcfourContext *ctx, unsigned char const *key,
32 | unsigned keybytes)
33 | {
34 | unsigned char tmp, k[256], *s;
35 | unsigned i, j;
36 |
37 | s = ctx->s;
38 | assert(keybytes <= 256);
39 | ctx->i = ctx->j = 0;
40 | for (i = 0; i < 256; i++) {
41 | s[i] = i;
42 | k[i] = key[i % keybytes];
43 | }
44 | j = 0;
45 | for (i = 0; i < 256; i++) {
46 | j = (j + s[i] + k[i]) & 0xff;
47 | tmp = s[i]; s[i] = s[j]; s[j] = tmp;
48 | }
49 | }
50 |
51 | /* -- Interface with PuTTY -- */
52 |
53 | /*
54 | * We don't implement Arcfour in SSH-1 because it's utterly insecure in
55 | * several ways. See CERT Vulnerability Notes VU#25309, VU#665372,
56 | * and VU#565052.
57 | *
58 | * We don't implement the "arcfour" algorithm in SSH-2 because it doesn't
59 | * stir the cipher state before emitting keystream, and hence is likely
60 | * to leak data about the key.
61 | */
62 |
63 | static void *arcfour_make_context(void)
64 | {
65 | return snew(ArcfourContext);
66 | }
67 |
68 | static void arcfour_free_context(void *handle)
69 | {
70 | sfree(handle);
71 | }
72 |
73 | static void arcfour_stir(ArcfourContext *ctx)
74 | {
75 | unsigned char *junk = snewn(1536, unsigned char);
76 | memset(junk, 0, 1536);
77 | arcfour_block(ctx, junk, 1536);
78 | memset(junk, 0, 1536);
79 | sfree(junk);
80 | }
81 |
82 | static void arcfour128_key(void *handle, unsigned char *key)
83 | {
84 | ArcfourContext *ctx = (ArcfourContext *)handle;
85 | arcfour_setkey(ctx, key, 16);
86 | arcfour_stir(ctx);
87 | }
88 |
89 | static void arcfour256_key(void *handle, unsigned char *key)
90 | {
91 | ArcfourContext *ctx = (ArcfourContext *)handle;
92 | arcfour_setkey(ctx, key, 32);
93 | arcfour_stir(ctx);
94 | }
95 |
96 | static void arcfour_iv(void *handle, unsigned char *key)
97 | {
98 |
99 | }
100 |
101 | const struct ssh2_cipher ssh_arcfour128_ssh2 = {
102 | arcfour_make_context, arcfour_free_context, arcfour_iv, arcfour128_key,
103 | arcfour_block, arcfour_block,
104 | "arcfour128",
105 | 1, 128, 0, "Arcfour-128"
106 | };
107 |
108 | const struct ssh2_cipher ssh_arcfour256_ssh2 = {
109 | arcfour_make_context, arcfour_free_context, arcfour_iv, arcfour256_key,
110 | arcfour_block, arcfour_block,
111 | "arcfour256",
112 | 1, 256, 0, "Arcfour-256"
113 | };
114 |
115 | static const struct ssh2_cipher *const arcfour_list[] = {
116 | &ssh_arcfour256_ssh2,
117 | &ssh_arcfour128_ssh2,
118 | };
119 |
120 | const struct ssh2_ciphers ssh2_arcfour = {
121 | sizeof(arcfour_list) / sizeof(*arcfour_list),
122 | arcfour_list
123 | };
124 |
--------------------------------------------------------------------------------
/icons/Makefile:
--------------------------------------------------------------------------------
1 | # Makefile for the PuTTY icon suite.
2 |
3 | ICONS = putty puttycfg puttygen pscp pageant pterm ptermcfg puttyins
4 | SIZES = 16 32 48
5 |
6 | MODE = # override to -it on command line for opaque testing
7 |
8 | PNGS = $(foreach I,$(ICONS),$(foreach S,$(SIZES),$(I)-$(S).png))
9 | MONOPNGS = $(foreach I,$(ICONS),$(foreach S,$(SIZES),$(I)-$(S)-mono.png))
10 | TRUEPNGS = $(foreach I,$(ICONS),$(foreach S,$(SIZES),$(I)-$(S)-true.png))
11 |
12 | ICOS = putty.ico puttygen.ico pscp.ico pageant.ico pageants.ico puttycfg.ico \
13 | puttyins.ico
14 | CICONS = xpmputty.c xpmpucfg.c xpmpterm.c xpmptcfg.c
15 |
16 | base: icos cicons
17 |
18 | all: pngs monopngs base # truepngs currently disabled by default
19 |
20 | pngs: $(PNGS)
21 | monopngs: $(MONOPNGS)
22 | truepngs: $(TRUEPNGS)
23 |
24 | icos: $(ICOS)
25 | cicons: $(CICONS)
26 |
27 | install: icos cicons
28 | cp $(ICOS) ../windows
29 | cp $(CICONS) ../unix
30 |
31 | $(PNGS): %.png: mkicon.py
32 | ./mkicon.py $(MODE) $(join $(subst -, ,$(basename $@)),_icon) $@
33 |
34 | $(MONOPNGS): %.png: mkicon.py
35 | ./mkicon.py -2 $(MODE) $(join $(subst -, ,$(subst -mono,,$(basename $@))),_icon) $@
36 |
37 | $(TRUEPNGS): %.png: mkicon.py
38 | ./mkicon.py -T $(MODE) $(join $(subst -, ,$(subst -true,,$(basename $@))),_icon) $@
39 |
40 | putty.ico: putty-16.png putty-32.png putty-48.png \
41 | putty-16-mono.png putty-32-mono.png putty-48-mono.png
42 | ./icon.pl -4 $(filter-out %-mono.png, $^) -1 $(filter %-mono.png, $^) > $@
43 |
44 | puttycfg.ico: puttycfg-16.png puttycfg-32.png puttycfg-48.png \
45 | puttycfg-16-mono.png puttycfg-32-mono.png puttycfg-48-mono.png
46 | ./icon.pl -4 $(filter-out %-mono.png, $^) -1 $(filter %-mono.png, $^) > $@
47 |
48 | puttygen.ico: puttygen-16.png puttygen-32.png puttygen-48.png \
49 | puttygen-16-mono.png puttygen-32-mono.png puttygen-48-mono.png
50 | ./icon.pl -4 $(filter-out %-mono.png, $^) -1 $(filter %-mono.png, $^) > $@
51 |
52 | pageant.ico: pageant-16.png pageant-32.png pageant-48.png \
53 | pageant-16-mono.png pageant-32-mono.png pageant-48-mono.png
54 | ./icon.pl -4 $(filter-out %-mono.png, $^) -1 $(filter %-mono.png, $^) > $@
55 |
56 | pageants.ico: pageant-16.png pageant-16-mono.png
57 | ./icon.pl -4 $(filter-out %-mono.png, $^) -1 $(filter %-mono.png, $^) > $@
58 |
59 | pscp.ico: pscp-16.png pscp-32.png pscp-48.png \
60 | pscp-16-mono.png pscp-32-mono.png pscp-48-mono.png
61 | ./icon.pl -4 $(filter-out %-mono.png, $^) -1 $(filter %-mono.png, $^) > $@
62 |
63 | # Because the installer icon makes heavy use of brown when drawing
64 | # the cardboard box, it's worth having 8-bit versions of it in
65 | # addition to the 4- and 1-bit ones.
66 | puttyins.ico: puttyins-16.png puttyins-32.png puttyins-48.png \
67 | puttyins-16-mono.png puttyins-32-mono.png \
68 | puttyins-48-mono.png \
69 | puttyins-16-true.png puttyins-32-true.png \
70 | puttyins-48-true.png
71 | ./icon.pl -8 $(filter %-true.png, $^) \
72 | -4 $(filter-out %-true.png, $(filter-out %-mono.png, $^)) \
73 | -1 $(filter %-mono.png, $^) > $@
74 |
75 | # Icon for the website. (This isn't linked into "make all".)
76 | website.ico: putty-16.png
77 | ./icon.pl -4 $^ >$@
78 |
79 | xpmputty.c: putty-16.png putty-32.png putty-48.png
80 | ./cicon.pl main_icon $^ > $@
81 |
82 | xpmpucfg.c: puttycfg-16.png puttycfg-32.png puttycfg-48.png
83 | ./cicon.pl cfg_icon $^ > $@
84 |
85 | xpmpterm.c: pterm-16.png pterm-32.png pterm-48.png
86 | ./cicon.pl main_icon $^ > $@
87 |
88 | xpmptcfg.c: ptermcfg-16.png ptermcfg-32.png ptermcfg-48.png
89 | ./cicon.pl cfg_icon $^ > $@
90 |
91 | clean:
92 | rm -f *.png *.ico *.c
93 |
--------------------------------------------------------------------------------
/windows/winhelp.c:
--------------------------------------------------------------------------------
1 | /*
2 | * winhelp.c: centralised functions to launch Windows help files,
3 | * and to decide whether to use .HLP or .CHM help in any given
4 | * situation.
5 | */
6 |
7 | #include
8 | #include
9 | #include
10 | #include
11 |
12 | #include "putty.h"
13 |
14 | #ifndef NO_HTMLHELP
15 | #include
16 | #endif /* NO_HTMLHELP */
17 |
18 | static int requested_help;
19 | static char *help_path;
20 | static int help_has_contents;
21 | #ifndef NO_HTMLHELP
22 | DECL_WINDOWS_FUNCTION(static, HWND, HtmlHelpA, (HWND, LPCSTR, UINT, DWORD));
23 | static char *chm_path;
24 | #endif /* NO_HTMLHELP */
25 |
26 | void init_help(void)
27 | {
28 | char b[2048], *p, *q, *r;
29 | FILE *fp;
30 |
31 | GetModuleFileName(NULL, b, sizeof(b) - 1);
32 | r = b;
33 | p = strrchr(b, '\\');
34 | if (p && p >= r) r = p+1;
35 | q = strrchr(b, ':');
36 | if (q && q >= r) r = q+1;
37 | strcpy(r, PUTTY_HELP_FILE);
38 | if ( (fp = fopen(b, "r")) != NULL) {
39 | help_path = dupstr(b);
40 | fclose(fp);
41 | } else
42 | help_path = NULL;
43 | strcpy(r, PUTTY_HELP_CONTENTS);
44 | if ( (fp = fopen(b, "r")) != NULL) {
45 | help_has_contents = TRUE;
46 | fclose(fp);
47 | } else
48 | help_has_contents = FALSE;
49 |
50 | #ifndef NO_HTMLHELP
51 | strcpy(r, PUTTY_CHM_FILE);
52 | if ( (fp = fopen(b, "r")) != NULL) {
53 | chm_path = dupstr(b);
54 | fclose(fp);
55 | } else
56 | chm_path = NULL;
57 | if (chm_path) {
58 | HINSTANCE dllHH = load_system32_dll("hhctrl.ocx");
59 | GET_WINDOWS_FUNCTION(dllHH, HtmlHelpA);
60 | if (!p_HtmlHelpA) {
61 | chm_path = NULL;
62 | if (dllHH)
63 | FreeLibrary(dllHH);
64 | }
65 | }
66 | #endif /* NO_HTMLHELP */
67 | }
68 |
69 | void shutdown_help(void)
70 | {
71 | /* Nothing to do currently.
72 | * (If we were running HTML Help single-threaded, this is where we'd
73 | * call HH_UNINITIALIZE.) */
74 | }
75 |
76 | int has_help(void)
77 | {
78 | /*
79 | * FIXME: it would be nice here to disregard help_path on
80 | * platforms that didn't have WINHLP32. But that's probably
81 | * unrealistic, since even Vista will have it if the user
82 | * specifically downloads it.
83 | */
84 | return (help_path
85 | #ifndef NO_HTMLHELP
86 | || chm_path
87 | #endif /* NO_HTMLHELP */
88 | );
89 | }
90 |
91 | void launch_help(HWND hwnd, const char *topic)
92 | {
93 | if (topic) {
94 | int colonpos = strcspn(topic, ":");
95 |
96 | #ifndef NO_HTMLHELP
97 | if (chm_path) {
98 | char *fname;
99 | assert(topic[colonpos] != '\0');
100 | fname = dupprintf("%s::/%s.html>main", chm_path,
101 | topic + colonpos + 1);
102 | p_HtmlHelpA(hwnd, fname, HH_DISPLAY_TOPIC, 0);
103 | sfree(fname);
104 | } else
105 | #endif /* NO_HTMLHELP */
106 | if (help_path) {
107 | char *cmd = dupprintf("JI(`',`%.*s')", colonpos, topic);
108 | WinHelp(hwnd, help_path, HELP_COMMAND, (DWORD)cmd);
109 | sfree(cmd);
110 | }
111 | } else {
112 | #ifndef NO_HTMLHELP
113 | if (chm_path) {
114 | p_HtmlHelpA(hwnd, chm_path, HH_DISPLAY_TOPIC, 0);
115 | } else
116 | #endif /* NO_HTMLHELP */
117 | if (help_path) {
118 | WinHelp(hwnd, help_path,
119 | help_has_contents ? HELP_FINDER : HELP_CONTENTS, 0);
120 | }
121 | }
122 | requested_help = TRUE;
123 | }
124 |
125 | void quit_help(HWND hwnd)
126 | {
127 | if (requested_help) {
128 | #ifndef NO_HTMLHELP
129 | if (chm_path) {
130 | p_HtmlHelpA(NULL, NULL, HH_CLOSE_ALL, 0);
131 | } else
132 | #endif /* NO_HTMLHELP */
133 | if (help_path) {
134 | WinHelp(hwnd, help_path, HELP_QUIT, 0);
135 | }
136 | requested_help = FALSE;
137 | }
138 | }
139 |
--------------------------------------------------------------------------------
/windows/winnoise.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Noise generation for PuTTY's cryptographic random number
3 | * generator.
4 | */
5 |
6 | #include
7 |
8 | #include "putty.h"
9 | #include "ssh.h"
10 | #include "storage.h"
11 |
12 | /*
13 | * This function is called once, at PuTTY startup, and will do some
14 | * seriously silly things like listing directories and getting disk
15 | * free space and a process snapshot.
16 | */
17 |
18 | void noise_get_heavy(void (*func) (void *, int))
19 | {
20 | HANDLE srch;
21 | WIN32_FIND_DATA finddata;
22 | DWORD pid;
23 | char winpath[MAX_PATH + 3];
24 |
25 | GetWindowsDirectory(winpath, sizeof(winpath));
26 | strcat(winpath, "\\*");
27 | srch = FindFirstFile(winpath, &finddata);
28 | if (srch != INVALID_HANDLE_VALUE) {
29 | do {
30 | func(&finddata, sizeof(finddata));
31 | } while (FindNextFile(srch, &finddata));
32 | FindClose(srch);
33 | }
34 |
35 | pid = GetCurrentProcessId();
36 | func(&pid, sizeof(pid));
37 |
38 | read_random_seed(func);
39 | /* Update the seed immediately, in case another instance uses it. */
40 | random_save_seed();
41 | }
42 |
43 | void random_save_seed(void)
44 | {
45 | int len;
46 | void *data;
47 |
48 | if (random_active) {
49 | random_get_savedata(&data, &len);
50 | write_random_seed(data, len);
51 | sfree(data);
52 | }
53 | }
54 |
55 | /*
56 | * This function is called every time the random pool needs
57 | * stirring, and will acquire the system time in all available
58 | * forms.
59 | */
60 | void noise_get_light(void (*func) (void *, int))
61 | {
62 | SYSTEMTIME systime;
63 | DWORD adjust[2];
64 | BOOL rubbish;
65 |
66 | GetSystemTime(&systime);
67 | func(&systime, sizeof(systime));
68 |
69 | GetSystemTimeAdjustment(&adjust[0], &adjust[1], &rubbish);
70 | func(&adjust, sizeof(adjust));
71 | }
72 |
73 | /*
74 | * This function is called on a timer, and it will monitor
75 | * frequently changing quantities such as the state of physical and
76 | * virtual memory, the state of the process's message queue, which
77 | * window is in the foreground, which owns the clipboard, etc.
78 | */
79 | void noise_regular(void)
80 | {
81 | HWND w;
82 | DWORD z;
83 | POINT pt;
84 | MEMORYSTATUS memstat;
85 | FILETIME times[4];
86 |
87 | w = GetForegroundWindow();
88 | random_add_noise(&w, sizeof(w));
89 | w = GetCapture();
90 | random_add_noise(&w, sizeof(w));
91 | w = GetClipboardOwner();
92 | random_add_noise(&w, sizeof(w));
93 | z = GetQueueStatus(QS_ALLEVENTS);
94 | random_add_noise(&z, sizeof(z));
95 |
96 | GetCursorPos(&pt);
97 | random_add_noise(&pt, sizeof(pt));
98 |
99 | GlobalMemoryStatus(&memstat);
100 | random_add_noise(&memstat, sizeof(memstat));
101 |
102 | GetThreadTimes(GetCurrentThread(), times, times + 1, times + 2,
103 | times + 3);
104 | random_add_noise(×, sizeof(times));
105 | GetProcessTimes(GetCurrentProcess(), times, times + 1, times + 2,
106 | times + 3);
107 | random_add_noise(×, sizeof(times));
108 | }
109 |
110 | /*
111 | * This function is called on every keypress or mouse move, and
112 | * will add the current Windows time and performance monitor
113 | * counter to the noise pool. It gets the scan code or mouse
114 | * position passed in.
115 | */
116 | void noise_ultralight(unsigned long data)
117 | {
118 | DWORD wintime;
119 | LARGE_INTEGER perftime;
120 |
121 | random_add_noise(&data, sizeof(DWORD));
122 |
123 | wintime = GetTickCount();
124 | random_add_noise(&wintime, sizeof(DWORD));
125 |
126 | if (QueryPerformanceCounter(&perftime))
127 | random_add_noise(&perftime, sizeof(perftime));
128 | }
129 |
--------------------------------------------------------------------------------
/unix/uxnoise.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Noise generation for PuTTY's cryptographic random number
3 | * generator.
4 | */
5 |
6 | #include
7 | #include
8 | #include
9 |
10 | #include
11 | #include
12 | #include
13 | #include
14 |
15 | #include "putty.h"
16 | #include "ssh.h"
17 | #include "storage.h"
18 |
19 | static int read_dev_urandom(char *buf, int len)
20 | {
21 | int fd;
22 | int ngot, ret;
23 |
24 | fd = open("/dev/urandom", O_RDONLY);
25 | if (fd < 0)
26 | return 0;
27 |
28 | ngot = 0;
29 | while (ngot < len) {
30 | ret = read(fd, buf+ngot, len-ngot);
31 | if (ret < 0) {
32 | close(fd);
33 | return 0;
34 | }
35 | ngot += ret;
36 | }
37 |
38 | close(fd);
39 |
40 | return 1;
41 | }
42 |
43 | /*
44 | * This function is called once, at PuTTY startup. It will do some
45 | * slightly silly things such as fetching an entire process listing
46 | * and scanning /tmp, load the saved random seed from disk, and
47 | * also read 32 bytes out of /dev/urandom.
48 | */
49 |
50 | void noise_get_heavy(void (*func) (void *, int))
51 | {
52 | char buf[512];
53 | FILE *fp;
54 | int ret;
55 | int got_dev_urandom = 0;
56 |
57 | if (read_dev_urandom(buf, 32)) {
58 | got_dev_urandom = 1;
59 | func(buf, 32);
60 | }
61 |
62 | fp = popen("ps -axu 2>/dev/null", "r");
63 | if (fp) {
64 | while ( (ret = fread(buf, 1, sizeof(buf), fp)) > 0)
65 | func(buf, ret);
66 | pclose(fp);
67 | } else if (!got_dev_urandom) {
68 | fprintf(stderr, "popen: %s\n"
69 | "Unable to access fallback entropy source\n", strerror(errno));
70 | exit(1);
71 | }
72 |
73 | fp = popen("ls -al /tmp 2>/dev/null", "r");
74 | if (fp) {
75 | while ( (ret = fread(buf, 1, sizeof(buf), fp)) > 0)
76 | func(buf, ret);
77 | pclose(fp);
78 | } else if (!got_dev_urandom) {
79 | fprintf(stderr, "popen: %s\n"
80 | "Unable to access fallback entropy source\n", strerror(errno));
81 | exit(1);
82 | }
83 |
84 | read_random_seed(func);
85 | random_save_seed();
86 | }
87 |
88 | void random_save_seed(void)
89 | {
90 | int len;
91 | void *data;
92 |
93 | if (random_active) {
94 | random_get_savedata(&data, &len);
95 | write_random_seed(data, len);
96 | sfree(data);
97 | }
98 | }
99 |
100 | /*
101 | * This function is called every time the random pool needs
102 | * stirring, and will acquire the system time.
103 | */
104 | void noise_get_light(void (*func) (void *, int))
105 | {
106 | struct timeval tv;
107 | gettimeofday(&tv, NULL);
108 | func(&tv, sizeof(tv));
109 | }
110 |
111 | /*
112 | * This function is called on a timer, and grabs as much changeable
113 | * system data as it can quickly get its hands on.
114 | */
115 | void noise_regular(void)
116 | {
117 | int fd;
118 | int ret;
119 | char buf[512];
120 | struct rusage rusage;
121 |
122 | if ((fd = open("/proc/meminfo", O_RDONLY)) >= 0) {
123 | while ( (ret = read(fd, buf, sizeof(buf))) > 0)
124 | random_add_noise(buf, ret);
125 | close(fd);
126 | }
127 | if ((fd = open("/proc/stat", O_RDONLY)) >= 0) {
128 | while ( (ret = read(fd, buf, sizeof(buf))) > 0)
129 | random_add_noise(buf, ret);
130 | close(fd);
131 | }
132 | getrusage(RUSAGE_SELF, &rusage);
133 | random_add_noise(&rusage, sizeof(rusage));
134 | }
135 |
136 | /*
137 | * This function is called on every keypress or mouse move, and
138 | * will add the current time to the noise pool. It gets the scan
139 | * code or mouse position passed in, and adds that too.
140 | */
141 | void noise_ultralight(unsigned long data)
142 | {
143 | struct timeval tv;
144 | gettimeofday(&tv, NULL);
145 | random_add_noise(&tv, sizeof(tv));
146 | random_add_noise(&data, sizeof(data));
147 | }
148 |
--------------------------------------------------------------------------------
/proxy.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Network proxy abstraction in PuTTY
3 | *
4 | * A proxy layer, if necessary, wedges itself between the
5 | * network code and the higher level backend.
6 | *
7 | * Supported proxies: HTTP CONNECT, generic telnet, SOCKS 4 & 5
8 | */
9 |
10 | #ifndef PUTTY_PROXY_H
11 | #define PUTTY_PROXY_H
12 |
13 | #define PROXY_ERROR_GENERAL 8000
14 | #define PROXY_ERROR_UNEXPECTED 8001
15 |
16 | typedef struct Socket_proxy_tag * Proxy_Socket;
17 |
18 | struct Socket_proxy_tag {
19 | const struct socket_function_table *fn;
20 | /* the above variable absolutely *must* be the first in this structure */
21 |
22 | char * error;
23 |
24 | Socket sub_socket;
25 | Plug plug;
26 | SockAddr remote_addr;
27 | int remote_port;
28 |
29 | bufchain pending_output_data;
30 | bufchain pending_oob_output_data;
31 | int pending_flush;
32 | bufchain pending_input_data;
33 |
34 | #define PROXY_STATE_NEW -1
35 | #define PROXY_STATE_ACTIVE 0
36 |
37 | int state; /* proxy states greater than 0 are implementation
38 | * dependent, but represent various stages/states
39 | * of the initialization/setup/negotiation with the
40 | * proxy server.
41 | */
42 | int freeze; /* should we freeze the underlying socket when
43 | * we are done with the proxy negotiation? this
44 | * simply caches the value of sk_set_frozen calls.
45 | */
46 |
47 | #define PROXY_CHANGE_NEW -1
48 | #define PROXY_CHANGE_CLOSING 0
49 | #define PROXY_CHANGE_SENT 1
50 | #define PROXY_CHANGE_RECEIVE 2
51 | #define PROXY_CHANGE_ACCEPTING 3
52 |
53 | /* something has changed (a call from the sub socket
54 | * layer into our Proxy Plug layer, or we were just
55 | * created, etc), so the proxy layer needs to handle
56 | * this change (the type of which is the second argument)
57 | * and further the proxy negotiation process.
58 | */
59 |
60 | int (*negotiate) (Proxy_Socket /* this */, int /* change type */);
61 |
62 | /* current arguments of plug handlers
63 | * (for use by proxy's negotiate function)
64 | */
65 |
66 | /* closing */
67 | const char *closing_error_msg;
68 | int closing_error_code;
69 | int closing_calling_back;
70 |
71 | /* receive */
72 | int receive_urgent;
73 | char *receive_data;
74 | int receive_len;
75 |
76 | /* sent */
77 | int sent_bufsize;
78 |
79 | /* accepting */
80 | OSSocket accepting_sock;
81 |
82 | /* configuration, used to look up proxy settings */
83 | Config cfg;
84 |
85 | /* CHAP transient data */
86 | int chap_num_attributes;
87 | int chap_num_attributes_processed;
88 | int chap_current_attribute;
89 | int chap_current_datalen;
90 | };
91 |
92 | typedef struct Plug_proxy_tag * Proxy_Plug;
93 |
94 | struct Plug_proxy_tag {
95 | const struct plug_function_table *fn;
96 | /* the above variable absolutely *must* be the first in this structure */
97 |
98 | Proxy_Socket proxy_socket;
99 |
100 | };
101 |
102 | extern void proxy_activate (Proxy_Socket);
103 |
104 | extern int proxy_http_negotiate (Proxy_Socket, int);
105 | extern int proxy_telnet_negotiate (Proxy_Socket, int);
106 | extern int proxy_socks4_negotiate (Proxy_Socket, int);
107 | extern int proxy_socks5_negotiate (Proxy_Socket, int);
108 |
109 | /*
110 | * This may be reused by local-command proxies on individual
111 | * platforms.
112 | */
113 | char *format_telnet_command(SockAddr addr, int port, const Config *cfg);
114 |
115 | /*
116 | * These are implemented in cproxy.c or nocproxy.c, depending on
117 | * whether encrypted proxy authentication is available.
118 | */
119 | extern void proxy_socks5_offerencryptedauth(char *command, int *len);
120 | extern int proxy_socks5_handlechap (Proxy_Socket p);
121 | extern int proxy_socks5_selectchap(Proxy_Socket p);
122 |
123 | #endif
124 |
--------------------------------------------------------------------------------
/windows/puttygen.rc:
--------------------------------------------------------------------------------
1 | /*
2 | * Windows resources for PuTTYgen.
3 | */
4 |
5 | #include "rcstuff.h"
6 |
7 | #define APPNAME "PuTTYgen"
8 | #define APPDESC "PuTTY SSH key generation utility"
9 |
10 | 200 ICON "puttygen.ico"
11 |
12 | 201 DIALOG DISCARDABLE 0, 0, 318, 270
13 | STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
14 | CAPTION "PuTTY Key Generator"
15 | FONT 8, "MS Shell Dlg"
16 | BEGIN
17 | END
18 |
19 | 210 DIALOG DISCARDABLE 0, 0, 140, 60
20 | STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
21 | CAPTION "PuTTYgen: Enter Passphrase"
22 | FONT 8, "MS Shell Dlg"
23 | BEGIN
24 | CTEXT "Enter passphrase for key", 100, 10, 6, 120, 8
25 | CTEXT "", 101, 10, 16, 120, 8
26 | EDITTEXT 102, 10, 26, 120, 12, ES_PASSWORD | ES_AUTOHSCROLL
27 | DEFPUSHBUTTON "O&K", IDOK, 20, 42, 40, 14
28 | PUSHBUTTON "&Cancel", IDCANCEL, 80, 42, 40, 14
29 | END
30 |
31 | /* Accelerators used: cl */
32 | 213 DIALOG DISCARDABLE 140, 40, 136, 70
33 | STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
34 | CAPTION "About PuTTYgen"
35 | FONT 8, "MS Shell Dlg"
36 | BEGIN
37 | DEFPUSHBUTTON "&Close", IDOK, 82, 52, 48, 14
38 | PUSHBUTTON "View &Licence", 101, 6, 52, 70, 14
39 | CTEXT "PuTTYgen", 102, 10, 6, 120, 8
40 | CTEXT "", 100, 10, 16, 120, 16
41 | CTEXT "\251 1997-2011 Simon Tatham. All rights reserved.",
42 | 103, 10, 34, 120, 16
43 | END
44 |
45 | /* No accelerators used */
46 | 214 DIALOG DISCARDABLE 50, 50, 226, 263
47 | STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
48 | CAPTION "PuTTY Licence"
49 | FONT 8, "MS Shell Dlg"
50 | BEGIN
51 | DEFPUSHBUTTON "OK", IDOK, 98, 243, 44, 14
52 |
53 | LTEXT "Copyright \251 1997-2011 Simon Tatham", 1000, 10, 10, 206, 8
54 |
55 | LTEXT "Portions copyright Robert de Bath, Joris van Rantwijk, Delian", 1001, 10, 26, 206, 8
56 | LTEXT "Delchev, Andreas Schultz, Jeroen Massar, Wez Furlong, Nicolas", 1002, 10, 34, 206, 8
57 | LTEXT "Barry, Justin Bradford, Ben Harris, Malcolm Smith, Ahmad Khalifa,", 1003, 10, 42, 206, 8
58 | LTEXT "Markus Kuhn, Colin Watson, and CORE SDI S.A.", 1004, 10, 50, 206, 8
59 |
60 | LTEXT "Permission is hereby granted, free of charge, to any person", 1005, 10, 66, 206, 8
61 | LTEXT "obtaining a copy of this software and associated documentation", 1006, 10, 74, 206, 8
62 | LTEXT "files (the ""Software""), to deal in the Software without restriction,", 1007, 10, 82, 206, 8
63 | LTEXT "including without limitation the rights to use, copy, modify, merge,", 1008, 10, 90, 206, 8
64 | LTEXT "publish, distribute, sublicense, and/or sell copies of the Software,", 1009, 10, 98, 206, 8
65 | LTEXT "and to permit persons to whom the Software is furnished to do so,", 1010, 10, 106, 206, 8
66 | LTEXT "subject to the following conditions:", 1011, 10, 114, 206, 8
67 |
68 | LTEXT "The above copyright notice and this permission notice shall be", 1012, 10, 130, 206, 8
69 | LTEXT "included in all copies or substantial portions of the Software.", 1013, 10, 138, 206, 8
70 |
71 | LTEXT "THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT", 1014, 10, 154, 206, 8
72 | LTEXT "WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,", 1015, 10, 162, 206, 8
73 | LTEXT "INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF", 1016, 10, 170, 206, 8
74 | LTEXT "MERCHANTABILITY, FITNESS FOR A PARTICULAR", 1017, 10, 178, 206, 8
75 | LTEXT "PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE", 1018, 10, 186, 206, 8
76 | LTEXT "COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES", 1019, 10, 194, 206, 8
77 | LTEXT "OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,", 1020, 10, 202, 206, 8
78 | LTEXT "TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN", 1021, 10, 210, 206, 8
79 | LTEXT "CONNECTION WITH THE SOFTWARE OR THE USE OR", 1022, 10, 218, 206, 8
80 | LTEXT "OTHER DEALINGS IN THE SOFTWARE.", 1023, 10, 226, 206, 8
81 |
82 | END
83 |
84 | #include "version.rc2"
85 |
86 | #ifndef NO_MANIFESTS
87 | 1 RT_MANIFEST "puttygen.mft"
88 | #endif /* NO_MANIFESTS */
89 |
--------------------------------------------------------------------------------
/sshrsag.c:
--------------------------------------------------------------------------------
1 | /*
2 | * RSA key generation.
3 | */
4 |
5 | #include "ssh.h"
6 |
7 | #define RSA_EXPONENT 37 /* we like this prime */
8 |
9 | int rsa_generate(struct RSAKey *key, int bits, progfn_t pfn,
10 | void *pfnparam)
11 | {
12 | Bignum pm1, qm1, phi_n;
13 |
14 | /*
15 | * Set up the phase limits for the progress report. We do this
16 | * by passing minus the phase number.
17 | *
18 | * For prime generation: our initial filter finds things
19 | * coprime to everything below 2^16. Computing the product of
20 | * (p-1)/p for all prime p below 2^16 gives about 20.33; so
21 | * among B-bit integers, one in every 20.33 will get through
22 | * the initial filter to be a candidate prime.
23 | *
24 | * Meanwhile, we are searching for primes in the region of 2^B;
25 | * since pi(x) ~ x/log(x), when x is in the region of 2^B, the
26 | * prime density will be d/dx pi(x) ~ 1/log(B), i.e. about
27 | * 1/0.6931B. So the chance of any given candidate being prime
28 | * is 20.33/0.6931B, which is roughly 29.34 divided by B.
29 | *
30 | * So now we have this probability P, we're looking at an
31 | * exponential distribution with parameter P: we will manage in
32 | * one attempt with probability P, in two with probability
33 | * P(1-P), in three with probability P(1-P)^2, etc. The
34 | * probability that we have still not managed to find a prime
35 | * after N attempts is (1-P)^N.
36 | *
37 | * We therefore inform the progress indicator of the number B
38 | * (29.34/B), so that it knows how much to increment by each
39 | * time. We do this in 16-bit fixed point, so 29.34 becomes
40 | * 0x1D.57C4.
41 | */
42 | pfn(pfnparam, PROGFN_PHASE_EXTENT, 1, 0x10000);
43 | pfn(pfnparam, PROGFN_EXP_PHASE, 1, -0x1D57C4 / (bits / 2));
44 | pfn(pfnparam, PROGFN_PHASE_EXTENT, 2, 0x10000);
45 | pfn(pfnparam, PROGFN_EXP_PHASE, 2, -0x1D57C4 / (bits - bits / 2));
46 | pfn(pfnparam, PROGFN_PHASE_EXTENT, 3, 0x4000);
47 | pfn(pfnparam, PROGFN_LIN_PHASE, 3, 5);
48 | pfn(pfnparam, PROGFN_READY, 0, 0);
49 |
50 | /*
51 | * We don't generate e; we just use a standard one always.
52 | */
53 | key->exponent = bignum_from_long(RSA_EXPONENT);
54 |
55 | /*
56 | * Generate p and q: primes with combined length `bits', not
57 | * congruent to 1 modulo e. (Strictly speaking, we wanted (p-1)
58 | * and e to be coprime, and (q-1) and e to be coprime, but in
59 | * general that's slightly more fiddly to arrange. By choosing
60 | * a prime e, we can simplify the criterion.)
61 | */
62 | key->p = primegen(bits / 2, RSA_EXPONENT, 1, NULL,
63 | 1, pfn, pfnparam);
64 | key->q = primegen(bits - bits / 2, RSA_EXPONENT, 1, NULL,
65 | 2, pfn, pfnparam);
66 |
67 | /*
68 | * Ensure p > q, by swapping them if not.
69 | */
70 | if (bignum_cmp(key->p, key->q) < 0) {
71 | Bignum t = key->p;
72 | key->p = key->q;
73 | key->q = t;
74 | }
75 |
76 | /*
77 | * Now we have p, q and e. All we need to do now is work out
78 | * the other helpful quantities: n=pq, d=e^-1 mod (p-1)(q-1),
79 | * and (q^-1 mod p).
80 | */
81 | pfn(pfnparam, PROGFN_PROGRESS, 3, 1);
82 | key->modulus = bigmul(key->p, key->q);
83 | pfn(pfnparam, PROGFN_PROGRESS, 3, 2);
84 | pm1 = copybn(key->p);
85 | decbn(pm1);
86 | qm1 = copybn(key->q);
87 | decbn(qm1);
88 | phi_n = bigmul(pm1, qm1);
89 | pfn(pfnparam, PROGFN_PROGRESS, 3, 3);
90 | freebn(pm1);
91 | freebn(qm1);
92 | key->private_exponent = modinv(key->exponent, phi_n);
93 | pfn(pfnparam, PROGFN_PROGRESS, 3, 4);
94 | key->iqmp = modinv(key->q, key->p);
95 | pfn(pfnparam, PROGFN_PROGRESS, 3, 5);
96 |
97 | /*
98 | * Clean up temporary numbers.
99 | */
100 | freebn(phi_n);
101 |
102 | return 1;
103 | }
104 |
--------------------------------------------------------------------------------
/unix/uxputty.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Unix PuTTY main program.
3 | */
4 |
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 |
12 | #include "putty.h"
13 | #include "storage.h"
14 |
15 | /*
16 | * Stubs to avoid uxpty.c needing to be linked in.
17 | */
18 | const int use_pty_argv = FALSE;
19 | char **pty_argv; /* never used */
20 |
21 | /*
22 | * Clean up and exit.
23 | */
24 | void cleanup_exit(int code)
25 | {
26 | /*
27 | * Clean up.
28 | */
29 | sk_cleanup();
30 | random_save_seed();
31 | exit(code);
32 | }
33 |
34 | Backend *select_backend(Config *cfg)
35 | {
36 | Backend *back = backend_from_proto(cfg->protocol);
37 | assert(back != NULL);
38 | return back;
39 | }
40 |
41 | int cfgbox(Config *cfg)
42 | {
43 | char *title = dupcat(appname, " Configuration", NULL);
44 | int ret = do_config_box(title, cfg, 0, 0);
45 | sfree(title);
46 | return ret;
47 | }
48 |
49 | static int got_host = 0;
50 |
51 | const int use_event_log = 1, new_session = 1, saved_sessions = 1;
52 |
53 | int process_nonoption_arg(char *arg, Config *cfg, int *allow_launch)
54 | {
55 | char *p, *q = arg;
56 |
57 | if (got_host) {
58 | /*
59 | * If we already have a host name, treat this argument as a
60 | * port number. NB we have to treat this as a saved -P
61 | * argument, so that it will be deferred until it's a good
62 | * moment to run it.
63 | */
64 | int ret = cmdline_process_param("-P", arg, 1, cfg);
65 | assert(ret == 2);
66 | } else if (!strncmp(q, "telnet:", 7)) {
67 | /*
68 | * If the hostname starts with "telnet:",
69 | * set the protocol to Telnet and process
70 | * the string as a Telnet URL.
71 | */
72 | char c;
73 |
74 | q += 7;
75 | if (q[0] == '/' && q[1] == '/')
76 | q += 2;
77 | cfg->protocol = PROT_TELNET;
78 | p = q;
79 | while (*p && *p != ':' && *p != '/')
80 | p++;
81 | c = *p;
82 | if (*p)
83 | *p++ = '\0';
84 | if (c == ':')
85 | cfg->port = atoi(p);
86 | else
87 | cfg->port = -1;
88 | strncpy(cfg->host, q, sizeof(cfg->host) - 1);
89 | cfg->host[sizeof(cfg->host) - 1] = '\0';
90 | got_host = 1;
91 | } else {
92 | /*
93 | * Otherwise, treat this argument as a host name.
94 | */
95 | p = arg;
96 | while (*p && !isspace((unsigned char)*p))
97 | p++;
98 | if (*p)
99 | *p++ = '\0';
100 | strncpy(cfg->host, q, sizeof(cfg->host) - 1);
101 | cfg->host[sizeof(cfg->host) - 1] = '\0';
102 | got_host = 1;
103 | }
104 | if (got_host)
105 | *allow_launch = TRUE;
106 | return 1;
107 | }
108 |
109 | char *make_default_wintitle(char *hostname)
110 | {
111 | return dupcat(hostname, " - ", appname, NULL);
112 | }
113 |
114 | /*
115 | * X11-forwarding-related things suitable for Gtk app.
116 | */
117 |
118 | char *platform_get_x_display(void) {
119 | const char *display;
120 | /* Try to take account of --display and what have you. */
121 | if (!(display = gdk_get_display()))
122 | /* fall back to traditional method */
123 | display = getenv("DISPLAY");
124 | return dupstr(display);
125 | }
126 |
127 | int main(int argc, char **argv)
128 | {
129 | extern int pt_main(int argc, char **argv);
130 | sk_init();
131 | flags = FLAG_VERBOSE | FLAG_INTERACTIVE;
132 | default_protocol = be_default_protocol;
133 | /* Find the appropriate default port. */
134 | {
135 | Backend *b = backend_from_proto(default_protocol);
136 | default_port = 0; /* illegal */
137 | if (b)
138 | default_port = b->default_port;
139 | }
140 | return pt_main(argc, argv);
141 | }
142 |
--------------------------------------------------------------------------------
/doc/intro.but:
--------------------------------------------------------------------------------
1 | \define{versionidintro} \versionid $Id$
2 |
3 | \C{intro} Introduction to PuTTY
4 |
5 | PuTTY is a free SSH, Telnet and Rlogin client for 32-bit Windows
6 | systems.
7 |
8 | \H{you-what} What are SSH, Telnet and Rlogin?
9 |
10 | If you already know what SSH, Telnet and Rlogin are, you can safely
11 | skip on to the next section.
12 |
13 | SSH, Telnet and Rlogin are three ways of doing the same thing:
14 | logging in to a multi-user computer from another computer, over a
15 | network.
16 |
17 | Multi-user operating systems, such as Unix and VMS, usually present
18 | a \i{command-line interface} to the user, much like the \q{\i{Command
19 | Prompt}} or \q{\i{MS-DOS Prompt}} in Windows. The system prints a
20 | prompt, and you type commands which the system will obey.
21 |
22 | Using this type of interface, there is no need for you to be sitting
23 | at the same machine you are typing commands to. The commands, and
24 | responses, can be sent over a network, so you can sit at one
25 | computer and give commands to another one, or even to more than one.
26 |
27 | SSH, Telnet and Rlogin are \i\e{network protocols} that allow you to
28 | do this. On the computer you sit at, you run a \i\e{client}, which
29 | makes a network connection to the other computer (the \i\e{server}).
30 | The network connection carries your keystrokes and commands from the
31 | client to the server, and carries the server's responses back to
32 | you.
33 |
34 | These protocols can also be used for other types of keyboard-based
35 | interactive session. In particular, there are a lot of bulletin
36 | boards, \i{talker systems} and \i{MUDs} (Multi-User Dungeons) which support
37 | access using Telnet. There are even a few that support SSH.
38 |
39 | You might want to use SSH, Telnet or Rlogin if:
40 |
41 | \b you have an account on a Unix or VMS system which you want to be
42 | able to access from somewhere else
43 |
44 | \b your Internet Service Provider provides you with a login account
45 | on a \i{web server}. (This might also be known as a \i\e{shell account}.
46 | A \e{shell} is the program that runs on the server and interprets
47 | your commands for you.)
48 |
49 | \b you want to use a \i{bulletin board system}, talker or MUD which can
50 | be accessed using Telnet.
51 |
52 | You probably do \e{not} want to use SSH, Telnet or Rlogin if:
53 |
54 | \b you only use Windows. Windows computers have their own
55 | ways of networking between themselves, and unless you are doing
56 | something fairly unusual, you will not need to use any of these
57 | remote login protocols.
58 |
59 | \H{which-one} How do SSH, Telnet and Rlogin differ?
60 |
61 | This list summarises some of the \i{differences between SSH, Telnet
62 | and Rlogin}.
63 |
64 | \b SSH (which stands for \q{\i{secure shell}}) is a recently designed,
65 | high-security protocol. It uses strong cryptography to protect your
66 | connection against eavesdropping, hijacking and other attacks. Telnet
67 | and Rlogin are both older protocols offering minimal security.
68 |
69 | \b SSH and Rlogin both allow you to \I{passwordless login}log in to the
70 | server without having to type a password. (Rlogin's method of doing this is
71 | insecure, and can allow an attacker to access your account on the
72 | server. SSH's method is much more secure, and typically breaking the
73 | security requires the attacker to have gained access to your actual
74 | client machine.)
75 |
76 | \b SSH allows you to connect to the server and automatically send a
77 | command, so that the server will run that command and then
78 | disconnect. So you can use it in automated processing.
79 |
80 | The Internet is a hostile environment and security is everybody's
81 | responsibility. If you are connecting across the open Internet, then
82 | we recommend you use SSH. If the server you want to connect to
83 | doesn't support SSH, it might be worth trying to persuade the
84 | administrator to install it.
85 |
86 | If your client and server are both behind the same (good) firewall,
87 | it is more likely to be safe to use Telnet or Rlogin, but we still
88 | recommend you use SSH.
89 |
--------------------------------------------------------------------------------
/unix/uxmisc.c:
--------------------------------------------------------------------------------
1 | /*
2 | * PuTTY miscellaneous Unix stuff
3 | */
4 |
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 | #include
13 |
14 | #include "putty.h"
15 |
16 | long tickcount_offset = 0;
17 |
18 | unsigned long getticks(void)
19 | {
20 | struct timeval tv;
21 | gettimeofday(&tv, NULL);
22 | /*
23 | * We want to use milliseconds rather than microseconds,
24 | * because we need a decent number of them to fit into a 32-bit
25 | * word so it can be used for keepalives.
26 | */
27 | return tv.tv_sec * 1000 + tv.tv_usec / 1000 + tickcount_offset;
28 | }
29 |
30 | Filename filename_from_str(const char *str)
31 | {
32 | Filename ret;
33 | strncpy(ret.path, str, sizeof(ret.path));
34 | ret.path[sizeof(ret.path)-1] = '\0';
35 | return ret;
36 | }
37 |
38 | const char *filename_to_str(const Filename *fn)
39 | {
40 | return fn->path;
41 | }
42 |
43 | int filename_equal(Filename f1, Filename f2)
44 | {
45 | return !strcmp(f1.path, f2.path);
46 | }
47 |
48 | int filename_is_null(Filename fn)
49 | {
50 | return !*fn.path;
51 | }
52 |
53 | #ifdef DEBUG
54 | static FILE *debug_fp = NULL;
55 |
56 | void dputs(char *buf)
57 | {
58 | if (!debug_fp) {
59 | debug_fp = fopen("debug.log", "w");
60 | }
61 |
62 | write(1, buf, strlen(buf));
63 |
64 | fputs(buf, debug_fp);
65 | fflush(debug_fp);
66 | }
67 | #endif
68 |
69 | char *get_username(void)
70 | {
71 | struct passwd *p;
72 | uid_t uid = getuid();
73 | char *user, *ret = NULL;
74 |
75 | /*
76 | * First, find who we think we are using getlogin. If this
77 | * agrees with our uid, we'll go along with it. This should
78 | * allow sharing of uids between several login names whilst
79 | * coping correctly with people who have su'ed.
80 | */
81 | user = getlogin();
82 | setpwent();
83 | if (user)
84 | p = getpwnam(user);
85 | else
86 | p = NULL;
87 | if (p && p->pw_uid == uid) {
88 | /*
89 | * The result of getlogin() really does correspond to
90 | * our uid. Fine.
91 | */
92 | ret = user;
93 | } else {
94 | /*
95 | * If that didn't work, for whatever reason, we'll do
96 | * the simpler version: look up our uid in the password
97 | * file and map it straight to a name.
98 | */
99 | p = getpwuid(uid);
100 | if (!p)
101 | return NULL;
102 | ret = p->pw_name;
103 | }
104 | endpwent();
105 |
106 | return dupstr(ret);
107 | }
108 |
109 | /*
110 | * Display the fingerprints of the PGP Master Keys to the user.
111 | * (This is here rather than in uxcons because it's appropriate even for
112 | * Unix GUI apps.)
113 | */
114 | void pgp_fingerprints(void)
115 | {
116 | fputs("These are the fingerprints of the PuTTY PGP Master Keys. They can\n"
117 | "be used to establish a trust path from this executable to another\n"
118 | "one. See the manual for more information.\n"
119 | "(Note: these fingerprints have nothing to do with SSH!)\n"
120 | "\n"
121 | "PuTTY Master Key (RSA), 1024-bit:\n"
122 | " " PGP_RSA_MASTER_KEY_FP "\n"
123 | "PuTTY Master Key (DSA), 1024-bit:\n"
124 | " " PGP_DSA_MASTER_KEY_FP "\n", stdout);
125 | }
126 |
127 | /*
128 | * Set FD_CLOEXEC on a file descriptor
129 | */
130 | int cloexec(int fd) {
131 | int fdflags;
132 |
133 | fdflags = fcntl(fd, F_GETFD);
134 | if (fdflags == -1) return -1;
135 | return fcntl(fd, F_SETFD, fdflags | FD_CLOEXEC);
136 | }
137 |
138 | FILE *f_open(struct Filename filename, char const *mode, int is_private)
139 | {
140 | if (!is_private) {
141 | return fopen(filename.path, mode);
142 | } else {
143 | int fd;
144 | assert(mode[0] == 'w'); /* is_private is meaningless for read,
145 | and tricky for append */
146 | fd = open(filename.path, O_WRONLY | O_CREAT | O_TRUNC,
147 | 0700);
148 | if (fd < 0)
149 | return NULL;
150 | return fdopen(fd, mode);
151 | }
152 | }
153 |
--------------------------------------------------------------------------------
/misc.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Header for misc.c.
3 | */
4 |
5 | #ifndef PUTTY_MISC_H
6 | #define PUTTY_MISC_H
7 |
8 | #include "puttymem.h"
9 |
10 | #include /* for FILE * */
11 | #include /* for va_list */
12 | #include /* for struct tm */
13 |
14 | #ifndef FALSE
15 | #define FALSE 0
16 | #endif
17 | #ifndef TRUE
18 | #define TRUE 1
19 | #endif
20 |
21 | typedef struct Filename Filename;
22 | typedef struct FontSpec FontSpec;
23 |
24 | unsigned long parse_blocksize(const char *bs);
25 | char ctrlparse(char *s, char **next);
26 |
27 | char *dupstr(const char *s);
28 | char *dupcat(const char *s1, ...);
29 | char *dupprintf(const char *fmt, ...);
30 | char *dupvprintf(const char *fmt, va_list ap);
31 |
32 | char *fgetline(FILE *fp);
33 |
34 | void base64_encode_atom(unsigned char *data, int n, char *out);
35 |
36 | struct bufchain_granule;
37 | typedef struct bufchain_tag {
38 | struct bufchain_granule *head, *tail;
39 | int buffersize; /* current amount of buffered data */
40 | } bufchain;
41 |
42 | void bufchain_init(bufchain *ch);
43 | void bufchain_clear(bufchain *ch);
44 | int bufchain_size(bufchain *ch);
45 | void bufchain_add(bufchain *ch, const void *data, int len);
46 | void bufchain_prefix(bufchain *ch, void **data, int *len);
47 | void bufchain_consume(bufchain *ch, int len);
48 | void bufchain_fetch(bufchain *ch, void *data, int len);
49 |
50 | struct tm ltime(void);
51 |
52 | /*
53 | * Debugging functions.
54 | *
55 | * Output goes to debug.log
56 | *
57 | * debug(()) (note the double brackets) is like printf().
58 | *
59 | * dmemdump() and dmemdumpl() both do memory dumps. The difference
60 | * is that dmemdumpl() is more suited for when the memory address is
61 | * important (say because you'll be recording pointer values later
62 | * on). dmemdump() is more concise.
63 | */
64 |
65 | #ifdef DEBUG
66 | void debug_printf(char *fmt, ...);
67 | void debug_memdump(void *buf, int len, int L);
68 | #define debug(x) (debug_printf x)
69 | #define dmemdump(buf,len) debug_memdump (buf, len, 0);
70 | #define dmemdumpl(buf,len) debug_memdump (buf, len, 1);
71 | #else
72 | #define debug(x)
73 | #define dmemdump(buf,len)
74 | #define dmemdumpl(buf,len)
75 | #endif
76 |
77 | #ifndef lenof
78 | #define lenof(x) ( (sizeof((x))) / (sizeof(*(x))))
79 | #endif
80 |
81 | #ifndef min
82 | #define min(x,y) ( (x) < (y) ? (x) : (y) )
83 | #endif
84 | #ifndef max
85 | #define max(x,y) ( (x) > (y) ? (x) : (y) )
86 | #endif
87 |
88 | #define GET_32BIT_LSB_FIRST(cp) \
89 | (((unsigned long)(unsigned char)(cp)[0]) | \
90 | ((unsigned long)(unsigned char)(cp)[1] << 8) | \
91 | ((unsigned long)(unsigned char)(cp)[2] << 16) | \
92 | ((unsigned long)(unsigned char)(cp)[3] << 24))
93 |
94 | #define PUT_32BIT_LSB_FIRST(cp, value) ( \
95 | (cp)[0] = (unsigned char)(value), \
96 | (cp)[1] = (unsigned char)((value) >> 8), \
97 | (cp)[2] = (unsigned char)((value) >> 16), \
98 | (cp)[3] = (unsigned char)((value) >> 24) )
99 |
100 | #define GET_16BIT_LSB_FIRST(cp) \
101 | (((unsigned long)(unsigned char)(cp)[0]) | \
102 | ((unsigned long)(unsigned char)(cp)[1] << 8))
103 |
104 | #define PUT_16BIT_LSB_FIRST(cp, value) ( \
105 | (cp)[0] = (unsigned char)(value), \
106 | (cp)[1] = (unsigned char)((value) >> 8) )
107 |
108 | #define GET_32BIT_MSB_FIRST(cp) \
109 | (((unsigned long)(unsigned char)(cp)[0] << 24) | \
110 | ((unsigned long)(unsigned char)(cp)[1] << 16) | \
111 | ((unsigned long)(unsigned char)(cp)[2] << 8) | \
112 | ((unsigned long)(unsigned char)(cp)[3]))
113 |
114 | #define GET_32BIT(cp) GET_32BIT_MSB_FIRST(cp)
115 |
116 | #define PUT_32BIT_MSB_FIRST(cp, value) ( \
117 | (cp)[0] = (unsigned char)((value) >> 24), \
118 | (cp)[1] = (unsigned char)((value) >> 16), \
119 | (cp)[2] = (unsigned char)((value) >> 8), \
120 | (cp)[3] = (unsigned char)(value) )
121 |
122 | #define PUT_32BIT(cp, value) PUT_32BIT_MSB_FIRST(cp, value)
123 |
124 | #define GET_16BIT_MSB_FIRST(cp) \
125 | (((unsigned long)(unsigned char)(cp)[0] << 8) | \
126 | ((unsigned long)(unsigned char)(cp)[1]))
127 |
128 | #define PUT_16BIT_MSB_FIRST(cp, value) ( \
129 | (cp)[0] = (unsigned char)((value) >> 8), \
130 | (cp)[1] = (unsigned char)(value) )
131 |
132 | #endif
133 |
--------------------------------------------------------------------------------
/windows/pageant.rc:
--------------------------------------------------------------------------------
1 | /*
2 | * Windows resources for Pageant.
3 | */
4 |
5 | #include "rcstuff.h"
6 |
7 | #define APPNAME "Pageant"
8 | #define APPDESC "PuTTY SSH authentication agent"
9 |
10 | 200 ICON "pageant.ico"
11 | 201 ICON "pageants.ico"
12 |
13 | 210 DIALOG DISCARDABLE 0, 0, 140, 60
14 | STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
15 | CAPTION "Pageant: Enter Passphrase"
16 | FONT 8, "MS Shell Dlg"
17 | BEGIN
18 | CTEXT "Enter passphrase for key", 100, 10, 6, 120, 8
19 | CTEXT "", 101, 10, 16, 120, 8
20 | EDITTEXT 102, 10, 26, 120, 12, ES_PASSWORD | ES_AUTOHSCROLL
21 | DEFPUSHBUTTON "O&K", IDOK, 20, 42, 40, 14
22 | PUSHBUTTON "&Cancel", IDCANCEL, 80, 42, 40, 14
23 | END
24 |
25 | 211 DIALOG DISCARDABLE 0, 0, 330, 200
26 | STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
27 | CAPTION "Pageant Key List"
28 | FONT 8, "MS Shell Dlg"
29 | BEGIN
30 | LISTBOX 100, 10, 10, 310, 155,
31 | LBS_EXTENDEDSEL | LBS_HASSTRINGS | LBS_USETABSTOPS | WS_VSCROLL | WS_TABSTOP
32 | PUSHBUTTON "&Add Key", 101, 75, 162, 60, 14
33 | PUSHBUTTON "&Remove Key", 102, 195, 162, 60, 14
34 | PUSHBUTTON "&Help", 103, 10, 182, 50, 14
35 | DEFPUSHBUTTON "&Close", IDOK, 270, 182, 50, 14
36 | END
37 |
38 | /* Accelerators used: cl */
39 | 213 DIALOG DISCARDABLE 140, 40, 136, 70
40 | STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
41 | CAPTION "About Pageant"
42 | FONT 8, "MS Shell Dlg"
43 | BEGIN
44 | DEFPUSHBUTTON "&Close", IDOK, 82, 52, 48, 14
45 | PUSHBUTTON "View &Licence", 101, 6, 52, 70, 14
46 | CTEXT "Pageant", 102, 10, 6, 120, 8
47 | CTEXT "", 100, 10, 16, 120, 16
48 | CTEXT "\251 1997-2011 Simon Tatham. All rights reserved.",
49 | 103, 10, 34, 120, 16
50 | END
51 |
52 | /* No accelerators used */
53 | 214 DIALOG DISCARDABLE 50, 50, 226, 263
54 | STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
55 | CAPTION "PuTTY Licence"
56 | FONT 8, "MS Shell Dlg"
57 | BEGIN
58 | DEFPUSHBUTTON "OK", IDOK, 98, 243, 44, 14
59 |
60 | LTEXT "Copyright \251 1997-2011 Simon Tatham", 1000, 10, 10, 206, 8
61 |
62 | LTEXT "Portions copyright Robert de Bath, Joris van Rantwijk, Delian", 1001, 10, 26, 206, 8
63 | LTEXT "Delchev, Andreas Schultz, Jeroen Massar, Wez Furlong, Nicolas", 1002, 10, 34, 206, 8
64 | LTEXT "Barry, Justin Bradford, Ben Harris, Malcolm Smith, Ahmad Khalifa,", 1003, 10, 42, 206, 8
65 | LTEXT "Markus Kuhn, Colin Watson, and CORE SDI S.A.", 1004, 10, 50, 206, 8
66 |
67 | LTEXT "Permission is hereby granted, free of charge, to any person", 1005, 10, 66, 206, 8
68 | LTEXT "obtaining a copy of this software and associated documentation", 1006, 10, 74, 206, 8
69 | LTEXT "files (the ""Software""), to deal in the Software without restriction,", 1007, 10, 82, 206, 8
70 | LTEXT "including without limitation the rights to use, copy, modify, merge,", 1008, 10, 90, 206, 8
71 | LTEXT "publish, distribute, sublicense, and/or sell copies of the Software,", 1009, 10, 98, 206, 8
72 | LTEXT "and to permit persons to whom the Software is furnished to do so,", 1010, 10, 106, 206, 8
73 | LTEXT "subject to the following conditions:", 1011, 10, 114, 206, 8
74 |
75 | LTEXT "The above copyright notice and this permission notice shall be", 1012, 10, 130, 206, 8
76 | LTEXT "included in all copies or substantial portions of the Software.", 1013, 10, 138, 206, 8
77 |
78 | LTEXT "THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT", 1014, 10, 154, 206, 8
79 | LTEXT "WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,", 1015, 10, 162, 206, 8
80 | LTEXT "INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF", 1016, 10, 170, 206, 8
81 | LTEXT "MERCHANTABILITY, FITNESS FOR A PARTICULAR", 1017, 10, 178, 206, 8
82 | LTEXT "PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE", 1018, 10, 186, 206, 8
83 | LTEXT "COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES", 1019, 10, 194, 206, 8
84 | LTEXT "OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,", 1020, 10, 202, 206, 8
85 | LTEXT "TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN", 1021, 10, 210, 206, 8
86 | LTEXT "CONNECTION WITH THE SOFTWARE OR THE USE OR", 1022, 10, 218, 206, 8
87 | LTEXT "OTHER DEALINGS IN THE SOFTWARE.", 1023, 10, 226, 206, 8
88 |
89 | END
90 |
91 | #include "version.rc2"
92 |
93 | #ifndef NO_MANIFESTS
94 | 1 RT_MANIFEST "pageant.mft"
95 | #endif /* NO_MANIFESTS */
96 |
--------------------------------------------------------------------------------
/int64.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Handling of the int64 and uint64 types. Done in 32-bit integers,
3 | * for (pre-C99) portability. Hopefully once C99 becomes widespread
4 | * we can kiss this lot goodbye...
5 | */
6 |
7 | #include
8 | #include
9 |
10 | #include "int64.h"
11 |
12 | uint64 uint64_div10(uint64 x, int *remainder)
13 | {
14 | uint64 y;
15 | unsigned int rem, r2;
16 | y.hi = x.hi / 10;
17 | y.lo = x.lo / 10;
18 | rem = x.lo % 10;
19 | /*
20 | * Now we have to add in the remainder left over from x.hi.
21 | */
22 | r2 = x.hi % 10;
23 | y.lo += r2 * 429496729;
24 | rem += r2 * 6;
25 | y.lo += rem / 10;
26 | rem %= 10;
27 |
28 | if (remainder)
29 | *remainder = rem;
30 | return y;
31 | }
32 |
33 | void uint64_decimal(uint64 x, char *buffer)
34 | {
35 | char buf[20];
36 | int start = 20;
37 | int d;
38 |
39 | do {
40 | x = uint64_div10(x, &d);
41 | assert(start > 0);
42 | buf[--start] = d + '0';
43 | } while (x.hi || x.lo);
44 |
45 | memcpy(buffer, buf + start, sizeof(buf) - start);
46 | buffer[sizeof(buf) - start] = '\0';
47 | }
48 |
49 | uint64 uint64_make(unsigned long hi, unsigned long lo)
50 | {
51 | uint64 y;
52 | y.hi = hi & 0xFFFFFFFFU;
53 | y.lo = lo & 0xFFFFFFFFU;
54 | return y;
55 | }
56 |
57 | uint64 uint64_add(uint64 x, uint64 y)
58 | {
59 | x.lo = (x.lo + y.lo) & 0xFFFFFFFFU;
60 | x.hi += y.hi + (x.lo < y.lo ? 1 : 0);
61 | return x;
62 | }
63 |
64 | uint64 uint64_add32(uint64 x, unsigned long y)
65 | {
66 | uint64 yy;
67 | yy.hi = 0;
68 | yy.lo = y;
69 | return uint64_add(x, yy);
70 | }
71 |
72 | int uint64_compare(uint64 x, uint64 y)
73 | {
74 | if (x.hi != y.hi)
75 | return x.hi < y.hi ? -1 : +1;
76 | if (x.lo != y.lo)
77 | return x.lo < y.lo ? -1 : +1;
78 | return 0;
79 | }
80 |
81 | uint64 uint64_subtract(uint64 x, uint64 y)
82 | {
83 | x.lo = (x.lo - y.lo) & 0xFFFFFFFFU;
84 | x.hi = (x.hi - y.hi - (x.lo > (y.lo ^ 0xFFFFFFFFU) ? 1 : 0)) & 0xFFFFFFFFU;
85 | return x;
86 | }
87 |
88 | double uint64_to_double(uint64 x)
89 | {
90 | return (4294967296.0 * x.hi) + (double)x.lo;
91 | }
92 |
93 | uint64 uint64_shift_right(uint64 x, int shift)
94 | {
95 | if (shift < 32) {
96 | x.lo >>= shift;
97 | x.lo |= (x.hi << (32-shift)) & 0xFFFFFFFFU;
98 | x.hi >>= shift;
99 | } else {
100 | x.lo = x.hi >> (shift-32);
101 | x.hi = 0;
102 | }
103 | return x;
104 | }
105 |
106 | uint64 uint64_shift_left(uint64 x, int shift)
107 | {
108 | if (shift < 32) {
109 | x.hi = (x.hi << shift) & 0xFFFFFFFFU;
110 | x.hi |= (x.lo >> (32-shift));
111 | x.lo = (x.lo << shift) & 0xFFFFFFFFU;
112 | } else {
113 | x.hi = (x.lo << (shift-32)) & 0xFFFFFFFFU;
114 | x.lo = 0;
115 | }
116 | return x;
117 | }
118 |
119 | uint64 uint64_from_decimal(char *str)
120 | {
121 | uint64 ret;
122 | ret.hi = ret.lo = 0;
123 | while (*str >= '0' && *str <= '9') {
124 | ret = uint64_add(uint64_shift_left(ret, 3),
125 | uint64_shift_left(ret, 1));
126 | ret = uint64_add32(ret, *str - '0');
127 | str++;
128 | }
129 | return ret;
130 | }
131 |
132 | #ifdef TESTMODE
133 |
134 | #include
135 |
136 | int main(void)
137 | {
138 | uint64 x, y, z;
139 | char buf[80];
140 |
141 | x = uint64_make(0x3456789AUL, 0xDEF01234UL);
142 | printf("%08lx.%08lx\n", x.hi, x.lo);
143 | uint64_decimal(x, buf);
144 | printf("%s\n", buf);
145 |
146 | y = uint64_add32(x, 0xFFFFFFFFU);
147 | printf("%08lx.%08lx\n", y.hi, y.lo);
148 | uint64_decimal(y, buf);
149 | printf("%s\n", buf);
150 |
151 | z = uint64_subtract(y, x);
152 | printf("%08lx.%08lx\n", z.hi, z.lo);
153 | uint64_decimal(z, buf);
154 | printf("%s\n", buf);
155 |
156 | z = uint64_subtract(x, y);
157 | printf("%08lx.%08lx\n", z.hi, z.lo);
158 | uint64_decimal(z, buf);
159 | printf("%s\n", buf);
160 |
161 | y = uint64_shift_right(x, 4);
162 | printf("%08lx.%08lx\n", y.hi, y.lo);
163 |
164 | y = uint64_shift_right(x, 36);
165 | printf("%08lx.%08lx\n", y.hi, y.lo);
166 |
167 | y = uint64_shift_left(x, 4);
168 | printf("%08lx.%08lx\n", x.hi, x.lo);
169 |
170 | y = uint64_shift_left(x, 36);
171 | printf("%08lx.%08lx\n", x.hi, x.lo);
172 |
173 | return 0;
174 | }
175 | #endif
176 |
--------------------------------------------------------------------------------
/unix/uxagentc.c:
--------------------------------------------------------------------------------
1 | /*
2 | * SSH agent client code.
3 | */
4 |
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 |
13 | #include "putty.h"
14 | #include "misc.h"
15 | #include "tree234.h"
16 | #include "puttymem.h"
17 |
18 | int agent_exists(void)
19 | {
20 | if (getenv("SSH_AUTH_SOCK") != NULL)
21 | return TRUE;
22 | return FALSE;
23 | }
24 |
25 | static tree234 *agent_connections;
26 | struct agent_connection {
27 | int fd;
28 | char *retbuf;
29 | char sizebuf[4];
30 | int retsize, retlen;
31 | void (*callback)(void *, void *, int);
32 | void *callback_ctx;
33 | };
34 | static int agent_conncmp(void *av, void *bv)
35 | {
36 | struct agent_connection *a = (struct agent_connection *) av;
37 | struct agent_connection *b = (struct agent_connection *) bv;
38 | if (a->fd < b->fd)
39 | return -1;
40 | if (a->fd > b->fd)
41 | return +1;
42 | return 0;
43 | }
44 | static int agent_connfind(void *av, void *bv)
45 | {
46 | int afd = *(int *) av;
47 | struct agent_connection *b = (struct agent_connection *) bv;
48 | if (afd < b->fd)
49 | return -1;
50 | if (afd > b->fd)
51 | return +1;
52 | return 0;
53 | }
54 |
55 | static int agent_select_result(int fd, int event)
56 | {
57 | int ret;
58 | struct agent_connection *conn;
59 |
60 | assert(event == 1); /* not selecting for anything but R */
61 |
62 | conn = find234(agent_connections, &fd, agent_connfind);
63 | if (!conn) {
64 | uxsel_del(fd);
65 | return 1;
66 | }
67 |
68 | ret = read(fd, conn->retbuf+conn->retlen, conn->retsize-conn->retlen);
69 | if (ret <= 0) {
70 | if (conn->retbuf != conn->sizebuf) sfree(conn->retbuf);
71 | conn->retbuf = NULL;
72 | conn->retlen = 0;
73 | goto done;
74 | }
75 | conn->retlen += ret;
76 | if (conn->retsize == 4 && conn->retlen == 4) {
77 | conn->retsize = GET_32BIT(conn->retbuf);
78 | if (conn->retsize <= 0) {
79 | conn->retbuf = NULL;
80 | conn->retlen = 0;
81 | goto done;
82 | }
83 | conn->retsize += 4;
84 | assert(conn->retbuf == conn->sizebuf);
85 | conn->retbuf = snewn(conn->retsize, char);
86 | memcpy(conn->retbuf, conn->sizebuf, 4);
87 | }
88 |
89 | if (conn->retlen < conn->retsize)
90 | return 0; /* more data to come */
91 |
92 | done:
93 | /*
94 | * We have now completed the agent query. Do the callback, and
95 | * clean up. (Of course we don't free retbuf, since ownership
96 | * of that passes to the callback.)
97 | */
98 | conn->callback(conn->callback_ctx, conn->retbuf, conn->retlen);
99 | uxsel_del(fd);
100 | close(fd);
101 | del234(agent_connections, conn);
102 | sfree(conn);
103 | return 0;
104 | }
105 |
106 | int agent_query(void *in, int inlen, void **out, int *outlen,
107 | void (*callback)(void *, void *, int), void *callback_ctx)
108 | {
109 | char *name;
110 | int sock;
111 | struct sockaddr_un addr;
112 | int done;
113 | struct agent_connection *conn;
114 |
115 | name = getenv("SSH_AUTH_SOCK");
116 | if (!name)
117 | goto failure;
118 |
119 | sock = socket(PF_UNIX, SOCK_STREAM, 0);
120 | if (sock < 0) {
121 | perror("socket(PF_UNIX)");
122 | exit(1);
123 | }
124 |
125 | cloexec(sock);
126 |
127 | addr.sun_family = AF_UNIX;
128 | strncpy(addr.sun_path, name, sizeof(addr.sun_path));
129 | if (connect(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
130 | close(sock);
131 | goto failure;
132 | }
133 |
134 | for (done = 0; done < inlen ;) {
135 | int ret = write(sock, (char *)in + done, inlen - done);
136 | if (ret <= 0) {
137 | close(sock);
138 | goto failure;
139 | }
140 | done += ret;
141 | }
142 |
143 | if (!agent_connections)
144 | agent_connections = newtree234(agent_conncmp);
145 |
146 | conn = snew(struct agent_connection);
147 | conn->fd = sock;
148 | conn->retbuf = conn->sizebuf;
149 | conn->retsize = 4;
150 | conn->retlen = 0;
151 | conn->callback = callback;
152 | conn->callback_ctx = callback_ctx;
153 | add234(agent_connections, conn);
154 |
155 | uxsel_set(sock, 1, agent_select_result);
156 | return 0;
157 |
158 | failure:
159 | *out = NULL;
160 | *outlen = 0;
161 | return 1;
162 | }
163 |
--------------------------------------------------------------------------------
/charset/localenc.c:
--------------------------------------------------------------------------------
1 | /*
2 | * local.c - translate our internal character set codes to and from
3 | * our own set of plausibly legible character-set names. Also
4 | * provides a canonical name for each encoding (useful for software
5 | * announcing what character set it will be using), and a set of
6 | * enumeration functions which return a list of supported
7 | * encodings one by one.
8 | *
9 | * charset_from_localenc will attempt all other text translations
10 | * as well as this table, to maximise the number of different ways
11 | * you can select a supported charset.
12 | */
13 |
14 | #include
15 | #include "charset.h"
16 | #include "internal.h"
17 |
18 | static const struct {
19 | const char *name;
20 | int charset;
21 | int return_in_enum; /* enumeration misses some charsets */
22 | } localencs[] = {
23 | { "", CS_NONE, 0 },
24 | { "ISO-8859-1", CS_ISO8859_1, 1 },
25 | { "ISO-8859-1 with X11 line drawing", CS_ISO8859_1_X11, 0 },
26 | { "ISO-8859-2", CS_ISO8859_2, 1 },
27 | { "ISO-8859-3", CS_ISO8859_3, 1 },
28 | { "ISO-8859-4", CS_ISO8859_4, 1 },
29 | { "ISO-8859-5", CS_ISO8859_5, 1 },
30 | { "ISO-8859-6", CS_ISO8859_6, 1 },
31 | { "ISO-8859-7", CS_ISO8859_7, 1 },
32 | { "ISO-8859-8", CS_ISO8859_8, 1 },
33 | { "ISO-8859-9", CS_ISO8859_9, 1 },
34 | { "ISO-8859-10", CS_ISO8859_10, 1 },
35 | { "ISO-8859-11", CS_ISO8859_11, 1 },
36 | { "ISO-8859-13", CS_ISO8859_13, 1 },
37 | { "ISO-8859-14", CS_ISO8859_14, 1 },
38 | { "ISO-8859-15", CS_ISO8859_15, 1 },
39 | { "ISO-8859-16", CS_ISO8859_16, 1 },
40 | { "CP437", CS_CP437, 1 },
41 | { "CP850", CS_CP850, 1 },
42 | { "CP866", CS_CP866, 1 },
43 | { "CP1250", CS_CP1250, 1 },
44 | { "CP1251", CS_CP1251, 1 },
45 | { "CP1252", CS_CP1252, 1 },
46 | { "CP1253", CS_CP1253, 1 },
47 | { "CP1254", CS_CP1254, 1 },
48 | { "CP1255", CS_CP1255, 1 },
49 | { "CP1256", CS_CP1256, 1 },
50 | { "CP1257", CS_CP1257, 1 },
51 | { "CP1258", CS_CP1258, 1 },
52 | { "KOI8-R", CS_KOI8_R, 1 },
53 | { "KOI8-U", CS_KOI8_U, 1 },
54 | { "Mac Roman", CS_MAC_ROMAN, 1 },
55 | { "Mac Turkish", CS_MAC_TURKISH, 1 },
56 | { "Mac Croatian", CS_MAC_CROATIAN, 1 },
57 | { "Mac Iceland", CS_MAC_ICELAND, 1 },
58 | { "Mac Romanian", CS_MAC_ROMANIAN, 1 },
59 | { "Mac Greek", CS_MAC_GREEK, 1 },
60 | { "Mac Cyrillic", CS_MAC_CYRILLIC, 1 },
61 | { "Mac Thai", CS_MAC_THAI, 1 },
62 | { "Mac Centeuro", CS_MAC_CENTEURO, 1 },
63 | { "Mac Symbol", CS_MAC_SYMBOL, 1 },
64 | { "Mac Dingbats", CS_MAC_DINGBATS, 1 },
65 | { "Mac Roman (old)", CS_MAC_ROMAN_OLD, 0 },
66 | { "Mac Croatian (old)", CS_MAC_CROATIAN_OLD, 0 },
67 | { "Mac Iceland (old)", CS_MAC_ICELAND_OLD, 0 },
68 | { "Mac Romanian (old)", CS_MAC_ROMANIAN_OLD, 0 },
69 | { "Mac Greek (old)", CS_MAC_GREEK_OLD, 0 },
70 | { "Mac Cyrillic (old)", CS_MAC_CYRILLIC_OLD, 0 },
71 | { "Mac Ukraine", CS_MAC_UKRAINE, 1 },
72 | { "Mac VT100", CS_MAC_VT100, 1 },
73 | { "Mac VT100 (old)", CS_MAC_VT100_OLD, 0 },
74 | { "VISCII", CS_VISCII, 1 },
75 | { "HP ROMAN8", CS_HP_ROMAN8, 1 },
76 | { "DEC MCS", CS_DEC_MCS, 1 },
77 | { "UTF-8", CS_UTF8, 1 },
78 | };
79 |
80 | const char *charset_to_localenc(int charset)
81 | {
82 | int i;
83 |
84 | for (i = 0; i < (int)lenof(localencs); i++)
85 | if (charset == localencs[i].charset)
86 | return localencs[i].name;
87 |
88 | return NULL; /* not found */
89 | }
90 |
91 | int charset_from_localenc(const char *name)
92 | {
93 | int i;
94 |
95 | if ( (i = charset_from_mimeenc(name)) != CS_NONE)
96 | return i;
97 | if ( (i = charset_from_xenc(name)) != CS_NONE)
98 | return i;
99 |
100 | for (i = 0; i < (int)lenof(localencs); i++) {
101 | const char *p, *q;
102 | p = name;
103 | q = localencs[i].name;
104 | while (*p || *q) {
105 | if (tolower((unsigned char)*p) != tolower((unsigned char)*q))
106 | break;
107 | p++; q++;
108 | }
109 | if (!*p && !*q)
110 | return localencs[i].charset;
111 | }
112 |
113 | return CS_NONE; /* not found */
114 | }
115 |
116 | int charset_localenc_nth(int n)
117 | {
118 | int i;
119 |
120 | for (i = 0; i < (int)lenof(localencs); i++)
121 | if (localencs[i].return_in_enum && !n--)
122 | return localencs[i].charset;
123 |
124 | return CS_NONE; /* end of list */
125 | }
126 |
--------------------------------------------------------------------------------
/windows/version.rc2:
--------------------------------------------------------------------------------
1 | /*
2 | * Standard Windows version information.
3 | * (For inclusion in other .rc files with appropriate macro definitions.)
4 | * FIXME: This file is called '.rc2' rather than '.rc' to avoid MSVC trying
5 | * to compile it on its own when using the project files. Nicer solutions
6 | * welcome.
7 | */
8 |
9 | /*
10 | * Binary versions in Windows are major.minor.build.revision. Each
11 | * component is 16-bit.
12 | * Here we have:
13 | * major.minor
14 | * PuTTY version number (e.g. 0.58). (We've made a policy decision
15 | * that these will be numeric from now on.)
16 | * Present in releases and snapshots (for the sake of monotonicity
17 | * in version numbers).
18 | * build
19 | * In releases, always 0.
20 | * In snapshots, nearest Subversion revision. (It shouldn't be
21 | * assumed that only one binary will have a given build number, of
22 | * course.)
23 | * revision
24 | * Reserved; always 0.
25 | *
26 | * Examples of these version numbers:
27 | * Release: 0.58.0.0 (but 0.58 didn't have a VERSIONINFO resource)
28 | * Snapshot: 0.58.6356.0 (between 0.58 and the next release)
29 | * Local: 0.0.0.0
30 | */
31 |
32 | /*
33 | * Mechanics of version naming/numbering.
34 | * (This is a ripoff of ../version.c.)
35 | */
36 |
37 | #define STR1(x) #x
38 | #define STR(x) STR1(x)
39 |
40 | /* We keep this around even for snapshots, for monotonicity of version
41 | * numbering. It needs to be kept up to date. NB _comma_-separated. */
42 | #define BASE_VERSION 0,60
43 |
44 | #if defined SNAPSHOT
45 |
46 | /* Make SVN_REV mandatory for snapshots, to avoid issuing binary
47 | * version numbers that look like full releases. */
48 | #ifndef SVN_REV
49 | #error SVN_REV not defined/nonzero for snapshot build
50 | #endif
51 |
52 | #define VERSION_TEXT "Development snapshot " STR(SNAPSHOT) ":r" STR(SVN_REV)
53 | #ifdef MODIFIED
54 | #define BINARY_VERSION 0,0,0,0
55 | #else
56 | #define BINARY_VERSION BASE_VERSION,SVN_REV,0
57 | #endif
58 |
59 | #elif defined RELEASE
60 |
61 | #define VERSION_TEXT "Release " STR(RELEASE)
62 | #define BINARY_VERSION BASE_VERSION,0,0
63 |
64 | #elif defined SVN_REV
65 |
66 | #define VERSION_TEXT "Custom build r" STR(SVN_REV)
67 | #ifdef MODIFIED
68 | #define BINARY_VERSION 0,0,0,0
69 | #else
70 | #define BINARY_VERSION BASE_VERSION,SVN_REV,0
71 | #endif
72 |
73 | #else
74 |
75 | /* We can't reliably get the same date and time as version.c, so
76 | * we won't bother trying. */
77 | #define VERSION_TEXT "Unidentified build"
78 | #define BINARY_VERSION 0,0,0,0
79 |
80 | #endif
81 |
82 | /*
83 | * The actual VERSIONINFO resource.
84 | */
85 | VS_VERSION_INFO VERSIONINFO
86 | /* (None of this "fixed" info appears to be trivially user-visible on
87 | * Win98SE. The binary version does show up on Win2K.) */
88 | FILEVERSION BINARY_VERSION
89 | PRODUCTVERSION BINARY_VERSION /* version of whole suite */
90 | FILEFLAGSMASK VS_FF_DEBUG | VS_FF_PRERELEASE | VS_FF_PRIVATEBUILD
91 | FILEFLAGS 0x0L
92 | #if defined DEBUG
93 | | VS_FF_DEBUG
94 | #endif
95 | #if defined SNAPSHOT
96 | | VS_FF_PRERELEASE
97 | #elif !defined RELEASE
98 | | VS_FF_PRIVATEBUILD
99 | #endif
100 | FILEOS VOS__WINDOWS32
101 | FILETYPE VFT_APP
102 | FILESUBTYPE 0x0L /* n/a for VFT_APP */
103 | BEGIN
104 | /* (On Win98SE and Win2K, we can see most of this on the Version tab
105 | * in the file properties in Explorer.) */
106 | BLOCK "StringFileInfo"
107 | BEGIN
108 | /* "lang-charset" LLLLCCCC = (UK English, Unicode) */
109 | BLOCK "080904B0"
110 | BEGIN
111 | VALUE "CompanyName", "Simon Tatham" /* required :/ */
112 | VALUE "ProductName", "PuTTY suite"
113 | VALUE "FileDescription", APPDESC
114 | VALUE "InternalName", APPNAME
115 | VALUE "OriginalFilename", APPNAME
116 | VALUE "FileVersion", VERSION_TEXT
117 | VALUE "ProductVersion", VERSION_TEXT
118 | VALUE "LegalCopyright", "Copyright \251 1997-2011 Simon Tatham."
119 | #if (!defined SNAPSHOT) && (!defined RELEASE)
120 | /* Only if VS_FF_PRIVATEBUILD. */
121 | VALUE "PrivateBuild", VERSION_TEXT /* NBI */
122 | #endif
123 | END
124 | END
125 | BLOCK "VarFileInfo"
126 | BEGIN
127 | /* Once again -- same meanings -- apparently necessary */
128 | VALUE "Translation", 0x809, 1200
129 | END
130 | END
131 |
132 | #undef VERSION_TEXT
133 | #undef BASE_VERSION
134 | #undef BINARY_VERSION
135 |
--------------------------------------------------------------------------------
/storage.h:
--------------------------------------------------------------------------------
1 | /*
2 | * storage.h: interface defining functions for storage and recovery
3 | * of PuTTY's persistent data.
4 | */
5 |
6 | #ifndef PUTTY_STORAGE_H
7 | #define PUTTY_STORAGE_H
8 |
9 | /* ----------------------------------------------------------------------
10 | * Functions to save and restore PuTTY sessions. Note that this is
11 | * only the low-level code to do the reading and writing. The
12 | * higher-level code that translates a Config structure into a set
13 | * of (key,value) pairs is elsewhere, since it doesn't (mostly)
14 | * change between platforms.
15 | */
16 |
17 | /*
18 | * Write a saved session. The caller is expected to call
19 | * open_setting_w() to get a `void *' handle, then pass that to a
20 | * number of calls to write_setting_s() and write_setting_i(), and
21 | * then close it using close_settings_w(). At the end of this call
22 | * sequence the settings should have been written to the PuTTY
23 | * persistent storage area.
24 | *
25 | * A given key will be written at most once while saving a session.
26 | * Keys may be up to 255 characters long. String values have no length
27 | * limit.
28 | *
29 | * Any returned error message must be freed after use.
30 | */
31 | void *open_settings_w(const char *sessionname, char **errmsg);
32 | void write_setting_s(void *handle, const char *key, const char *value);
33 | void write_setting_i(void *handle, const char *key, int value);
34 | void write_setting_filename(void *handle, const char *key, Filename value);
35 | void write_setting_fontspec(void *handle, const char *key, FontSpec font);
36 | void close_settings_w(void *handle);
37 |
38 | /*
39 | * Read a saved session. The caller is expected to call
40 | * open_setting_r() to get a `void *' handle, then pass that to a
41 | * number of calls to read_setting_s() and read_setting_i(), and
42 | * then close it using close_settings_r().
43 | *
44 | * read_setting_s() writes into the provided buffer and returns a
45 | * pointer to the same buffer.
46 | *
47 | * If a particular string setting is not present in the session,
48 | * read_setting_s() can return NULL, in which case the caller
49 | * should invent a sensible default. If an integer setting is not
50 | * present, read_setting_i() returns its provided default.
51 | *
52 | * read_setting_filename() and read_setting_fontspec() each read into
53 | * the provided buffer, and return zero if they failed to.
54 | */
55 | void *open_settings_r(const char *sessionname);
56 | char *read_setting_s(void *handle, const char *key, char *buffer, int buflen);
57 | int open_read_settings_s(const char *key, const char *subkey, char *buffer, int buflen);
58 | int read_setting_i(void *handle, const char *key, int defvalue);
59 | int read_setting_filename(void *handle, const char *key, Filename *value);
60 | int read_setting_fontspec(void *handle, const char *key, FontSpec *font);
61 | void close_settings_r(void *handle);
62 |
63 | /*
64 | * Delete a whole saved session.
65 | */
66 | void del_settings(const char *sessionname);
67 |
68 | /*
69 | * Enumerate all saved sessions.
70 | */
71 | void *enum_settings_start(void);
72 | char *enum_settings_next(void *handle, char *buffer, int buflen);
73 | void enum_settings_finish(void *handle);
74 |
75 | /* ----------------------------------------------------------------------
76 | * Functions to access PuTTY's host key database.
77 | */
78 |
79 | /*
80 | * See if a host key matches the database entry. Return values can
81 | * be 0 (entry matches database), 1 (entry is absent in database),
82 | * or 2 (entry exists in database and is different).
83 | */
84 | int verify_host_key(const char *hostname, int port,
85 | const char *keytype, const char *key);
86 |
87 | /*
88 | * Write a host key into the database, overwriting any previous
89 | * entry that might have been there.
90 | */
91 | void store_host_key(const char *hostname, int port,
92 | const char *keytype, const char *key);
93 |
94 | /* ----------------------------------------------------------------------
95 | * Functions to access PuTTY's random number seed file.
96 | */
97 |
98 | typedef void (*noise_consumer_t) (void *data, int len);
99 |
100 | /*
101 | * Read PuTTY's random seed file and pass its contents to a noise
102 | * consumer function.
103 | */
104 | void read_random_seed(noise_consumer_t consumer);
105 |
106 | /*
107 | * Write PuTTY's random seed file from a given chunk of noise.
108 | */
109 | void write_random_seed(void *data, int len);
110 |
111 | /* ----------------------------------------------------------------------
112 | * Cleanup function: remove all of PuTTY's persistent state.
113 | */
114 | void cleanup_all(void);
115 |
116 | #endif
117 |
--------------------------------------------------------------------------------
/windows/sizetip.c:
--------------------------------------------------------------------------------
1 | /*
2 | * sizetip.c - resize tips for PuTTY(tel) terminal window.
3 | */
4 |
5 | #include
6 | #include
7 | #include
8 |
9 | #include "putty.h"
10 |
11 | static ATOM tip_class = 0;
12 |
13 | static HFONT tip_font;
14 | static COLORREF tip_bg;
15 | static COLORREF tip_text;
16 |
17 | static LRESULT CALLBACK SizeTipWndProc(HWND hWnd, UINT nMsg,
18 | WPARAM wParam, LPARAM lParam)
19 | {
20 |
21 | switch (nMsg) {
22 | case WM_ERASEBKGND:
23 | return TRUE;
24 |
25 | case WM_PAINT:
26 | {
27 | HBRUSH hbr;
28 | HGDIOBJ holdbr;
29 | RECT cr;
30 | int wtlen;
31 | LPTSTR wt;
32 | HDC hdc;
33 |
34 | PAINTSTRUCT ps;
35 | hdc = BeginPaint(hWnd, &ps);
36 |
37 | SelectObject(hdc, tip_font);
38 | SelectObject(hdc, GetStockObject(BLACK_PEN));
39 |
40 | hbr = CreateSolidBrush(tip_bg);
41 | holdbr = SelectObject(hdc, hbr);
42 |
43 | GetClientRect(hWnd, &cr);
44 | Rectangle(hdc, cr.left, cr.top, cr.right, cr.bottom);
45 |
46 | wtlen = GetWindowTextLength(hWnd);
47 | wt = (LPTSTR) snewn(wtlen + 1, TCHAR);
48 | GetWindowText(hWnd, wt, wtlen + 1);
49 |
50 | SetTextColor(hdc, tip_text);
51 | SetBkColor(hdc, tip_bg);
52 |
53 | TextOut(hdc, cr.left + 3, cr.top + 3, wt, wtlen);
54 |
55 | sfree(wt);
56 |
57 | SelectObject(hdc, holdbr);
58 | DeleteObject(hbr);
59 |
60 | EndPaint(hWnd, &ps);
61 | }
62 | return 0;
63 |
64 | case WM_NCHITTEST:
65 | return HTTRANSPARENT;
66 |
67 | case WM_DESTROY:
68 | DeleteObject(tip_font);
69 | tip_font = NULL;
70 | break;
71 |
72 | case WM_SETTEXT:
73 | {
74 | LPCTSTR str = (LPCTSTR) lParam;
75 | SIZE sz;
76 | HDC hdc = CreateCompatibleDC(NULL);
77 |
78 | SelectObject(hdc, tip_font);
79 | GetTextExtentPoint32(hdc, str, _tcslen(str), &sz);
80 |
81 | SetWindowPos(hWnd, NULL, 0, 0, sz.cx + 6, sz.cy + 6,
82 | SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);
83 | InvalidateRect(hWnd, NULL, FALSE);
84 |
85 | DeleteDC(hdc);
86 | }
87 | break;
88 | }
89 |
90 | return DefWindowProc(hWnd, nMsg, wParam, lParam);
91 | }
92 |
93 | static HWND tip_wnd = NULL;
94 | static int tip_enabled = 0;
95 |
96 | void UpdateSizeTip(HWND src, int cx, int cy)
97 | {
98 | TCHAR str[32];
99 |
100 | if (!tip_enabled)
101 | return;
102 |
103 | if (!tip_wnd) {
104 | NONCLIENTMETRICS nci;
105 |
106 | /* First make sure the window class is registered */
107 |
108 | if (!tip_class) {
109 | WNDCLASS wc;
110 | wc.style = CS_HREDRAW | CS_VREDRAW;
111 | wc.lpfnWndProc = SizeTipWndProc;
112 | wc.cbClsExtra = 0;
113 | wc.cbWndExtra = 0;
114 | wc.hInstance = hinst;
115 | wc.hIcon = NULL;
116 | wc.hCursor = NULL;
117 | wc.hbrBackground = NULL;
118 | wc.lpszMenuName = NULL;
119 | wc.lpszClassName = "SizeTipClass";
120 |
121 | tip_class = RegisterClass(&wc);
122 | }
123 | #if 0
124 | /* Default values based on Windows Standard color scheme */
125 |
126 | tip_font = GetStockObject(SYSTEM_FONT);
127 | tip_bg = RGB(255, 255, 225);
128 | tip_text = RGB(0, 0, 0);
129 | #endif
130 |
131 | /* Prepare other GDI objects and drawing info */
132 |
133 | tip_bg = GetSysColor(COLOR_INFOBK);
134 | tip_text = GetSysColor(COLOR_INFOTEXT);
135 |
136 | memset(&nci, 0, sizeof(NONCLIENTMETRICS));
137 | nci.cbSize = sizeof(NONCLIENTMETRICS);
138 | SystemParametersInfo(SPI_GETNONCLIENTMETRICS,
139 | sizeof(NONCLIENTMETRICS), &nci, 0);
140 | tip_font = CreateFontIndirect(&nci.lfStatusFont);
141 | }
142 |
143 | /* Generate the tip text */
144 |
145 | sprintf(str, "%dx%d", cx, cy);
146 |
147 | if (!tip_wnd) {
148 | HDC hdc;
149 | SIZE sz;
150 | RECT wr;
151 | int ix, iy;
152 |
153 | /* calculate the tip's size */
154 |
155 | hdc = CreateCompatibleDC(NULL);
156 | GetTextExtentPoint32(hdc, str, _tcslen(str), &sz);
157 | DeleteDC(hdc);
158 |
159 | GetWindowRect(src, &wr);
160 |
161 | ix = wr.left;
162 | if (ix < 16)
163 | ix = 16;
164 |
165 | iy = wr.top - sz.cy;
166 | if (iy < 16)
167 | iy = 16;
168 |
169 | /* Create the tip window */
170 |
171 | tip_wnd =
172 | CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST,
173 | MAKEINTRESOURCE(tip_class), str, WS_POPUP, ix,
174 | iy, sz.cx, sz.cy, NULL, NULL, hinst, NULL);
175 |
176 | ShowWindow(tip_wnd, SW_SHOWNOACTIVATE);
177 |
178 | } else {
179 |
180 | /* Tip already exists, just set the text */
181 |
182 | SetWindowText(tip_wnd, str);
183 | }
184 | }
185 |
186 | void EnableSizeTip(int bEnable)
187 | {
188 | if (tip_wnd && !bEnable) {
189 | DestroyWindow(tip_wnd);
190 | tip_wnd = NULL;
191 | }
192 |
193 | tip_enabled = bEnable;
194 | }
195 |
--------------------------------------------------------------------------------
/windows/winprint.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Printing interface for PuTTY.
3 | */
4 |
5 | #include "putty.h"
6 | #include
7 |
8 | struct printer_enum_tag {
9 | int nprinters;
10 | DWORD enum_level;
11 | union {
12 | LPPRINTER_INFO_4 i4;
13 | LPPRINTER_INFO_5 i5;
14 | } info;
15 | };
16 |
17 | struct printer_job_tag {
18 | HANDLE hprinter;
19 | };
20 |
21 | static char *printer_add_enum(int param, DWORD level, char *buffer,
22 | int offset, int *nprinters_ptr)
23 | {
24 | DWORD needed = 0, nprinters = 0;
25 |
26 | buffer = sresize(buffer, offset+512, char);
27 |
28 | /*
29 | * Exploratory call to EnumPrinters to determine how much space
30 | * we'll need for the output. Discard the return value since it
31 | * will almost certainly be a failure due to lack of space.
32 | */
33 | EnumPrinters(param, NULL, level, buffer+offset, 512,
34 | &needed, &nprinters);
35 |
36 | if (needed < 512)
37 | needed = 512;
38 |
39 | buffer = sresize(buffer, offset+needed, char);
40 |
41 | if (EnumPrinters(param, NULL, level, buffer+offset,
42 | needed, &needed, &nprinters) == 0)
43 | return NULL;
44 |
45 | *nprinters_ptr += nprinters;
46 |
47 | return buffer;
48 | }
49 |
50 | printer_enum *printer_start_enum(int *nprinters_ptr)
51 | {
52 | printer_enum *ret = snew(printer_enum);
53 | char *buffer = NULL, *retval;
54 |
55 | *nprinters_ptr = 0; /* default return value */
56 | buffer = snewn(512, char);
57 |
58 | /*
59 | * Determine what enumeration level to use.
60 | * When enumerating printers, we need to use PRINTER_INFO_4 on
61 | * NT-class systems to avoid Windows looking too hard for them and
62 | * slowing things down; and we need to avoid PRINTER_INFO_5 as
63 | * we've seen network printers not show up.
64 | * On 9x-class systems, PRINTER_INFO_4 isn't available and
65 | * PRINTER_INFO_5 is recommended.
66 | * Bletch.
67 | */
68 | if (osVersion.dwPlatformId != VER_PLATFORM_WIN32_NT) {
69 | ret->enum_level = 5;
70 | } else {
71 | ret->enum_level = 4;
72 | }
73 |
74 | retval = printer_add_enum(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS,
75 | ret->enum_level, buffer, 0, nprinters_ptr);
76 | if (!retval)
77 | goto error;
78 | else
79 | buffer = retval;
80 |
81 | switch (ret->enum_level) {
82 | case 4:
83 | ret->info.i4 = (LPPRINTER_INFO_4)buffer;
84 | break;
85 | case 5:
86 | ret->info.i5 = (LPPRINTER_INFO_5)buffer;
87 | break;
88 | }
89 | ret->nprinters = *nprinters_ptr;
90 |
91 | return ret;
92 |
93 | error:
94 | sfree(buffer);
95 | sfree(ret);
96 | *nprinters_ptr = 0;
97 | return NULL;
98 | }
99 |
100 | char *printer_get_name(printer_enum *pe, int i)
101 | {
102 | if (!pe)
103 | return NULL;
104 | if (i < 0 || i >= pe->nprinters)
105 | return NULL;
106 | switch (pe->enum_level) {
107 | case 4:
108 | return pe->info.i4[i].pPrinterName;
109 | case 5:
110 | return pe->info.i5[i].pPrinterName;
111 | default:
112 | return NULL;
113 | }
114 | }
115 |
116 | void printer_finish_enum(printer_enum *pe)
117 | {
118 | if (!pe)
119 | return;
120 | switch (pe->enum_level) {
121 | case 4:
122 | sfree(pe->info.i4);
123 | break;
124 | case 5:
125 | sfree(pe->info.i5);
126 | break;
127 | }
128 | sfree(pe);
129 | }
130 |
131 | printer_job *printer_start_job(char *printer)
132 | {
133 | printer_job *ret = snew(printer_job);
134 | DOC_INFO_1 docinfo;
135 | int jobstarted = 0, pagestarted = 0;
136 |
137 | ret->hprinter = NULL;
138 | if (!OpenPrinter(printer, &ret->hprinter, NULL))
139 | goto error;
140 |
141 | docinfo.pDocName = "PuTTY remote printer output";
142 | docinfo.pOutputFile = NULL;
143 | docinfo.pDatatype = "RAW";
144 |
145 | if (!StartDocPrinter(ret->hprinter, 1, (LPSTR)&docinfo))
146 | goto error;
147 | jobstarted = 1;
148 |
149 | if (!StartPagePrinter(ret->hprinter))
150 | goto error;
151 | pagestarted = 1;
152 |
153 | return ret;
154 |
155 | error:
156 | if (pagestarted)
157 | EndPagePrinter(ret->hprinter);
158 | if (jobstarted)
159 | EndDocPrinter(ret->hprinter);
160 | if (ret->hprinter)
161 | ClosePrinter(ret->hprinter);
162 | sfree(ret);
163 | return NULL;
164 | }
165 |
166 | void printer_job_data(printer_job *pj, void *data, int len)
167 | {
168 | DWORD written;
169 |
170 | if (!pj)
171 | return;
172 |
173 | WritePrinter(pj->hprinter, data, len, &written);
174 | }
175 |
176 | void printer_finish_job(printer_job *pj)
177 | {
178 | if (!pj)
179 | return;
180 |
181 | EndPagePrinter(pj->hprinter);
182 | EndDocPrinter(pj->hprinter);
183 | ClosePrinter(pj->hprinter);
184 | sfree(pj);
185 | }
186 |
--------------------------------------------------------------------------------
/testdata/colours.txt:
--------------------------------------------------------------------------------
1 | Test of most colour rendering. Omits the SCO fg and bg sequences,
2 | since they are destructive.
3 | Normal text [1mand bold[m; [7mreverse video [1mand bold[m
4 | ANSI plus bold: [30m0 [1mbold[m [31m1 [1mbold[m [32m2 [1mbold[m [33m3 [1mbold[m [34m4 [1mbold[m [35m5 [1mbold[m [36m6 [1mbold[m [37m7 [1mbold[m
5 | xterm bright: [90mfg0[m [100mbg0[m [91mfg1[m [101mbg1[m [92mfg2[m [102mbg2[m [93mfg3[m [103mbg3[m [94mfg4[m [104mbg4[m [95mfg5[m [105mbg5[m [96mfg6[m [106mbg6[m [97mfg7[m [107mbg7[m
6 | xterm 256:
7 | [38;5;0m 0[m[38;5;1m 1[m[38;5;2m 2[m[38;5;3m 3[m[38;5;4m 4[m[38;5;5m 5[m[38;5;6m 6[m[38;5;7m 7[m[38;5;8m 8[m[38;5;9m 9[m[38;5;10m 10[m[38;5;11m 11[m[38;5;12m 12[m[38;5;13m 13[m[38;5;14m 14[m[38;5;15m 15[m
8 | [38;5;16m 16[m[38;5;17m 17[m[38;5;18m 18[m[38;5;19m 19[m[38;5;20m 20[m[38;5;21m 21[m[38;5;22m 22[m[38;5;23m 23[m[38;5;24m 24[m[38;5;25m 25[m[38;5;26m 26[m[38;5;27m 27[m[38;5;28m 28[m[38;5;29m 29[m[38;5;30m 30[m[38;5;31m 31[m
9 | [38;5;32m 32[m[38;5;33m 33[m[38;5;34m 34[m[38;5;35m 35[m[38;5;36m 36[m[38;5;37m 37[m[38;5;38m 38[m[38;5;39m 39[m[38;5;40m 40[m[38;5;41m 41[m[38;5;42m 42[m[38;5;43m 43[m[38;5;44m 44[m[38;5;45m 45[m[38;5;46m 46[m[38;5;47m 47[m
10 | [38;5;48m 48[m[38;5;49m 49[m[38;5;50m 50[m[38;5;51m 51[m[38;5;52m 52[m[38;5;53m 53[m[38;5;54m 54[m[38;5;55m 55[m[38;5;56m 56[m[38;5;57m 57[m[38;5;58m 58[m[38;5;59m 59[m[38;5;60m 60[m[38;5;61m 61[m[38;5;62m 62[m[38;5;63m 63[m
11 | [38;5;64m 64[m[38;5;65m 65[m[38;5;66m 66[m[38;5;67m 67[m[38;5;68m 68[m[38;5;69m 69[m[38;5;70m 70[m[38;5;71m 71[m[38;5;72m 72[m[38;5;73m 73[m[38;5;74m 74[m[38;5;75m 75[m[38;5;76m 76[m[38;5;77m 77[m[38;5;78m 78[m[38;5;79m 79[m
12 | [38;5;80m 80[m[38;5;81m 81[m[38;5;82m 82[m[38;5;83m 83[m[38;5;84m 84[m[38;5;85m 85[m[38;5;86m 86[m[38;5;87m 87[m[38;5;88m 88[m[38;5;89m 89[m[38;5;90m 90[m[38;5;91m 91[m[38;5;92m 92[m[38;5;93m 93[m[38;5;94m 94[m[38;5;95m 95[m
13 | [38;5;96m 96[m[38;5;97m 97[m[38;5;98m 98[m[38;5;99m 99[m[38;5;100m 100[m[38;5;101m 101[m[38;5;102m 102[m[38;5;103m 103[m[38;5;104m 104[m[38;5;105m 105[m[38;5;106m 106[m[38;5;107m 107[m[38;5;108m 108[m[38;5;109m 109[m[38;5;110m 110[m[38;5;111m 111[m
14 | [38;5;112m 112[m[38;5;113m 113[m[38;5;114m 114[m[38;5;115m 115[m[38;5;116m 116[m[38;5;117m 117[m[38;5;118m 118[m[38;5;119m 119[m[38;5;120m 120[m[38;5;121m 121[m[38;5;122m 122[m[38;5;123m 123[m[38;5;124m 124[m[38;5;125m 125[m[38;5;126m 126[m[38;5;127m 127[m
15 | [38;5;128m 128[m[38;5;129m 129[m[38;5;130m 130[m[38;5;131m 131[m[38;5;132m 132[m[38;5;133m 133[m[38;5;134m 134[m[38;5;135m 135[m[38;5;136m 136[m[38;5;137m 137[m[38;5;138m 138[m[38;5;139m 139[m[38;5;140m 140[m[38;5;141m 141[m[38;5;142m 142[m[38;5;143m 143[m
16 | [38;5;144m 144[m[38;5;145m 145[m[38;5;146m 146[m[38;5;147m 147[m[38;5;148m 148[m[38;5;149m 149[m[38;5;150m 150[m[38;5;151m 151[m[38;5;152m 152[m[38;5;153m 153[m[38;5;154m 154[m[38;5;155m 155[m[38;5;156m 156[m[38;5;157m 157[m[38;5;158m 158[m[38;5;159m 159[m
17 | [38;5;160m 160[m[38;5;161m 161[m[38;5;162m 162[m[38;5;163m 163[m[38;5;164m 164[m[38;5;165m 165[m[38;5;166m 166[m[38;5;167m 167[m[38;5;168m 168[m[38;5;169m 169[m[38;5;170m 170[m[38;5;171m 171[m[38;5;172m 172[m[38;5;173m 173[m[38;5;174m 174[m[38;5;175m 175[m
18 | [38;5;176m 176[m[38;5;177m 177[m[38;5;178m 178[m[38;5;179m 179[m[38;5;180m 180[m[38;5;181m 181[m[38;5;182m 182[m[38;5;183m 183[m[38;5;184m 184[m[38;5;185m 185[m[38;5;186m 186[m[38;5;187m 187[m[38;5;188m 188[m[38;5;189m 189[m[38;5;190m 190[m[38;5;191m 191[m
19 | [38;5;192m 192[m[38;5;193m 193[m[38;5;194m 194[m[38;5;195m 195[m[38;5;196m 196[m[38;5;197m 197[m[38;5;198m 198[m[38;5;199m 199[m[38;5;200m 200[m[38;5;201m 201[m[38;5;202m 202[m[38;5;203m 203[m[38;5;204m 204[m[38;5;205m 205[m[38;5;206m 206[m[38;5;207m 207[m
20 | [38;5;208m 208[m[38;5;209m 209[m[38;5;210m 210[m[38;5;211m 211[m[38;5;212m 212[m[38;5;213m 213[m[38;5;214m 214[m[38;5;215m 215[m[38;5;216m 216[m[38;5;217m 217[m[38;5;218m 218[m[38;5;219m 219[m[38;5;220m 220[m[38;5;221m 221[m[38;5;222m 222[m[38;5;223m 223[m
21 | [38;5;224m 224[m[38;5;225m 225[m[38;5;226m 226[m[38;5;227m 227[m[38;5;228m 228[m[38;5;229m 229[m[38;5;230m 230[m[38;5;231m 231[m[38;5;232m 232[m[38;5;233m 233[m[38;5;234m 234[m[38;5;235m 235[m[38;5;236m 236[m[38;5;237m 237[m[38;5;238m 238[m[38;5;239m 239[m
22 | [38;5;240m 240[m[38;5;241m 241[m[38;5;242m 242[m[38;5;243m 243[m[38;5;244m 244[m[38;5;245m 245[m[38;5;246m 246[m[38;5;247m 247[m[38;5;248m 248[m[38;5;249m 249[m[38;5;250m 250[m[38;5;251m 251[m[38;5;252m 252[m[38;5;253m 253[m[38;5;254m 254[m[38;5;255m 255[m
23 |
--------------------------------------------------------------------------------
/pgssapi.c:
--------------------------------------------------------------------------------
1 | /* This file actually defines the GSSAPI function pointers for
2 | * functions we plan to import from a GSSAPI library.
3 | */
4 | #include "putty.h"
5 |
6 | #ifndef NO_GSSAPI
7 |
8 | #include "pgssapi.h"
9 |
10 | #ifndef NO_LIBDL
11 |
12 | /* Reserved static storage for GSS_oids. Comments are quotes from RFC 2744. */
13 | static const gss_OID_desc oids[] = {
14 | /* The implementation must reserve static storage for a
15 | * gss_OID_desc object containing the value */
16 | {10, (void *)"\x2a\x86\x48\x86\xf7\x12\x01\x02\x01\x01"},
17 | /* corresponding to an object-identifier value of
18 | * {iso(1) member-body(2) United States(840) mit(113554)
19 | * infosys(1) gssapi(2) generic(1) user_name(1)}. The constant
20 | * GSS_C_NT_USER_NAME should be initialized to point
21 | * to that gss_OID_desc.
22 |
23 | * The implementation must reserve static storage for a
24 | * gss_OID_desc object containing the value */
25 | {10, (void *)"\x2a\x86\x48\x86\xf7\x12\x01\x02\x01\x02"},
26 | /* corresponding to an object-identifier value of
27 | * {iso(1) member-body(2) United States(840) mit(113554)
28 | * infosys(1) gssapi(2) generic(1) machine_uid_name(2)}.
29 | * The constant GSS_C_NT_MACHINE_UID_NAME should be
30 | * initialized to point to that gss_OID_desc.
31 |
32 | * The implementation must reserve static storage for a
33 | * gss_OID_desc object containing the value */
34 | {10, (void *)"\x2a\x86\x48\x86\xf7\x12\x01\x02\x01\x03"},
35 | /* corresponding to an object-identifier value of
36 | * {iso(1) member-body(2) United States(840) mit(113554)
37 | * infosys(1) gssapi(2) generic(1) string_uid_name(3)}.
38 | * The constant GSS_C_NT_STRING_UID_NAME should be
39 | * initialized to point to that gss_OID_desc.
40 | *
41 | * The implementation must reserve static storage for a
42 | * gss_OID_desc object containing the value */
43 | {6, (void *)"\x2b\x06\x01\x05\x06\x02"},
44 | /* corresponding to an object-identifier value of
45 | * {iso(1) org(3) dod(6) internet(1) security(5)
46 | * nametypes(6) gss-host-based-services(2)). The constant
47 | * GSS_C_NT_HOSTBASED_SERVICE_X should be initialized to point
48 | * to that gss_OID_desc. This is a deprecated OID value, and
49 | * implementations wishing to support hostbased-service names
50 | * should instead use the GSS_C_NT_HOSTBASED_SERVICE OID,
51 | * defined below, to identify such names;
52 | * GSS_C_NT_HOSTBASED_SERVICE_X should be accepted a synonym
53 | * for GSS_C_NT_HOSTBASED_SERVICE when presented as an input
54 | * parameter, but should not be emitted by GSS-API
55 | * implementations
56 | *
57 | * The implementation must reserve static storage for a
58 | * gss_OID_desc object containing the value */
59 | {10, (void *)"\x2a\x86\x48\x86\xf7\x12\x01\x02\x01\x04"},
60 | /* corresponding to an object-identifier value of {iso(1)
61 | * member-body(2) Unites States(840) mit(113554) infosys(1)
62 | * gssapi(2) generic(1) service_name(4)}. The constant
63 | * GSS_C_NT_HOSTBASED_SERVICE should be initialized
64 | * to point to that gss_OID_desc.
65 | *
66 | * The implementation must reserve static storage for a
67 | * gss_OID_desc object containing the value */
68 | {6, (void *)"\x2b\x06\01\x05\x06\x03"},
69 | /* corresponding to an object identifier value of
70 | * {1(iso), 3(org), 6(dod), 1(internet), 5(security),
71 | * 6(nametypes), 3(gss-anonymous-name)}. The constant
72 | * and GSS_C_NT_ANONYMOUS should be initialized to point
73 | * to that gss_OID_desc.
74 | *
75 | * The implementation must reserve static storage for a
76 | * gss_OID_desc object containing the value */
77 | {6, (void *)"\x2b\x06\x01\x05\x06\x04"},
78 | /* corresponding to an object-identifier value of
79 | * {1(iso), 3(org), 6(dod), 1(internet), 5(security),
80 | * 6(nametypes), 4(gss-api-exported-name)}. The constant
81 | * GSS_C_NT_EXPORT_NAME should be initialized to point
82 | * to that gss_OID_desc.
83 | */
84 | };
85 |
86 | /* Here are the constants which point to the static structure above.
87 | *
88 | * Constants of the form GSS_C_NT_* are specified by rfc 2744.
89 | */
90 | const_gss_OID GSS_C_NT_USER_NAME = oids+0;
91 | const_gss_OID GSS_C_NT_MACHINE_UID_NAME = oids+1;
92 | const_gss_OID GSS_C_NT_STRING_UID_NAME = oids+2;
93 | const_gss_OID GSS_C_NT_HOSTBASED_SERVICE_X = oids+3;
94 | const_gss_OID GSS_C_NT_HOSTBASED_SERVICE = oids+4;
95 | const_gss_OID GSS_C_NT_ANONYMOUS = oids+5;
96 | const_gss_OID GSS_C_NT_EXPORT_NAME = oids+6;
97 |
98 | #endif /* NO_LIBDL */
99 |
100 | static gss_OID_desc gss_mech_krb5_desc =
101 | { 9, (void *)"\x2a\x86\x48\x86\xf7\x12\x01\x02\x02" };
102 | /* iso(1) member-body(2) United States(840) mit(113554) infosys(1) gssapi(2) krb5(2)*/
103 | const gss_OID GSS_MECH_KRB5 = &gss_mech_krb5_desc;
104 |
105 | #endif /* NO_GSSAPI */
106 |
--------------------------------------------------------------------------------
/charset/charset.h:
--------------------------------------------------------------------------------
1 | /*
2 | * charset.h - header file for general character set conversion
3 | * routines.
4 | */
5 |
6 | #ifndef charset_charset_h
7 | #define charset_charset_h
8 |
9 | #include
10 |
11 | /*
12 | * Enumeration that lists all the multibyte or single-byte
13 | * character sets known to this library.
14 | */
15 | typedef enum {
16 | CS_NONE, /* used for reporting errors, etc */
17 | CS_ISO8859_1,
18 | CS_ISO8859_1_X11, /* X font encoding with VT100 glyphs */
19 | CS_ISO8859_2,
20 | CS_ISO8859_3,
21 | CS_ISO8859_4,
22 | CS_ISO8859_5,
23 | CS_ISO8859_6,
24 | CS_ISO8859_7,
25 | CS_ISO8859_8,
26 | CS_ISO8859_9,
27 | CS_ISO8859_10,
28 | CS_ISO8859_11,
29 | CS_ISO8859_13,
30 | CS_ISO8859_14,
31 | CS_ISO8859_15,
32 | CS_ISO8859_16,
33 | CS_CP437,
34 | CS_CP850,
35 | CS_CP866,
36 | CS_CP1250,
37 | CS_CP1251,
38 | CS_CP1252,
39 | CS_CP1253,
40 | CS_CP1254,
41 | CS_CP1255,
42 | CS_CP1256,
43 | CS_CP1257,
44 | CS_CP1258,
45 | CS_KOI8_R,
46 | CS_KOI8_U,
47 | CS_MAC_ROMAN,
48 | CS_MAC_TURKISH,
49 | CS_MAC_CROATIAN,
50 | CS_MAC_ICELAND,
51 | CS_MAC_ROMANIAN,
52 | CS_MAC_GREEK,
53 | CS_MAC_CYRILLIC,
54 | CS_MAC_THAI,
55 | CS_MAC_CENTEURO,
56 | CS_MAC_SYMBOL,
57 | CS_MAC_DINGBATS,
58 | CS_MAC_ROMAN_OLD,
59 | CS_MAC_CROATIAN_OLD,
60 | CS_MAC_ICELAND_OLD,
61 | CS_MAC_ROMANIAN_OLD,
62 | CS_MAC_GREEK_OLD,
63 | CS_MAC_CYRILLIC_OLD,
64 | CS_MAC_UKRAINE,
65 | CS_MAC_VT100,
66 | CS_MAC_VT100_OLD,
67 | CS_VISCII,
68 | CS_HP_ROMAN8,
69 | CS_DEC_MCS,
70 | CS_UTF8
71 | } charset_t;
72 |
73 | typedef struct {
74 | unsigned long s0;
75 | } charset_state;
76 |
77 | /*
78 | * Routine to convert a MB/SB character set to Unicode.
79 | *
80 | * This routine accepts some number of bytes, updates a state
81 | * variable, and outputs some number of Unicode characters. There
82 | * are no guarantees. You can't even guarantee that at most one
83 | * Unicode character will be output per byte you feed in; for
84 | * example, suppose you're reading UTF-8, you've seen E1 80, and
85 | * then you suddenly see FE. Now you need to output _two_ error
86 | * characters - one for the incomplete sequence E1 80, and one for
87 | * the completely invalid UTF-8 byte FE.
88 | *
89 | * Returns the number of wide characters output; will never output
90 | * more than the size of the buffer (as specified on input).
91 | * Advances the `input' pointer and decrements `inlen', to indicate
92 | * how far along the input string it got.
93 | *
94 | * The sequence of `errlen' wide characters pointed to by `errstr'
95 | * will be used to indicate a conversion error. If `errstr' is
96 | * NULL, `errlen' will be ignored, and the library will choose
97 | * something sensible to do on its own. For Unicode, this will be
98 | * U+FFFD (REPLACEMENT CHARACTER).
99 | */
100 |
101 | int charset_to_unicode(char **input, int *inlen, wchar_t *output, int outlen,
102 | int charset, charset_state *state,
103 | const wchar_t *errstr, int errlen);
104 |
105 | /*
106 | * Routine to convert Unicode to an MB/SB character set.
107 | *
108 | * This routine accepts some number of Unicode characters, updates
109 | * a state variable, and outputs some number of bytes.
110 | *
111 | * Returns the number of bytes characters output; will never output
112 | * more than the size of the buffer (as specified on input), and
113 | * will never output a partial MB character. Advances the `input'
114 | * pointer and decrements `inlen', to indicate how far along the
115 | * input string it got.
116 | *
117 | * The sequence of `errlen' characters pointed to by `errstr' will
118 | * be used to indicate a conversion error. If `errstr' is NULL,
119 | * `errlen' will be ignored, and the library will choose something
120 | * sensible to do on its own (which will vary depending on the
121 | * output charset).
122 | */
123 |
124 | int charset_from_unicode(wchar_t **input, int *inlen, char *output, int outlen,
125 | int charset, charset_state *state,
126 | const char *errstr, int errlen);
127 |
128 | /*
129 | * Convert X11 encoding names to and from our charset identifiers.
130 | */
131 | const char *charset_to_xenc(int charset);
132 | int charset_from_xenc(const char *name);
133 |
134 | /*
135 | * Convert MIME encoding names to and from our charset identifiers.
136 | */
137 | const char *charset_to_mimeenc(int charset);
138 | int charset_from_mimeenc(const char *name);
139 |
140 | /*
141 | * Convert our own encoding names to and from our charset
142 | * identifiers.
143 | */
144 | const char *charset_to_localenc(int charset);
145 | int charset_from_localenc(const char *name);
146 | int charset_localenc_nth(int n);
147 |
148 | /*
149 | * Convert Mac OS script/region/font to our charset identifiers.
150 | */
151 | int charset_from_macenc(int script, int region, int sysvers,
152 | const char *fontname);
153 |
154 | #endif /* charset_charset_h */
155 |
--------------------------------------------------------------------------------
/doc/man-pl.but:
--------------------------------------------------------------------------------
1 | \cfg{man-identity}{plink}{1}{2004-03-24}{PuTTY tool suite}{PuTTY tool suite}
2 |
3 | \H{plink-manpage} Man page for Plink
4 |
5 | \S{plink-manpage-name} NAME
6 |
7 | \cw{plink} \- PuTTY link, command line network connection tool
8 |
9 | \S{plink-manpage-synopsis} SYNOPSIS
10 |
11 | \c plink [options] [user@]host [command]
12 | \e bbbbb iiiiiii iiiib iiii iiiiiii
13 |
14 | \S{plink-manpage-description} DESCRIPTION
15 |
16 | \cw{plink} is a network connection tool supporting several protocols.
17 |
18 | \S{plink-manpage-options} OPTIONS
19 |
20 | The command-line options supported by \cw{plink} are:
21 |
22 | \dt \cw{-V}
23 |
24 | \dd Show version information and exit.
25 |
26 | \dt \cw{-pgpfp}
27 |
28 | \dd Display the fingerprints of the PuTTY PGP Master Keys and exit,
29 | to aid in verifying new files released by the PuTTY team.
30 |
31 | \dt \cw{-v}
32 |
33 | \dd Show verbose messages.
34 |
35 | \dt \cw{-load} \e{session}
36 |
37 | \dd Load settings from saved session.
38 |
39 | \dt \cw{-ssh}
40 |
41 | \dd Force use of SSH protocol (default).
42 |
43 | \dt \cw{-telnet}
44 |
45 | \dd Force use of Telnet protocol.
46 |
47 | \dt \cw{-rlogin}
48 |
49 | \dd Force use of rlogin protocol.
50 |
51 | \dt \cw{-raw}
52 |
53 | \dd Force raw mode.
54 |
55 | \dt \cw{-serial}
56 |
57 | \dd Force serial mode.
58 |
59 | \dt \cw{-P} \e{port}
60 |
61 | \dd Connect to port \e{port}.
62 |
63 | \dt \cw{-l} \e{user}
64 |
65 | \dd Set remote username to \e{user}.
66 |
67 | \dt \cw{-m} \e{path}
68 |
69 | \dd Read remote command(s) from local file \e{path}.
70 |
71 | \dt \cw{-batch}
72 |
73 | \dd Disable interactive prompts.
74 |
75 | \dt \cw{-pw} \e{password}
76 |
77 | \dd Set remote password to \e{password}. \e{CAUTION:} this will likely
78 | make the password visible to other users of the local machine (via
79 | commands such as \q{\c{w}}).
80 |
81 | \dt \cw{\-L} \cw{[}\e{srcaddr}\cw{:]}\e{srcport}\cw{:}\e{desthost}\cw{:}\e{destport}
82 |
83 | \dd Set up a local port forwarding: listen on \e{srcport} (or
84 | \e{srcaddr}:\e{srcport} if specified), and forward any connections
85 | over the SSH connection to the destination address
86 | \e{desthost}:\e{destport}. Only works in SSH.
87 |
88 | \dt \cw{\-R} \cw{[}\e{srcaddr}\cw{:]}\e{srcport}\cw{:}\e{desthost}\cw{:}\e{destport}
89 |
90 | \dd Set up a remote port forwarding: ask the SSH server to listen on
91 | \e{srcport} (or \e{srcaddr}:\e{srcport} if specified), and to
92 | forward any connections back over the SSH connection where the
93 | client will pass them on to the destination address
94 | \e{desthost}:\e{destport}. Only works in SSH.
95 |
96 | \dt \cw{\-D} [\e{srcaddr}:]\e{srcport}
97 |
98 | \dd Set up dynamic port forwarding. The client listens on
99 | \e{srcport} (or \e{srcaddr}:\e{srcport} if specified), and
100 | implements a SOCKS server. So you can point SOCKS-aware applications
101 | at this port and they will automatically use the SSH connection to
102 | tunnel all their connections. Only works in SSH.
103 |
104 | \dt \cw{-X}
105 |
106 | \dd Enable X11 forwarding.
107 |
108 | \dt \cw{-x}
109 |
110 | \dd Disable X11 forwarding (default).
111 |
112 | \dt \cw{-A}
113 |
114 | \dd Enable agent forwarding.
115 |
116 | \dt \cw{-a}
117 |
118 | \dd Disable agent forwarding (default).
119 |
120 | \dt \cw{-t}
121 |
122 | \dd Enable pty allocation (default if a command is NOT specified).
123 |
124 | \dt \cw{-T}
125 |
126 | \dd Disable pty allocation (default if a command is specified).
127 |
128 | \dt \cw{-1}
129 |
130 | \dd Force use of SSH protocol version 1.
131 |
132 | \dt \cw{-2}
133 |
134 | \dd Force use of SSH protocol version 2.
135 |
136 | \dt \cw{-C}
137 |
138 | \dd Enable SSH compression.
139 |
140 | \dt \cw{-i} \e{path}
141 |
142 | \dd Private key file for authentication.
143 |
144 | \dt \cw{-s}
145 |
146 | \dd Remote command is SSH subsystem (SSH-2 only).
147 |
148 | \dt \cw{-N}
149 |
150 | \dd Don't start a remote command or shell at all (SSH-2 only).
151 |
152 | \dt \cw{\-sercfg} \e{configuration-string}
153 |
154 | \dd Specify the configuration parameters for the serial port, in
155 | \cw{-serial} mode. \e{configuration-string} should be a
156 | comma-separated list of configuration parameters as follows:
157 |
158 | \lcont{
159 |
160 | \b Any single digit from 5 to 9 sets the number of data bits.
161 |
162 | \b \cq{1}, \cq{1.5} or \cq{2} sets the number of stop bits.
163 |
164 | \b Any other numeric string is interpreted as a baud rate.
165 |
166 | \b A single lower-case letter specifies the parity: \cq{n} for none,
167 | \cq{o} for odd, \cq{e} for even, \cq{m} for mark and \cq{s} for space.
168 |
169 | \b A single upper-case letter specifies the flow control: \cq{N} for
170 | none, \cq{X} for XON/XOFF, \cq{R} for RTS/CTS and \cq{D} for
171 | DSR/DTR.
172 |
173 | }
174 |
175 | \S{plink-manpage-more-information} MORE INFORMATION
176 |
177 | For more information on plink, it's probably best to go and look at
178 | the manual on the PuTTY web page:
179 |
180 | \W{http://www.chiark.greenend.org.uk/~sgtatham/putty/}\cw{http://www.chiark.greenend.org.uk/~sgtatham/putty/}
181 |
182 | \S{plink-manpage-bugs} BUGS
183 |
184 | This man page isn't terribly complete. See the above web link for
185 | better documentation.
186 |
--------------------------------------------------------------------------------
/windows/win_res.rc2:
--------------------------------------------------------------------------------
1 | /*
2 | * Windows resources shared between PuTTY and PuTTYtel, to be #include'd
3 | * after defining appropriate macros.
4 | * Note that many of these strings mention PuTTY. Due to restrictions in
5 | * VC's handling of string concatenation, this can't easily be fixed.
6 | * It's fixed up at runtime.
7 | * FIXME: This file is called '.rc2' rather than '.rc' to avoid MSVC trying
8 | * to compile it on its own when using the project files. Nicer solutions
9 | * welcome.
10 | */
11 |
12 | #include "win_res.h"
13 |
14 | IDB_TREE BITMAP DISCARDABLE "LIST.BMP"
15 | IDI_DUP_SESS ICON "dupsession.ico"
16 | IDI_SESS_CFG ICON "setting.ico"
17 | IDI_RESET_SESS ICON "resetconnection.ico"
18 | IDI_SFTP ICON "pscp.ico"
19 | IDI_SHOW_LOG ICON "log.ico"
20 | IDI_COYP_ALL ICON "copyall.ico"
21 | IDI_PASTE ICON "paste.ico"
22 | IDI_CLEAR_SB ICON "clear.ico"
23 | IDI_FULL_SCREEN ICON "fullscreen.ico"
24 | IDI_ABOUT ICON "about.ico"
25 | IDI_SEARCH_PRE ICON "up.ico"
26 | IDI_SEARCH_NEXT ICON "down.ico"
27 | IDI_SEARCH_RESET ICON "reset.ico"
28 | IDI_TAB_SHORTCUT ICON "shortcut.ico"
29 | IDI_START_LOG ICON "start.ico"
30 |
31 | IDI_MAINICON ICON "putty.ico"
32 |
33 | IDI_CFGICON ICON "puttycfg.ico"
34 |
35 | /* Accelerators used: clw */
36 | IDD_ABOUTBOX DIALOG DISCARDABLE 140, 40, 214, 70
37 | STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
38 | CAPTION "About PuTTY"
39 | FONT 8, "MS Shell Dlg"
40 | BEGIN
41 | DEFPUSHBUTTON "&Close", IDOK, 160, 52, 48, 14
42 | PUSHBUTTON "View &Licence", IDA_LICENCE, 6, 52, 70, 14
43 | PUSHBUTTON "Visit &Web Site", IDA_WEB, 84, 52, 70, 14
44 | CTEXT "PuTTY", IDA_TEXT1, 10, 6, 194, 8
45 | CTEXT "", IDA_VERSION, 10, 16, 194, 16
46 | CTEXT "\251 1997-2011 Simon Tatham. All rights reserved.",
47 | IDA_TEXT2, 10, 34, 194, 16
48 | END
49 |
50 | /* Accelerators used: aco */
51 | IDD_MAINBOX DIALOG DISCARDABLE 0, 0, 300, 252
52 | STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
53 | CAPTION "PuTTY Configuration"
54 | FONT 8, "MS Shell Dlg"
55 | CLASS "PuTTYConfigBox"
56 | BEGIN
57 | END
58 |
59 | /* Accelerators used: co */
60 | IDD_LOGBOX DIALOG DISCARDABLE 100, 20, 300, 119
61 | STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
62 | CAPTION "PuTTY Event Log"
63 | FONT 8, "MS Shell Dlg"
64 | BEGIN
65 | DEFPUSHBUTTON "&Close", IDOK, 135, 102, 44, 14
66 | PUSHBUTTON "C&opy", IDN_COPY, 81, 102, 44, 14
67 | LISTBOX IDN_LIST, 3, 3, 294, 95, LBS_HASSTRINGS | LBS_USETABSTOPS | WS_VSCROLL | LBS_EXTENDEDSEL
68 | END
69 |
70 | /* No accelerators used */
71 | IDD_LICENCEBOX DIALOG DISCARDABLE 50, 50, 226, 279
72 | STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
73 | CAPTION "PuTTY Licence"
74 | FONT 8, "MS Shell Dlg"
75 | BEGIN
76 | DEFPUSHBUTTON "OK", IDOK, 98, 259, 44, 14
77 |
78 | LTEXT "Copyright \251 1997-2011 Simon Tatham", 1000, 10, 10, 206, 8
79 |
80 | LTEXT "Portions copyright Robert de Bath, Joris van Rantwijk, Delian", 1001, 10, 26, 206, 8
81 | LTEXT "Delchev, Andreas Schultz, Jeroen Massar, Wez Furlong, Nicolas", 1002, 10, 34, 206, 8
82 | LTEXT "Barry, Justin Bradford, Ben Harris, Malcolm Smith, Ahmad Khalifa,", 1003, 10, 42, 206, 8
83 | LTEXT "Markus Kuhn, Colin Watson, and CORE SDI S.A.", 1004, 10, 50, 206, 8
84 |
85 | LTEXT "Portions copyright Lu Dong, Lokesh for the putty-nd's changes." , 1005, 10, 66, 206, 8
86 |
87 | LTEXT "Permission is hereby granted, free of charge, to any person" , 1006, 10, 84, 206, 8
88 | LTEXT "obtaining a copy of this software and associated documentation" , 1007, 10, 92, 206, 8
89 | LTEXT "files (the ""Software""), to deal in the Software without restriction,", 1008, 10, 100, 206, 8
90 | LTEXT "including without limitation the rights to use, copy, modify, merge," , 1009, 10, 108, 206, 8
91 | LTEXT "publish, distribute, sublicense, and/or sell copies of the Software," , 1010, 10, 116, 206, 8
92 | LTEXT "and to permit persons to whom the Software is furnished to do so," , 1011, 10, 124, 206, 8
93 | LTEXT "subject to the following conditions:" , 1012, 10, 132, 206, 8
94 |
95 | LTEXT "The above copyright notice and this permission notice shall be" , 1013, 10, 148, 206, 8
96 | LTEXT "included in all copies or substantial portions of the Software." , 1014, 10, 156, 206, 8
97 |
98 | LTEXT "THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT" , 1015, 10, 172, 206, 8
99 | LTEXT "WARRANTY OF ANY KIND, EXPRESS OR IMPLIED," , 1016, 10, 180, 206, 8
100 | LTEXT "INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF" , 1017, 10, 188, 206, 8
101 | LTEXT "MERCHANTABILITY, FITNESS FOR A PARTICULAR" , 1018, 10, 196, 206, 8
102 | LTEXT "PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE" , 1019, 10, 204, 206, 8
103 | LTEXT "COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES" , 1020, 10, 212, 206, 8
104 | LTEXT "OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT," , 1021, 10, 220, 206, 8
105 | LTEXT "TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN" , 1022, 10, 228, 206, 8
106 | LTEXT "CONNECTION WITH THE SOFTWARE OR THE USE OR" , 1023, 10, 236, 206, 8
107 | LTEXT "OTHER DEALINGS IN THE SOFTWARE." , 1024, 10, 244, 206, 8
108 |
109 | END
110 |
111 | #include "version.rc2"
112 |
--------------------------------------------------------------------------------