mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-10 01:48:00 +00:00
We now have a fairly minimal Mac application.
I'm about to try lashing in the terminal emulator... [originally from svn r52]
This commit is contained in:
parent
36cbe625d4
commit
e230e36e2f
12
PuTTY.make
12
PuTTY.make
@ -1,4 +1,4 @@
|
|||||||
# $Id: PuTTY.make,v 1.1.2.3 1999/02/19 21:44:14 ben Exp $
|
# $Id: PuTTY.make,v 1.1.2.4 1999/02/20 22:10:33 ben Exp $
|
||||||
# This is the Makefile for building PuTTY for the Mac OS.
|
# This is the Makefile for building PuTTY for the Mac OS.
|
||||||
# Users of non-Mac systems will see some pretty strange characters around.
|
# Users of non-Mac systems will see some pretty strange characters around.
|
||||||
|
|
||||||
@ -39,14 +39,14 @@ PuTTY
|
|||||||
"{Libraries}Interface.o"
|
"{Libraries}Interface.o"
|
||||||
|
|
||||||
|
|
||||||
PuTTY ÄÄ {¥MondoBuild¥} bjh21:putty:putty.r
|
PuTTY ÄÄ {¥MondoBuild¥} putty.r macresid.h
|
||||||
Rez bjh21:putty:putty.r -o {Targ} {Includes} -append
|
Rez putty.r -o {Targ} {Includes} -append
|
||||||
|
|
||||||
|
|
||||||
"{ObjDir¥68K}mac.c.o" Ä {¥MondoBuild¥} mac.c
|
"{ObjDir¥68K}mac.c.o" Ä {¥MondoBuild¥} mac.c putty.h macresid.h
|
||||||
{C} mac.c -o {Targ} {COptions}
|
{C} mac.c -o {Targ} {COptions}
|
||||||
|
|
||||||
"{ObjDir¥68K}misc.c.o" Ä {¥MondoBuild¥} misc.c
|
"{ObjDir¥68K}misc.c.o" Ä {¥MondoBuild¥} misc.c putty.h
|
||||||
{C} misc.c -o {Targ} {COptions}
|
{C} misc.c -o {Targ} {COptions}
|
||||||
|
|
||||||
"{ObjDir¥68K}ssh.c.o" Ä {¥MondoBuild¥} ssh.c
|
"{ObjDir¥68K}ssh.c.o" Ä {¥MondoBuild¥} ssh.c
|
||||||
@ -73,6 +73,6 @@ PuTTY
|
|||||||
"{ObjDir¥68K}telnet.c.o" Ä {¥MondoBuild¥} telnet.c
|
"{ObjDir¥68K}telnet.c.o" Ä {¥MondoBuild¥} telnet.c
|
||||||
{C} telnet.c -o {Targ} {COptions}
|
{C} telnet.c -o {Targ} {COptions}
|
||||||
|
|
||||||
"{ObjDir¥68K}terminal.c.o" Ä {¥MondoBuild¥} terminal.c
|
"{ObjDir¥68K}terminal.c.o" Ä {¥MondoBuild¥} terminal.c putty.h
|
||||||
{C} terminal.c -o {Targ} {COptions}
|
{C} terminal.c -o {Targ} {COptions}
|
||||||
|
|
||||||
|
226
mac.c
226
mac.c
@ -1,4 +1,4 @@
|
|||||||
/* $Id: mac.c,v 1.1.2.3 1999/02/19 23:51:21 ben Exp $ */
|
/* $Id: mac.c,v 1.1.2.4 1999/02/20 22:10:33 ben Exp $ */
|
||||||
/*
|
/*
|
||||||
* mac.c -- miscellaneous Mac-specific routines
|
* mac.c -- miscellaneous Mac-specific routines
|
||||||
*/
|
*/
|
||||||
@ -10,11 +10,15 @@
|
|||||||
#include <Menus.h>
|
#include <Menus.h>
|
||||||
#include <TextEdit.h>
|
#include <TextEdit.h>
|
||||||
#include <Dialogs.h>
|
#include <Dialogs.h>
|
||||||
|
#include <Devices.h>
|
||||||
|
#include <DiskInit.h>
|
||||||
|
#include <ToolUtils.h>
|
||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdlib.h> /* putty.h needs size_t */
|
#include <stdlib.h> /* putty.h needs size_t */
|
||||||
|
|
||||||
|
#include "macresid.h"
|
||||||
#include "putty.h"
|
#include "putty.h"
|
||||||
|
|
||||||
QDGlobals qd;
|
QDGlobals qd;
|
||||||
@ -23,6 +27,17 @@ int cold = 1;
|
|||||||
|
|
||||||
static void mac_startup(void);
|
static void mac_startup(void);
|
||||||
static void mac_eventloop(void);
|
static void mac_eventloop(void);
|
||||||
|
static void mac_event(EventRecord *);
|
||||||
|
static void mac_contentclick(WindowPtr, EventRecord *);
|
||||||
|
static void mac_updatewindow(WindowPtr);
|
||||||
|
static void mac_keypress(EventRecord *);
|
||||||
|
static int mac_windowtype(WindowPtr);
|
||||||
|
static void mac_menucommand(long);
|
||||||
|
static void mac_adjustcursor(void);
|
||||||
|
static void mac_adjustmenus(void);
|
||||||
|
static void mac_closewindow(WindowPtr);
|
||||||
|
static void mac_zoomwindow(WindowPtr, short);
|
||||||
|
static void mac_shutdown(void);
|
||||||
|
|
||||||
int main (int argc, char **argv) {
|
int main (int argc, char **argv) {
|
||||||
|
|
||||||
@ -45,16 +60,16 @@ static void mac_startup(void) {
|
|||||||
TEInit();
|
TEInit();
|
||||||
/* Init Dialog Manager */
|
/* Init Dialog Manager */
|
||||||
InitDialogs(nil);
|
InitDialogs(nil);
|
||||||
InitCursor();
|
|
||||||
cold = 0;
|
cold = 0;
|
||||||
|
|
||||||
menuBar = GetNewMBar(128);
|
menuBar = GetNewMBar(128);
|
||||||
if (menuBar == NULL)
|
if (menuBar == NULL)
|
||||||
fatalbox("Unable to create menu bar.");
|
fatalbox("Unable to create menu bar.");
|
||||||
SetMenuBar(menuBar);
|
SetMenuBar(menuBar);
|
||||||
AppendResMenu(GetMenuHandle(128), 'DRVR');
|
AppendResMenu(GetMenuHandle(mApple), 'DRVR');
|
||||||
/* adjustmenus */
|
mac_adjustmenus();
|
||||||
DrawMenuBar();
|
DrawMenuBar();
|
||||||
|
InitCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mac_eventloop(void) {
|
static void mac_eventloop(void) {
|
||||||
@ -62,10 +77,209 @@ static void mac_eventloop(void) {
|
|||||||
EventRecord event;
|
EventRecord event;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < 100; i++) {
|
for (;;) {
|
||||||
|
mac_adjustcursor();
|
||||||
gotevent = WaitNextEvent(everyEvent, &event, LONG_MAX, NULL);
|
gotevent = WaitNextEvent(everyEvent, &event, LONG_MAX, NULL);
|
||||||
|
mac_adjustcursor();
|
||||||
|
if (gotevent)
|
||||||
|
mac_event(&event);
|
||||||
}
|
}
|
||||||
fatalbox("I'm bored.");
|
}
|
||||||
|
|
||||||
|
static void mac_event(EventRecord *event) {
|
||||||
|
short part;
|
||||||
|
WindowPtr window;
|
||||||
|
Point pt;
|
||||||
|
|
||||||
|
switch (event->what) {
|
||||||
|
case mouseDown:
|
||||||
|
part = FindWindow(event->where, &window);
|
||||||
|
switch (part) {
|
||||||
|
case inMenuBar:
|
||||||
|
mac_adjustmenus();
|
||||||
|
mac_menucommand(MenuSelect(event->where));
|
||||||
|
break;
|
||||||
|
case inSysWindow:
|
||||||
|
SystemClick(event, window);
|
||||||
|
break;
|
||||||
|
case inContent:
|
||||||
|
if (window != FrontWindow())
|
||||||
|
/* XXX: check for movable modal dboxes? */
|
||||||
|
SelectWindow(window);
|
||||||
|
else
|
||||||
|
mac_contentclick(window, event);
|
||||||
|
break;
|
||||||
|
case inGoAway:
|
||||||
|
if (TrackGoAway(window, event->where))
|
||||||
|
mac_closewindow(window);
|
||||||
|
break;
|
||||||
|
case inDrag:
|
||||||
|
/* XXX: moveable modal check? */
|
||||||
|
DragWindow(window, event->where, &qd.screenBits.bounds);
|
||||||
|
break;
|
||||||
|
case inGrow:
|
||||||
|
break;
|
||||||
|
case inZoomIn:
|
||||||
|
case inZoomOut:
|
||||||
|
if (TrackBox(window, event->where, part))
|
||||||
|
mac_zoomwindow(window, part);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case keyDown:
|
||||||
|
case autoKey:
|
||||||
|
mac_keypress(event);
|
||||||
|
break;
|
||||||
|
case activateEvt:
|
||||||
|
/* FIXME: Do something */
|
||||||
|
break;
|
||||||
|
case updateEvt:
|
||||||
|
mac_updatewindow((WindowPtr)event->message);
|
||||||
|
break;
|
||||||
|
case diskEvt:
|
||||||
|
if (HiWord(event->message) != noErr) {
|
||||||
|
SetPt(&pt, 120, 120);
|
||||||
|
DIBadMount(pt, event->message);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void mac_contentclick(WindowPtr window, EventRecord *event) {
|
||||||
|
short item;
|
||||||
|
|
||||||
|
switch (mac_windowtype(window)) {
|
||||||
|
case wTerminal:
|
||||||
|
/* XXX: Do something. */
|
||||||
|
break;
|
||||||
|
case wAbout:
|
||||||
|
if (DialogSelect(event, &(DialogPtr)window, &item))
|
||||||
|
switch (item) {
|
||||||
|
case wiAboutClose:
|
||||||
|
mac_closewindow(window);
|
||||||
|
break;
|
||||||
|
case wiAboutLicence:
|
||||||
|
/* XXX: Do something */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void mac_updatewindow(WindowPtr window) {
|
||||||
|
|
||||||
|
switch (mac_windowtype(window)) {
|
||||||
|
case wTerminal:
|
||||||
|
/* XXX: DO something */
|
||||||
|
break;
|
||||||
|
case wAbout:
|
||||||
|
BeginUpdate(window);
|
||||||
|
UpdateDialog(window, window->visRgn);
|
||||||
|
EndUpdate(window);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Work out what kind of window we're dealing with.
|
||||||
|
* Concept shamelessly nicked from SurfWriter.
|
||||||
|
*/
|
||||||
|
static int mac_windowtype(WindowPtr window) {
|
||||||
|
int kind;
|
||||||
|
|
||||||
|
if (window == NULL)
|
||||||
|
return wNone;
|
||||||
|
kind = ((WindowPeek)window)->windowKind;
|
||||||
|
if (kind < 0)
|
||||||
|
return wDA;
|
||||||
|
else if (kind == userKind)
|
||||||
|
return wTerminal;
|
||||||
|
else
|
||||||
|
return GetWRefCon(window);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Handle a key press
|
||||||
|
*/
|
||||||
|
static void mac_keypress(EventRecord *event) {
|
||||||
|
char key;
|
||||||
|
|
||||||
|
if (event->what == keyDown && (event->modifiers & cmdKey)) {
|
||||||
|
mac_adjustmenus();
|
||||||
|
mac_menucommand(MenuKey(event->message & charCodeMask));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void mac_menucommand(long result) {
|
||||||
|
short menu, item;
|
||||||
|
Str255 da;
|
||||||
|
|
||||||
|
menu = HiWord(result);
|
||||||
|
item = LoWord(result);
|
||||||
|
switch (menu) {
|
||||||
|
case mApple:
|
||||||
|
switch (item) {
|
||||||
|
case iAbout:
|
||||||
|
GetNewDialog(wAbout, NULL, (GrafPort *)-1);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
GetMenuItemText(GetMenuHandle(mApple), item, da);
|
||||||
|
OpenDeskAcc(da);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case mFile:
|
||||||
|
switch (item) {
|
||||||
|
case iClose:
|
||||||
|
mac_closewindow(FrontWindow());
|
||||||
|
break;
|
||||||
|
case iQuit:
|
||||||
|
mac_shutdown();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
HiliteMenu(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void mac_closewindow(WindowPtr window) {
|
||||||
|
|
||||||
|
switch (mac_windowtype(window)) {
|
||||||
|
case wDA:
|
||||||
|
CloseDeskAcc(((WindowPeek)window)->windowKind);
|
||||||
|
break;
|
||||||
|
case wTerminal:
|
||||||
|
/* FIXME: end session and stuff */
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
CloseWindow(window);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void mac_zoomwindow(WindowPtr window, short part) {
|
||||||
|
|
||||||
|
/* FIXME: do something */
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Make the menus look right before the user gets to see them.
|
||||||
|
*/
|
||||||
|
static void mac_adjustmenus(void) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Make sure the right cursor's being displayed.
|
||||||
|
*/
|
||||||
|
static void mac_adjustcursor(void) {
|
||||||
|
|
||||||
|
SetCursor(&qd.arrow);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void mac_shutdown(void) {
|
||||||
|
|
||||||
|
ExitToShell();
|
||||||
}
|
}
|
||||||
|
|
||||||
void fatalbox(const char *fmt, ...) {
|
void fatalbox(const char *fmt, ...) {
|
||||||
|
32
macresid.h
Normal file
32
macresid.h
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
/* $Id: macresid.h,v 1.1.2.1 1999/02/20 22:10:34 ben Exp $ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* macresid.h -- Mac resource IDs
|
||||||
|
*
|
||||||
|
* This file is shared by C and Rez source files
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* Menu bar IDs */
|
||||||
|
#define MBAR_Main 128
|
||||||
|
|
||||||
|
/* Menu IDs */
|
||||||
|
#define mApple 128
|
||||||
|
#define mFile 129
|
||||||
|
|
||||||
|
/* Menu Items */
|
||||||
|
/* Apple menu */
|
||||||
|
#define iAbout 1
|
||||||
|
/* File menu */
|
||||||
|
#define iClose 1
|
||||||
|
#define iQuit 3
|
||||||
|
|
||||||
|
/* Window types (and resource IDs) */
|
||||||
|
#define wNone 0 /* Dummy value for no window */
|
||||||
|
#define wDA 1 /* DUmmy value for desk accessory */
|
||||||
|
#define wFatal 128
|
||||||
|
#define wAbout 129
|
||||||
|
#define wiAboutClose 1
|
||||||
|
#define wiAboutLicence 2
|
||||||
|
#define wTerminal 130
|
||||||
|
#define wLicence 131
|
116
putty.r
116
putty.r
@ -1,8 +1,13 @@
|
|||||||
/* $Id: putty.r,v 1.1.2.4 1999/02/19 23:41:24 ben Exp $ */
|
/* $Id: putty.r,v 1.1.2.5 1999/02/20 22:10:34 ben Exp $ */
|
||||||
/* PuTTY resources */
|
/* PuTTY resources */
|
||||||
|
|
||||||
|
#define PICT_RezTemplateVersion 1
|
||||||
|
|
||||||
#include "Types.r"
|
#include "Types.r"
|
||||||
|
|
||||||
|
/* Get resource IDs we share with C code */
|
||||||
|
#include "macresid.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Finder-related resources
|
* Finder-related resources
|
||||||
*/
|
*/
|
||||||
@ -243,12 +248,12 @@ resource 'icl8' (130, purgeable) {
|
|||||||
|
|
||||||
/* Menu bar */
|
/* Menu bar */
|
||||||
|
|
||||||
resource 'MBAR' (128, preload) {
|
resource 'MBAR' (MBAR_Main, preload) {
|
||||||
{ 128, 129 }
|
{ mApple, mFile }
|
||||||
};
|
};
|
||||||
|
|
||||||
resource 'MENU' (128, preload) {
|
resource 'MENU' (mApple, preload) {
|
||||||
128,
|
mApple,
|
||||||
textMenuProc,
|
textMenuProc,
|
||||||
0b11111111111111111111111111111101,
|
0b11111111111111111111111111111101,
|
||||||
enabled,
|
enabled,
|
||||||
@ -259,27 +264,29 @@ resource 'MENU' (128, preload) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
resource 'MENU' (129, preload) {
|
resource 'MENU' (mFile, preload) {
|
||||||
129,
|
mFile,
|
||||||
textMenuProc,
|
textMenuProc,
|
||||||
0b11111111111111111111111111111111,
|
0b11111111111111111111111111111101,
|
||||||
enabled,
|
enabled,
|
||||||
"File",
|
"File",
|
||||||
{
|
{
|
||||||
|
"Close", noicon, "W", nomark, plain,
|
||||||
|
"-", noicon, nokey, nomark, plain,
|
||||||
"Quit", noicon, "Q", nomark, plain,
|
"Quit", noicon, "Q", nomark, plain,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Fatal error box. Stolen from the Finder. */
|
/* Fatal error box. Stolen from the Finder. */
|
||||||
|
|
||||||
resource 'ALRT' (128, "fatalbox", purgeable) {
|
resource 'ALRT' (wFatal, "fatalbox", purgeable) {
|
||||||
{54, 67, 152, 435},
|
{54, 67, 152, 435},
|
||||||
128,
|
wFatal,
|
||||||
beepStages,
|
beepStages,
|
||||||
alertPositionMainScreen
|
alertPositionMainScreen
|
||||||
};
|
};
|
||||||
|
|
||||||
resource 'DITL' (128, "fatalbox", purgeable) {
|
resource 'DITL' (wFatal, "fatalbox", purgeable) {
|
||||||
{ /* array DITLarray: 3 elements */
|
{ /* array DITLarray: 3 elements */
|
||||||
/* [1] */
|
/* [1] */
|
||||||
{68, 299, 88, 358},
|
{68, 299, 88, 358},
|
||||||
@ -302,3 +309,90 @@ resource 'DITL' (128, "fatalbox", purgeable) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* "About" box */
|
||||||
|
|
||||||
|
resource 'DLOG' (wAbout, "about", purgeable) {
|
||||||
|
{ 0, 0, 120, 186 },
|
||||||
|
noGrowDocProc,
|
||||||
|
visible,
|
||||||
|
goAway,
|
||||||
|
wAbout, /* RefCon -- identifies the window to PuTTY */
|
||||||
|
wAbout, /* DITL ID */
|
||||||
|
"About PuTTY",
|
||||||
|
alertPositionMainScreen
|
||||||
|
};
|
||||||
|
|
||||||
|
resource 'DITL' (wAbout, "about", purgeable) {
|
||||||
|
{
|
||||||
|
{ 87, 116, 107, 173 },
|
||||||
|
Button { enabled, "Close" },
|
||||||
|
{ 87, 13, 107, 103 },
|
||||||
|
Button { enabled, "View Licence" },
|
||||||
|
{ 13, 13, 29, 173 },
|
||||||
|
StaticText { disabled, "PuTTY"},
|
||||||
|
{ 42, 13, 74, 173 },
|
||||||
|
StaticText { disabled, "Mac Development\n© 1997-9 Simon Tatham"},
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Licence box */
|
||||||
|
|
||||||
|
resource 'DLOG' (wLicence, "licence", purgeable) {
|
||||||
|
{ 0, 0, 300, 300 },
|
||||||
|
noGrowDocProc,
|
||||||
|
visible,
|
||||||
|
goAway,
|
||||||
|
wLicence,
|
||||||
|
wLicence,
|
||||||
|
"PuTTY Licence",
|
||||||
|
alertPositionParentWindowScreen
|
||||||
|
};
|
||||||
|
|
||||||
|
type 'TEXT' {
|
||||||
|
string;
|
||||||
|
};
|
||||||
|
|
||||||
|
resource 'TEXT' (wLicence, "licence", purgeable) {
|
||||||
|
"Copyright © 1997-9 Simon Tatham\n"
|
||||||
|
"Portions copyright Gary S. Brown and Eric Young\n\n"
|
||||||
|
|
||||||
|
"Permission is hereby granted, free of charge, to any person "
|
||||||
|
"obtaining a copy of this software and associated documentation "
|
||||||
|
"files (the \"Software\"), to deal in the Software without "
|
||||||
|
"restriction, including without limitation the rights to use, "
|
||||||
|
"copy, modify, merge, publish, distribute, sublicense, and/or "
|
||||||
|
"sell copies of the Software, and to permit persons to whom the "
|
||||||
|
"Software is furnished to do so, subject to the following "
|
||||||
|
"conditions:\n\n"
|
||||||
|
|
||||||
|
"The above copyright notice and this permission notice shall be "
|
||||||
|
"included in all copies or substantial portions of the Software.\n\n"
|
||||||
|
|
||||||
|
"THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, "
|
||||||
|
"EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF "
|
||||||
|
"MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND "
|
||||||
|
"NONINFRINGEMENT. IN NO EVENT SHALL SIMON TATHAM BE LIABLE FOR "
|
||||||
|
"ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF "
|
||||||
|
"CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN "
|
||||||
|
"CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE "
|
||||||
|
"SOFTWARE."
|
||||||
|
};
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
resource 'DITL' (wLicence, "licence", purgeable) {
|
||||||
|
{
|
||||||
|
{ 13, 23, 287, 277 },
|
||||||
|
Picture { enabled, wLicence }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
resource 'PICT' (wLicence, "licence", purgeable) {
|
||||||
|
{ 0, 0, 274, 254 },
|
||||||
|
VersionTwo {
|
||||||
|
{
|
||||||
|
LongText { { 16, 0 }, "Copyright © 1997-9 Simon Tatham" },
|
||||||
|
LongText { { 32, 0 }, "Portions copyright Gary S. Brown and Eric Young" },
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
41
ssh.c
41
ssh.c
@ -1,16 +1,10 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#ifndef macintosh
|
||||||
#include <winsock.h>
|
#include <winsock.h>
|
||||||
|
#endif /* not macintosh */
|
||||||
|
|
||||||
#include "putty.h"
|
#include "putty.h"
|
||||||
|
|
||||||
#ifndef FALSE
|
|
||||||
#define FALSE 0
|
|
||||||
#endif
|
|
||||||
#ifndef TRUE
|
|
||||||
#define TRUE 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "ssh.h"
|
#include "ssh.h"
|
||||||
|
|
||||||
/* Coroutine mechanics for the sillier bits of the code */
|
/* Coroutine mechanics for the sillier bits of the code */
|
||||||
@ -30,14 +24,9 @@
|
|||||||
#define crStop(z) do{ crLine = 0; return (z); }while(0)
|
#define crStop(z) do{ crLine = 0; return (z); }while(0)
|
||||||
#define crStopV do{ crLine = 0; return; }while(0)
|
#define crStopV do{ crLine = 0; return; }while(0)
|
||||||
|
|
||||||
#ifndef FALSE
|
#ifndef macintosh
|
||||||
#define FALSE 0
|
|
||||||
#endif
|
|
||||||
#ifndef TRUE
|
|
||||||
#define TRUE 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static SOCKET s = INVALID_SOCKET;
|
static SOCKET s = INVALID_SOCKET;
|
||||||
|
#endif
|
||||||
|
|
||||||
static unsigned char session_key[32];
|
static unsigned char session_key[32];
|
||||||
static struct ssh_cipher *cipher = NULL;
|
static struct ssh_cipher *cipher = NULL;
|
||||||
@ -52,6 +41,11 @@ static enum {
|
|||||||
|
|
||||||
static int size_needed = FALSE;
|
static int size_needed = FALSE;
|
||||||
|
|
||||||
|
#ifdef macintosh
|
||||||
|
static void s_write (unsigned char *buf, int len) {
|
||||||
|
panic("s_write not implemented");
|
||||||
|
}
|
||||||
|
#else /* not macintosh */
|
||||||
static void s_write (char *buf, int len) {
|
static void s_write (char *buf, int len) {
|
||||||
while (len > 0) {
|
while (len > 0) {
|
||||||
int i = send (s, buf, len, 0);
|
int i = send (s, buf, len, 0);
|
||||||
@ -59,7 +53,13 @@ static void s_write (char *buf, int len) {
|
|||||||
len -= i, buf += i;
|
len -= i, buf += i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif /* not macintosh */
|
||||||
|
|
||||||
|
#ifdef macintosh
|
||||||
|
static int s_read (unsigned char *buf, int len) {
|
||||||
|
panic("s_read not implemented");
|
||||||
|
}
|
||||||
|
#else /* not macintosh */
|
||||||
static int s_read (char *buf, int len) {
|
static int s_read (char *buf, int len) {
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
while (len > 0) {
|
while (len > 0) {
|
||||||
@ -71,6 +71,7 @@ static int s_read (char *buf, int len) {
|
|||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void c_write (char *buf, int len) {
|
static void c_write (char *buf, int len) {
|
||||||
while (len--) {
|
while (len--) {
|
||||||
@ -174,8 +175,8 @@ static void s_wrpkt_start(int type, int len) {
|
|||||||
pktout.length = len-5;
|
pktout.length = len-5;
|
||||||
if (pktout.maxlen < biglen) {
|
if (pktout.maxlen < biglen) {
|
||||||
pktout.maxlen = biglen;
|
pktout.maxlen = biglen;
|
||||||
pktout.data = (pktout.data == NULL ? malloc(biglen+4) :
|
pktout.data = (pktout.data == NULL ? malloc(biglen) :
|
||||||
realloc(pktout.data, biglen+4));
|
realloc(pktout.data, biglen));
|
||||||
if (!pktout.data)
|
if (!pktout.data)
|
||||||
fatalbox("Out of memory");
|
fatalbox("Out of memory");
|
||||||
}
|
}
|
||||||
@ -214,7 +215,7 @@ static void s_wrpkt(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int do_ssh_init(void) {
|
static int do_ssh_init(void) {
|
||||||
char c;
|
unsigned char c;
|
||||||
char version[10];
|
char version[10];
|
||||||
char vstring[40];
|
char vstring[40];
|
||||||
int i;
|
int i;
|
||||||
@ -250,7 +251,7 @@ static int do_ssh_init(void) {
|
|||||||
|
|
||||||
sprintf(vstring, "SSH-%s-7.7.7\n",
|
sprintf(vstring, "SSH-%s-7.7.7\n",
|
||||||
(strcmp(version, "1.5") <= 0 ? version : "1.5"));
|
(strcmp(version, "1.5") <= 0 ? version : "1.5"));
|
||||||
s_write(vstring, strlen(vstring));
|
s_write((unsigned char *)vstring, strlen(vstring));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -476,7 +477,7 @@ static void ssh_protocol(unsigned char *in, int inlen, int ispkt) {
|
|||||||
long len = 0;
|
long len = 0;
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
len = (len << 8) + pktin.body[i];
|
len = (len << 8) + pktin.body[i];
|
||||||
c_write(pktin.body+4, len);
|
c_write((char *)pktin.body+4, len);
|
||||||
} else if (pktin.type == 1) {
|
} else if (pktin.type == 1) {
|
||||||
/* SSH_MSG_DISCONNECT: do nothing */
|
/* SSH_MSG_DISCONNECT: do nothing */
|
||||||
} else if (pktin.type == 14) {
|
} else if (pktin.type == 14) {
|
||||||
|
11
telnet.c
11
telnet.c
@ -1,17 +1,12 @@
|
|||||||
|
#ifndef macintosh
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include <winsock.h>
|
||||||
|
#endif /* not macintosh */
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <winsock.h>
|
|
||||||
|
|
||||||
#include "putty.h"
|
#include "putty.h"
|
||||||
|
|
||||||
#ifndef FALSE
|
|
||||||
#define FALSE 0
|
|
||||||
#endif
|
|
||||||
#ifndef TRUE
|
|
||||||
#define TRUE 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static SOCKET s = INVALID_SOCKET;
|
static SOCKET s = INVALID_SOCKET;
|
||||||
|
|
||||||
#define IAC 255 /* interpret as command: */
|
#define IAC 255 /* interpret as command: */
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
|
#ifndef macintosh
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#endif /* not macintosh */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
Loading…
Reference in New Issue
Block a user