Subversion Repositories NettleSSH

Compare Revisions

Ignore whitespace Rev 1 → Rev 2

/vendor/v0.2023/keyboard.c
New file
0,0 → 1,390
/**
* Keyboard translation code
* (C) Nettle developers 2000-2001
*
* $Id: keyboard,v 1.11 2001/09/12 13:53:54 archifishal Exp $
*/
 
 
#include "generic.h"
#include "globals.h"
 
#include "keyboard.h"
#include "seln.h"
#include "wimp.h"
 
 
bool inkey (int key)
{
return _swi(OS_Byte, _INR(0,2)|_RETURN(1), 129, key & 255, key >> 8)
? true : false;
}
 
 
static int
setmod (char *block, const char *key, int extra)
{
int length = strlen (key);
 
strncpy (block, key, length);
 
extra = (extra | extra >> 1) & 0x5; /* modifier keys: ccss -> 0c0s */
block[length] = "~$ ^@"[extra];
 
return length + 1;
}
 
 
 
int
decode_key (struct session_struct *session, int key, int extra, char *block)
{
#define SETBLOCK(STR) { strcpy (block, STR); return sizeof(STR)-1; }
int ekey = extra >> 16;
#define APPLI(TRUE,FALSE) \
((session->other_session_flags & NETTLE_OTHER_APPLI_MODE) ? TRUE : FALSE)
 
switch (key)
{
case 0x008: /* Backspace */
if (ekey == 30 && (session->other_session_flags & NETTLE_OTHER_BACKSPACE_MODE))
{
SETBLOCK ("\x7F");
}
else
{
SETBLOCK ("\b");
}
case 0x00D: /* Return */
if (ekey == 103 &&
(((session->other_session_flags & NETTLE_OTHER_APPLI_MODE) != 0) ^
((extra & 0x3) != 0)))
{
SETBLOCK ("\x1BOM"); /* Enter */
}
/* Leaving this as it is for now - it's more likely to break things if we change it */
/* now IMO - leave it til post 1st Sep */
#ifdef KEYBOARD_RETURN_BODGE
else if (session->other_session_flags & NETTLE_OTHER_LINEFEED_MODE)
{
SETBLOCK ("\r\n");
}
else
{
SETBLOCK ("\r");
}
#else
else if (session->connection_type == NETTLE_TASKWINDOW ||
session->connection_type == NETTLE_RLOGIN ||
session->connection_type == NETTLE_SSH)
{
SETBLOCK ("\r");
}
else if (session->other_session_flags & NETTLE_OTHER_LINEFEED_MODE)
{
SETBLOCK ("\r\n\n");
}
else
{
SETBLOCK ("\r\n");
}
#endif
case 0x01E: /* Home */
if (ekey != 32)
{
SETBLOCK ("\x1E");
}
else
{
return setmod (block, "\x1B[1", extra);
}
case 0x07F: /* Delete */
if (session->other_session_flags & NETTLE_OTHER_BACKSPACE_MODE)
{
return setmod (block, "\x1B[3", extra);
}
else
{
SETBLOCK ("\x7F");
}
 
case 0x181: /* F1 */
SETBLOCK ("\x1BOP");
case 0x182: /* F2 */
SETBLOCK ("\x1BOQ");
case 0x183: /* F3 */
SETBLOCK ("\x1BOR");
case 0x184: /* F4 */
SETBLOCK ("\x1BOS");
case 0x185: /* F5 */
SETBLOCK ("\x1B[15~");
case 0x186: /* F6 */
SETBLOCK ("\x1B[17~");
case 0x187: /* F7 */
SETBLOCK ("\x1B[18~");
case 0x188: /* F8 */
SETBLOCK ("\x1B[19~");
case 0x189: /* F9 */
SETBLOCK ("\x1B[20~");
case 0x18A: /* Tab */
SETBLOCK ("\t");
case 0x18B: /* Copy */
SETBLOCK ("\x1B[4~");
case 0x18C: /* Left */
SETBLOCK (APPLI ("\x1BOD", "\x1B[D"));
case 0x18D: /* Right */
SETBLOCK (APPLI ("\x1BOC", "\x1B[C"));
case 0x18E: /* Down, sPageDown */
if (ekey == 54)
{
scroll_term (session, -1);
break;
}
SETBLOCK (APPLI ("\x1BOB", "\x1B[B"));
case 0x18F: /* Up, sPageUp */
if (ekey == 33)
{
scroll_term (session, 1);
break;
}
SETBLOCK (APPLI ("\x1BOA", "\x1B[A"));
case 0x191: /* sF1 */
SETBLOCK ("\x1B[23~");
case 0x192: /* sF2 */
SETBLOCK ("\x1B[24~");
case 0x193: /* sF3 */
SETBLOCK ("\x1B[25~");
case 0x194: /* sF4 */
SETBLOCK ("\x1B[26~");
case 0x195: /* sF5 */
SETBLOCK ("\x1B[28~");
case 0x196: /* sF6 */
SETBLOCK ("\x1B[29~");
case 0x197: /* sF7 */
SETBLOCK ("\x1B[31~");
case 0x198: /* sF8 */
SETBLOCK ("\x1B[32~");
case 0x199: /* sF9 */
SETBLOCK ("\x1B[33~");
case 0x19A: /* sTab */
SETBLOCK ("\x1B[Z");
case 0x19B: /* sCopy */
SETBLOCK ("\x1B[4$");
case 0x19C: /* sLeft */
SETBLOCK (APPLI ("\x1BOd", "\x1B[d"));
case 0x19D: /* sRight */
SETBLOCK (APPLI ("\x1BOc", "\x1B[c"));
case 0x19E: /* PgDown, sDown */
if (ekey == 99)
{
SETBLOCK (APPLI ("\x1BOb", "\x1B[b"))
}
else
{
SETBLOCK ("\x1B[6~")
}
case 0x19F: /* PgUp, sUp */
if (ekey == 89)
{
SETBLOCK (APPLI ("\x1BOa", "\x1B[a"))
}
else
{
SETBLOCK ("\x1B[5~")
}
 
case 0x1A1: /* cF1 */
SETBLOCK ("\x1B[11^");
case 0x1A2: /* cF2 */
SETBLOCK ("\x1B[12^");
case 0x1A3: /* cF3 */
SETBLOCK ("\x1B[13^");
case 0x1A4: /* cF4 */
SETBLOCK ("\x1B[14^");
case 0x1A5: /* cF5 */
SETBLOCK ("\x1B[15^");
case 0x1A6: /* cF6 */
SETBLOCK ("\x1B[17^");
case 0x1A7: /* cF7 */
SETBLOCK ("\x1B[18^");
case 0x1A8: /* cF8 */
SETBLOCK ("\x1B[19^");
case 0x1A9: /* cF9 */
SETBLOCK ("\x1B[20^");
case 0x1AA: /* cTab */
SETBLOCK ("\t");
case 0x1AB: /* cCopy */
SETBLOCK ("\x1B[4^");
case 0x1AC: /* cLeft */
SETBLOCK (APPLI ("\x1B[d", "\x1BOd"));
case 0x1AD: /* cRight */
SETBLOCK (APPLI ("\x1B[c", "\x1BOc"));
case 0x1AE: /* scPgDown, cDown */
if (ekey == 99)
{
SETBLOCK (APPLI ("\x1B[b", "\x1BOb"));
}
else
{
SETBLOCK ("\x1B[6@");
}
case 0x1AF: /* scPgUp, cUp */
if (ekey == 89)
{
SETBLOCK (APPLI ("\x1B[a", "\x1BOa"));
}
else
{
SETBLOCK ("\x1B[5@");
};
 
case 0x1B1: /* csF1 */
SETBLOCK ("\x1B[23^");
case 0x1B2: /* csF2 */
SETBLOCK ("\x1B[24^");
case 0x1B3: /* csF3 */
SETBLOCK ("\x1B[25^");
case 0x1B4: /* csF4 */
SETBLOCK ("\x1B[26^");
case 0x1B5: /* csF5 */
SETBLOCK ("\x1B[28^");
case 0x1B6: /* csF6 */
SETBLOCK ("\x1B[29^");
case 0x1B7: /* csF7 */
SETBLOCK ("\x1B[31^");
case 0x1B8: /* csF8 */
SETBLOCK ("\x1B[32^");
case 0x1B9: /* csF9 */
SETBLOCK ("\x1B[33~");
case 0x1BA: /* csTab */
SETBLOCK ("\x1B[Z");
case 0x1BB: /* csCopy */
SETBLOCK ("\x1B[4@");
case 0x1BC: /* scLeft */
SETBLOCK (APPLI ("\x1B[d", "\x1BOd"));
case 0x1BD: /* scRight */
SETBLOCK (APPLI ("\x1B[c", "\x1BOc"));
case 0x1BE: /* cPgDown, scDown */
if (ekey == 99)
{
SETBLOCK (APPLI ("\x1BOb", "\x1B[b"));
}
else
{
SETBLOCK ("\x1B[6^");
}
case 0x1BF: /* cPgUp, scUp */
if (ekey == 89)
{
SETBLOCK (APPLI ("\x1BOa", "\x1B[a"));
}
else
{
SETBLOCK ("\x1B[5^");
}
 
case 0x1CA: /* F10 */
SETBLOCK ("\x1B[21~");
case 0x1CB: /* F11 */
SETBLOCK ("\x1B[23~");
case 0x1CC: /* F12 */
SETBLOCK ("\x1B[24~");
case 0x1CD: /* Insert */
SETBLOCK ("\x1B[2~");
 
case 0x1DA: /* sF10 */
SETBLOCK ("\x1B[34~");
case 0x1DB: /* sF11 */
SETBLOCK ("\x1B[23~");
case 0x1DC: /* sF12 */
SETBLOCK ("\x1B[24~");
 
case 0x1EA: /* cF10 */
SETBLOCK ("\x1B[21^");
case 0x1EB: /* cF11 */
SETBLOCK ("\x1B[23^");
case 0x1EC: /* cF12 */
SETBLOCK ("\x1B[24^");
case 0x1ED: /* cInsert */
SETBLOCK ("\x1B[2^");
 
case 0x1FA: /* csF10 */
SETBLOCK ("\x1B[34^");
case 0x1FB: /* csF11 */
SETBLOCK ("\x1B[23^");
case 0x1FC: /* csF12 */
SETBLOCK ("\x1B[24^");
case 0x1FD: /* csInsert */
SETBLOCK ("\x1B[2@");
 
default:
if (((session->other_session_flags & NETTLE_OTHER_APPLI_MODE) != 0) ^
((extra & 0x3) != 0))
/* application keypad *eor* Shift pressed */
switch (key)
{
case '0': /* keypad 0 */
if (ekey == 101)
SETBLOCK ("\x1BOp");
break;
case '1': /* keypad 1 */
if (ekey == 90)
SETBLOCK ("\x1BOq");
break;
case '2': /* keypad 2 */
if (ekey == 91)
SETBLOCK ("\x1BOr");
break;
case '3': /* keypad 3 */
if (ekey == 92)
SETBLOCK ("\x1BOs");
break;
case '4': /* keypad 4 */
if (ekey == 72)
SETBLOCK ("\x1BOt");
break;
case '5': /* keypad 5 */
if (ekey == 73)
SETBLOCK ("\x1BOu");
break;
case '6': /* keypad 6 */
if (ekey == 74)
SETBLOCK ("\x1BOv");
break;
case '7': /* keypad 7 */
if (ekey == 55)
SETBLOCK ("\x1BOw");
break;
case '8': /* keypad 8 */
if (ekey == 56)
SETBLOCK ("\x1BOx");
break;
case '9': /* keypad 9 */
if (ekey == 57)
SETBLOCK ("\x1BOy");
break;
case '+': /* keypad + */
if (ekey == 75)
SETBLOCK ("\x1BOl"); /* should be on ','... */
break;
case '-': /* keypad - */
if (ekey == 58)
SETBLOCK ("\x1BOm");
break;
case '.': /* keypad . */
if (ekey == 102)
SETBLOCK ("\x1BOn");
break;
case 0x0D: /* Enter */
if (ekey == 57)
SETBLOCK ("\x1BOM");
break;
}
if (key < 0x100)
{
sprintf (block, "%c", key);
return 1;
}
}
return 0;
}
/vendor/v0.2023/misc.h
New file
0,0 → 1,61
/**
* Nettle miscellaneous code headers
* (C) Nettle Developers 2001-2002
*
* $Id: misc,v 1.20 2002/03/18 01:47:55 ijeffray Exp $
*/
 
#ifndef MISC_H
#define MISC_H
 
#include <string.h>
 
char *get_system_variable(char *, const char *, int);
int binary(const char *);
int instr(const char *, const char *);
int esc_instr(const char *, const char *, int);
void misc_zero_terminate_ctrl_string(char *);
char *read_mem(char *, const char *, int);
void log_string(const char *);
void log_byte(char);
void close_log(bool force);
void create_log(void);
char *get_country(char *, int);
bool dynamic_areas_available(void);
void misc_setfiletype(const char *filename, int type);
 
#ifndef __UNIXLIB_TYPES_H
char *strdup(const char *s);
#endif
 
 
/**
* printf like function for writing to the log file
*
* @param format printf() style format string
* @param ... parameters matching format string
*/
void log_f(const char */*format*/, ...);
 
 
 
/**
* misc_string_lower takes a string and lower-cases it
*
* @param s string to be converted
*
* @return converted string
*/
char *misc_string_lower(char */*string*/);
 
 
/**
* misc_string_upper takes a string and upper-cases it
*
* @param s string to be converted
*
* @return converted string
*/
char *misc_string_upper(char */*string*/);
 
#endif /* MISC_H */
/vendor/v0.2023/options.h
New file
0,0 → 1,54
/*******************************************************************
* File: options
* Purpose: Configuration and optional bits and pieces
* Author: Justin Fletcher
* Date: 04 Jul 2002
******************************************************************/
 
#ifndef OPTIONS_H
#define OPTIONS_H
 
/* Here we define what the options are for this build of Nettle.
We do so through these defines so that the code can remain in place
and we can see things that we've tried in the past and did not
work (or did), with their annotations.
 
EXP_* options are experimental features.
*/
 
/* Visual bell is currently experimental and we have turned it off to
ensure that it isn't confusion.
Work needed:
1) User interface to enable it.
*/
/* #define EXP_VISUAL_BELL */
 
 
/* Taskwindow warping was a very experimental feature added for Daniel
Ellis to indicate how VduVariables might be propogated to a taskwindow
such that it was aware of its size.
Work needed:
1) Removing if we're not keeping it; it's very evil
*/
/* #define EXP_TASKWINDOW_WARPING */
 
/* The Scrollbars option controls whether the DEC scrollbar control is
allowed or not. There is no user interface component so you're most
likely left with no choice but to close and restart the connection
if the scrollbars are turned off without you wanting them off.
Work needed:
1) UI to re-enable the scrollbars
2) Forced Scroll to cursor when scrollbars removed to ensure that
the cursor is always visible.
*/
/* #define EXP_SCROLLBARS */
 
/* The Protocol menu is an experimental feature which will be expanded into
a more generic menu at some future date. At present it causes failures
on non-Telnet mode because only Telnet it supported at present.
Work needed:
1) Abstract menu creation/entries, allowing callbacks for entries ?
*/
/* #define EXP_PROTOCOL_MENU */
 
#endif
/vendor/v0.2023/init.c
New file
0,0 → 1,278
/**
* Initialisation code
* (C) Nettle developers 2000-2001
*
* $Id: init,v 1.55 2002/02/10 15:44:09 ijeffray Exp $
*/
 
#include "generic.h"
#include "globals.h"
 
#include "choices.h"
#include "hotlist.h"
#include "init.h"
#include "messages.h"
#include "misc.h"
#include "nettle.h"
#include "scripts.h"
#include "quit.h"
#include "sockwatch.h"
#include "templ.h"
#include "timers.h"
#include "url.h"
#include "wimp.h"
#include "wimputil.h"
#include "zapredraw.h"
 
#define MAX_TEMPLATES 14
#define LOAD_TEMPLATE_NO_FONTS (int *)(-1)
#define LOAD_TEMPLATE_WIMP_SPRITE_AREA (struct os_spriteop_area *)(1)
 
static int zapredraw_block[128];
static int maxindirected=0;
static int *indirected[MAX_TEMPLATES];
 
static void initialise_wimp(void)
{
static const int messages[] =
{
WIMP_MESSAGE_DATASAVE,
WIMP_MESSAGE_DATASAVEACK,
WIMP_MESSAGE_DATALOAD,
WIMP_MESSAGE_DATALOADACK,
WIMP_MESSAGE_PREQUIT,
WIMP_MESSAGE_CLIP_CLAIMENTITY,
WIMP_MESSAGE_CLIP_DATAREQUEST,
WIMP_MESSAGE_MENUWARNING,
WIMP_MESSAGE_MODECHANGE,
WIMP_MESSAGE_MENUSDELETED,
WIMP_MESSAGE_WINDOWINFO,
COLOURPICKER_COLOUR_CHOICE,
COLOURPICKER_CLOSE_REQUEST,
WIMP_MESSAGE_TASKWINDOW_OUTPUT,
WIMP_MESSAGE_TASKWINDOW_EGO,
WIMP_MESSAGE_TASKWINDOW_MORIO,
URI_MProcess,
URI_MReturnResult,
Wimp_MOpenUrl,
WIMP_MESSAGE_QUIT /* must be last! */
};
 
_swi(Wimp_Initialise, _INR(0,3)|_OUTR(0,1), 310, MAGIC_TASK,
application_name, messages, &wimp_version, &task_handle);
}
 
static void open_template(void)
{
char country[16];
char template_filename[1024];
FILE *file_handle;
 
/* Again, set country to UK if we don't know */
if (strlen(get_country(country, sizeof(country)))==0)
strcpy(country,"UK");
 
/* Put together filename */
sprintf(template_filename,"<%s$Dir>.Resources.%s",application_name,country);
 
/* append filename */
strcat(template_filename,".Templates");
 
file_handle=fopen(template_filename,"r");
 
/* If we fail to open, change to UK */
if (file_handle==0)
{
strcpy(country,"UK");
}
else
{
fclose(file_handle);
}
 
/* Put together filename */
sprintf(template_filename,"<%s$Dir>.Resources.%s",application_name,country);
 
/* append filename */
strcat(template_filename,".Templates");
 
file_handle=fopen(template_filename,"r");
 
/* this time, if we fail to open, moan about lack of templates and quit */
if (file_handle==0)
{
generror("NoTemplates", true);
closedown_application();
}
else
{
fclose(file_handle);
}
 
_swi(Wimp_OpenTemplate, _IN(1), template_filename);
}
 
 
static int load_template(int *font_array, const char *window_name, struct os_spriteop_area *templ_sprite, int furniture)
{
char window_name_copy[12];
struct wimp_createwindow_block *template_data;
int *indirected_data;
int size_of_template_data;
int size_of_indirected_data;
int window_handle;
 
assert(maxindirected<MAX_TEMPLATES);
 
/* template name must be in a writable 12-byte buffer */
strcpy(window_name_copy, window_name);
 
/* get sizes of template data and indirected_data */
_swi(Wimp_LoadTemplate, _IN(1)|_INR(5,6)|_OUTR(1,2), 0, window_name_copy,
0, &size_of_template_data, &size_of_indirected_data);
 
/* alloc this amount, indirected first to be heap friendly */
indirected_data=malloc(size_of_indirected_data);
assert(indirected_data != NULL);
 
template_data=malloc(size_of_template_data);
assert(template_data != NULL);
 
indirected[maxindirected++]=indirected_data;
 
/* load the template */
_swi(Wimp_LoadTemplate, _INR(1,6), template_data, indirected_data,
indirected_data+size_of_indirected_data, font_array, window_name_copy,
0);
 
/* set the sprite area pointer */
template_data->sprite_area=templ_sprite;
 
/* Need to set a bit to mark a window as furniture */
/* This might not be preserved by a template editor, so do it here! */
if (furniture)
template_data->window_flags |= (1<<23);
 
window_handle = _swi(Wimp_CreateWindow, _IN(1)|_RETURN(0), template_data);
 
/* free the template data (indirected is still needed) */
free(template_data);
 
return window_handle;
}
 
 
static void close_template(void)
{
_swi(Wimp_CloseTemplate, 0);
}
 
 
void lose_templates(void)
{
int i;
for(i=0; i<maxindirected; i++)
free(indirected[i]);
}
 
static void load_templates(void)
{
char info_data[60];
 
/* open the templates file */
open_template();
 
/* read template definitions */
win_info=load_template(LOAD_TEMPLATE_NO_FONTS,"info",LOAD_TEMPLATE_WIMP_SPRITE_AREA, 0);
set_icon_data(win_info,icon_info_name,lookup("AppName", info_data, sizeof(info_data)));
set_icon_data(win_info,icon_info_author,lookup("AppAuthor", info_data, sizeof(info_data)));
set_icon_data(win_info,icon_info_version,lookup("AppVersion", info_data, sizeof(info_data)));
set_icon_data(win_info,icon_info_purpose,lookup("AppPurpose", info_data, sizeof(info_data)));
 
win_choices=load_template(LOAD_TEMPLATE_NO_FONTS,"choices",LOAD_TEMPLATE_WIMP_SPRITE_AREA, 0);
win_paneterm=load_template(LOAD_TEMPLATE_NO_FONTS,"paneterm",LOAD_TEMPLATE_WIMP_SPRITE_AREA, 0);
win_panecols=load_template(LOAD_TEMPLATE_NO_FONTS,"panecols",LOAD_TEMPLATE_WIMP_SPRITE_AREA, 0);
win_panehot=load_template(LOAD_TEMPLATE_NO_FONTS,"panehot",LOAD_TEMPLATE_WIMP_SPRITE_AREA, 0);
win_hotpane=load_template(LOAD_TEMPLATE_NO_FONTS,"hotpane",LOAD_TEMPLATE_WIMP_SPRITE_AREA, 0);
win_hotedit=load_template(LOAD_TEMPLATE_NO_FONTS,"hotedit",LOAD_TEMPLATE_WIMP_SPRITE_AREA, 0);
win_panemisc=load_template(LOAD_TEMPLATE_NO_FONTS,"panemisc",LOAD_TEMPLATE_WIMP_SPRITE_AREA, 0);
 
win_open=load_template(LOAD_TEMPLATE_NO_FONTS,"open",LOAD_TEMPLATE_WIMP_SPRITE_AREA, 0);
set_icon_data(win_open,icon_open_contype,lookup("Telnet", info_data, sizeof(info_data)));
 
win_resize=load_template(LOAD_TEMPLATE_NO_FONTS,"resize",LOAD_TEMPLATE_WIMP_SPRITE_AREA, 0);
win_sizebar=load_template(LOAD_TEMPLATE_NO_FONTS,"sizebar",LOAD_TEMPLATE_WIMP_SPRITE_AREA, 1);
 
win_save=load_template(LOAD_TEMPLATE_NO_FONTS,"save",LOAD_TEMPLATE_WIMP_SPRITE_AREA, 0);
win_spoolsave=load_template(LOAD_TEMPLATE_NO_FONTS,"spoolsave",LOAD_TEMPLATE_WIMP_SPRITE_AREA, 0);
 
/* close the templates file */
close_template();
}
 
 
static void load_zap_fonts(void)
{
redraw.r_workarea=zapredraw_block;
 
/* load in hires and lores zap fonts */
zap_font_area=load_font(zap_font);
zap_lowres_font_area=load_font(zap_lowres_font);
 
/* do mode_change to set things up */
mode_change();
}
 
 
static void create_icon_bar_icon(void)
{
struct wimp_createicon_block block;
 
block.window_handle=-1; /* window handle */
block.min.x =0; /* min x */
block.min.y =0; /* min y */
block.max.x =68; /* max x */
block.max.y =68; /* max y */
block.icon_flags =WIMP_ICON_BGCOL(1) | WIMP_ICON_FGCOL(7) | WIMP_ICON_TYPE(3) | \
WIMP_ICON_VCENT_BIT | WIMP_ICON_HCENT_BIT | WIMP_ICON_SPRITE_BIT ;
 
strcpy(block.contents.t.text, application_icon_name);
 
iconbar_handle=_swi(Wimp_CreateIcon, _IN(1)|_RETURN(0), &block);
}
 
 
void initialise_application(void)
{
#ifdef FORTIFY
Fortify_EnterScope();
#endif
 
/* Turn on hourglass */
_swi(Hourglass_On, 0);
 
/* Initialise application */
initialise_wimp();
 
/* load things in */
load_messages();
load_choices();
load_hotlist();
load_scripts();
load_templates();
load_zap_fonts();
 
create_log();
 
/* create the iconbar icon */
create_icon_bar_icon();
 
/* Set up the timer interface */
timer_init();
 
socketwatch_initialise();
 
/* Turn off hourglass */
_swi(Hourglass_Off, 0);
 
}
/vendor/v0.2023/keyboard.h
New file
0,0 → 1,18
/**
* Keyboard translation code
* (C) Nettle developers 2000-2001
*
* $Id: keyboard,v 1.4 2002/01/08 13:39:16 archifishal Exp $
*/
 
#ifndef KEYBOARD_H
#define KEYBOARD_H
 
#define KEYBOARD_SHIFT -1
#define KEYBOARD_CTRL -2
#define KEYBOARD_META -3
 
bool inkey (int key);
int decode_key (struct session_struct *, int key, int extra, char *block);
 
#endif
/vendor/v0.2023/init.h
New file
0,0 → 1,14
/**
* Nettle initialisation code headers
* (C) Nettle developers 2000-2001
*
* $Id: init,v 1.8 2001/08/14 13:12:20 ijeffray Exp $
*/
 
#ifndef INIT_H
#define INIT_H
 
extern void initialise_application(void);
extern void lose_templates(void);
 
#endif /* INIT_H */
/vendor/v0.2023/p_taskwindow.c
New file
0,0 → 1,234
/**
* Protocol TaskWindow specific support code
* (C) Nettle developers 2002
*
* $Id$
*/
 
#include "generic.h"
#include "globals.h"
#include "messages.h"
#include "wimputil.h"
#include "p_taskwindow.h"
 
/* #define INSECURE_STUFF */
 
/* Prototypes */
char *taskwindow_session_setup(struct session_struct *);
char *taskwindow_session_shutdown(struct session_struct *);
 
protocol_t protocol_taskwindow = {
"task", /* Protocol name in Choices file */
"snettle_task", /* Sprite to use to indicate this protocol */
"Taskwindow", /* Token for this protocol name in messages file */
#ifdef INSECURE_STUFF
"ansitaskwindow:", /* URI scheme prefix (non-standard) */
#else
NULL, /* URI scheme prefix, or NULL if none */
#endif
-1, /* Default port, or -1 if no port */
NETTLE_TASKWINDOW, /* Protocol type number */
 
/* Protocol flags */
PROTOCOL_HAS_COMMAND,
 
taskwindow_session_setup,
taskwindow_session_shutdown,
NULL /* Default URL handler */
};
 
/* JRF: When defined, this will use the experimental size tracking module
to control the size of taskwindows - we leave it off for now because
this module is... well, crap */
/* #define TASKWINDOW_WARPING */
 
/*************************************************** Gerph *********
Function: taskwindow_message
Description: Handle wimp messages directly related to taskwindow
protocol
Parameters: wimp_block-> message block to process
Returns: true if handled, false if not handled
******************************************************************/
bool taskwindow_message(union wimp_poll_block *wimp_block)
{
int message_number = wimp_block->user_message.message_code;
int sender_ref = wimp_block->user_message.sender_ref;
 
switch (message_number)
{
case WIMP_MESSAGE_TASKWINDOW_OUTPUT:
{
struct session_struct *session = sessions;
 
while (session && session->socket_handle != sender_ref) {
session = session->next;
}
 
if (session)
{
write_out_data(session,
wimp_block->user_message.contents.task_window_output.data,
wimp_block->user_message.contents.task_window_output.size);
/* JRF: Why do we ack the output message ?
SH says we should; the PRMs say no such thing */
wimp_block->user_message.my_ref=wimp_block->user_message.your_ref;
 
_swi(Wimp_SendMessage, _INR(0,2), 19, wimp_block, sender_ref);
 
return true;
}
}
break;
 
case WIMP_MESSAGE_TASKWINDOW_EGO:
{
struct session_struct *session = sessions;
int txt_handle = wimp_block->user_message.contents.task_window_ego.txt_handle;
 
while (session && session != (struct session_struct *) txt_handle) {
session = session->next;
}
 
if (session)
{
char string[256];
 
sprintf(string, "Nettle/%s (%s)", terminal_name[session->terminal_type],
lookup_static("Taskwindow"));
 
session->socket_state = NETTLE_SESSION_CONNECTED;
session->socket_handle = sender_ref;
set_title_bar (session->window_handle, string);
 
return true;
}
}
break;
 
case WIMP_MESSAGE_TASKWINDOW_MORIO:
{
struct session_struct *session = sessions;
 
while (session && session->socket_handle != sender_ref)
{
session = session->next;
}
 
if (session)
{
set_title_bar (session->window_handle, lookup_static ("title_closed"));
close_session(session);
reset_terminal (session);
write_out_strings (session, "\r\n", lookup_static ("twclosed"), "\r\n", 0);
 
return true;
}
}
break;
}
 
/* If we got to here, we didn't handle it */
return false;
}
 
/*************************************************** Gerph *********
Function: taskwindow_senddata
Description: Send data on to the taskwindow
Parameters: session-> the session we're processing
data-> the data to send
length-> the length to send
Returns: length sent
******************************************************************/
int taskwindow_senddata(struct session_struct *session,
const char *data, int length)
{
/* send a WIMP message */
union wimp_poll_block block;
int copy = (length > 63) ? 63 : length;
 
memcpy (block.user_message.contents.task_window_input.data, data, copy);
 
block.user_message.length =(28+copy) & ~3;
block.user_message.my_ref =0;
block.user_message.message_code =WIMP_MESSAGE_TASKWINDOW_INPUT;
block.user_message.contents.task_window_input.size=length;
 
_swi(Wimp_SendMessage, _INR(0,2), 17, &block, session->socket_handle);
 
return copy;
}
 
/*************************************************** Gerph *********
Function: taskwindow_resized
Description: Window has been resized; we need to inform the remote
end of this fact
Parameters: session-> the session that has changed (new size in
terminal_size)
old_size = the old size coord structure, in case it
is needed
Returns: none
******************************************************************/
void taskwindow_resized(struct session_struct *session,
struct coords old_size)
{
#ifdef TASKWINDOW_WARPING
#define TaskWindow_SetVDUVariables (0x500)
int pairs[] = {
0,(1<<0), /* non-graphics mode */
1,0, /* width-1 */
2,0, /* height-1 */
0x100,0, /* width */
0x101,0, /* height */
0x84,0, /* text window left */
0x85,0, /* text window bottom */
0x86,0, /* text window right */
0x87,0, /* text window top */
-1,0 /* terminator */
};
pairs[1+2*1]=session->terminal_size.x-1;
pairs[1+2*2]=session->terminal_size.y-1;
pairs[1+2*3]=session->terminal_size.x;
pairs[1+2*4]=session->terminal_size.y;
pairs[1+2*5]=0;
pairs[1+2*6]=session->terminal_size.y-1;
pairs[1+2*7]=session->terminal_size.x-1;
pairs[1+2*8]=0;
_swix(TaskWindow_SetVDUVariables,_INR(0,1),pairs,session->socket_handle);
 
#else
char temp_string[16];
sprintf(temp_string, "%d", session->terminal_size.y);
_swi(OS_SetVarVal, _INR(0,4), "LINES", temp_string, strlen(temp_string), 0, 4);
sprintf(temp_string, "%d", session->terminal_size.x);
_swi(OS_SetVarVal, _INR(0,4), "COLUMNS", temp_string, strlen(temp_string), 0, 4);
#endif
}
 
/*************************************************** Gerph *********
Function: taskwindow_session_setup
Description: Set up a protocol session
Parameters: session-> the session we're constructing
Returns: pointer to token to return as an error, or NULL if none
******************************************************************/
char *taskwindow_session_setup(struct session_struct *session)
{
session->session_data = write_out_data;
session->session_connected = NULL; /* No negotiation on connect */
session->session_resolved = NULL; /* No options on resolve */
session->session_send = taskwindow_senddata;
session->session_resized = taskwindow_resized;
 
/* Most of the main creation code should be here */
return NULL;
}
 
/*************************************************** Gerph *********
Function: taskwindow_session_shutdown
Description: Shut down a protocol session
Parameters: session-> the session we're constructing
Returns: pointer to token to return as an error, or NULL if none
******************************************************************/
char *taskwindow_session_shutdown(struct session_struct *session)
{
return NULL;
}
/vendor/v0.2023/wimputil.c
New file
0,0 → 1,758
/**
* Wimp Utility functions (reasonably app-generic stuff)
* (C) Nettle developers 2000-2001
*
* $Id: wimputil,v 1.11 2002/03/18 01:57:04 ijeffray Exp $
*/
 
#include "sys/errno.h"
#include <stdarg.h>
 
#include "generic.h"
#include "globals.h"
 
#include "misc.h"
#include "wimp.h"
#include "wimputil.h"
 
bool win_is_open(int window_handle)
{
struct wimp_getwindowstate_block window;
 
window.window_handle=window_handle;
_swi(Wimp_GetWindowState, _IN(1), &window);
 
if (window.window_flags & (1<<16))
return true;
 
return false;
}
 
void closedown_wimp(void)
{
/* JRF: Strictly, it isn't necessary to give the wimp our handle */
_swi(Wimp_CloseDown, _INR(0,1), task_handle, MAGIC_TASK);
}
 
void generror(const char *string, bool is_message)
{
char message[252];
struct wimp_reporterror_block block;
 
if (is_message)
string = lookup(string, message, sizeof(message));
 
block.errnum=255;
 
strcpy(block.errmess, string);
 
_swi(Wimp_ReportError, _INR(0,2), &block, 0, application_name);
}
 
 
 
/*
* Description: Ask a question of the user, providing a pair of
* buttons. The first button should be the 'yes' button
* and the second button the 'no' button.
* Parameters: formattok-> the TOKEN in the messages file for the
* query as a formatted string; ensure that
* its parameters match those of the caller
* buttonstok-> the TOKEN in messages file that gives
* a comma separated list of buttons -
* params = number of variable parameters to substitute
* Returns: true if 'yes' pressed; false otherwise
*/
bool generror_question(const char *buttonstok,const char *formattok,int params,...)
{
va_list va;
int button;
struct wimp_reporterror_block block;
 
block.errnum=255;
 
va_start(va,params);
strcpy(block.errmess, lookup_static_sub(formattok, params, va) );
va_end(va);
 
if (wimp_version < 350)
{
button = _swi(Wimp_ReportError, _INR(0,2)|_RETURN(1),
&block,
(1<<1) | (1<<0),
application_name);
}
else
{
button = _swi(Wimp_ReportError, _INR(0,5)|_RETURN(1),
&block,
(1<<8) | (4<<9),
application_name,
application_icon_name,
1,
lookup_inbuffer(buttonstok));
}
return (button == 1) || (button == 3) ? true : false;
}
 
void gensaveerror (FILE *file_handle, const char *msg)
{
bool error = true;
char string[512];
 
while (error)
{
/* An error - report it */
_kernel_oserror *err = _kernel_last_oserror ();
 
if (msg)
{
lookup (msg, string, 256);
strcat (string, err ? err->errmess : strerror(errno));
}
else
strcpy (string, err ? err->errmess : strerror(errno));
string[251] = '\0'; /* Terminate to fit error block (just in case it went further) */
 
generror (string, false);
 
error = false;
 
if (file_handle)
{
if (fclose (file_handle))
error=true; /* Possible second I/O error */
 
file_handle=NULL;
}
}
}
 
 
 
void set_icon_state (int window_handle, int icon_handle, int eor, int clear)
{
struct wimp_seticonstate_block icon_set;
 
icon_set.window_handle = window_handle;
icon_set.icon_handle = icon_handle;
icon_set.eor = eor;
icon_set.clear = clear;
 
_swi (Wimp_SetIconState, _IN(1), &icon_set);
}
 
 
void set_icon_data(int window_handle, int icon_handle, const char *contents)
{
struct wimp_geticonstate_block block;
 
block.window_handle=window_handle;
block.icon_handle =icon_handle;
 
_swi(Wimp_GetIconState, _IN(1), &block);
 
if (block.icon_flags & WIMP_ICON_INDIRECTED_BIT)
{
if (strcmp(block.contents.it.text, contents) != 0)
{
strcpy(block.contents.it.text, contents);
 
set_icon_state(window_handle, icon_handle, 0, 0);
check_set_caret_position(window_handle, icon_handle);
}
}
else
{
char string[6];
sprintf(string,"Icon %d in window %X is not indirected.",icon_handle,window_handle);
generror(string, false);
}
}
 
 
 
char *read_icon_data(int window_handle, int icon_handle, char *buffer, int buf_len)
{
struct wimp_geticonstate_block block;
 
block.window_handle = window_handle;
block.icon_handle = icon_handle;
 
_swi(Wimp_GetIconState, _IN(1), &block);
 
if (block.icon_flags & WIMP_ICON_INDIRECTED_BIT)
{
read_mem(buffer, block.contents.it.text, buf_len);
}
else
{
int len = (buf_len > 12) ? 12 : (buf_len - 1);
assert (len >= 0);
memcpy (buffer, block.contents.t.text, len);
buffer[len] = '\0';
while (--len >= 0)
if (buffer[len] < 32)
buffer[len] = '\0';
}
return buffer;
}
 
 
 
int get_icon_data_length(int window_handle, int icon_handle)
{
struct wimp_geticonstate_block block;
int length = 0;
 
block.window_handle = window_handle;
block.icon_handle = icon_handle;
 
_swi(Wimp_GetIconState, _IN(1), &block);
 
if (block.icon_flags & WIMP_ICON_INDIRECTED_BIT)
{
char *data = block.contents.it.text;
 
while (*data != '\0' && *data != '\x0d' && *data != '\x0a') {
length++;
data++;
}
}
else
{
char string[64];
sprintf(string,"Icon %d in window %X is not indirected.",icon_handle,window_handle);
generror(string, false);
}
return length;
}
 
 
char *get_icon_validation (int window_handle, int icon_handle)
{
struct wimp_geticonstate_block block;
 
block.window_handle = window_handle;
block.icon_handle = icon_handle;
_swi (Wimp_GetIconState, _IN(1), &block);
 
if ((block.icon_flags & WIMP_ICON_INDIRECTED_BIT) == 0)
{
char string[64];
sprintf(string,"Icon %d in window %X is not indirected.",icon_handle,window_handle);
generror(string, false);
return 0;
}
 
if ((block.icon_flags & WIMP_ICON_TEXT_BIT) == 0 ||
block.contents.it.validation == 0 ||
block.contents.it.validation == (char *)-1)
{
char string[64];
sprintf(string,"Icon %d in window %X has no validation string.",icon_handle,window_handle);
generror(string, false);
return 0;
}
 
return block.contents.it.validation;
}
 
bool read_icon_ticked (int window_handle, int icon_handle)
{
struct wimp_geticonstate_block block;
 
block.window_handle = window_handle;
block.icon_handle = icon_handle;
_swi (Wimp_GetIconState, _IN(1), &block);
 
return (block.icon_flags & WIMP_ICON_SELECTED_BIT) ? true : false;
}
 
 
 
/* Create menu code */
 
int *create_menu(int *menu_defn, char *indirected, char *title, char *entries, ... )
{
va_list args;
int window_handle;
char *item;
bool last_item=false;
int position=7;
char *pos;
int menu_flags = 0;
 
if (strlen(title)<12)
{
strcpy((char *)menu_defn, title);
}
else
{
int length = strlen (title);
 
if (indirected==0)
{
generror("Some fool didn't set indirected to something sane on entry to create_menu. "
"Bloody coders. Nettle will probably crash now.", false);
}
else
{
strcpy (indirected, title);
menu_defn[0] = (int) indirected;
menu_defn[1] = (int) indirected + length;
menu_defn[2] = length + 1;
indirected += length + 1;
 
menu_flags = 1 << 8; /* indirected menu title */
}
}
 
menu_defn[3]=(7<<0)+(2<<8)+(7<<16)+(0<<24); /* black on white items, black on grey title text */
menu_defn[4]=0;
menu_defn[5]=44;
menu_defn[6]=0;
 
va_start(args, entries);
 
item=entries;
 
while (!last_item)
{
int icon_flags = WIMP_ICON_FGCOL(7) | WIMP_ICON_VCENT_BIT |
WIMP_ICON_FILLED_BIT | WIMP_ICON_TEXT_BIT;
/* menu_flags is reset at the *end* of the loop -
* first time round, there may be an 'indirected title' flag */
 
window_handle=-1;
{
menu_defn[position]=0;
item--;
for (;;)
{
switch (*++item)
{
case '#':
icon_flags |= WIMP_ICON_SHADED_BIT;
continue; /* the for loop */
case '.':
menu_flags |= 1 << 1; /* dotted line follows */
continue;
case '/':
menu_flags |= 1 << 0; /* ticked */
continue;
case '[':
menu_flags |= 1 << 3; /* submenu => menu warning message */
continue;
}
break; /* didn't match anything - exit the loop */
}
}
 
pos=item+strlen(item);
for (;;)
{
switch (*--pos)
{
case '>':
window_handle=va_arg(args,int);
continue;
case '\\':
last_item=true;
menu_flags |= 1 << 7;
continue;
}
break;
}
 
menu_defn[position++] = menu_flags;
menu_defn[position++] = window_handle;
 
if (strlen(item)<13)
{
menu_defn[position++] = icon_flags;
 
strncpy(((char *) menu_defn)+(position*4),item,pos-item+1);
 
{
char *menu_data_char=(char *) menu_defn;
menu_data_char[(position*4)+pos-item+1]='\0';
}
 
position+=3;
}
else
{
int length = pos - item + 1;
 
menu_defn[position++] = icon_flags | WIMP_ICON_INDIRECTED_BIT;
 
if (indirected==0)
{
generror("Some fool didn't set indirected to something sane on entry to create_menu. "
"Bloody coders. Nettle will probably crash now.",false);
}
else
{
strncpy(indirected, item, length);
indirected[length]='\0';
menu_defn[position++]=(int) indirected;
menu_defn[position++]=(int) indirected+length;
menu_defn[position++]=length+1;
indirected+=length+1;
}
}
 
item=va_arg(args,char *);
 
menu_flags=0;
}
 
va_end(args);
 
return menu_defn;
}
 
 
/*************************************************** Gerph *********
Function: crate_menu_given_array
Description: create a menu entry block, given an array of token
strings which should be used as the text.
Parameters: menu_defn-> where to write to
indirected-> space to write indirected text to
indirected_len = amount of space in the indirect
buffer
title_tok-> the token to use for the title of the
menu
nentries = number of entries we're going to write
entries-> an array of the menu entries token names
we're going to expand for the text of the
menu items
Returns: pointer to the menu
******************************************************************/
int *create_menu_given_array(int *menu_defn,
char *indirected, int indirected_len,
char *title_tok,
int nentries, const char *entries[])
{
int position=7;
int menu_flags = 0;
const char *title;
 
if (indirected==NULL || indirected_len < 0)
indirected_len=0;
 
title = lookup_static(title_tok);
 
if (strlen(title)<12)
{
strcpy((char *)menu_defn, title);
}
else
{
int length = strlen (title);
 
if (indirected_len < length+1)
{
generror("Some fool didn't set indirected to something sane on entry to create_menu_given_array. "
"Bloody coders. Nettle will probably crash now.", false);
}
else
{
strcpy (indirected, title);
menu_defn[0] = (int) indirected;
menu_defn[1] = (int) indirected + length;
menu_defn[2] = length + 1;
indirected += length + 1;
indirected_len -= length + 1;
 
menu_flags = 1 << 8; /* indirected menu title */
}
}
 
menu_defn[3]=(7<<0)+(2<<8)+(7<<16)+(0<<24); /* black on white items, black on grey title text */
menu_defn[4]=0;
menu_defn[5]=44;
menu_defn[6]=0;
 
if (nentries==0)
{
menu_defn[position++] = menu_flags | (1<<7); /* Also last! */
menu_defn[position++] = -1; /* No submenu */
menu_defn[position++] = WIMP_ICON_FGCOL(7) | WIMP_ICON_VCENT_BIT |
WIMP_ICON_FILLED_BIT | WIMP_ICON_TEXT_BIT |
WIMP_ICON_SHADED_BIT;
 
strcpy((char *) &menu_defn[position],"None"); /* FIXME: i18n */
}
 
while (nentries-->0)
{
const char *item = lookup_static(*entries++);
int length = strlen(item);
int icon_flags = WIMP_ICON_FGCOL(7) | WIMP_ICON_VCENT_BIT |
WIMP_ICON_FILLED_BIT | WIMP_ICON_TEXT_BIT;
/* menu_flags is reset at the *end* of the loop -
* first time round, there may be an 'indirected title' flag */
 
if (nentries==0)
menu_flags |= 1 << 7; /* Last item */
 
menu_defn[position++] = menu_flags;
menu_defn[position++] = -1; /* No submenu */
 
if (length < 13)
{
menu_defn[position++] = icon_flags;
 
strncpy((char *) &menu_defn[position],item,length);
 
{
char *menu_data_char=(char *) menu_defn;
menu_data_char[(position*4)+length]='\0';
}
 
position+=3;
}
else
{
 
menu_defn[position++] = icon_flags | WIMP_ICON_INDIRECTED_BIT;
 
if (indirected_len < length+1)
{
generror("Some fool didn't set indirected to something sane on entry to create_menu_given_array. "
"Bloody coders. Nettle will probably crash now.",false);
}
else
{
strncpy(indirected, item, length);
indirected[length]='\0';
menu_defn[position++]=(int) indirected;
menu_defn[position++]=(int) indirected+length;
menu_defn[position++]=length+1;
indirected += length+1;
indirected_len -= length+1;
}
}
 
menu_flags=0;
}
 
return menu_defn;
}
 
 
 
char *get_menu_item(const char *name)
{
char contents[MESSAGE_MAX_MENU];
char *value = lookup(name, contents, MESSAGE_MAX_MENU);
char *item = malloc(strlen(value) + 1);
 
assert(item != NULL);
 
return strcpy(item, value);
}
 
 
 
char *get_last_menu_item(const char *name)
{
char contents[MESSAGE_MAX_MENU];
char *value = lookup(name, contents, MESSAGE_MAX_MENU);
char *item = malloc(strlen(value) + 2);
 
assert(item != NULL);
 
strcpy(item, value);
return strcat(item, "\\");
}
 
 
 
char *get_grey_menu_item(const char *name)
{
char contents[MESSAGE_MAX_MENU];
char *value = lookup(name, contents, MESSAGE_MAX_MENU);
char *item = malloc(strlen(value) + 2);
 
assert(item != NULL);
 
item[0] = '#';
item[1] = '\0';
return strcat(item, value);
}
 
 
 
char *get_grey_last_menu_item(const char *name)
{
char contents[MESSAGE_MAX_MENU];
char *value = lookup(name, contents, 20);
char *item = malloc(strlen(value) + 3);
 
assert(item != NULL);
 
item[0] = '#';
strcpy(item + 1, value);
strcat(item,"\\");
return item;
}
 
 
 
/* Set title bar code */
void set_title_bar(int window_handle, const char *title)
{
struct wimp_getwindowinfo_block block;
 
block.window_handle=window_handle;
 
_swi(Wimp_GetWindowInfo, _IN(1), ((int) &block)+1);
 
if (block.icon_flags & (1<<8))
{
if (strcmp(block.title.it.text, title) != 0)
{
strcpy(block.title.it.text, title);
 
_swi(Wimp_ForceRedraw, _INR(0,2), window_handle, MAGIC_TASK, 3);
}
}
else
{
generror("Title bar in window is not indirected.", false);
}
}
 
 
/* Force redraw code */
void force_redraw(int window_handle, int minx, int miny, int maxx, int maxy)
{
_swi(Wimp_ForceRedraw, _INR(0,4), window_handle, minx, miny, maxx, maxy);
}
 
 
 
void drag_start(int window_handle, int icon_handle)
{
int xstart, ystart, xsize, ysize;
char string[256], *ptr;
 
drag_window_handle=window_handle;
 
{
struct wimp_getwindowstate_block block;
 
block.window_handle=window_handle;
 
_swi(Wimp_GetWindowState, _IN(1), &block);
 
xstart=block.min.x-block.scroll.x;
ystart=block.max.y-block.scroll.y;
}
 
xsize=_swi(OS_ReadModeVariable, _INR(0,1)|_RETURN(2), -1, 11);
ysize=_swi(OS_ReadModeVariable, _INR(0,1)|_RETURN(2), -1, 12);
 
xsize <<= eig.x;
ysize <<= eig.y;
 
{
struct wimp_geticonstate_block gis_block;
struct wimp_dragbox_block block;
 
gis_block.window_handle=window_handle;
gis_block.icon_handle =icon_handle;
 
_swi(Wimp_GetIconState, _IN(1), &gis_block);
 
block.window_handle=window_handle;
block.drag_type =5;
block.min.x =gis_block.min.x+xstart;
block.min.y =gis_block.min.y+ystart;
block.max.x =gis_block.max.x+xstart;
block.max.y =gis_block.max.y+ystart;
block.parent_min.x =0;
block.parent_min.y =0;
block.parent_max.x =xsize;
block.parent_max.y =ysize;
 
strcpy(string, get_icon_validation(window_handle, icon_handle));
ptr=strchr(string,';');
if (ptr) *ptr='\0';
 
if (_swi(OS_Byte, _INR(0,1)|_RETURN(2), 161, 28) & (1<<1))
{
_swi(DragASprite_Start, _INR(0,4), 0xc5, 1, &string[1], &block.min.x, 0);
}
else
{
_swi(Wimp_DragBox, _IN(1), &block);
}
}
}
 
 
void create_menu_by_icon (int *menu, int window, int icon)
{
/* open the menu in the proper place next to a menu icon */
struct wimp_geticonstate_block gisblock;
struct wimp_getwindowstate_block gwsblock;
 
gisblock.window_handle = window;
gisblock.icon_handle = icon;
_swi (Wimp_GetIconState, _IN(1), (int) &gisblock);
 
gwsblock.window_handle = window;
_swi (Wimp_GetWindowState, _IN(1), (int) &gwsblock);
 
_swi(Wimp_CreateMenu, _INR(1,3), menu,
(gwsblock.min.x - gwsblock.scroll.x) + gisblock.max.x,
(gwsblock.max.y - gwsblock.scroll.y) + gisblock.max.y);
}
 
 
/*******************************************************************
Function: tick_menu_for_icon_text
Description: Ticks the menu item that matches the text in the
icon specified
Parameters: menu-> the menu structure
window = the window handle
icon = the icon handle
Returns: none
******************************************************************/
void tick_menu_for_icon_text(int *menu, int window_handle, int icon)
{
char string[64];
 
read_icon_data(window_handle, icon, string, sizeof(string));
 
/* Menu header is 7 entries;
* All menu entries are 6 entries;
* We do the menu increment first to make the tail check easier
*/
menu+=7-6; /* Skip the menu header */
 
do
{
char *text;
menu+=6;
 
if (menu[2] & (1<<0)) /* Text present */
{
if (menu[2] & (1<<8)) /* Text is indirected */
text = (char *)menu[3];
else
text = (char *)&menu[3];
 
if (strcmp(text,string)==0)
menu[0] |= (1<<0); /* Tick item, 'cos it matches */
else
menu[0] &= ~(1<<0); /* Untick item */
 
}
 
} while ((menu[0] & (1<<7)) == 0);
}
/vendor/v0.2023/chardefn.c
New file
0,0 → 1,392
/**
* Zap font character definitions
* (C) Nettle developers 2000-2001
*
* $Id: chardefn,v 1.14 2002/02/02 21:30:45 ijeffray Exp $
*/
 
#include "generic.h"
#include "globals.h"
 
#include "chardefn.h"
#include "misc.h"
#include "zapredraw.h"
 
/* Define Zap graphics characters */
 
 
static void copypair (char *area, int step, int height,
const char *base, char upper, char lower)
{
int x, y;
const char *ptr = base + upper * step * height;
for (y = 0; y < height; y++)
{
memcpy (area, ptr, step);
if ((height & 1) && y == height / 2)
ptr = base + lower * step * height;
else
ptr += step;
for (x = step - 1; x >= 0; x--)
area[x] |= ptr[x];
if ((height & 1) == 0 && y == (height - 1) / 2)
ptr = base + lower * step * height;
else
ptr += step;
area += step;
}
}
 
 
static void make_underline (char *area, int step, int height)
{
char pixels[8] = {0}; /* hmm, trouble if the font is > 64 pixels wide... */
int x;
 
area += step * height;
 
while (--height > 1)
{
area -= step;
for (x = step - 1; x >= 0; --x)
{
area[x >> 3] |= area[(x >> 3) - 2 * step] & ~pixels[x >> 3];
pixels[x >> 3] |= area[x >> 3];
}
}
}
 
 
void define_zap_chars(int *int_area, int char_size, int width, int height)
{
int loop;
int step=char_size/height;
char *area=(char *) int_area;
const char *base = area;
/* define characters */
area += 0x100 * char_size;
 
/* initialise extra character area (chars 0x100-<end>) to 0 */
memset (area, 0, EXTRA_ZAP_CHARS * char_size);
 
/* Active Cursor 0x100 */
switch (cursor_type)
{
case cursor_solid:
/* filled rectangle */
memset (area, 0xff, char_size);
break;
 
case cursor_underline:
/* Bottom lines of the cursor */
{
int lines = (height+4)/8;
/* 8 pixels -> 1 line cursor
12 pixels -> 2 line cursor
16 pixels -> 2 line cursor
20 pixels -> 3 line cursor */
for (loop = 0; loop < step*lines; loop++)
area[char_size - loop - 1] = 0xff;
}
}
area += char_size;
 
/* Inactive Cursor 0x101 */
switch (cursor_type)
{
case cursor_solid:
/* unfilled rectangle */
for (loop = 0; loop < step; loop++)
area[char_size - loop - 1] = area[loop] = 0xFF;
if (step == 1)
for (loop = step; loop < char_size - step; loop += step)
area[loop] = 1 | 1 << (width - 1);
else
for (loop = step; loop < char_size - step; loop += step)
{
area[loop] = 1;
area[loop + step - 1] = 1 << ((width - 1) & 7);
}
break;
 
case cursor_underline:
/* Bottom lines of the cursor as a dither pattern */
{
int lines = (height+4)/8;
char *areaend = &area[char_size - 1];
/* 8 pixels -> 1 line cursor
12 pixels -> 2 line cursor
16 pixels -> 2 line cursor
20 pixels -> 3 line cursor */
while (lines-->0)
{
for (loop = 0; loop < step; loop++)
areaend[- loop] = (lines&1) ? 0xAA : 0x55;
areaend-=step;
}
}
break;
}
area+=char_size;
 
/* Diamond 0x102 */
{
int scale = (height >= width * 2) ? 2 : 1;
int pix1 = (MIN (height, width) - 1) / 2;
int pix2 = pix1;
char *ptr = area + (height >> 1) * step;
while (pix1 >= 0)
{
int loop2;
char *ptr2 = ptr - pix1 * step * scale;
/* top half */
for (loop2 = pix1; loop2 <= pix2; loop2++)
ptr2[loop2 / 8] |= 1 << (loop2 & 7);
if (scale == 2)
{
memcpy (ptr2 - step, ptr2, step); /*duplicate*/
memmove (ptr + pix1 * step * scale - step, ptr2 - step, step * 2); /*mirror*/
}
else
memcpy (ptr + pix1 * step * scale, ptr2, step); /*mirror*/
pix1--;
pix2++;
}
}
area+=char_size;
 
/* Checkerboard 0x103 */
{
char fill = 0xAA;
for (loop = 0; loop < char_size; loop += step)
{
memset (area + loop, fill, step);
fill = ~fill;
}
}
area+=char_size;
 
/* H topleft/T bottomright 0x104 */
copypair (area, step, height, base, 'H', 'T');
area+=char_size;
 
/* F topleft/F bottomright 0x105 */
copypair (area, step, height, base, 'F', 'F');
area+=char_size;
 
/* C topleft/R bottomright 0x106 */
copypair (area, step, height, base, 'C', 'R');
area+=char_size;
 
/* L topleft/F bottomright 0x107 */
copypair (area, step, height, base, 'L', 'F');
area+=char_size;
 
/* N topleft/L bottomright 0x108 */
copypair (area, step, height, base, 'N', 'L');
area+=char_size;
 
/* V topleft/T bottomright 0x109 */
copypair (area, step, height, base, 'V', 'T');
area+=char_size;
 
/* _| (bottomright of box) 0x10A */
for (loop=0; loop<(char_size/2); loop+=step)
area[loop + (width / 16)] = 1 << (width / 2 & 7);
for (loop = 0; loop <= width / 2; loop++)
area[step * (height >> 1) + loop / 8] |= 1 << (loop & 7);
area+=char_size;
 
/* -, (topright of box) 0x10B */
for (loop = char_size - step; loop > (char_size/2); loop-=step)
area[loop + (width / 16)] = 1 << (width / 2 & 7);
for (loop = 0; loop <= width / 2; loop++)
area[step * (height >> 1) + loop / 8] |= 1 << (loop & 7);
area+=char_size;
 
/* ,- (topleft of box) 0x10C */
for (loop = char_size - step; loop > (char_size/2); loop-=step)
area[loop + (width / 16)] = 1 << (width / 2 & 7);
for (loop = width / 2; loop < width; loop++)
area[step * (height >> 1) + loop / 8] |= 1 << (loop & 7);
area+=char_size;
 
/* |_ (bottomleft of box) 0x10D */
for (loop=0; loop<(char_size/2); loop+=step)
area[loop + (width / 16)] = 1 << (width / 2 & 7);
for (loop = width / 2; loop < width; loop++)
area[step * (height >> 1) + loop / 8] |= 1 << (loop & 7);
area+=char_size;
 
/* -|- (crossing lines) 0x10E */
for (loop=0; loop<char_size; loop+=step)
area[loop + (width / 16)] = 1 << (width / 2 & 7);
memset (area + step * (height >> 1), 0xFF, step);
area+=char_size;
 
/* Horiz line - scan 1 0x10F */
memset (area, 0xFF, step);
area+=char_size;
 
/* Scan 3 0x110 */
memset (area + step * (int) (height * 3 / 10), 0xFF, step);
area+=char_size;
 
/* Scan 5 0x111 */
memset (area + step * (int) (height * 5 / 10), 0xFF, step);
area+=char_size;
 
/* Scan 7 0x112 */
memset (area + step * (int) (height * 7 / 10), 0xFF, step);
area+=char_size;
 
/* Scan 9 0x113 */
memset (area + step * (int) (height * 9 / 10), 0xFF, step);
area+=char_size;
 
/* Left T |- 0x114 */
for (loop=0; loop<char_size; loop+=step)
area[loop + (width / 16)] = 1 << (width / 2 & 7);
for (loop = width / 2; loop < width; loop++)
area[step * (height >> 1) + loop / 8] |= 1 << (loop & 7);
area+=char_size;
 
/* Right T -| 0x115 */
for (loop=0; loop<char_size; loop+=step)
area[loop + (width / 16)] = 1 << (width / 2 & 7);
for (loop = 0; loop < width / 2; loop++)
area[step * (height >> 1) + loop / 8] |= 1 << (loop & 7);
area+=char_size;
 
/* Bottom T _|_ 0x116 */
for (loop = 0; loop < (char_size/2); loop+=step)
area[loop + (width / 16)] = 1 << (width / 2 & 7);
memset (area + step * (height >> 1), 0xFF, step);
area+=char_size;
 
/* Top T T 0x117 */
for (loop = char_size - step; loop > (char_size/2); loop-=step)
area[loop + (width / 16)] = 1 << (width / 2 & 7);
memset (area + step * (height >> 1), 0xFF, step);
area+=char_size;
 
/* Vertical bar | 0x118 */
for (loop = 0; loop < char_size; loop+=step)
area[loop + (width / 16)] = 1 << (width / 2 & 7);
area+=char_size;
 
/* <= 0x119 */
memcpy (area, base + '<' * char_size, char_size);
make_underline (area, step, height);
area+=char_size;
 
/* >= 0x11A */
memcpy (area, base + '>' * char_size, char_size);
make_underline (area, step, height);
area+=char_size;
 
/* PI 0x11B */
{
int pix1 = (width <= 8) ? 1 : 2;
int pix2 = width - 2 - (width > 8);
char *ptr = area + (height * 3 / 8) * step;
for (loop = pix1; loop <= pix2; loop++)
ptr[loop / 8] |= 1 << (loop & 7);
pix1 += (width <= 8) ? 1 : 2;
pix2 -= (width <= 8) ? 1 : 2;
if (pix2 == pix1 + 1)
pix2 += 1;
for (loop = (height * 3 / 8) * step; loop <= (height * 7 / 8) * step; loop++)
{
ptr[pix1 / 8] |= 1 << (pix1 & 7);
ptr[pix2 / 8] |= 1 << (pix2 & 7);
ptr += step;
}
}
area+=char_size;
 
/* Not equal 0x11C */
{
const char *ptr1 = base + '=' * char_size;
const char *ptr2 = base + '/' * char_size;
for (loop = char_size - 1; loop >= 0; loop--)
area[loop] = ptr1[loop] | ptr2[loop];
}
area+=char_size;
 
/* Underline 0x11D */
{
/* Principle: locate _ and make /any/ pixels that are set span the
entire row. */
const char *ptr1 = base + '_' * char_size;
char *ptr2 = area;
for (loop = 0; loop<height; loop++)
{
int loop2;
int anyset=0;
for (loop2 = 0; loop2<step; loop2++)
anyset|=*ptr1++;
 
if (anyset)
{
for (loop2 = 0; loop2<step; loop2++)
*ptr2++=0xff;
}
else
ptr2+=step;
}
}
}
 
 
void define_zap_undef_chars(int *int_area, int first_char, int last_char,
int char_size, int width, int height)
{
char *area = (char *)int_area;
 
if (width == 8 && (height == 8 || height == 16))
{
/* System font size - fill in blanks from there */
int chr = (first_char < 32) ? (last_char - 1) : 31;
char def[9];
while (++chr < 0x100)
{
if (chr == first_char)
{
/* skip the defined characters */
chr = last_char;
if (chr >= 0x100)
break;
}
 
/* undefined character - fill in the definition */
def[0] = chr;
_swi (OS_Word, _INR(0,1), 10, def);
if (height == 8)
memcpy (area + chr * char_size, def + 1, 8);
else
{
int i;
char *ptr = area + chr * char_size;
for (i = 7; i >= 0; --i)
ptr[i*2 + 1] = ptr[i*2] = def[i + 1];
}
}
if (first_char > 32)
_swi (ZapRedraw_ReverseBitmaps, _INR(1,3),
area + 32 * char_size, area + 32 * char_size,
(first_char - 32) * char_size);
if (last_char < 256)
_swi (ZapRedraw_ReverseBitmaps, _INR(1,3),
area + last_char * char_size, area + last_char * char_size,
(256 - last_char) * char_size);
}
 
{
/* Now do the control characters */
int chr;
int step=char_size/height;
for (chr = 0; chr < 32 && chr < first_char; chr++)
copypair (area + chr * char_size, step, height, area, chr | 64, '-');
}
}
/vendor/v0.2023/dnslib.c
New file
0,0 → 1,186
/*
* RISC OS resolver abstraction code
*
* © Joseph Heenan, 2000
*
* $Id: dnslib,v 1.10 2002/01/08 14:09:09 archifishal Exp $
*/
 
#include "generic.h"
 
#ifdef USE_TCPIPLIB
# include "sys/types.h"
# include "netinet/in.h"
#endif
 
#include "arpa/inet.h" /* inet_aton */
#include "netdb.h" /* gethostname */
#include "sys/errno.h"
#include "sys/socket.h" /* AF_INET */
 
#include "dnslib.h"
#include "misc.h"
 
#define Resolver_GetHost 0x46001
 
struct dns_s
{
dns_status_t status;
char *hostname;
struct hostent *hostent;
struct hostent ourhostent; /* only used when user enters quad dotted ip */
struct in_addr *inaddrs[2];
struct in_addr inaddr;
};
 
 
 
dns_t *dns_gethostbyname(const char *hostname)
{
dns_t *dns;
 
dns = calloc(1, sizeof(struct dns_s));
if (!dns)
goto failed;
 
dns->status = dns_init;
 
dns->hostname = strdup(hostname);
if (!dns->hostname)
goto failed;
 
return dns;
 
failed:
free(dns);
 
return NULL;
}
 
 
void dns_dispose(dns_t *dns)
{
assert(dns);
 
if (dns)
{
free(dns->hostname);
free(dns);
}
}
 
 
 
dns_status_t dns_check(dns_t *dns)
{
_kernel_oserror *e;
int status;
 
assert(dns);
 
switch (dns->status)
{
case dns_init:
{
char swiname[32];
 
if (inet_aton(dns->hostname, &dns->inaddr) == 1)
{
/* setup a hostent structure containing result */
struct hostent host = {
NULL, NULL, AF_INET, sizeof(struct in_addr), NULL
};
dns->hostent = &dns->ourhostent;
memcpy(dns->hostent, &host, sizeof host);
dns->hostent->h_addr_list = (char **) &dns->inaddrs;
dns->hostent->h_addr_list[0] = (char *) &dns->inaddr;
dns->hostent->h_addr_list[1] = NULL;
/* valid ip address given */
dns->status = dns_complete_success;
break;
}
 
/* check if resolver module is present */
if (_swix(OS_SWINumberToString, _INR(0,2), Resolver_GetHost, swiname,
sizeof(swiname)-1) == NULL)
{
if (strcmp(swiname, "Resolver_GetHost") == 0)
{
/* Resolver is present and is the one that's got the resolver swi
* chunk */
dns->status = dns_inprogress;
}
else
{
/* Not present, fallback to simple gethostbyname() */
dns->status = dns_singletask;
}
}
else
{
/* swi lookup failed, fallback to simple gethostbyname() */
dns->status = dns_singletask;
}
break;
}
 
case dns_inprogress:
e = _swix(Resolver_GetHost, _IN(0)|_OUTR(0,1), dns->hostname, &status, &dns->hostent);
if (e && e->errnum == 486)
{
/* Bad SWI, fallback to singletasking lookup */
dns->status = dns_singletask;
}
else if (e)
{
/* error from swi */
dns->status = dns_complete_failure;
}
else if (status != EINPROGRESS)
{
/* finished */
if (dns->hostent)
dns->status = dns_complete_success;
else
dns->status = dns_complete_failure;
}
else
{
/* it's still resolving */
}
break;
 
case dns_singletask:
/* Bad SWI, fallback to singletasking lookup */
dns->hostent = gethostbyname(dns->hostname);
if (dns->hostent)
dns->status = dns_complete_success;
else
dns->status = dns_complete_failure;
break;
 
case dns_complete_failure:
case dns_complete_success:
/* finished, do nothing */
break;
 
default:
/* attempt to catch random crashes which look like they happen here */
printf("Error: Unknown dns status - %d\n", dns->status);
abort();
}
 
return dns->status;
}
 
 
 
struct hostent *dns_getanswer(dns_t *dns)
{
assert(dns);
 
if (dns->status != dns_complete_success)
return NULL;
 
return dns->hostent;
}
/vendor/v0.2023/ufortify.h
New file
0,0 → 1,69
/*
* FILE:
* ufortify.h
*
* DESCRIPTION:
* User options for fortify. Changes to this file require fortify.c to be
* recompiled, but nothing else.
*/
 
#ifndef __UFORTIFY_H__
#define __UFORTIFY_H__
 
 
#define FORTIFY_STORAGE /* storage for public functions */
 
#define FORTIFY_ALIGNMENT sizeof(double) /* Byte alignment of all memory blocks */
 
#define FORTIFY_BEFORE_SIZE 32 /* Bytes to allocate before block */
#define FORTIFY_BEFORE_VALUE 0xA3 /* Fill value before block */
#define FORTIFY_AFTER_SIZE 32 /* Bytes to allocate after block */
#define FORTIFY_AFTER_VALUE 0xA5 /* Fill value after block */
 
#define FORTIFY_FILL_ON_ALLOCATE /* Nuke out malloc'd memory */
#define FORTIFY_FILL_ON_ALLOCATE_VALUE 0xA7 /* Value to initialize with */
 
#define FORTIFY_FILL_ON_DEALLOCATE /* free'd memory is cleared */
#define FORTIFY_FILL_ON_DEALLOCATE_VALUE 0xA9 /* Value to de-initialize with */
 
#define FORTIFY_FILL_ON_CORRUPTION /* Nuke out corrupted memory */
 
/* #define FORTIFY_CHECK_ALL_MEMORY_ON_ALLOCATE */
/* #define FORTIFY_CHECK_ALL_MEMORY_ON_DEALLOCATE */
#define FORTIFY_PARANOID_DEALLOCATE
 
/* #define FORTIFY_WARN_ON_ZERO_MALLOC */ /* A debug is issued on a malloc(0) */
/* #define FORTIFY_FAIL_ON_ZERO_MALLOC */ /* A malloc(0) will fail */
 
#define FORTIFY_WARN_ON_ALLOCATE_FAIL /* A debug is issued on a failed alloc */
#define FORTIFY_WARN_ON_FALSE_FAIL /* See Fortify_SetAllocateFailRate */
#define FORTIFY_WARN_ON_SIZE_T_OVERFLOW /* Watch for breaking the 64K limit in */
/* some braindead architectures... */
 
#define FORTIFY_TRACK_DEALLOCATED_MEMORY
#define FORTIFY_DEALLOCATED_MEMORY_LIMIT 1048576 /* Maximum amount of deallocated bytes to keep */
/* #define FORTIFY_WARN_WHEN_DISCARDING_DEALLOCATED_MEMORY */
/* #define FORTIFY_VERBOSE_WARN_WHEN_DISCARDING_DEALLOCATED_MEMORY */
 
/* #define FORTIFY_NO_PERCENT_P */ /* sprintf() doesn't support %p */
/* #define FORTIFY_STRDUP */ /* if you use non-ANSI strdup() */
 
#define FORTIFY_LOCK()
#define FORTIFY_UNLOCK()
 
#define FORTIFY_DELETE_STACK_SIZE 256
 
#ifdef __cplusplus /* C++ only options go here */
 
/* #define FORTIFY_PROVIDE_ARRAY_NEW */
/* #define FORTIFY_PROVIDE_ARRAY_DELETE */
 
/* #define FORTIFY_AUTOMATIC_LOG_FILE */
#define FORTIFY_LOG_FILENAME "fortify.log"
#include <iostream.h>
#define FORTIFY_FIRST_ERROR_FUNCTION cout << "\a\a\aFortify Hit Generated!\n"
 
#endif /* __cplusplus */
 
#endif
/vendor/v0.2023/p_taskwindow.h
New file
0,0 → 1,50
/**
* Protocol TaskWindow specific support code
* (C) Nettle developers 2002
*
* $Id$
*/
 
#ifndef TASKWINDOW_H
#define TASKWINDOW_H
 
#include "generic.h"
#include "globals.h"
#include "protocols.h"
 
extern protocol_t protocol_taskwindow;
 
/*************************************************** Gerph *********
Function: taskwindow_message
Description: Handle wimp messages directly related to taskwindow
protocol
Parameters: wimp_block-> message block to process
Returns: true if handled, false if not handled
******************************************************************/
bool taskwindow_message(union wimp_poll_block *wimp_block);
 
/*************************************************** Gerph *********
Function: taskwindow_senddata
Description: Send data on to the taskwindow
Parameters: session-> the session we're processing
data-> the data to send
length-> the length to send
Returns: length sent
******************************************************************/
int taskwindow_senddata(struct session_struct *session,
const char *data, int length);
 
/*************************************************** Gerph *********
Function: taskwindow_resized
Description: Window has been resized; we need to inform the remote
end of this fact
Parameters: session-> the session that has changed (new size in
terminal_size)
old_size = the old size coord structure, in case it
is needed
Returns: none
******************************************************************/
void taskwindow_resized(struct session_struct *session,
struct coords old_size);
 
#endif
/vendor/v0.2023/process.c
New file
0,0 → 1,1411
/**
* Processing code
* (C) Nettle developers 2000-2002
*
* $Id: process,v 1.81 2002/02/10 21:23:40 ijeffray Exp $
*/
 
#include <stddef.h>
 
#include "generic.h"
#include "globals.h"
 
#include "graphics.h"
#include "keyboard.h"
#include "lineedit.h"
#include "main.h"
#include "messages.h"
#include "misc.h"
#include "mouse.h"
#include "nettle.h"
#include "process.h"
#include "seln.h"
#include "socket.h"
#include "spool.h"
#include "wimp.h"
#include "wimputil.h"
#include "zapredraw.h"
#include "timers.h"
 
static struct session_struct *changedsession;
static struct coordspair changedbox;
char csi_sequence[8];
 
void changedbox_init (struct session_struct *session)
{
changedsession = session;
changedbox.tl.x = 255;
changedbox.tl.y = 255;
changedbox.br.x = 0;
changedbox.br.y = 0;
}
 
void changedbox_update (int cx0, int cy0, int cx1, int cy1)
{
if (cx0 < changedbox.tl.x) changedbox.tl.x = cx0;
if (cy0 < changedbox.tl.y) changedbox.tl.y = cy0;
if (cx1 > changedbox.br.x) changedbox.br.x = cx1;
if (cy1 > changedbox.br.y) changedbox.br.y = cy1;
}
 
 
void changedbox_update_char (int cx0, int cy0)
{
if (cx0 < changedbox.tl.x) changedbox.tl.x = cx0;
if (cy0 < changedbox.tl.y) changedbox.tl.y = cy0;
if (cx0 > changedbox.br.x) changedbox.br.x = cx0;
if (cy0 > changedbox.br.y) changedbox.br.y = cy0;
}
 
 
void changedbox_update_offset (int calc)
{
int x = calc % changedsession->terminal_size.x;
int y = calc / changedsession->terminal_size.x;
changedbox_update_char (x, y);
}
 
 
void changedbox_update_whole (void)
{
changedbox_update (0, changedsession->scrollback,
changedsession->terminal_size.x - 1,
changedsession->scrollback + changedsession->terminal_size.y - 1);
}
 
 
void force_redraw_changedbox (void)
{
force_redraw (changedsession->window_handle,
changedbox.tl.x * redraw.r_charw << eig.x,
(-changedbox.br.y - 1) * redraw.r_charh << eig.y,
(changedbox.br.x + 1) * redraw.r_charw << eig.x,
-changedbox.tl.y * redraw.r_charh << eig.y);
}
 
 
void primary_da_request(struct session_struct *session)
{
/* Primary DA Request */
char block[16];
 
switch (session->terminal_type)
{
case NETTLE_TERMINAL_VT100:
sprintf(block, "%s?1;0c",csi_sequence);
break;
case NETTLE_TERMINAL_VT102:
sprintf(block, "%s?6c",csi_sequence);
break;
default:
sprintf(block,"%s?6x;1;6c",csi_sequence);
block[2+strlen(csi_sequence)]=session->terminal_mode+48;
break;
}
 
nettle_senddata(session,block,strlen(block));
}
 
void shuffle_up(struct session_struct *session, int start, int end)
{
struct term_char *wrapped_line;
int loop;
 
/* copy the wrapped line to a temporary buffer */
wrapped_line=session->assigned_area[start];
 
for (loop=start+1; loop<end+1; loop++)
{
if (valid_y(session, loop-1) && valid_y(session, loop))
{
session->assigned_area[loop-1]=session->assigned_area[loop];
}
}
 
session->assigned_area[end]=wrapped_line;
}
 
void shuffle_down(struct session_struct *session, int start, int end)
{
struct term_char *wrapped_line;
int loop;
 
/* copy the wrapped line to a temporary buffer */
wrapped_line=session->assigned_area[end];
 
for (loop=end; loop>start; loop--)
{
if (valid_y(session, loop) && valid_y(session, loop-1))
{
session->assigned_area[loop]=session->assigned_area[loop-1];
}
}
 
session->assigned_area[start]=wrapped_line;
}
 
void scroll_up(struct session_struct *session, bool wrap)
{
if (selection_session == session)
{
selection_start-=session->terminal_size.x;
selection_end-=session->terminal_size.x;
if (selection_start<0)
selection_start=0;
if (selection_end<0)
selection_end=0;
}
 
if (session->scroll_start==1 &&
(session->other_session_flags & NETTLE_OTHER_SCREEN_MODE) == 0)
{
shuffle_up(session, 0, session->scrollback+session->scroll_end-1);
}
else
{
shuffle_up(session, session->scrollback+session->scroll_start-1,
session->scrollback+session->scroll_end-1);
}
 
/* and clear or restore the new line */
if (!wrap)
{
/* wrap is false, clear the wrapped line */
int count;
 
for (count=0; count<session->terminal_size.x; count++)
{
write_assigned(session,
count,
session->scroll_end+session->scrollback-1,
7, 0, 0, 32);
}
}
 
if (session->scroll_start == 1 &&
(session->other_session_flags & NETTLE_OTHER_SCREEN_MODE) == 0)
changedbox_update (0, 0,
session->terminal_size.x - 1,
session->scrollback + session->scroll_end - 1);
else
changedbox_update (0, session->scrollback + session->scroll_start - 1,
session->terminal_size.x - 1,
session->scrollback + session->scroll_end - 1);
}
 
void scroll_down (struct session_struct *session, bool wrap)
{
if (selection_session == session)
{
selection_start+=session->terminal_size.x;
selection_end+=session->terminal_size.x;
if (selection_start>(session->terminal_size.x*
(session->terminal_size.y+session->scrollback)))
{
selection_start=(session->terminal_size.x*
(session->terminal_size.y+session->scrollback));
}
 
if (selection_end>(session->terminal_size.x*
(session->terminal_size.y+session->scrollback)))
{
selection_end=(session->terminal_size.x*
(session->terminal_size.y+session->scrollback));
}
}
 
shuffle_down(session, session->scrollback+session->scroll_start-1,
session->scrollback+session->scroll_end-1);
 
/* and clear or restore the new line */
if (!wrap)
{
/* wrap is false, clear the wrapped line */
int count;
 
for (count=0; count<session->terminal_size.x; count++)
{
write_assigned(session,
count,
session->scroll_start+session->scrollback-1,
7, 0, 0, 32);
}
}
 
 
changedbox_update (0, session->scrollback + session->scroll_start - 1,
session->terminal_size.x - 1,
session->scrollback + session->scroll_end - 1);
}
 
void reprocess_position_scroll(struct session_struct *session)
{
/* scroll if y>scroll_end */
 
/*while (session->pos.y>(session->scroll_end+session->scrollback-1))*/
if (session->pos.y==session->scroll_end+session->scrollback)
{
session->pos.y--;
scroll_up (session, false);
}
 
/* scroll if Y<scroll_start */
 
/*while (session->pos.y<(session->scroll_start+session->scrollback-1))*/
if (session->pos.y==session->scroll_start+session->scrollback-2)
{
session->pos.y++;
scroll_down (session, false);
}
}
 
 
void reprocess_position(struct session_struct *session)
{
/* this reshuffles everything so that everything is back on screen, this allows the cursor */
/* to sit at (81,24) without causing a newline (which would break pine and things) */
/* It also shuffles up the selection areas */
 
if (session->pos.x >= session->terminal_size.x)
{
if (session->other_session_flags & NETTLE_OTHER_WRAP_MODE)
{
session->pos.x=0;
session->pos.y++;
reprocess_position_scroll(session);
}
else
{
session->pos.x = session->terminal_size.x - 1;
}
}
}
 
 
void row_shift_right (struct session_struct *session, int chars)
{
int loop;
 
/* don't do too much */
if (chars > session->terminal_size.x - session->pos.x)
chars = session->terminal_size.x - session->pos.x;
 
/* do nothing if cursor is at/beyond RHS */
if (session->pos.x >= session->terminal_size.x)
return;
 
changedbox_update (session->pos.x, session->pos.y,
session->terminal_size.x - 1, session->pos.y);
 
for (loop=session->terminal_size.x-1; loop>session->pos.x+chars-1; loop--)
{
session->assigned_area[session->pos.y][loop]=
session->assigned_area[session->pos.y][loop-chars];
}
}
 
void work_out_character_character_set(struct session_struct *session,int character_set,
int xpos, int ypos, unsigned char byte)
{
switch (character_set)
{
case NETTLE_CHSET_ASCII:
write_assigned_character(session, xpos, ypos, byte);
break;
case NETTLE_CHSET_DEC_SUPPLEMENTAL_GRAPHICS:
write_assigned_character(session, xpos, ypos, byte | 0x80);
break;
case NETTLE_CHSET_UK_NATIONAL:
if (byte!='#')
{
write_assigned_character(session, xpos, ypos, byte);
}
else
{
write_assigned_character(session, xpos, ypos, '£');
}
break;
case NETTLE_CHSET_DEC_SPECIAL_GRAPHICS:
{
int graphics_byte=dec_graphics_table[byte];
 
if (graphics_byte<0x100)
{
write_assigned_character(session, xpos, ypos, (char) graphics_byte);
}
else
{
write_assigned_flags(session, xpos, ypos,
read_assigned_flags(session, xpos, ypos) | NETTLE_FLAG_PLUS100);
write_assigned_character(session, xpos, ypos, (char) graphics_byte-0x100);
}
}
break;
case NETTLE_CHSET_DOWNLINE_LOADABLE:
write_assigned_character(session, xpos, ypos, byte);
break;
}
}
 
void work_out_character(struct session_struct *session, int xpos, int ypos,
unsigned char byte)
{
int character_set_gl;
int character_set_gr;
 
switch (session->character_set_gl)
{
case NETTLE_CHSET_G0:
default:
character_set_gl=session->character_set_g0;
break;
 
case NETTLE_CHSET_G1:
character_set_gl=session->character_set_g1;
break;
 
case NETTLE_CHSET_G2:
character_set_gl=session->character_set_g2;
break;
 
case NETTLE_CHSET_G3:
character_set_gl=session->character_set_g3;
break;
}
 
switch (session->character_set_gr)
{
case NETTLE_CHSET_G0:
default:
character_set_gr=session->character_set_g0;
break;
 
case NETTLE_CHSET_G1:
character_set_gr=session->character_set_g1;
break;
 
case NETTLE_CHSET_G2:
character_set_gr=session->character_set_g2;
break;
 
case NETTLE_CHSET_G3:
character_set_gr=session->character_set_g3;
break;
}
 
if (byte<0x80)
{
work_out_character_character_set(session, character_set_gl, xpos, ypos, byte);
}
else
{
work_out_character_character_set(session, character_set_gr, xpos, ypos, byte & 0x7f);
}
}
 
 
void byte_null(struct session_struct *session)
{
NOT_USED(session);
}
 
void byte_enquiry(struct session_struct *session)
{
NOT_USED(session);
}
 
/* Callback routine, for timer to cancel the visual bell */
void cancel_vbell(struct session_struct *session,void *private,int overdue)
{
session->other_session_flags &= ~NETTLE_OTHER_VISUAL_BELL;
force_redraw (session->window_handle,
0,
(-session->terminal_size.y-session->scrollback) * redraw.r_charh <<eig.y,
session->terminal_size.x * redraw.r_charw << eig.x,
0);
}
 
void byte_bell(struct session_struct *session)
{
/* Bell */
if (session->other_session_flags & NETTLE_OTHER_VISUAL_BELL_MODE)
{
timer_add(session,10,NULL,cancel_vbell,0);
session->other_session_flags |= NETTLE_OTHER_VISUAL_BELL;
changedbox_update_whole();
}
else
_swi(OS_WriteI + 7, 0);
}
 
void byte_backspace(struct session_struct *session)
{
/* Backspace */
if (session->pos.x>0)
session->pos.x--;
}
 
void byte_horizontal_tabulation(struct session_struct *session)
{
/* Tab */
int loop;
int current_tab=session->terminal_size.x;
 
for (loop=0; loop<session->number_of_tabs; loop++)
{
if (session->tabs[loop]>session->pos.x &&
session->tabs[loop]<current_tab)
{
current_tab=session->tabs[loop];
}
}
 
if (current_tab<session->terminal_size.x)
{
session->pos.x=current_tab;
}
else
{
session->pos.x=session->terminal_size.x - 1;
}
}
 
void byte_reverse_horizontal_tabulation(struct session_struct *session)
{
/* Tab */
int loop;
int current_tab=session->terminal_size.x;
 
for (loop=session->number_of_tabs-1; loop>=0; loop--)
{
if (session->tabs[loop]<session->pos.x &&
session->tabs[loop]>current_tab)
{
current_tab=session->tabs[loop];
}
}
 
if (current_tab < session->terminal_size.x)
{
session->pos.x = current_tab;
}
else
{
session->pos.x = 0;
}
}
 
void byte_linefeed(struct session_struct *session)
{
/* LF,VT,FF */
session->pos.y++;
 
if (session->other_session_flags & NETTLE_OTHER_LINEFEED_MODE)
{
session->pos.x=0;
}
 
/*reprocess_position(session);*/
reprocess_position_scroll(session);
}
 
void byte_carriage_return(struct session_struct *session)
{
/* CR */
session->pos.x=0;
}
 
void byte_shift_out(struct session_struct *session)
{
session->character_set_gl=NETTLE_CHSET_G1;
}
 
void byte_shift_in(struct session_struct *session)
{
session->character_set_gl=NETTLE_CHSET_G0;
}
 
void byte_device_control_1(struct session_struct *session)
{
NOT_USED(session);
}
 
void byte_device_control_3(struct session_struct *session)
{
NOT_USED(session);
}
 
void byte_cancel(struct session_struct *session)
{
write_assigned(session, session->pos.x, session->pos.y,
session->current_fg,
session->current_bg,
session->current_flags,
'?');
 
session->escape_state=NETTLE_ESCAPE_NONE;
session->escape_string_length=0;
}
 
void byte_substitute(struct session_struct *session)
{
session->escape_state=NETTLE_ESCAPE_NONE;
session->escape_string_length=0;
}
 
void byte_escape(struct session_struct *session)
{
/* ESCAPE */
if (session->escape_state==NETTLE_ESCAPE_ESCAPE)
{
if (session->escape_string_length>=2)
{
if (session->escape_string[0]=='\x1B')
{
switch (session->escape_string[1])
{
case 'P': case '^': case '_': case ']':
return;
break;
}
}
}
}
 
session->escape_state=NETTLE_ESCAPE_ESCAPE;
session->escape_string[0]='\x1B';
session->escape_string_length=1;
}
 
void byte_delete(struct session_struct *session)
{
NOT_USED(session);
}
 
void byte_index(struct session_struct *session)
{
/* Index */
session->escape_state=NETTLE_ESCAPE_ESCAPE;
session->escape_string[0]='\x1B';
session->escape_string[1]='D';
session->escape_string_length=2;
}
 
void byte_next_line(struct session_struct *session)
{
/* Next line */
session->escape_state=NETTLE_ESCAPE_ESCAPE;
session->escape_string[0]='\x1B';
session->escape_string[1]='E';
session->escape_string_length=2;
}
 
void byte_horizontal_tab_set(struct session_struct *session)
{
/* Horizontal tab set */
session->escape_state=NETTLE_ESCAPE_ESCAPE;
session->escape_string[0]='\x1B';
session->escape_string[1]='H';
session->escape_string_length=2;
}
 
void byte_reverse_index(struct session_struct *session)
{
/* Reverse index */
session->escape_state=NETTLE_ESCAPE_ESCAPE;
session->escape_string[0]='\x1B';
session->escape_string[1]='M';
session->escape_string_length=2;
}
 
void byte_single_shift_g2(struct session_struct *session)
{
/* Single shift G2 */
session->escape_state=NETTLE_ESCAPE_ESCAPE;
session->escape_string[0]='\x1B';
session->escape_string[1]='N';
session->escape_string_length=2;
}
 
void byte_single_shift_g3(struct session_struct *session)
{
/* Single shift G3 */
session->escape_state=NETTLE_ESCAPE_ESCAPE;
session->escape_string[0]='\x1B';
session->escape_string[1]='O';
session->escape_string_length=2;
}
 
void byte_device_control_string(struct session_struct *session)
{
/* Device control string */
session->escape_state=NETTLE_ESCAPE_ESCAPE;
session->escape_string[0]='\x1B';
session->escape_string[1]='P';
session->escape_string_length=2;
}
 
void byte_control_sequence_intro(struct session_struct *session)
{
/* Control sequence introducer */
session->escape_state=NETTLE_ESCAPE_ESCAPE;
session->escape_string[0]='\x1B';
session->escape_string[1]='[';
session->escape_string_length=2;
}
 
void byte_string_terminator(struct session_struct *session)
{
/* String terminator */
if (session->escape_state==NETTLE_ESCAPE_ESCAPE)
{
if (session->escape_string_length>=2)
{
if (session->escape_string[0]=='\x1B')
{
if (session->escape_string[1]=='[')
{
session->escape_string[session->escape_string_length++]='\x1B';
session->escape_string[session->escape_string_length++]='\\';
}
}
}
}
}
 
 
void byte_telnet(struct session_struct *session)
{
/* Telnet negotiation */
session->escape_state=NETTLE_ESCAPE_ESCAPE;
session->escape_string[0]='\xFF';
session->escape_string_length=1;
}
 
void byte_default(struct session_struct *session, char byte)
{
if (session->escape_state==NETTLE_ESCAPE_NONE)
{
if (session->spool_file_name!=NULL && !(session->spool_raw))
{
spool_byte(session, byte);
}
 
reprocess_position(session);
 
if (session->other_session_flags & NETTLE_OTHER_INSERT_MODE)
{
/* If we're inserting a character, then shuffle all the characters along a byte */
row_shift_right (session, 1);
}
 
changedbox_update_char (session->pos.x, session->pos.y);
 
/* write out the data */
write_assigned(session, session->pos.x, session->pos.y,
session->current_fg,
session->current_bg,
session->current_flags,
'?');
 
work_out_character(session, session->pos.x, session->pos.y, byte);
 
session->pos.x++;
 
/* If we have a login handler, call it */
if (session->login_data)
session->login_data(session,byte);
}
}
 
void clear_screen(struct session_struct *session, int calc, int calc2, char fg, char bg,
char flags, char character)
{
int loop;
 
/* clear the specified area with the specified fg,bg,flags and character */
for (loop=calc; loop<calc2; loop++)
{
write_assigned(session,
loop % session->terminal_size.x,
loop / session->terminal_size.x,
fg, bg, flags, character);
}
}
 
void clear_alt_screen(struct session_struct *session, int calc, int calc2, char fg,
char bg,char flags, char character)
{
int loop;
 
/* clear the specified area with the specified fg,bg,flags and character */
for (loop=calc; loop<calc2; loop++)
{
write_alt_assigned(session,
loop % session->terminal_size.x,
loop / session->terminal_size.x,
fg, bg, flags, character);
}
}
 
void snap_cursor_to_terminal(struct session_struct *session)
{
/* snaps the cursor inside the terminal */
if (session->pos.x<0)
{
session->pos.x=0;
}
if (session->pos.x>=session->terminal_size.x)
{
session->pos.x=session->terminal_size.x-1;
}
 
if (session->other_session_flags & NETTLE_OTHER_ORIGIN_MODE)
{
if (session->pos.y<session->scroll_start+session->scrollback-1)
{
session->pos.y=session->scroll_start+session->scrollback-1;
}
if (session->pos.y>session->scroll_end+session->scrollback-1)
{
session->pos.y=session->scroll_end+session->scrollback-1;
}
}
else
{
if (session->pos.y<session->scrollback)
{
session->pos.y=session->scrollback;
}
if (session->pos.y>session->terminal_size.y+session->scrollback-1)
{
session->pos.y=session->terminal_size.y+session->scrollback-1;
}
}
}
 
void save_cursor_position (struct session_struct *session)
{
session->old_pos.x=session->pos.x;
session->old_pos.y=session->pos.y-session->scrollback;
session->old_current_flags=session->current_flags;
session->old_current_fg=session->current_fg;
session->old_current_bg=session->current_bg;
session->old_other_session_flags=session->other_session_flags & ~NETTLE_OTHER_CURSOR_VIS;
session->old_character_set_gl=session->character_set_gl;
session->old_character_set_gr=session->character_set_gr;
session->old_character_set_g0=session->character_set_g0;
session->old_character_set_g1=session->character_set_g1;
session->old_character_set_g2=session->character_set_g2;
session->old_character_set_g3=session->character_set_g3;
session->cursor_saved=true;
session->position_saved=true;
}
 
void restore_cursor_position (struct session_struct *session)
{
if (session->cursor_saved && session->position_saved)
{
session->pos.x=session->old_pos.x;
session->pos.y=session->old_pos.y+session->scrollback;
session->current_flags=session->old_current_flags;
session->current_fg=session->old_current_fg;
session->current_bg=session->old_current_bg;
session->other_session_flags|=session->old_other_session_flags & ~NETTLE_OTHER_CURSOR_VIS;
session->character_set_gl=session->old_character_set_gl;
session->character_set_gr=session->old_character_set_gr;
session->character_set_g0=session->old_character_set_g0;
session->character_set_g1=session->old_character_set_g1;
session->character_set_g2=session->old_character_set_g2;
session->character_set_g3=session->old_character_set_g3;
session->cursor_saved=false;
session->position_saved=false;
snap_cursor_to_terminal(session);
}
}
 
void swap_alternate_main(struct session_struct *session)
{
int xpos;
int ypos;
 
if (!session->alternate_area)
return;
 
for (ypos=0; ypos<session->terminal_size.y; ypos++)
{
for (xpos=0; xpos<session->terminal_size.x; xpos++)
{
char fg =read_alt_assigned_fg(session, xpos, ypos);
char bg =read_alt_assigned_bg(session, xpos, ypos);
char flags =read_alt_assigned_flags(session, xpos, ypos);
char character=read_alt_assigned_character(session, xpos, ypos);
 
write_alt_assigned(session, xpos, ypos,
read_assigned_fg(session, xpos, ypos+session->scrollback),
read_assigned_bg(session, xpos, ypos+session->scrollback),
read_assigned_flags(session, xpos, ypos+session->scrollback),
read_assigned_character(session, xpos, ypos+session->scrollback));
 
write_assigned(session, xpos, ypos+session->scrollback, fg, bg, flags, character);
}
}
}
 
void copy_alternate_main(struct session_struct *session)
{
int xpos;
int ypos;
 
if (!session->alternate_area)
return;
 
for (ypos=0; ypos<session->terminal_size.y; ypos++)
{
for (xpos=0; xpos<session->terminal_size.x; xpos++)
{
char fg =read_alt_assigned_fg(session, xpos, ypos);
char bg =read_alt_assigned_bg(session, xpos, ypos);
char flags =read_alt_assigned_flags(session, xpos, ypos);
char character=read_alt_assigned_character(session, xpos, ypos);
write_assigned(session, xpos, ypos+session->scrollback, fg, bg, flags, character);
}
}
}
 
void copy_main_alternate(struct session_struct *session)
{
int xpos;
int ypos;
 
if (!session->alternate_area)
return;
 
for (ypos=0; ypos<session->terminal_size.y; ypos++)
{
for (xpos=0; xpos<session->terminal_size.x; xpos++)
{
char fg =read_assigned_fg(session, xpos, ypos+session->scrollback);
char bg =read_assigned_bg(session, xpos, ypos+session->scrollback);
char flags =read_assigned_flags(session, xpos, ypos+session->scrollback);
char character=read_assigned_character(session, xpos, ypos+session->scrollback);
write_alt_assigned(session, xpos, ypos, fg, bg, flags, character);
}
}
}
 
void clear_main_screen(struct session_struct *session)
{
clear_screen(session, session->scrollback*session->terminal_size.x,
session->terminal_size.x*
(session->terminal_size.y+session->scrollback),
session->current_fg,
session->current_bg,
session->current_flags,
32);
}
 
void clear_alternate_screen(struct session_struct *session)
{
clear_alt_screen(session, 0,
session->terminal_size.x*session->terminal_size.y,
session->current_fg,
session->current_bg,
session->current_flags,
32);
}
 
 
void determine_character_set(struct session_struct *session)
{
switch (session->escape_string[2])
{
case 'B':
/* ASCII */
switch (session->escape_string[1])
{
case '(':
session->character_set_g0=NETTLE_CHSET_ASCII;
break;
case ')':
session->character_set_g1=NETTLE_CHSET_ASCII;
break;
case '*':
if (session->terminal_mode==2)
{
session->character_set_g2=NETTLE_CHSET_ASCII;
}
break;
case '+':
if (session->terminal_mode==2)
{
session->character_set_g3=NETTLE_CHSET_ASCII;
}
break;
}
break;
case '<':
/* DEC Supplemental graphics */
if (session->terminal_mode==2)
{
switch (session->escape_string[2])
{
case '(':
session->character_set_g0=NETTLE_CHSET_DEC_SUPPLEMENTAL_GRAPHICS;
break;
case ')':
session->character_set_g1=NETTLE_CHSET_DEC_SUPPLEMENTAL_GRAPHICS;
break;
case '*':
session->character_set_g2=NETTLE_CHSET_DEC_SUPPLEMENTAL_GRAPHICS;
break;
case '+':
session->character_set_g3=NETTLE_CHSET_DEC_SUPPLEMENTAL_GRAPHICS;
break;
}
}
break;
case 'A':
/* UK National */
if (session->terminal_mode==1)
{
switch (session->escape_string[1])
{
case '(':
session->character_set_g0=NETTLE_CHSET_UK_NATIONAL;
break;
case ')':
session->character_set_g1=NETTLE_CHSET_UK_NATIONAL;
break;
}
}
break;
case '0':
/* DEC Special Graphics */
switch (session->escape_string[1])
{
case '(':
session->character_set_g0=NETTLE_CHSET_DEC_SPECIAL_GRAPHICS;
break;
case ')':
session->character_set_g1=NETTLE_CHSET_DEC_SPECIAL_GRAPHICS;
break;
case '*':
if (session->terminal_mode==2)
{
session->character_set_g2=NETTLE_CHSET_DEC_SPECIAL_GRAPHICS;
}
break;
case '+':
if (session->terminal_mode==2)
{
session->character_set_g3=NETTLE_CHSET_DEC_SPECIAL_GRAPHICS;
}
break;
}
break;
}
}
 
 
void process_data(struct session_struct *session, char byte)
{
bool done=false;
 
if (session->bit_controls)
/* 8-bit */
strcpy(csi_sequence,"\x9B");
else
/* 7-bit */
strcpy(csi_sequence,"\x1B[");
 
if (session->escape_state==NETTLE_ESCAPE_ESCAPE)
{
if (session->escape_string_length==255)
{
generror(lookup_static ("esctoolong"), false);
session->escape_state=NETTLE_ESCAPE_NONE;
session->escape_string_length=0;
}
else
{
if ((session->escape_string[0]==TELNET_IAC) ||
(session->escape_string[0]==27 && (byte<8 || byte>13)))
{
session->escape_string[session->escape_string_length]=byte;
session->escape_string_length++;
done = process_escape(session);
}
}
}
 
if (session->spool_file_name!=NULL && session->spool_raw)
spool_byte(session, byte);
 
if (session->escape_state==NETTLE_ESCAPE_ESCAPE)
{
if (session->escape_string[0]==TELNET_IAC)
{
return;
}
}
 
if (!done)
{
if (session->spool_file_name!=NULL && !(session->spool_raw))
{
if (byte>=10 && byte<=12)
{
spool_byte(session, byte);
}
}
 
switch (byte)
{
/* VT codes */
case 0: byte_null (session); break;
case 1: break;
case 2: break;
case 3: break;
case 4: break;
case 5: byte_enquiry (session); break;
case 7: byte_bell (session); break;
case 8: byte_backspace (session); break;
case 9: byte_horizontal_tabulation (session); break;
case 10:
case 11:
case 12: byte_linefeed (session); break;
case 13: byte_carriage_return (session); break;
case 14: byte_shift_out (session); break;
case 15: byte_shift_in (session); break;
case 16: break;
case 17: byte_device_control_1 (session); break;
case 18: break;
case 19: byte_device_control_3 (session); break;
case 20: break;
case 21: break;
case 22: break;
case 23: break;
case 24: byte_cancel (session); break;
case 25: break;
case 26: byte_substitute (session); break;
case 27: byte_escape (session); break;
case 28: break;
case 29: break;
case 30: break;
case 31: break;
case 127: byte_delete (session); break;
 
/* Telnet codes */
case 255: byte_telnet (session); break;
 
/* Other codes */
default:
if (session->bit_controls)
{
/* 8-bit control sequences */
switch (byte)
{
/* VT C1 codes */
case 128: break;
case 129: break;
case 130: break;
case 131: break;
case 132: byte_index (session); break;
case 133: byte_next_line (session); break;
case 134: break;
case 135: break;
case 136: byte_horizontal_tab_set (session); break;
case 137: break;
case 138: break;
case 139: break;
case 140: break;
case 141: byte_reverse_index (session); break;
case 142: byte_single_shift_g2 (session); break;
case 143: byte_single_shift_g3 (session); break;
case 144: byte_device_control_string (session); break;
case 145: break;
case 146: break;
case 147: break;
case 148: break;
case 149: break;
case 150: break;
case 151: break;
case 152: break;
case 153: break;
case 154: break;
case 155: byte_control_sequence_intro(session); break;
case 156: byte_string_terminator (session); break;
case 157: break;
case 158: break;
case 159: break;
case 160: break;
 
/* Not a 7 or 8-bit control sequence, byte_default */
default: byte_default (session, byte); break;
}
}
else
{
/* Not a 7-bit control sequence (8-bit sequences N/A), byte_default */
byte_default (session, byte); break;
}
}
}
}
 
void append_paste_block (struct session_struct *session,
struct paste_buffer *paste, size_t size)
{
paste->next = NULL;
paste->length = size;
 
if (! session->paste)
session->paste = paste;
if (session->paste_head)
session->paste_head->next = paste;
session->paste_head = paste;
 
main_requirenull = true;
}
 
 
void process_wimp_key(struct session_struct *session, int key, int extra)
{
struct paste_buffer *send_block=malloc(264); /* Keys shouldn't be bigger than 256,
+ 4 for *next, +4 for length - better way? */
 
int size_of_send_block=0;
 
if (!send_block)
return;
 
size_of_send_block = decode_key (session, key, extra, send_block->data);
 
process_handle_buffer(session, send_block, size_of_send_block);
}
 
void process_line_editor(struct session_struct *session)
{
char *icon_text;
char data[512];
int line_editor_icon=0;
 
read_icon_data(session->pane_handle, line_editor_icon, data, sizeof(data));
 
icon_text = malloc(strlen(data) + 3);
assert(icon_text != NULL);
 
strcpy(icon_text, data);
strcat(icon_text, "\r");
 
process_data_transmission(session, icon_text, strlen(icon_text));
 
{
int loop;
 
for (loop=line_editor_size-1; loop>1; loop--)
{
strcpy(session->line_editor_history+(loop*512),
session->line_editor_history+((loop-1)*512));
}
}
 
strcpy(session->line_editor_history+(1*512), icon_text);
 
set_icon_data(session->pane_handle,line_editor_icon,"");
 
set_caret_position(session->pane_handle, line_editor_icon, -1, 0);
 
session->line_editor_position=0;
session->line_editor_total++;
 
if (session->line_editor_total>line_editor_size)
{
session->line_editor_total=line_editor_size;
}
 
free(icon_text);
}
 
void process_data_transmission(struct session_struct *session,
const char *icon_text, int size_of_data)
{
char block[256];
int size_of_block=0;
struct paste_buffer *send_block=0;
int size_of_send_block=0;
int allocated_send_size=0;
int loop;
 
for (loop=0; loop<size_of_data; loop++)
{
int key=icon_text[loop];
 
size_of_block = decode_key (session, key, 0, block);
 
if (size_of_send_block + size_of_block + offsetof (struct paste_buffer, data) > allocated_send_size)
{
allocated_send_size += 16384;
send_block = realloc (send_block, allocated_send_size);
if (!send_block)
{
generror ("CantAlloc", true);
return;
}
}
memcpy(send_block->data+size_of_send_block,block,size_of_block);
size_of_send_block+=size_of_block;
}
 
process_handle_buffer(session, send_block, size_of_send_block);
}
 
void process_handle_buffer(struct session_struct *session,
struct paste_buffer *send_block,
int size_of_send_block)
{
char cursor_flags;
struct coords pos;
 
if (session->other_session_flags & NETTLE_OTHER_KEYLOCK_MODE)
return;
 
/* Just for safety */
if (session->socket_state!=NETTLE_SESSION_CONNECTED)
return;
 
pos=get_cursor_position(session);
 
/* get the cursor flags */
cursor_flags=read_assigned_flags(session, pos.x, pos.y)
& (NETTLE_FLAG_CURSOR | NETTLE_FLAG_NO_INPUT);
 
/* if the cursor flags don't have cursor set, make it so */
cursor_flags |= NETTLE_FLAG_CURSOR;
 
/* remove the cursor from the position */
changedbox_init (session);
changedbox_update_char (pos.x, pos.y);
write_assigned_flags(session, pos.x, pos.y, read_assigned_flags(session, pos.x, pos.y)
& ~(NETTLE_FLAG_CURSOR | NETTLE_FLAG_NO_INPUT));
force_redraw_changedbox ();
 
changedbox_init (session);
 
if (session->local_echo == true) /* session->session_flags[1]==false) */
{
int loop;
 
for (loop=0; loop<size_of_send_block; loop++)
{
switch (send_block->data[loop])
{
case 7: byte_bell (session); break;
case 8: byte_backspace (session);
 
changedbox_update_char (session->pos.x, session->pos.y);
write_assigned(session, session->pos.x, session->pos.y,
session->current_fg,
session->current_bg,
session->current_flags,
32);
break;
 
case 9: byte_horizontal_tabulation(session); break;
case 10: byte_linefeed (session); break;
case 13: byte_carriage_return (session);
#ifdef KEYBOARD_RETURN_BODGE
byte_linefeed(session);
#endif
break;
 
default:
reprocess_position(session);
 
if (send_block->data[loop]<32)
{
changedbox_update_char (session->pos.x, session->pos.y);
write_assigned(session, session->pos.x, session->pos.y,
session->current_fg,
session->current_bg,
session->current_flags,
'^');
 
session->pos.x++;
reprocess_position(session);
}
 
/* write out the data */
changedbox_update_char (session->pos.x, session->pos.y);
write_assigned(session, session->pos.x, session->pos.y,
session->current_fg,
session->current_bg,
session->current_flags,
'?');
 
if (send_block->data[loop]<32)
{
write_assigned_character(session, session->pos.x, session->pos.y,
send_block->data[loop]+64);
}
else
{
work_out_character(session, session->pos.x, session->pos.y, send_block->data[loop]);
}
session->pos.x++;
 
break;
}
}
}
 
pos=get_cursor_position(session);
 
/* OR back in the cursor flags */
if (session->other_session_flags & NETTLE_OTHER_CURSOR_VIS)
{
write_assigned_flags(session, pos.x, pos.y,
read_assigned_flags(session, pos.x, pos.y) | cursor_flags);
}
 
/* redraw the window */
force_redraw_changedbox ();
 
/* force the selection back on (it may have got overwritten by new data) */
force_redraw_selection();
 
/* redraw the cursor, in case it isn't in the main redraw block */
if (session->other_session_flags & NETTLE_OTHER_CURSOR_VIS)
{
changedbox_init (session);
changedbox_update_char (pos.x, pos.y);
force_redraw_changedbox ();
}
 
/* queue the data for sending... */
if (send_block)
append_paste_block (session, send_block, size_of_send_block);
}
 
/* get the current cursor position */
struct coords get_cursor_position(struct session_struct *session)
{
struct coords pos;
 
pos.x = session->pos.x;
pos.y = session->pos.y;
 
/* get a sanitised x coordinate */
if (pos.x >= session->terminal_size.x)
pos.x = session->terminal_size.x - 1;
 
/* return real offset or, if outside terminal, the last available offset */
if (pos.y >= session->terminal_size.y + session->scrollback)
{
pos.x = session->terminal_size.x;
pos.y = session->terminal_size.y + session->scrollback - 1;
}
 
return pos;
}
/vendor/v0.2023/wimputil.h
New file
0,0 → 1,100
/**
* Nettle Wimp utilities - generic code
* (C) Nettle developers 2000-2002
*
* $Id: wimputil,v 1.7 2002/03/18 01:57:04 ijeffray Exp $
*/
 
#ifndef WIMPUTIL_H
#define WIMPUTIL_H
 
#include "nettle.h"
#include "messages.h"
 
/** Button enumeration for a click/drag/double click icon */
enum
{
ClickAdjust = 0x001 * 256,
ClickMenu = 0x002 * 1,
ClickSelect = 0x004 * 256,
DragAdjust = 0x001 * 16,
DragMenu = 0x002 * 16,
DragSelect = 0x004 * 16,
DoubleAdjust = 0x001 * 1,
DoubleSelect = 0x004 * 1
};
 
extern void closedown_wimp(void);
 
extern void generror(const char *, bool);
extern bool generror_question(const char *buttonstok, const char *formattok,int params,...);
extern void gensaveerror (FILE *, const char *);
 
extern void set_icon_state(int, int, int, int);
extern void set_icon_data(int, int, const char *);
extern char *read_icon_data(int, int, char *, int);
 
extern void set_title_bar(int, const char *);
extern void force_redraw(int,int,int,int,int);
 
extern void create_menu_by_icon(int *menu, int window, int icon);
extern bool win_is_open(int window_handle);
extern int get_icon_data_length(int window_handle, int icon_handle);
extern char *get_icon_validation (int window_handle, int icon_handle);
extern bool read_icon_ticked (int window_handle, int icon_handle);
 
extern int *create_menu(int *menu_defn, char *indirected, char *title, char *entries, ... );
extern char *get_menu_item(const char *name);
extern char *get_last_menu_item(const char *name);
extern char *get_grey_menu_item(const char *name);
extern char *get_grey_last_menu_item(const char *name);
 
extern void drag_start(int window_handle, int icon_handle);
 
/******************************************************************
Function: tick_menu_for_icon_text
Description: Ticks the menu item that matches the text in the
icon specified
Parameters: menu-> the menu structure
window = the window handle
icon = the icon handle
Returns: none
******************************************************************/
void tick_menu_for_icon_text(int *menu, int window_handle, int icon);
 
 
/*************************************************** Gerph *********
Function: tick_menu_for_icon_text
Description: Ticks the menu item that matches the text in the
icon specified
Parameters: menu-> the menu structure
window = the window handle
icon = the icon handle
Returns: none
******************************************************************/
void tick_menu_for_icon_text(int *menu, int window_handle, int icon);
 
 
/*************************************************** Gerph *********
Function: crate_menu_given_array
Description: create a menu entry block, given an array of token
strings which should be used as the text.
Parameters: menu_defn-> where to write to
indirected-> space to write indirected text to
indirected_len = amount of space in the indirect
buffer
title_tok-> the token to use for the title of the
menu
nentries = number of entries we're going to write
entries-> an array of the menu entries token names
we're going to expand for the text of the
menu items
Returns: pointer to the menu
******************************************************************/
int *create_menu_given_array(int *menu_defn,
char *indirected, int indirected_len,
char *title_tok,
int nentries, const char *entries[]);
 
 
#endif
/vendor/v0.2023/chardefn.h
New file
0,0 → 1,18
/**
* Zap font character definitions
* (C) Nettle developers 2000-2001
*
* $Id: chardefn,v 1.6 2002/02/02 21:37:48 ijeffray Exp $
*/
 
#ifndef CHARDEFN_H
#define CHARDEFN_H
 
/* Number of additional characters we are going to define at 0x100 in
chardefn.c */
#define EXTRA_ZAP_CHARS (0x1e)
 
extern void define_zap_chars(int *, int, int, int);
extern void define_zap_undef_chars(int *, int, int, int, int, int);
 
#endif
/vendor/v0.2023/dnslib.h
New file
0,0 → 1,32
/*
* RISC OS resolver abstraction code
*
* © Joseph Heenan, 2000
*
* $Id: dnslib,v 1.1 2001/08/29 22:56:33 jogu Exp $
*/
 
#ifndef DNS_H
#define DNS_H
 
typedef struct dns_s dns_t;
 
typedef enum
{
dns_init,
dns_inprogress,
dns_singletask,
dns_complete_success,
dns_complete_failure
}
dns_status_t;
 
dns_t *dns_gethostbyname(const char *host);
 
void dns_dispose(dns_t *query);
 
dns_status_t dns_check(dns_t *query);
 
struct hostent *dns_getanswer(dns_t *query);
 
#endif /* DNS_H */
/vendor/v0.2023/quit.c
New file
0,0 → 1,57
/**
* Closedown code
* (C) Nettle developers 2000-2001
*
* $Id: quit,v 1.22 2002/02/01 23:51:39 ijeffray Exp $
*/
 
#include "generic.h"
#include "globals.h"
 
#include "hotlist.h"
#include "init.h"
#include "messages.h"
#include "misc.h"
#include "nettle.h"
#include "quit.h"
#include "scripts.h"
#include "sockwatch.h"
#include "termlist.h"
#include "zapredraw.h"
#include "wimp.h"
 
#include "sshif.h"
 
void closedown_application(void)
{
/* Quit! */
 
while (sessions)
{
remove_session(sessions);
}
 
lose_messages();
lose_bitmaps();
lose_zapredraw_area();
 
free(zap_font_area);
free(zap_lowres_font_area);
lose_hotlist();
lose_termlist_menu();
socketwatch_finalise();
lose_templates();
script_closedown();
 
close_log(true);
 
sshinterface_finalise();
 
#ifdef FORTIFY
Fortify_LeaveScope();
#endif
 
closedown_wimp();
 
exit(EXIT_SUCCESS);
}
/vendor/v0.2023/process.h
New file
0,0 → 1,145
/**
* Processing code
* (C) Nettle developers 2000-2002
*
* $Id: process,v 1.17 2002/02/01 23:56:54 ijeffray Exp $
*/
 
#ifndef PROCESS_H
#define PROCESS_H
 
#define TELNET_SE 240
#define TELNET_NOP 241
#define TELNET_DATAMARK 242
#define TELNET_BRK 243
#define TELNET_IP 244
#define TELNET_AO 245
#define TELNET_AYT 246
#define TELNET_EC 247
#define TELNET_EL 248
#define TELNET_GA 249
#define TELNET_SB 250
#define TELNET_WILL 251
#define TELNET_WONT 252
#define TELNET_DO 253
#define TELNET_DONT 254
#define TELNET_IAC 255
 
/* Leave these indented by 1 char until they're handled somewhere! */
#define TELOPT_TRANSMIT_BINARY 0 /* RFC 856 */
#define TELOPT_ECHO 1 /* RFC 857 */
#define TELOPT_SUPPRESS_GO_AHEAD 3 /* RFC 858 */
#define TELOPT_STATUS 5 /* RFC 859 */
#define TELOPT_RTCE 7 /* RFC 726 */
#define TELOPT_TIMING_MARK 6 /* RFC 860 */
#define TELOPT_NAOCRD 10 /* RFC 652 */
#define TELOPT_NAOHTS 11 /* RFC 653 */
#define TELOPT_NAOHTD 12 /* RFC 654 */
#define TELOPT_NAOFFD 13 /* RFC 655 */
#define TELOPT_NAOVTS 14 /* RFC 656 */
#define TELOPT_NAOVTD 15 /* RFC 657 */
#define TELOPT_NAOFLD 16 /* RFC 658 */
#define TELOPT_EXTEND_ASCII 17 /* RFC 698 */
#define TELOPT_LOGOUT 18 /* RFC 727 */
#define TELOPT_BM 19 /* RFC 735 */
#define TELOPT_DET 20 /* RFC 1043 */
#define TELOPT_SUPDUP 21 /* RFC 736 */
#define TELOPT_SUPDUP_OUTPUT 22 /* RFC 749 */
#define TELOPT_SEND_LOCATION 23 /* RFC 779 */
#define TELOPT_TERMINAL_TYPE 24 /* RFC 1091 */
#define TELOPT_END_OF_RECORD 25 /* RFC 885 */
#define TELOPT_TUID 26 /* RFC 927 */
#define TELOPT_OUTMRK 27 /* RFC 933 */
#define TELOPT_TTYLOC 28 /* RFC 946 */
#define TELOPT_3270_REGIME 29 /* RFC 1041 */
#define TELOPT_X3_PAD 30 /* RFC 1053 */
#define TELOPT_NAWS 31 /* RFC 1073 */
#define TELOPT_TERMINAL_SPEED 32 /* RFC 1079 */
#define TELOPT_TOGGLE_FLOW_CONTROL 33 /* RFC 1372 */
#define TELOPT_LINEMODE 34 /* RFC 1184 */
#define TELOPT_XDISPLOC 35 /* RFC 1096 */
#define TELOPT_ENVIRON 36 /* RFC 1408 */
#define TELOPT_AUTHENTICATION 37 /* RFC 1416 */
#define TELOPT_NEW_ENVIRON 39 /* RFC 1572 */
#define TELOPT_EXTENDED_OPTIONS_LIST 255 /* RFC 861 */
 
#define TELOPT_SUB_IS 0
#define TELOPT_SUB_SEND 1
 
extern void changedbox_init (struct session_struct *session);
extern void changedbox_update (int cx0, int cy0, int cx1, int cy1);
extern void changedbox_update_char (int cx0, int cy0);
extern void changedbox_update_offset (int calc);
extern void changedbox_update_whole (void);
extern void force_redraw_changedbox (void);
extern void clear_screen(struct session_struct *session, int calc, int calc2, char fg, char bg,
char flags, char character);
extern void clear_alt_screen(struct session_struct *session, int calc, int calc2, char fg,
char bg,char flags, char character);
extern void copy_main_alternate(struct session_struct *session);
extern void process_data(struct session_struct *session, char byte);
extern void process_wimp_key(struct session_struct *session, int key, int extra);
extern void process_line_editor(struct session_struct *session);
extern void process_data_transmission(struct session_struct *session,
const char *icon_text, int size_of_data);
extern struct coords get_cursor_position(struct session_struct *session);
extern void primary_da_request(struct session_struct *session);
extern void shuffle_up(struct session_struct *session, int start, int end);
extern void shuffle_down(struct session_struct *session, int start, int end);
extern void scroll_up(struct session_struct *session, bool wrap);
extern void scroll_down (struct session_struct *session, bool wrap);
extern void reprocess_position_scroll(struct session_struct *session);
extern void reprocess_position(struct session_struct *session);
extern void row_shift_right (struct session_struct *session, int chars);
extern void work_out_character_character_set(struct session_struct *session,int character_set,
int xpos, int ypos, unsigned char byte);
extern void work_out_character(struct session_struct *session, int xpos, int ypos,
unsigned char byte);
extern void byte_null(struct session_struct *session);
extern void byte_enquiry(struct session_struct *session);
extern void byte_bell(struct session_struct *session);
extern void byte_backspace(struct session_struct *session);
extern void byte_horizontal_tabulation(struct session_struct *session);
extern void byte_reverse_horizontal_tabulation(struct session_struct *session);
extern void byte_linefeed(struct session_struct *session);
extern void byte_carriage_return(struct session_struct *session);
extern void byte_shift_out(struct session_struct *session);
extern void byte_shift_in(struct session_struct *session);
extern void byte_device_control_1(struct session_struct *session);
extern void byte_device_control_3(struct session_struct *session);
extern void byte_cancel(struct session_struct *session);
extern void byte_substitute(struct session_struct *session);
extern void byte_escape(struct session_struct *session);
extern void byte_delete(struct session_struct *session);
extern void byte_index(struct session_struct *session);
extern void byte_next_line(struct session_struct *session);
extern void byte_horizontal_tab_set(struct session_struct *session);
extern void byte_reverse_index(struct session_struct *session);
extern void byte_single_shift_g2(struct session_struct *session);
extern void byte_single_shift_g3(struct session_struct *session);
extern void byte_device_control_string(struct session_struct *session);
extern void byte_control_sequence_intro(struct session_struct *session);
extern void byte_string_terminator(struct session_struct *session);
extern void byte_telnet(struct session_struct *session);
extern void byte_default(struct session_struct *session, char byte);
extern void snap_cursor_to_terminal(struct session_struct *session);
extern void save_cursor_position (struct session_struct *session);
extern void restore_cursor_position (struct session_struct *session);
extern void swap_alternate_main(struct session_struct *session);
extern void copy_alternate_main(struct session_struct *session);
extern void clear_main_screen(struct session_struct *session);
extern void clear_alternate_screen(struct session_struct *session);
extern void determine_character_set(struct session_struct *session);
extern void append_paste_block (struct session_struct *session,
struct paste_buffer *paste, size_t size);
extern void process_handle_buffer(struct session_struct *session,
struct paste_buffer *send_block,
int size_of_send_block);
 
extern void handle_iac_will(struct session_struct *session);
extern void handle_iac_wont(struct session_struct *session);
extern void handle_iac_do(struct session_struct *session);
extern void handle_iac_dont(struct session_struct *session);
extern bool process_escape(struct session_struct *session);
 
#endif
/vendor/v0.2023/p_rexec.c
New file
0,0 → 1,220
/**
* Protocol RExec specific support code
* (C) Nettle developers 2002
*
* $Id$
*/
 
#include "generic.h"
#include "globals.h"
#include "messages.h"
#include "p_rexec.h"
#include "socket.h"
 
#define INITIAL_PORT (512)
#define MAXIMUM_PORT (600) /* JRF: Arbitrary */
 
/* Prototypes */
char *rexec_session_setup(struct session_struct *);
char *rexec_session_shutdown(struct session_struct *);
 
protocol_t protocol_rexec = {
"rexec", /* Protocol name in Choices file */
"snettle_rexec", /* Sprite to use to indicate this protocol */
"RExec", /* Token for this protocol name in messages file */
NULL, /* URI scheme prefix, or NULL if none */
512, /* Default port, or -1 if no port */
NETTLE_REXEC, /* Protocol type number */
 
/* Protocol flags */
PROTOCOL_HAS_HOST |
PROTOCOL_HAS_USER |
PROTOCOL_NEEDS_USER |
PROTOCOL_HAS_PASS |
PROTOCOL_NEEDS_PASS |
PROTOCOL_HAS_COMMAND |
PROTOCOL_NEEDS_COMMAND,
 
rexec_session_setup,
rexec_session_shutdown
};
 
/* RExec protocol (based on rcmd) :
Connect to server on port 512, from port 512-1023
Send <port for errors - null string for none>, 0,
<local user>, 0,
<remote user>, 0,
<terminal type>, 0
Read 1 byte:
0 = connection successful;
connection established, the remote end may challenge
as it sees fit
other = connection failed;
the next string to a newline or connection close is an
error message
*/
 
 
/*************************************************** Gerph *********
Function: rexec_data
Description: Data has been received; we process it and return.
We replace \n with \r\n because rexec only gives us
\ns.
Parameters: session-> the session from which the data arrives
data-> the data
datalen = the length of the data
Returns: none
******************************************************************/
void rexec_data(struct session_struct *session,const char *data,
int datalen)
{
int writelen;
if (datalen==0)
return;
 
writelen=0;
while (datalen>0)
{
if (data[writelen] == '\n')
{
write_out_data(session,data,writelen);
write_out_data(session,"\r",1);
data+=writelen;
writelen=0;
}
writelen++;
datalen--;
}
write_out_data(session,data,writelen);
}
 
/*************************************************** Gerph *********
Function: rexec_initialdata
Description: Data has been received; we process it and return.
We need to check the first byte and hand the rest
of the data on to the normal handlers
Parameters: session-> the session from which the data arrives
data-> the data
datalen = the length of the data
Returns: none
******************************************************************/
void rexec_initialdata(struct session_struct *session,const char *data,
int datalen)
{
if (datalen==0)
return;
 
write_out_formatted(session,"initialdata: %i\r\n",*data);
 
datalen--;
if (*data++)
{
const char *prefix = lookup_static("rexecrejected");
/* An error occurred at the remote end */
session->session_data = write_out_data;
write_out_data(session,prefix,strlen(prefix));
write_out_data(session,data,datalen);
 
/* The remote end will close the connection; we don't need to do
anything */
}
else
{
/* RExec request accepted; from now on, the remote end is performing
validation and normal terminal handling */
session->session_data = rexec_data;
rexec_data(session,data,datalen);
 
/* Must remember to unlock the keyboard, now that we're connected */
session->other_session_flags &= ~NETTLE_OTHER_KEYLOCK_MODE;
/* They don't like us echoing */
session->local_echo = false;
}
}
 
/*************************************************** Gerph *********
Function: rexec_connected
Description: Socket has now connected; we must send our initial
negotiation data to the remote.
Parameters: session-> the session we are connecting
Returns: none
******************************************************************/
void rexec_connected(struct session_struct *session)
{
/* This is a short data block; I'm assuming it will all transmit
without giving any errors */
nettle_senddata(session,"",1); /* No error port */
if (session->login_user==NULL)
{
write_out_string(session,"rexec: Internal error (user/pass was unset on connect)\r\n");
}
else
{
nettle_senddata(session,session->login_user,strlen(session->login_user)+1);
if (session->login_pass==NULL)
nettle_senddata(session,"",1);
else
nettle_senddata(session,session->login_pass,strlen(session->login_pass)+1);
nettle_senddata(session,session->login_command,strlen(session->login_command)+1);
 
free(session->login_user);
session->login_user = NULL;
free(session->login_pass);
session->login_pass = NULL;
 
session->session_data = rexec_initialdata;
}
}
 
 
/*************************************************** Gerph *********
Function: rexec_resolved
Description: Connection has resolved, socket is created and ready
for connecting; we must set up socket options. In this
case, we're going to bind to a low port. We must do
this because rlogind expects the connection to come
from ports between 512 and 1024.
Parameters: session-> the session we're operating on
Returns: none (may be error in future)
******************************************************************/
void rexec_resolved(struct session_struct *session)
{
int port=INITIAL_PORT;
while (socket_bind(session->socket_handle,port) &&
(port < MAXIMUM_PORT))
port++;
 
/* FIXME: Should report error */
}
 
/*************************************************** Gerph *********
Function: rexec_session_setup
Description: Set up a protocol session
Parameters: session-> the session we're constructing
Returns: pointer to token to return as an error, or NULL if none
******************************************************************/
char *rexec_session_setup(struct session_struct *session)
{
session->session_data = write_out_data;
session->session_connected = rexec_connected;
session->session_resolved = rexec_resolved;
 
session->session_send = nettle_senddata_socket;
session->session_resized = NULL;
 
/* Initially we want NO input from the user; this is the simplest
way in which to assert this */
session->other_session_flags |= NETTLE_OTHER_KEYLOCK_MODE;
return NULL;
}
 
/*************************************************** Gerph *********
Function: rexec_session_shutdown
Description: Shut down a protocol session
Parameters: session-> the session we're constructing
Returns: pointer to token to return as an error, or NULL if none
******************************************************************/
char *rexec_session_shutdown(struct session_struct *session)
{
return NULL;
}
/vendor/v0.2023/hotlist.c
New file
0,0 → 1,1382
/**
* Nettle Hotlist code
* (C) Nettle developers 2000-2002
*
* $Id: hotlist,v 1.28 2002/02/18 22:02:23 ijeffray Exp $
*/
 
#include "generic.h"
#include "globals.h"
 
#include "hotlist.h"
#include "lineedit.h"
#include "misc.h"
#include "messages.h"
#include "nettle.h"
#include "protocols.h"
#include "templ.h"
#include "wimp.h"
#include "wimputil.h"
 
#include <time.h>
#include <ctype.h>
 
#define ENTRYHEIGHT (44)
 
/* Some constants to make redraws clearer */
#define PANE_BOTTOM (-(1<<28))
#define PANE_RIGHT (1024)
 
#define BOGUSERROR(what) generror("This error shouldn't happen. (" what ")", false);
 
typedef struct _hotlistnode
{
struct _hotlistnode *next;
int type;
char *label;
char *host;
char *command;
unsigned char internal_state; /* Used for selection etc */
unsigned char vttype; /* An index in to the vt type array -- the user gives a string, and we match that to the array at load time */
unsigned char lineeditor;
unsigned short terminal_width;
unsigned short terminal_height;
unsigned short scrollback;
} hotlistnode;
 
static hotlistnode *editlisthead = NULL;
static hotlistnode *editlisttail = NULL;
static hotlistnode *hotlisthead = NULL;
static hotlistnode *hotlisttail = NULL;
static hotlistnode *selectednode = NULL;
static int selcon=0, seltype=0, selline=0;
static int edititems = 0;
static int items = 0;
static int *menublock = NULL;
 
static void int_lose_hotlist(hotlistnode **head);
static void addnodetolist(hotlistnode **head, hotlistnode **tail, hotlistnode *node);
static hotlistnode *hotlist_createnew(void);
static int hotlist_populate_selected(void);
static void hotlist_clear_states(void);
static hotlistnode *hotlist_createnew(void);
 
/******************************************************************************/
 
static void enable_buttons(bool enabled)
{
int flag = enabled ? 0 : WIMP_ICON_SHADED_BIT;
 
set_icon_state( win_panehot, icon_panehot_edit, flag, WIMP_ICON_SHADED_BIT);
set_icon_state( win_panehot, icon_panehot_copy, flag, WIMP_ICON_SHADED_BIT);
set_icon_state( win_panehot, icon_panehot_delete, flag, WIMP_ICON_SHADED_BIT);
}
 
/******************************************************************************/
 
static char *get_icon_data(int window, int icon)
{
static char buf[256];
 
return read_icon_data(window, icon, buf, 256);
}
 
/******************************************************************************/
 
static bool hotlist_copynode(hotlistnode *node, hotlistnode **nodenew)
{
hotlistnode *newnode = (hotlistnode *) malloc(sizeof(hotlistnode));
if (!newnode)
return false;
 
*nodenew = newnode;
 
newnode->next = NULL;
newnode->label = NULL;
newnode->host = NULL;
newnode->command = NULL;
newnode->internal_state = node->internal_state;
newnode->type = node->type;
newnode->vttype = node->vttype;
newnode->lineeditor = node->lineeditor;
newnode->terminal_width = node->terminal_width;
newnode->terminal_height= node->terminal_height;
newnode->scrollback = node->scrollback;
 
if (node->internal_state & 1)
node->internal_state &= ~1;
 
if (node->label)
{
newnode->label = malloc(strlen(node->label)+1);
if (!newnode->label)
goto err;
strcpy(newnode->label, node->label);
}
 
if (node->host)
{
newnode->host = malloc(strlen(node->host)+1);
if (!newnode->host)
goto err;
strcpy(newnode->host, node->host);
}
 
if (node->command)
{
newnode->command = malloc(strlen(node->command)+1);
if (!newnode->command)
goto err;
strcpy(newnode->command, node->command);
}
 
return true;
 
err:
free(newnode->label);
free(newnode->host);
free(newnode->command);
free(newnode);
return false;
}
 
/******************************************************************************/
 
static void copy_hotlist(bool edit_to_live) /* true = copy the editlist to the live list */
{
hotlistnode *node = edit_to_live ? editlisthead : hotlisthead;
hotlistnode *newnode;
 
int_lose_hotlist(edit_to_live ? &hotlisthead : &editlisthead);
 
if (edit_to_live)
items = 0;
else
edititems = 0;
 
while (node)
{
if (hotlist_copynode(node, &newnode) == false)
{
/* bleugh! Whatamess. Should inform the user */
return;
}
 
if (edit_to_live)
addnodetolist(&hotlisthead, &hotlisttail, newnode);
else
addnodetolist(&editlisthead, &editlisttail, newnode);
 
if (edit_to_live)
items++;
else
edititems++;
 
node = node->next;
}
 
if (win_hotpane)
{
/* JRF: The list has changed and so we should redraw the pane */
force_redraw(win_hotpane,0,PANE_BOTTOM,PANE_RIGHT,0);
/* And make sure that the buttons reflect the new state */
enable_buttons(false);
}
}
 
/******************************************************************************/
 
static int hash_term(unsigned char *type, const char *value)
{
int i;
*type = 0;
for(i=0; i<NO_OF_TERMINAL_TYPES; i++)
{
if (strcmp(value,terminal_name[i])==0)
{
*type = i;
return 0;
}
}
 
return 1;
}
 
/******************************************************************************/
 
static int read_hot_string(char **dest, char *value, char *check, const char *compare)
{
if (strncmp(check,compare,strlen(compare))==0)
{
if (*dest)
return 1;
*dest = malloc(strlen(value)+1);
if (!*dest)
return 1;
strcpy(*dest, value);
}
return 0;
}
 
/******************************************************************************/
 
static int read_hot_number(unsigned short *dest, char *value, char *check, const char *compare)
{
if (strncmp(check,compare,strlen(compare))==0)
{
unsigned long val = strtoul(value, NULL, 10);
if (val >= (1<<(8*sizeof(short))) ) /* 65535 */
return 1;
*dest = (unsigned short) val;
}
return 0;
}
 
/******************************************************************************/
 
static int read_hot_present(char *flag, char *value, char *check, const char *compare)
{
*flag = '\0';
if (strncmp(check,compare,strlen(compare))==0)
{
*flag = 'y';
}
return 0;
}
 
/******************************************************************************/
 
static void addnodetolist(hotlistnode **head, hotlistnode **tail, hotlistnode *node)
{
node->next = NULL;
if (!*head)
*head = node;
else
(*tail)->next = node;
*tail = node;
}
 
/******************************************************************************/
 
void lose_hotlist(void)
{
int_lose_hotlist(&hotlisthead);
int_lose_hotlist(&editlisthead);
}
 
/******************************************************************************/
 
static void int_lose_hotlist(hotlistnode **head)
{
while (*head)
{
hotlistnode *next = (*head)->next;
 
free((*head)->label);
free((*head)->command);
free((*head)->host);
free(*head);
 
*head = next;
}
 
free(menublock);
menublock = NULL;
}
 
/******************************************************************************/
 
static char *get_line(FILE *in)
{
static char string[256];
char *str;
int len;
 
str = fgets(string, sizeof(string), in);
if (!str)
return NULL;
 
/* strip CRs, spaces etc off the end */
len = strlen(string);
for(;len;len--)
{
if (string[len-1]>' ')
break;
else
string[len-1]='\0';
}
 
return string;
}
 
/******************************************************************************/
 
static hotlistnode *create_blank(void)
{
hotlistnode *node = (hotlistnode *) malloc(sizeof(hotlistnode));
if (!node)
return NULL;
 
node->next = NULL;
node->internal_state = 0;
node->type = NETTLE_TELNET;
node->label = NULL;
node->host = NULL;
node->command = NULL;
 
/* The following pull values from the global choices */
node->vttype = default_terminal;
node->lineeditor = line_editor;
node->terminal_width = defaultsize.x;
node->terminal_height = defaultsize.y;
node->scrollback = defaultscroll;
 
return node;
}
 
/******************************************************************************/
 
static void create_entry(char *title, FILE *in)
{
char *str,*tail,tmp;
unsigned short tmpy;
hotlistnode *node = create_blank();
if (!node)
goto error;
 
node->label = malloc(strlen(title)+1);
if (!node->label)
goto error;
 
strcpy(node->label, title);
 
str = get_line(in);
if (!(str[0]=='{' && str[1]=='\0'))
goto errbarf;
 
do
{
str = get_line(in);
if (str)
{
if (str[0]=='}')
{
addnodetolist(&editlisthead, &editlisttail, node);
edititems++;
return;
}
 
if (!(*str=='#' || *str=='\0'))
{
while (*str==' ')
str++;
 
if (strlen(str)<6 || str[4]!=':')
goto errbarf;
 
tail = str+5;
while (*tail==' ')
tail++;
 
if(read_hot_string(&node->host , tail, str, "host")) goto errbarf;
if(read_hot_string(&node->command , tail, str, "cmnd")) goto errbarf;
if(read_hot_number(&node->terminal_width , tail, str, "wide")) goto errbarf;
if(read_hot_number(&node->terminal_height, tail, str, "high")) goto errbarf;
if(read_hot_number(&node->scrollback , tail, str, "scrl")) goto errbarf;
tmpy = node->lineeditor;
if(read_hot_number(&tmpy , tail, str, "lned")) goto errbarf;
node->lineeditor = (char) tmpy;
switch (choices_file_version_number)
{
case 0:
if (node->lineeditor==LINEEDIT_CHECKBOX_OFF)
node->lineeditor=LINEEDIT_CHECKBOX_ON;
else if (node->lineeditor==LINEEDIT_CHECKBOX_ON)
node->lineeditor=LINEEDIT_ANTTERM;
}
 
if(read_hot_present(&tmp , tail, str, "type")) goto errbarf;
else if (tmp) if ((node->type=protocol_fromconfigname(tail)) == -1) goto errbarf;
if(read_hot_present(&tmp , tail, str, "term")) goto errbarf;
else if (tmp) if (hash_term(&node->vttype, tail)) goto errbarf;
 
}
}
} while (str);
 
errbarf:
generror("BadHotlist", true);
error:
if (node)
{
free(node->label);
free(node->host);
free(node->command);
free(node);
}
fseek(in, 0, SEEK_END);
 
}
 
/******************************************************************************/
 
static bool save_hotlist(void)
{
char hotlist_path[256];
char string[256];
hotlistnode *node = hotlisthead;
 
get_system_variable(hotlist_path, "Choices$Write", sizeof(hotlist_path));
 
if (hotlist_path[0] == '\0' )
{
sprintf(string, "<%s$Dir>.Choices", application_name);
}
else
{
sprintf(string, "<Choices$Write>.%s", application_name);
}
 
_swi(OS_File, _INR(0,1)|_IN(4), 8, string, 0);
strcat(string, ".Hotlist");
 
_kernel_last_oserror();
 
{
bool error=false;
FILE *file_handle=fopen(string, "w");
 
if (file_handle==NULL)
{
/* Couldn't open the file for writing */
error=true;
}
else
{
time_t current_time;
 
time(&current_time);
 
fprintf(file_handle, "# Nettle hotlist file\n");
fprintf(file_handle, "# Created on %s", ctime(&current_time));
 
while (node)
{
if(node->label && node->label[0])
fprintf(file_handle, "\n%s\n{\n", node->label);
else
fprintf(file_handle, "\n(Unnamed){\n");
 
if(node->host && node->host[0])
fprintf(file_handle, " host: %s\n", node->host);
 
if(node->command && node->command[0])
fprintf(file_handle, " cmnd: %s\n", node->command);
 
fprintf(file_handle, " type: %s\n", protocol_toconfigname(node->type));
 
fprintf(file_handle, " term: %s\n", terminal_name[node->vttype]);
 
fprintf(file_handle, " wide: %d\n", node->terminal_width);
 
fprintf(file_handle, " high: %d\n", node->terminal_height);
 
fprintf(file_handle, " scrl: %d\n", node->scrollback);
 
fprintf(file_handle, " lned: %d\n", node->lineeditor);
 
fprintf(file_handle, "}\n");
 
node = node->next;
}
 
 
if (!ferror(file_handle))
{
if (fclose(file_handle))
error=true;
 
file_handle=NULL;
}
}
 
if (error)
{
gensaveerror(file_handle, "CantSaveHotlist");
return false;
}
 
return true;
}
}
 
/******************************************************************************/
 
void load_hotlist(void)
{
FILE *file_handle;
char hotlist_path[256];
char string[256];
char *str;
 
get_system_variable(hotlist_path, "Choices$Write", sizeof(hotlist_path));
 
if (hotlist_path[0] == '\0' )
{
sprintf(string, "<%s$Dir>.Choices.Hotlist", application_name);
}
else
{
sprintf(string, "Choices:%s.Hotlist", application_name);
}
 
file_handle = fopen(string,"r");
if (!file_handle)
return;
 
do
{
str = get_line(file_handle);
if (str)
{
if (!(*str=='#' || *str=='\0'))
{
create_entry(str, file_handle);
}
}
} while (str);
 
copy_hotlist(true);
 
fclose(file_handle);
}
 
/******************************************************************************/
 
int *create_hotlist_menu(void)
{
hotlistnode *node = hotlisthead;
int position=7;
int wide=200;
 
if (!items)
return NULL;
 
if (!menublock)
{
menublock = (int *) malloc(24*items+28);
if (!menublock)
return NULL;
 
lookup("Hotlist", (char *)menublock, 12);
 
menublock[3]=(7<<0)+(2<<8)+(7<<16)+(0<<24); /* black on white items, black on grey title text */
menublock[4]=wide;
menublock[5]=44;
menublock[6]=0;
 
while (node)
{
menublock[position++]= node->next ? 0 : (1<<7); /* Set "last" bit if this is the end of the list */
menublock[position++]=-1; /* No submenu */
 
#ifdef HOTLIST_NO_SPRITES
menublock[position++]=WIMP_ICON_FGCOL(7) | WIMP_ICON_VCENT_BIT | WIMP_ICON_FILLED_BIT | \
WIMP_ICON_TEXT_BIT | WIMP_ICON_INDIRECTED_BIT;
 
menublock[position++]=(int) node->label;
menublock[position++]=0;
menublock[position++]=strlen(node->label)+1;
#else
menublock[position++]=WIMP_ICON_FGCOL(7) | WIMP_ICON_VCENT_BIT | WIMP_ICON_FILLED_BIT | \
WIMP_ICON_TEXT_BIT | WIMP_ICON_INDIRECTED_BIT | WIMP_ICON_SPRITE_BIT;
 
menublock[position++]=(int) node->label;
menublock[position++]=(int) protocol_tospritevalidation(node->type);
menublock[position++]=strlen(node->label)+1;
#endif
 
if (menublock[position-1]+1 * 16 > wide)
wide = menublock[position-1]+1 * 16;
 
node = node->next;
}
 
menublock[4] = wide;
}
return (int *) menublock;
}
 
/******************************************************************************/
 
static hotlistnode *decode_hotlist_menu(hotlistnode *node, int entry)
{
if (entry<0 || entry>=((node==hotlisthead)?items:edititems))
return NULL;
 
for(;entry>0;entry--)
node = node->next;
 
return node;
}
 
/******************************************************************************/
 
void hotlist_draw(struct wimp_getrectangle_block *getrect_block)
{
struct wimp_ploticon_block pib;
int y=-4;
hotlistnode *node = editlisthead;
 
pib.min.x = 12;
pib.max.x = PANE_RIGHT;
pib.icon_flags = WIMP_ICON_TEXT_BIT | WIMP_ICON_SPRITE_BIT | WIMP_ICON_VCENT_BIT | \
WIMP_ICON_INDIRECTED_BIT | WIMP_ICON_FILLED_BIT | WIMP_ICON_FGCOL(7);
 
for(;node;node=node->next)
{
pib.max.y = y;
pib.min.y = y - ENTRYHEIGHT;
y -= ENTRYHEIGHT;
 
pib.contents.it.text = node->label;
pib.contents.it.validation = (char *)protocol_tospritevalidation(node->type);
 
if (node->internal_state & 1)
pib.icon_flags |= WIMP_ICON_BGCOL(2);
else
pib.icon_flags &= ~WIMP_ICON_BGCOL((unsigned int)15);
 
pib.contents.it.text_len = strlen(pib.contents.it.text)+1;
_swi(Wimp_PlotIcon, _IN(1), &pib);
}
}
 
/******************************************************************************/
 
int hotlist_num_items(void)
{
return items;
}
 
/******************************************************************************/
 
static void hotlist_clear_states(void)
{
hotlistnode *node = editlisthead;
 
for(;node;node=node->next)
{
node->internal_state &= ~1;
}
enable_buttons(false);
}
 
/******************************************************************************/
 
static hotlistnode *hotlist_unlink_selected(void)
{
hotlistnode *node = editlisthead;
hotlistnode *prev = NULL;
 
for(;node;node=node->next)
{
if(node->internal_state & 1)
{
if (prev)
prev->next = node->next;
else
{
editlisthead = node->next;
prev = editlisthead;
}
 
if (editlisttail)
{
if (editlisttail == node)
editlisttail = prev;
}
 
edititems--;
return node;
}
prev = node;
}
BOGUSERROR("Unlink: no item selected");
return NULL;
}
 
/******************************************************************************/
 
static void hotlist_delete_selected(void)
{
hotlistnode *node = hotlist_unlink_selected();
 
if (node)
{
free(node->label);
free(node->command);
free(node->host);
free(node);
}
}
 
/******************************************************************************/
 
static hotlistnode *hotlist_get_selected(void)
{
hotlistnode *node = editlisthead;
 
for(;node;node=node->next)
{
if(node->internal_state & 1)
{
return node;
}
}
 
return NULL;
}
 
/******************************************************************************/
 
static void hotlist_copy_selected(void)
{
hotlistnode *node = hotlist_get_selected();
 
if (node)
{
hotlistnode *pop;
if (hotlist_copynode(node, &pop) == true)
{
addnodetolist(&editlisthead, &editlisttail, pop);
edititems++;
}
return;
}
 
_swi(0x107,0);
}
 
/******************************************************************************/
 
static bool copy_hotedit_to_selected(void)
{
char _label[100],*label=_label;
char _host[256],*host=_host;
char _command[256],*command=_command;
char *tmp;
int width, height, scrollback;
hotlistnode *node = selectednode;
 
if (!selectednode)
return true; /* Shouldn't be possible */
 
/* JRF: FIXME: We should do our checks on the fields here */
 
read_icon_data(win_hotedit, icon_hotedit_label, label, 100);
while (*label==' ')
label++;
 
if(*label<' ')
{
generror("HotBlankLabel",true);
return false;
}
 
read_icon_data(win_hotedit, icon_hotedit_hostname, host, 256);
while (*host==' ')
host++;
 
if(selcon != NETTLE_TASKWINDOW)
{
if(*host<' ')
{
generror("HotBlankHost",true);
return false;
}
}
 
read_icon_data(win_hotedit, icon_hotedit_command, command, 256);
while (*command==' ')
command++;
 
if(selcon == NETTLE_TASKWINDOW)
{
if(*command<' ')
{
generror("HotBlankCommand",true);
return false;
}
}
 
tmp = get_icon_data(win_hotedit, icon_hotedit_termwidth);
width = atoi(tmp);
 
if (width<2 || width>65535)
{
generror("HotBadWidth",true);
return false;
}
 
 
tmp = get_icon_data(win_hotedit, icon_hotedit_termheight);
height = atoi(tmp);
 
if (height<2 || height>65535)
{
generror("HotBadHeight",true);
return false;
}
 
 
tmp = get_icon_data(win_hotedit, icon_hotedit_scrollback);
scrollback = atoi(tmp);
 
if (scrollback<0 || scrollback>65535)
{
generror("HotBadScroll",true);
return false;
}
 
 
free(node->label);
node->label = strdup(label);
assert(node->label);
 
free(node->host);
node->host = strdup(host);
assert(node->host);
 
free(node->command);
node->command = strdup(command);
assert(node->command);
 
node->terminal_width = width;
node->terminal_height = height;
node->scrollback = scrollback;
 
node->type = selcon;
node->vttype = seltype;
node->lineeditor = selline;
 
return true;
}
 
/******************************************************************************/
 
static void do_grey_hotedit(int contype)
{
int protocol_flags = protocol_toflags(contype);
 
if (protocol_flags & PROTOCOL_HAS_HOST)
{
set_icon_state( win_hotedit, icon_hotedit_hostname, 0, WIMP_ICON_SHADED_BIT);
set_icon_state( win_hotedit, icon_hotedit_hostlabel, 0, WIMP_ICON_SHADED_BIT);
}
else
{
set_icon_state( win_hotedit, icon_hotedit_hostname, WIMP_ICON_SHADED_BIT, WIMP_ICON_SHADED_BIT);
set_icon_state( win_hotedit, icon_hotedit_hostlabel, WIMP_ICON_SHADED_BIT, WIMP_ICON_SHADED_BIT);
}
 
if (protocol_flags & PROTOCOL_HAS_COMMAND)
{
set_icon_state( win_hotedit, icon_hotedit_command, 0, WIMP_ICON_SHADED_BIT);
set_icon_state( win_hotedit, icon_hotedit_commandlabel, 0, WIMP_ICON_SHADED_BIT);
}
else
{
set_icon_state( win_hotedit, icon_hotedit_command, WIMP_ICON_SHADED_BIT, WIMP_ICON_SHADED_BIT);
set_icon_state( win_hotedit, icon_hotedit_commandlabel, WIMP_ICON_SHADED_BIT, WIMP_ICON_SHADED_BIT);
}
 
if (protocol_flags & PROTOCOL_HAS_HOST)
{
set_caret_position(win_hotedit, icon_hotedit_hostname, -1,
get_icon_data_length(win_hotedit, icon_hotedit_hostname));
}
else
{
if (protocol_flags & PROTOCOL_HAS_COMMAND)
{
set_caret_position(win_hotedit, icon_hotedit_command, -1,
get_icon_data_length(win_hotedit, icon_hotedit_command));
}
}
}
 
/******************************************************************************/
 
static int hotlist_populate_selected(void)
{
char tmp[20];
selectednode = hotlist_get_selected();
 
if(!selectednode)
return 0;
 
set_icon_data(win_hotedit, icon_hotedit_label, selectednode->label ? selectednode->label : "<unnamed>");
set_icon_data(win_hotedit, icon_hotedit_hostname, selectednode->host ? selectednode->host : "");
set_icon_data(win_hotedit, icon_hotedit_command, selectednode->command ? selectednode->command : "");
sprintf(tmp,"%d",selectednode->terminal_width);
set_icon_data(win_hotedit, icon_hotedit_termwidth, tmp);
sprintf(tmp,"%d",selectednode->terminal_height);
set_icon_data(win_hotedit, icon_hotedit_termheight, tmp);
sprintf(tmp,"%d",selectednode->scrollback);
set_icon_data(win_hotedit, icon_hotedit_scrollback, tmp);
 
set_icon_data(win_hotedit, icon_hotedit_contype,
lookup_static(protocol_totoken(selectednode->type)));
selcon = selectednode->type;
 
set_icon_data(win_hotedit, icon_hotedit_termtype, terminal_name[selectednode->vttype]);
seltype = selectednode->vttype;
 
sprintf(tmp,"LineEd%d", selectednode->lineeditor);
set_icon_data(win_hotedit, icon_hotedit_lineedittype, lookup_static(tmp));
selline = selectednode->lineeditor;
 
return 1;
}
 
/******************************************************************************/
 
static hotlistnode *hotlist_createnew(void)
{
hotlistnode *node = create_blank();
if (!node)
return NULL;
 
free(menublock);
menublock = NULL;
 
node->label = malloc(100);
if (!node->label)
goto err;
node->command = malloc(256);
if (!node->label)
goto err;
node->host = malloc(256);
if (!node->label)
goto err;
 
strcpy(node->label, "New item");
node->command[0]='\0';
node->host[0]='\0';
 
addnodetolist(&editlisthead, &editlisttail, node);
edititems++;
 
return node;
 
err:
free(node->label);
free(node->command);
free(node->host);
free(node);
 
return NULL;
}
 
/******************************************************************************/
 
void win_panehot_click(int x, int y, int buttons, int icon_handle)
{
switch (icon_handle)
{
case icon_panehot_new:
{
hotlistnode *node = hotlist_createnew();
hotlist_clear_states();
node->internal_state |= 1;
}
hotlist_populate_selected();
open_window_centred(win_hotedit);
do_grey_hotedit(selcon);
_swi(Wimp_SetCaretPosition, _INR(0,5), win_hotedit, icon_hotedit_label, \
-1, -1, -1, get_icon_data_length(win_hotedit, icon_hotedit_label));
resize_hotpane();
force_redraw(win_hotpane,0,PANE_BOTTOM,PANE_RIGHT,0);
{
struct wimp_getwindowstate_block window;
window.window_handle=win_hotpane;
_swi(Wimp_GetWindowState, _IN(1), &window);
window.scroll.y=PANE_BOTTOM;
_swi(Wimp_OpenWindow, _IN(1), &window);
}
break;
 
case icon_panehot_edit:
if (hotlist_populate_selected())
{
open_window_centred(win_hotedit);
do_grey_hotedit(selcon);
_swi(Wimp_SetCaretPosition, _INR(0,5), win_hotedit, icon_hotedit_label, \
-1, -1, -1, get_icon_data_length(win_hotedit, icon_hotedit_label));
}
break;
 
case icon_panehot_copy:
close_window(win_hotedit);
if (hotlist_populate_selected())
{
hotlist_copy_selected();
resize_hotpane();
force_redraw(win_hotpane,0,PANE_BOTTOM,PANE_RIGHT,0);
{
struct wimp_getwindowstate_block window;
window.window_handle=win_hotpane;
_swi(Wimp_GetWindowState, _IN(1), &window);
window.scroll.y = PANE_BOTTOM;
_swi(Wimp_OpenWindow, _IN(1), &window);
}
}
break;
 
case icon_panehot_delete:
close_window(win_hotedit);
if (hotlist_populate_selected())
{
if (generror_question("DeleteHotButtons","DeleteHot",0))
{
hotlist_delete_selected();
resize_hotpane();
force_redraw(win_hotpane,0,PANE_BOTTOM,PANE_RIGHT,0);
{
struct wimp_getwindowstate_block window;
window.window_handle=win_hotpane;
_swi(Wimp_GetWindowState, _IN(1), &window);
_swi(Wimp_OpenWindow, _IN(1), &window);
}
}
}
break;
 
}
}
 
/******************************************************************************/
 
static void hotlist_drawitem(hotlistnode *draw)
{
int y=-4;
hotlistnode *node = editlisthead;
 
for(;node;node=node->next, y -= ENTRYHEIGHT)
{
if (node == draw)
{
force_redraw(win_hotpane,0,y-ENTRYHEIGHT,PANE_RIGHT,y);
return;
}
}
}
 
/******************************************************************************/
 
void win_hotpane_click(int x, int y, int buttons, int icon_handle)
{
int item, y_pos;
hotlistnode *node, *sel;
struct wimp_getwindowstate_block gwsblock;
 
gwsblock.window_handle=win_hotpane;
_swi(Wimp_GetWindowState, _IN(1), &gwsblock);
y_pos=gwsblock.max.y-gwsblock.scroll.y;
 
item = -((y - y_pos) + 4) / ENTRYHEIGHT;
 
node = decode_hotlist_menu(editlisthead, item);
if (!node)
{
_swi(0x107, 0);
return;
}
 
switch(buttons)
{
case ClickSelect:
case DoubleSelect:
case DragSelect:
sel = hotlist_get_selected();
if(node == sel)
if (buttons == ClickSelect) return;
 
if (sel && node!=sel)
{
sel->internal_state &= ~1;
hotlist_drawitem(sel);
}
if (!(node->internal_state & 1))
{
node->internal_state |= 1;
hotlist_drawitem(node);
enable_buttons(true);
}
switch (buttons)
{
case DoubleSelect:
win_panehot_click(0,0,4,icon_panehot_edit);
break;
 
case DragSelect:
{
struct wimp_dragbox_block dragblock;
struct wimp_autoscroll_block scrollblock;
 
dragblock.window_handle = win_hotpane;
dragblock.drag_type = 5; /* Fixed size box */
dragblock.parent_min.x = gwsblock.min.x;
dragblock.parent_min.y = gwsblock.min.y - ENTRYHEIGHT;
dragblock.parent_max.x = gwsblock.max.x;
dragblock.parent_max.y = gwsblock.max.y + ENTRYHEIGHT;
dragblock.min.x = gwsblock.min.x ;
dragblock.min.y = gwsblock.max.y -(item * ENTRYHEIGHT) - 4 - ENTRYHEIGHT - gwsblock.scroll.y;
dragblock.max.y = dragblock.min.y + ENTRYHEIGHT;
dragblock.max.x = dragblock.min.x + (gwsblock.max.x - gwsblock.min.x );
 
_swi(Wimp_DragBox, _INR(1,3), &dragblock, 0x4b534154, 3);
drag_window_handle = win_hotpane;
 
scrollblock.window_handle = win_hotpane;
scrollblock.left_pause = 0;
scrollblock.right_pause = 0;
scrollblock.bottom_pause = ENTRYHEIGHT*2;
scrollblock.top_pause = ENTRYHEIGHT*2;
scrollblock.pause_duration = 0; /* no pause time */
scrollblock.statechange_handler = 1; /* Use Wimp pointer shape routine */
_swix(Wimp_AutoScroll, _INR(0,1), 2, &scrollblock);
}
break;
}
break;
 
case ClickAdjust:
if (node->internal_state & 1)
{
node->internal_state &= ~1;
hotlist_drawitem(node);
enable_buttons(false);
}
break;
 
}
}
 
/******************************************************************************/
 
void hotlist_dragdone(void)
{
int item, y_pos;
struct wimp_getwindowstate_block gwsblock;
struct wimp_getpointerinfo_block wgpi;
hotlistnode *node,*sel;
 
_swi(Wimp_DragBox, _IN(1), -1); /* Stop dragging */
_swix(Wimp_AutoScroll, _IN(0), 0); /* Stop auto scrolling */
 
sel = hotlist_get_selected();
 
if (!sel)
return; /* shouldn't be possible! */
 
gwsblock.window_handle=win_hotpane;
_swi(Wimp_GetWindowState, _IN(1), &gwsblock);
y_pos=gwsblock.max.y-gwsblock.scroll.y;
 
_swi(Wimp_GetPointerInfo, _IN(1), &wgpi);
item = -((wgpi.pos.y - y_pos) + 4) / ENTRYHEIGHT;
 
node = decode_hotlist_menu(editlisthead, item);
 
if (node == sel || edititems<2)
return; /* Dropped the thing back on itself, so don't do anything */
 
if (node==NULL || node==editlisthead)
{
if (item<=0)
{
if (!hotlist_unlink_selected())
return; /* Shouldn't happen */
sel->next = editlisthead;
editlisthead = sel;
}
else
{
if (!hotlist_unlink_selected())
return; /* Shouldn't happen */
if (editlisttail)
editlisttail->next = sel;
editlisttail = sel;
sel->next = NULL;
}
}
else
{
if (!hotlist_unlink_selected())
return; /* Shouldn't happen */
sel->next = node->next;
node->next = sel;
if (node==editlisttail)
editlisttail = sel;
}
 
edititems++;
 
force_redraw(win_hotpane,0,PANE_BOTTOM,PANE_RIGHT,0);
}
 
/******************************************************************************/
 
void win_hotedit_click(int x, int y, int buttons, int icon_handle)
{
switch(icon_handle)
{
case icon_hotedit_cancel:
close_window(win_hotedit);
break;
 
case icon_hotedit_update:
if(copy_hotedit_to_selected())
{
close_window(win_hotedit);
force_redraw(win_hotpane,0,PANE_BOTTOM,PANE_RIGHT,0);
}
break;
 
case icon_hotedit_delete:
if (generror_question("DeleteHotButtons","DeleteHot",0))
{
close_window(win_hotedit);
hotlist_delete_selected();
resize_hotpane();
force_redraw(win_hotpane,0,PANE_BOTTOM,PANE_RIGHT,0);
{
struct wimp_getwindowstate_block window;
window.window_handle=win_hotpane;
_swi(Wimp_GetWindowState, _IN(1), &window);
_swi(Wimp_OpenWindow, _IN(1), &window);
}
}
break;
 
case icon_hotedit_lineeditbut:
create_lineeditor_type_menu(win_hotedit, icon_hotedit_lineedittype, icon_hotedit_lineeditbut);
break;
 
case icon_hotedit_contypebut:
create_connection_type_menu(win_hotedit, icon_hotedit_contype, icon_hotedit_contypebut);
break;
 
case icon_hotedit_termtypebut:
create_terminal_type_menu(win_hotedit, icon_hotedit_termtype, icon_hotedit_termtypebut);
break;
}
}
 
/******************************************************************************/
 
void resize_hotpane(void)
{
struct wimp_getwindowinfo_block window;
struct wimp_setextent_block ext;
window.window_handle=win_hotpane;
 
_swi(Wimp_GetWindowInfo, _IN(1), 1 + (int) &window); /* no icons */
ext.min.x = 0;
ext.max.y = 0;
ext.max.x = window.max.x - window.min.x;
ext.min.y = -(edititems * ENTRYHEIGHT + 16);
if (ext.min.y > -(window.max.y - window.min.y))
ext.min.y = -(window.max.y - window.min.y);
 
_swi(Wimp_SetExtent,_INR(0,1),win_hotpane, &ext);
 
enable_buttons(hotlist_get_selected()?true:false);
}
 
/******************************************************************************/
 
void fire_hotlist(int item)
{
hotlistnode *hot = decode_hotlist_menu(hotlisthead, item);
struct connection_params params;
 
if (!hot)
return;
 
params.terminal_type = (enum nettle_terminal) hot->vttype;
params.host = hot->host;
params.port = 0;
params.command = hot->command;
params.width = hot->terminal_width;
params.height = hot->terminal_height;
params.scrollback = hot->scrollback;
params.line_editor_type = hot->lineeditor;
params.login_user = NULL;
params.login_pass = NULL;
strcpy(params.label, hot->label);
 
params.connection_type = hot->type;
 
start_connection_friedport(&params);
}
 
/******************************************************************************/
 
bool finish_hotlist_editing(int dowhat) /* 0=cancel, 1=set, 2=save */
{
if (dowhat<0 || dowhat>2)
{
BOGUSERROR("Finish: bad code");
return false;
}
 
copy_hotlist(dowhat ? true : false);
 
if (dowhat == 2)
{
return save_hotlist();
}
 
return true;
}
 
/******************************************************************************/
 
void hotlist_inform(int icon, int menuselection)
{
if (menuselection<0)
return;
 
switch(icon)
{
case icon_hotedit_lineedittype:
selline = menuselection;
break;
 
case icon_hotedit_contype:
{
/* JRF: Find which protocol it really was (don't like this) */
int sel=0;
protocol_t *proto=NULL;
while ( (proto = protocol_enumerate(proto)) != NULL &&
sel!=menuselection)
sel++;
if (proto==NULL)
return;
selcon = proto->type;
do_grey_hotedit(selcon);
}
break;
 
case icon_hotedit_termtype:
seltype = menuselection;
break;
 
default:
BOGUSERROR("Inform: Bad icon");
break;
}
}
/vendor/v0.2023/templ.h
New file
0,0 → 1,166
/*
* AUTO GENERATED CODE - DO NOT EDIT BY HAND!
*
* (C) Copyright, Nettle developers 2002
*/
 
 
enum info_icons {
icon_info_name = 0,
icon_info_author = 1,
icon_info_version = 5,
icon_info_purpose = 6,
icon_info_website = 8
};
 
 
enum resize_icons {
icon_resize_width = 0,
icon_resize_height = 2,
icon_resize_scroll = 4,
icon_resize_cancel = 6,
icon_resize_set = 7
};
 
 
enum save_icons {
icon_save_cancel = 0,
icon_save_save = 1,
icon_save_filename = 2,
icon_save_drag = 3,
icon_save_ansi = 4
};
 
 
enum choices_icons {
icon_choices_cancel = 1,
icon_choices_set = 2,
icon_choices_save = 3,
icon_choices_size = 4,
icon_choices_colour = 5,
icon_choices_hotlist = 6,
icon_choices_misc = 7
};
 
 
enum paneterm_icons {
icon_paneterm_termwidth = 2,
icon_paneterm_termheight = 3,
icon_paneterm_scrollback = 6,
icon_paneterm_termtype = 9,
icon_paneterm_termtypebut = 10,
icon_paneterm_lineeditor = 13,
icon_paneterm_lineedittype = 16,
icon_paneterm_lineeditbut = 17,
icon_paneterm_hifont = 20,
icon_paneterm_hifontbut = 21,
icon_paneterm_lofontbut = 22,
icon_paneterm_lofont = 23
};
 
 
enum panecols_icons {
icon_panecols_col0 = 0,
icon_panecols_col1 = 1,
icon_panecols_col2 = 2,
icon_panecols_col3 = 3,
icon_panecols_col4 = 4,
icon_panecols_col5 = 5,
icon_panecols_col6 = 6,
icon_panecols_col7 = 7,
icon_panecols_col0but = 8,
icon_panecols_col1but = 9,
icon_panecols_col2but = 10,
icon_panecols_col3but = 11,
icon_panecols_col4but = 12,
icon_panecols_col5but = 13,
icon_panecols_col6but = 14,
icon_panecols_col7but = 15,
icon_panecols_bold0 = 16,
icon_panecols_bold1 = 17,
icon_panecols_bold2 = 18,
icon_panecols_bold3 = 19,
icon_panecols_bold4 = 20,
icon_panecols_bold5 = 21,
icon_panecols_bold6 = 22,
icon_panecols_bold7 = 23,
icon_panecols_bold0but = 24,
icon_panecols_bold1but = 25,
icon_panecols_bold2but = 26,
icon_panecols_bold3but = 27,
icon_panecols_bold4but = 28,
icon_panecols_bold5but = 29,
icon_panecols_bold6but = 30,
icon_panecols_bold7but = 31,
icon_panecols_default = 48,
icon_panecols_invertall = 51
};
 
 
enum panehot_icons {
icon_panehot_new = 0,
icon_panehot_edit = 1,
icon_panehot_delete = 2,
icon_panehot_copy = 3
};
 
 
enum hotedit_icons {
icon_hotedit_label = 0,
icon_hotedit_hostname = 1,
icon_hotedit_command = 2,
icon_hotedit_termwidth = 3,
icon_hotedit_termheight = 4,
icon_hotedit_scrollback = 5,
icon_hotedit_termtype = 9,
icon_hotedit_termtypebut = 10,
icon_hotedit_lineedittype = 13,
icon_hotedit_lineeditbut = 14,
icon_hotedit_hostlabel = 15,
icon_hotedit_commandlabel = 16,
icon_hotedit_update = 21,
icon_hotedit_cancel = 22,
icon_hotedit_delete = 23,
icon_hotedit_contype = 24,
icon_hotedit_contypebut = 25
};
 
 
enum spoolsave_icons {
icon_spoolsave_cancel = 0,
icon_spoolsave_save = 1,
icon_spoolsave_filename = 2,
icon_spoolsave_drag = 3,
icon_spoolsave_raw = 4
};
 
 
enum panemisc_icons {
icon_panemisc_passf12 = 0,
icon_panemisc_blinking = 1,
icon_panemisc_cursorblink = 2,
icon_panemisc_dontrequirectrl = 3,
icon_panemisc_cursortype = 4,
icon_panemisc_cursortypebut = 5
};
 
 
enum sizebar_icons {
icon_sizebar_size = 0
};
 
 
enum open_icons {
icon_open_host = 0,
icon_open_cancel = 1,
icon_open_connect = 2,
icon_open_contype = 3,
icon_open_contypebut = 4,
icon_open_command = 6,
icon_open_termtype = 7,
icon_open_termtypebut = 8,
icon_open_hostlabel = 10,
icon_open_commandlabel = 11
};
 
 
/vendor/v0.2023/quit.h
New file
0,0 → 1,14
/**
* Nettle closedown code headers
* (C) Nettle developers 2000-2001
*
* $Id: quit,v 1.4 2001/08/08 03:11:07 spanners Exp $
*/
 
#ifndef QUIT_H
#define QUIT_H
 
extern void closedown_wimp(void);
extern void closedown_application(void);
 
#endif /* QUIT_H */
/vendor/v0.2023/p_rexec.h
New file
0,0 → 1,49
/**
* Protocol RExec specific support code
* (C) Nettle developers 2002
*
* $Id$
*/
 
#ifndef REXEC_H
#define REXEC_H
 
#include "protocols.h"
 
extern protocol_t protocol_rexec;
 
/*************************************************** Gerph *********
Function: rexec_initialdata
Description: Data has been received; we process it and return.
We need to check the first byte and hand the rest
of the data on to the normal handlers
Parameters: session-> the session from which the data arrives
data-> the data
datalen = the length of the data
Returns: none
******************************************************************/
void rexec_initialdata(struct session_struct *session,const char *data,
int datalen);
 
/*************************************************** Gerph *********
Function: rexec_connected
Description: Socket has now connected; we must send our initial
negotiation data to the remote.
Parameters: session-> the session we are connecting
Returns: none
******************************************************************/
void rexec_connected(struct session_struct *session);
 
/*************************************************** Gerph *********
Function: rexec_resolved
Description: Connection has resolved, socket is created and ready
for connecting; we must set up socket options. In this
case, we're going to bind to a low port. We must do
this because rlogind expects the connection to come
from ports between 512 and 1024.
Parameters: session-> the session we're operating on
Returns: none (may be error in future)
******************************************************************/
void rexec_resolved(struct session_struct *session);
 
#endif
/vendor/v0.2023/nettle.c
New file
0,0 → 1,1652
/**
* Nettle specific code
* (C) Nettle developers 2000-2002
*
* $Id: nettle,v 1.104 2002/03/18 01:54:33 ijeffray Exp $
*/
 
#include "generic.h"
#include "globals.h"
 
#include "lineedit.h"
#include "main.h"
#include "messages.h"
#include "misc.h"
#include "mouse.h"
#include "nettle.h"
#include "process.h"
#include "protocols.h"
#include "p_rexec.h"
#include "p_rlogin.h"
#include "p_taskwindow.h"
#include "p_telnet.h"
#include "seln.h"
#include "socket.h"
#include "spool.h"
#include "templ.h"
#include "timers.h"
#include "wimp.h"
#include "wimputil.h"
#include "zapredraw.h"
 
 
/*************************************************** Gerph *********
Function: nettle_senddata_socket
Description: Send data on to the socket
Parameters: session-> the session we're processing
data-> the data to send
length-> the length to send
Returns: length sent
******************************************************************/
int nettle_senddata_socket(struct session_struct *session,
const char *data, int length)
{
if (session->socket_handle != -1)
return socket_senddata(session->socket_handle,data,length);
return 0;
}
 
/*************************************************** Gerph *********
Function: strip_uri_protocol
Description: Strip off a protocol from the start of the string,
based on the connection type specified
Parameters: type = the type to look for the protocol of
string-> the string to modify
Returns: true if anything went wrong, false if no errors
******************************************************************/
static int strip_uri_protocol (int type, char *string)
{
int len;
const char *expect=NULL;
 
expect = protocol_touriprefix(type);
 
if (expect == NULL)
return false;
 
len=strlen(expect);
if (strncmp (string, expect, len) == 0)
strcpy (string, string + len);
 
return false;
}
 
/*
* Description: Decode a host string into user, pass, host, port
* Parameters: string-> the string to parse
* tempbuf-> the string to use for holding password
* and user name in (guarenteed as long as
* string+4)
* host-> hostname to update (pointer into tempbuf)
* port-> the port to connect on, or -1 if unset
* user-> user name to update (pointer into tempbuf)
* pass-> pointer to password to update (pointer into tempbuf)
*
* user,pass,host will be set to NULL if not supplied
*
* Returns: true if we succeeded, false otherwise
*/
bool decode_host_string (const char *string, char *tempbuf,
char **host, int *port,
char **user, char **pass)
{
const char *sptr;
 
*host=NULL;
*port=-1;
*user=NULL;
*pass=NULL;
 
if (! string )
{
generror("InvalidAddr", true);
return false;
}
 
/* Is there a user/pass component ? */
sptr = strchr(string, '@');
if (sptr)
{
/* We have a user/password section */
const char *end=sptr;
const char *userp=string;
char *colon;
sptr=&end[1]; /* sptr-> the hostname */
 
/* Find the password */
colon=strchr(string,':');
if (colon > end)
colon = NULL; /* We matched a colon after the @, so ignore */
 
if (colon != NULL)
{
const char *passp = &colon[1];
*pass=tempbuf;
memcpy(tempbuf,passp,end-passp);
tempbuf+=end-passp;
*tempbuf++='\0';
end=colon;
}
 
*user = tempbuf;
memcpy(tempbuf,userp,end-userp);
tempbuf+=end-userp;
*tempbuf++='\0';
 
/* The rest of the string needs parsing for hostname/port */
string=sptr;
}
 
/* Now process the hostname/port */
sptr = strpbrk (string, ": ,/");
if (sptr)
{
/* There's a port on the end */
*port = atoi (sptr + 1) & 65535;
if (*port < 1 /*|| *port > 65535*/)
{
generror("InvalidPort", true);
return false;
}
}
else
sptr = string + strlen(string);
 
*host=tempbuf;
memcpy(tempbuf,string,sptr-string);
tempbuf+=sptr-string;
*tempbuf++='\0';
 
/* success */
return true;
}
 
bool start_connection_friedport(struct connection_params *params )
{
char host[1024];
char tempbuf[1024];
 
if (params->connection_type != NETTLE_TASKWINDOW)
{
if (!params->host)
return false;
 
strcpy(host,params->host);
 
if (strip_uri_protocol(params->connection_type, host))
return false;
 
if (decode_host_string(host, tempbuf,
(char**)&params->host,
&params->port,
(char **)&params->login_user,
(char **)&params->login_pass) == false)
return false;
 
if (params->port == -1)
params->port = protocol_toport(params->connection_type);
 
/* FIXME: Check parameters */
}
 
start_connection(params);
 
return true;
}
 
 
bool start_connection_fromwindow(void)
{
struct connection_params params;
char string[1024];
char command[1024];
char tempbuf[1024];
int loop;
int connection_type;
int protocol_flags;
enum nettle_terminal terminal_type;
 
read_icon_data(win_open, icon_open_contype, string, sizeof(string));
 
connection_type = protocol_fromname(string);
 
terminal_type = read_terminal_type (win_open, icon_open_termtype);
 
params.connection_type = connection_type;
params.terminal_type = terminal_type;
params.host = NULL;
params.port = -1;
params.command = NULL;
params.width = defaultsize.x;
params.height = defaultsize.y;
params.scrollback = defaultscroll;
params.line_editor_type = line_editor;
params.label[0] = '\0';
params.login_user = NULL;
params.login_pass = NULL;
 
protocol_flags = protocol_toflags(connection_type);
 
if (protocol_flags & PROTOCOL_HAS_HOST)
{
read_icon_data(win_open, icon_open_host, string, sizeof(string));
 
if (strip_uri_protocol(connection_type, string))
return false;
 
if (decode_host_string(string, tempbuf,
(char **)&params.host,
&params.port,
(char **)&params.login_user,
(char **)&params.login_pass) == false)
return false;
}
 
if (protocol_flags & PROTOCOL_HAS_COMMAND)
{
read_icon_data (win_open, icon_open_command, command, sizeof (command));
loop = strlen (command);
while (command[loop - 1] == ' ')
loop--;
command[loop] = '\0'; /* trim trailing spaces */
loop = strspn (command, " "); /* number of leading spaces */
 
params.command = command+loop;
}
 
if (!protocol_check_connect_data(connection_type,
params.host,
params.port,
params.login_user,
params.login_pass,
params.command))
return false; /* Invalid details */
 
if (params.port == -1)
params.port = protocol_toport(params.connection_type);
 
start_connection (&params);
 
return true;
}
 
/*
* Description: Create a new window for the terminal, based on the
* information in the session block, and write into the
* session block the details
* Parameters: session-> the session to create the window for and
* to update
* Returns: none
*/
static void make_new_terminal_window(struct session_struct *session)
{
static int max_y = -1; /* the top of the next window to be opened, or -1
to generate a new position */
struct wimp_createwindow_block block;
 
if (max_y == -1)
{
/* First window, or a reset window */
 
/* We want to position the window toward the top of the screen, so the
* algorithm we use is simple - 7/8 of the way up the screen, which is
* reasonable for nearly all screen sizes
*/
max_y = (screensize.y*7)/8;
}
 
block.min.x =102;
block.min.y =max_y-(session->terminal_size.y*redraw.r_charh << eig.y);
block.max.x =102+(session->terminal_size.x*redraw.r_charw << eig.x);
block.max.y =max_y;
block.scroll.x =0;
block.scroll.y =-((session->terminal_size.y+
session->scrollback)
*(redraw.r_charh << eig.y));
block.handle_behind =-1;
block.window_flags =0xff00c002;
block.title_fg =7;
block.title_bg =2;
block.work_fg =7;
block.work_bg =0xFF;
 
block.scroll_outer_colour=3;
block.scroll_inner_colour=1;
block.title_focus_colour =12;
block.flags =0;
 
block.work_min.x=0;
block.work_min.y=-((session->terminal_size.y+
session->scrollback)
*(redraw.r_charh << eig.y));
block.work_max.x=session->terminal_size.x*redraw.r_charw << eig.x;
block.work_max.y=0;
 
block.icon_flags =0x00000119;
block.workarea_flags=10<<12; /* clicks (*256), drags (*16), double clicks (*1) */
block.sprite_area =(struct os_spriteop_area *) 1;
block.min_width =4;
block.min_height =4;
 
block.title.it.text =session->title;
block.title.it.validation=0;
block.title.it.text_len =256;
 
block.number_of_icons =0;
 
session->window_handle = _swi(Wimp_CreateWindow, _IN(1)|_RETURN(0), &block);
 
set_title_bar(session->window_handle,"Nettle");
 
open_window(NULL, session->window_handle);
 
{
/* update the next window position */
struct wimp_getwindowstate_block window;
window.window_handle = session->window_handle;
_swi (Wimp_GetWindowState, _IN(1), (int) &window);
 
max_y = (window.min.y < 256) ? -1 : window.max.y - 40;
 
if (session->line_editor_type!=LINEEDIT_NONE)
open_pane_window(session, (struct wimp_openwindow_block *) &window);
}
 
switch (session->line_editor_type)
{
case LINEEDIT_CHECKBOX_ON:
case LINEEDIT_ANTTERM:
set_caret_position(session->pane_handle,0,-1,get_icon_data_length(session->pane_handle, 0));
break;
default:
set_caret_position(session->window_handle,-1,-1,-1);
break;
}
}
 
/* **** Login details - icky! **** */
 
/* What we do is we match each character against the data we expect to
get; if a character matches, we increment the index into the string.
If the next character in the match string is a \n, we know we've
completed a match (because this is a MessageTrans buffer string)
and we act upon it. If it does NOT match, we reset the index to 0.
*/
 
 
/*
* Description: Data has been received from the remote end of the
* connection; we need to either match the current
* string, or reset our counter
* Parameters: session-> the session we're part of
* c = character received
* Returns: none
*/
static void login_data(struct session_struct *session, char c)
{
if (c == session->login_match[ session->login_index ])
{
session->login_index++;
if (session->login_match[ session->login_index ] == '\0')
{
/* We've reached the end of a match string, so we need to act upon it */
free(session->login_match);
session->login_match = NULL;
 
if (session->login_user != NULL)
{
/* We matched the username request, so send the string they
provided us with */
 
nettle_senddata(session,session->login_user, strlen(session->login_user) );
nettle_senddata(session,"\r", 1);
 
free(session->login_user);
session->login_user = NULL;
}
else if (session->login_pass != NULL)
{
/* We matched the password request, so send the string they
provided us with */
 
nettle_senddata(session,session->login_pass, strlen(session->login_pass) );
nettle_senddata(session,"\r", 1);
 
free(session->login_pass);
session->login_pass = NULL;
}
 
/* Having acted upon the matched string, we now move on to the
next action */
if (session->login_pass != NULL)
{
session->login_match = lookup_alloc("LoginMatch_Pass");
assert(session->login_match);
}
else
{
/* All done. Remove our processing routines */
session->login_data = NULL;
}
 
/* Remember to reset the index; doesn't hurt if we're already
complete */
session->login_index = 0;
}
}
else
{
/* reset the character counter */
session->login_index = 0;
}
}
 
 
 
void start_connection (struct connection_params *params )
{
int loop;
const protocol_t *protocol = protocol_findbytype(params->connection_type);
struct session_struct *session;
 
if (protocol == NULL)
return; /* Couldn't find protocol details; give up */
 
if (params->command && params->command[0]=='\0')
params->command = NULL; /* Ensure that null commands are easy to check */
 
if (params->label[0]=='\0')
{
/* Construct a default title for the window */
char *tail=params->label;
int flags = protocol->flags;
 
if (flags & PROTOCOL_HAS_HOST)
{
/* Provide a default label:
* <protocol> [<user>@]<host>[:<port>]
*/
tail+=sprintf(tail, "%s ", lookup_static(protocol->token));
 
if ((flags & PROTOCOL_HAS_USER) &&
params->login_user)
tail+=sprintf(tail,"%s@",params->login_user);
if (params->port != protocol->default_port)
sprintf(tail, "%s:%d", params->host, params->port);
else
strcpy(tail, params->host);
}
else
{
/* Provide a default label:
* <command>[ for <user>]
* or
* <protocol>[ for <user>]
*/
if (params->command)
tail+=sprintf(tail, "%s", params->command);
else
tail+=sprintf(tail, "%s", lookup_static(protocol->token));
 
if ((flags & PROTOCOL_HAS_USER) &&
params->login_user)
tail+=sprintf(tail," for %s",params->login_user);
}
}
 
session = malloc(sizeof(struct session_struct));
if (session == NULL)
{
generror("OutOfMem", true);
return;
}
 
session->protocol = protocol;
 
/* clear all the session flags */
for (loop=0; loop<256; loop++)
{
session->session_flags[loop]=false;
}
session->local_echo = true;
session->want_blink = false;
session->socket_state = NETTLE_SESSION_NONE;
 
session->dns = NULL; /* Should be null for non telnet/ssh sessions */
 
if ((protocol->flags & PROTOCOL_HAS_COMMAND) &&
params->command)
{
session->login_command = strdup(params->command);
if (session->login_command == NULL)
{
free(session);
generror("OutOfMem", true);
return;
}
}
else
session->login_command = NULL;
 
/* This should all be a callback */
switch (params->connection_type)
{
case NETTLE_TELNET:
case NETTLE_RLOGIN:
case NETTLE_REXEC:
case NETTLE_SSH:
/* host, port already parsed */
session->socket_handle=-1;
session->socket_state=NETTLE_SESSION_RESOLVE;
session->socket_port = params->port;
strcpy (session->socket_host, params->host);
session->dns = dns_gethostbyname(session->socket_host);
assert(session->dns != NULL);
break;
 
case NETTLE_TASKWINDOW:
/* start the task window */
{
int taskwindow_handle;
char temp_string[1024];
#ifdef EXP_TASKWINDOW_WARPING
 
sprintf(temp_string, "%d", params->height);
_swi(OS_SetVarVal, _INR(0,4), "LINES", temp_string, strlen(temp_string), 0, 4);
_swi(OS_SetVarVal, _INR(0,4), "ROWS", temp_string, strlen(temp_string), 0, 4); /* for old unixlib progs */
sprintf(temp_string, "%d", params->width);
_swi(OS_SetVarVal, _INR(0,4), "COLUMNS", temp_string, strlen(temp_string), 0, 4);
#endif
 
if (session->login_command)
{
FILE *pipefile;
 
/* To disable escape in ANSI TaskWindows, we need to execute
*FX 229,1 before the task proper is run. Make an Obey file
in Pipe: to achieve this */
 
/* Race condition here with such a static filename */
pipefile = fopen("Pipe:$.NettleTask", "w");
if (!pipefile)
{
free(session->login_command);
free(session);
generror("NoStartTask", true);
return;
}
else
{
fprintf(pipefile, "fx 229 1\n%s\n", session->login_command);
fclose(pipefile);
misc_setfiletype("Pipe:$.NettleTask", 0xfeb);
 
/* JRF: May fail with long command lines */
sprintf (temp_string, "%%TaskWindow \"%%Obey -c Pipe:$.NettleTask\" -ctrl -name \"Nettle task - %s\"" \
" -quit -task &%X -txt &%X", session->login_command, task_handle, (int)session);
}
}
else
{
sprintf (temp_string, "%%TaskWindow -ctrl -name \"Nettle task\"" \
" -task &%X -txt &%X", task_handle, (int)session);
}
 
 
_swi(Wimp_StartTask, _IN(0)|_OUT(0), temp_string, &taskwindow_handle);
#ifdef EXP_TASKWINDOW_WARPING
#define TaskWindow_SetVDUVariables (0x500)
if (taskwindow_handle!=0)
{
int pairs[] = {
0,(1<<0), /* non-graphics mode */
1,0, /* width-1 */
2,0, /* height-1 */
0x100,0, /* width */
0x101,0, /* height */
0x84,0, /* text window left */
0x85,0, /* text window bottom */
0x86,0, /* text window right */
0x87,0, /* text window top */
-1,0 /* terminator */
}; /* See OS_ReadVduVariables */
pairs[1+2*1]=params->width-1;
pairs[1+2*2]=params->height-1;
pairs[1+2*3]=params->width;
pairs[1+2*4]=params->height;
pairs[1+2*5]=0;
pairs[1+2*6]=params->height-1;
pairs[1+2*7]=params->width-1;
pairs[1+2*8]=0;
_swix(TaskWindow_SetVDUVariables,_INR(0,1),pairs,taskwindow_handle);
}
#endif
}
 
/* set ECHO bit to true */
session->session_flags[1]=true;
session->local_echo = false;
 
break;
}
 
/* set all the attributes to their defaults */
strcpy(session->label, params->label);
session->terminal_size.x = params->width;
session->terminal_size.y = params->height;
session->scrollback = params->scrollback;
session->title=malloc(256);
assert(session->title != NULL);
strcpy(session->title,"");
 
session->login_user = ((protocol->flags & PROTOCOL_HAS_USER) && params->login_user) ?
strdup(params->login_user) : NULL;
session->login_pass = ((protocol->flags & PROTOCOL_HAS_PASS) && params->login_pass) ?
strdup(params->login_pass) : NULL;
 
if ((protocol->flags & PROTOCOL_HAS_USER) && params->login_user)
assert(session->login_user);
if ((protocol->flags & PROTOCOL_HAS_PASS) && params->login_pass)
assert(session->login_pass);
 
if (session->login_user && params->connection_type!=NETTLE_SSH)
{
/* Where a user/password exists, we want to set up the login details */
session->login_index = 0; /* We're 0 characters into the match string */
session->login_match = lookup_alloc("LoginMatch_User");
assert(session->login_match);
 
/* Function pointers for handling matching */
session->login_data = login_data;
}
else
{
/* If we have no user, we have no data function */
session->login_data = NULL;
session->login_match = NULL;
}
 
 
session->icon_name=malloc(256);
assert(session->icon_name != NULL);
strcpy(session->icon_name,"");
 
create_terminal(session, session->terminal_size, session->scrollback);
 
session->pos.x=0;
session->pos.y=session->scrollback;
session->connection_type=params->connection_type;
session->terminal_type=params->terminal_type;
session->paste=NULL;
session->paste_head=NULL;
session->window_needs_resized=false;
session->visual_bell_timeout=0;
reset_terminal(session);
 
/* clear out the assigned area with black bg, white fg, no flags and ' ' */
clear_screen(session,
0,
session->terminal_size.x*(session->terminal_size.y+session->scrollback),
NETTLE_COLOUR_NORMAL_WHITE,
NETTLE_COLOUR_NORMAL_BLACK,
0,
' ');
 
copy_main_alternate(session);
 
/* create tabs */
session->number_of_tabs=0;
for (loop=0; loop<session->terminal_size.x; loop+=8)
{
session->tabs[session->number_of_tabs]=loop;
session->number_of_tabs++;
}
 
session->line_editor_type=params->line_editor_type;
 
session->spool_file_name=NULL; /* make sure filename is undefined */
 
/* if line editor is turned on, allocate all the lineeditor space */
if (session->line_editor_type==LINEEDIT_NONE)
session->pane_handle=0;
else
lineedit_allocate_space(session);
 
make_new_terminal_window(session);
 
switch (params->connection_type)
{
case NETTLE_TELNET:
case NETTLE_RLOGIN:
case NETTLE_REXEC:
case NETTLE_SSH:
set_title_bar(session->window_handle, lookup_static ("title_conn"));
write_out_strings (session, lookup_static ("lookup"),
session->socket_host, "...\r\n", 0);
main_requirenull = true;
break;
}
 
allocate_zapredraw_area(session->terminal_size.x, session->terminal_size.y, session->scrollback);
 
/* Default handlers */
session->session_data = NULL; /* No data accepted for client */
session->session_send = NULL; /* No data accepted for remote */
session->session_connected = NULL; /* No negotiation on connect */
session->session_closed = NULL; /* No tidy up on close */
session->session_resolved = NULL; /* No options on resolve */
session->session_resized = NULL; /* No resize handler */
 
/* Setup the protocol module */
session->protocol->protocol_session_setup(session);
 
/* JRF: Should insert into the list /last/ in case anything bad happens in
here - then we'll only lose one batch of local resources, not the
entire application. */
 
/* Insert into list */
session->prev = NULL;
session->next = sessions;
if (sessions)
{
sessions->prev = session;
}
sessions = session;
 
}
 
void write_out_string(struct session_struct *session, const char *string)
{
write_out_data(session, string, strlen(string));
}
 
void write_out_strings (struct session_struct *session, ...)
{
va_list va;
const char *str;
va_start (va, session);
 
while ((str = va_arg (va, const char *)) != 0)
{
write_out_data(session, str, strlen (str));
}
}
 
/* Note: Limit of 1k on this function */
void write_out_formatted (struct session_struct *session, const char *format,
...)
{
char buffer[1024];
va_list va;
va_start (va, format);
vsprintf(buffer, format, va);
va_end (va);
write_out_data(session, buffer, strlen (buffer));
}
 
/*************************************************** Gerph *********
Function: write_out_data
Description: Process a block of data as if it has come from the
remote end of the connection.
Parameters: session-> the session we're processing
data-> the data to process
length = length of the data
Returns: none
******************************************************************/
void write_out_data(struct session_struct *session, const char *data, int length_data)
{
int loop;
struct coords pos;
char cursor_flags;
 
if (length_data == 0) {
return;
}
 
pos=get_cursor_position(session);
 
/* get the cursor flags */
cursor_flags=read_assigned_flags(session, pos.x, pos.y) &
(NETTLE_FLAG_CURSOR | NETTLE_FLAG_NO_INPUT);
 
/* if the cursor flags don't have cursor set, make it so */
cursor_flags |= NETTLE_FLAG_CURSOR;
 
/* remove the cursor from the position */
changedbox_init (session);
changedbox_update_char (pos.x, pos.y);
write_assigned_flags(session, pos.x, pos.y,
read_assigned_flags(session, pos.x, pos.y) &
~(NETTLE_FLAG_CURSOR | NETTLE_FLAG_NO_INPUT));
force_redraw_changedbox ();
 
changedbox_init (session);
 
for (loop = 0; loop < length_data; loop++)
{
/* log the byte */
log_byte(data[loop]);
 
/*close_log(true);*/
 
 
/* process the current byte at this position */
process_data(session, data[loop]);
 
}
 
pos=get_cursor_position(session);
 
/* OR back in the cursor flags */
if (session->other_session_flags & NETTLE_OTHER_CURSOR_VIS)
{
write_assigned_flags(session, pos.x, pos.y,
read_assigned_flags(session, pos.x, pos.y) | cursor_flags);
}
 
/* redraw the window */
force_redraw_changedbox();
 
/* force the selection back on (it may have got overwritten by new data) */
force_redraw_selection();
 
/* redraw the cursor, in case it isn't in the main redraw block */
if (session->other_session_flags & NETTLE_OTHER_CURSOR_VIS)
{
changedbox_init (session);
changedbox_update_char (pos.x, pos.y);
force_redraw_changedbox ();
}
}
 
 
/* Just close the session. Do NOTHING else. */
void close_session(struct session_struct *session)
{
if (session->socket_handle != -1)
{
switch (session->connection_type)
{
case NETTLE_TELNET:
case NETTLE_RLOGIN:
case NETTLE_REXEC:
case NETTLE_SSH:
socket_close(session->socket_handle);
break;
 
case NETTLE_TASKWINDOW:
{
/* terminate the taskwindow - this might be better as a callback
to the taskwindow protocol ? session_closing ? */
union wimp_poll_block block;
 
block.user_message.length =20;
block.user_message.my_ref =0;
block.user_message.message_code=WIMP_MESSAGE_TASKWINDOW_MORITE;
 
_swi(Wimp_SendMessage, _INR(0,2), 17, &block, session->socket_handle);
}
break;
}
 
session->socket_handle = -1;
session->socket_state = NETTLE_SESSION_NONE;
 
if (session->session_closed)
session->session_closed(session);
}
}
 
void remove_session(struct session_struct *session)
{
/* We unlink *first* such that if there's an error with
* anything else, the session is effectively dead and we never
* deal with it ever again. This may result in leaking sockets,
* and leaking memory if anything fails, but ensures that we
* don't get repeated errors that take down the application
* leaking /every/ socket that was in use
*/
if (session->prev)
{
session->prev->next = session->next;
}
else
{
sessions = session->next;
}
 
if (session->next)
{
session->next->prev = session->prev;
}
 
/* Remove any timers associated with this session */
timer_removesession(session);
 
close_session(session);
 
if (session->dns != NULL)
{
dns_dispose(session->dns);
session->dns = NULL;
}
 
{
/* delete the window */
struct wimp_deletewindow_block block;
 
block.window_handle=session->window_handle;
 
_swi(Wimp_DeleteWindow, _IN(1), &block);
 
}
 
/* free any paste buffers */
{
struct paste_buffer *paste = session->paste;
while (paste)
{
struct paste_buffer *next_paste = paste->next;
free (paste);
paste = next_paste;
}
}
 
/* free lineeditor space */
if (session->line_editor_type!=LINEEDIT_NONE)
{
lineedit_free_space(session);
}
 
/* free auto-login details */
free(session->login_user);
free(session->login_pass);
free(session->login_match);
free(session->login_command);
 
/* free the icon name */
free(session->icon_name);
 
/* free the data area and title */
delete_terminal(session);
free(session->title);
 
/* close the spool if any */
if (session->spool_file_name!=NULL)
{
spool_close(session, true);
}
 
/* cancel the selection if there was one in this session */
if (selection_session == session)
{
selection_session = NULL;
}
 
if (cursor_session == session)
cursor_session = NULL;
 
/* Release any protocol-specific data */
if (session->protocol->protocol_session_shutdown)
session->protocol->protocol_session_shutdown(session);
 
free(session);
}
 
int nettle_senddata(struct session_struct *session, const char *data, int length)
{
return session->session_send(session,data,length);
}
 
void reset_terminal(struct session_struct *session)
{
session->other_session_flags=NETTLE_OTHER_CURSOR_VIS | NETTLE_OTHER_WRAP_MODE;
 
#ifdef EXP_VISUAL_BELL
/* JRF: DEBUGGING - TURN THE BELL ON BY DEFAULT TO CHECK THAT IT WORKS!
* Remove this before commiting
*/
session->other_session_flags|=NETTLE_OTHER_VISUAL_BELL_MODE;
#endif
 
session->current_fg=7;
session->current_bg=0;
session->current_flags=NETTLE_FLAG_VALID;
session->escape_string_length=0;
session->escape_state=NETTLE_ESCAPE_NONE;
session->scroll_start=1;
session->scroll_end=session->terminal_size.y;
session->character_set_gl=NETTLE_CHSET_G0;
session->character_set_gr=NETTLE_CHSET_G3;
 
session->character_set_g0=NETTLE_CHSET_ASCII;
session->character_set_g1=NETTLE_CHSET_DEC_SUPPLEMENTAL_GRAPHICS;
session->character_set_g2=NETTLE_CHSET_ASCII;
session->character_set_g3=NETTLE_CHSET_DEC_SUPPLEMENTAL_GRAPHICS;
 
session->cursor_saved=false;
 
switch (session->terminal_type)
{
case NETTLE_TERMINAL_VT100: case NETTLE_TERMINAL_VT102:
session->terminal_mode=1;
break;
default:
session->terminal_mode=2;
break;
}
 
session->bit_controls=false;
session->want_blink = false;
 
session->mouse_terminal_attached=true;
session->mouse_mode=MOUSE_MODE_OFF;
}
 
bool valid_x(struct session_struct *session, int xpos)
{
if (xpos<0 || xpos>=session->terminal_size.x)
{
printf("Attempt to read/write outside alternate line, X position %d\n", xpos);
return false;
}
return true;
}
 
bool valid_y(struct session_struct *session, int ypos)
{
if (ypos<0 || ypos>=session->terminal_size.y+session->scrollback)
{
printf("Attempt to read/write outside assigned area %p, Y position %d\n", session, ypos);
return false;
}
return true;
}
 
bool valid_alt_y(struct session_struct *session, int ypos)
{
if (ypos<0 || ypos>=session->terminal_size.y)
{
printf("Attempt to read/write outside alternate area %p, Y position %d\n", session, ypos);
return false;
}
return true;
}
 
void write_assigned(struct session_struct *session, int xpos, int ypos,
char fg, char bg, char flags, char character)
{
if (valid_x(session, xpos) && valid_y(session, ypos))
{
session->assigned_area[ypos][xpos].fg = fg;
session->assigned_area[ypos][xpos].bg = bg;
session->assigned_area[ypos][xpos].flags = flags;
session->assigned_area[ypos][xpos].chr = character;
}
}
 
void write_alt_assigned(struct session_struct *session, int xpos, int ypos,
char fg, char bg, char flags, char character)
{
if (valid_x(session, xpos) && valid_alt_y(session, ypos))
{
session->alternate_area[ypos][xpos].fg = fg;
session->alternate_area[ypos][xpos].bg = bg;
session->alternate_area[ypos][xpos].flags = flags;
session->alternate_area[ypos][xpos].chr = character;
}
}
 
char read_assigned_fg(struct session_struct *session, int xpos, int ypos)
{
if (valid_x(session, xpos) && valid_y(session, ypos))
{
return session->assigned_area[ypos][xpos].fg;
}
 
return 0;
}
 
char read_assigned_bg(struct session_struct *session, int xpos, int ypos)
{
if (valid_x(session, xpos) && valid_y(session, ypos))
{
return session->assigned_area[ypos][xpos].bg;
}
 
return 0;
}
 
char read_assigned_flags(struct session_struct *session, int xpos, int ypos)
{
if (valid_x(session, xpos) && valid_y(session, ypos))
{
return session->assigned_area[ypos][xpos].flags;
}
 
return 0;
}
 
char read_assigned_character(struct session_struct *session, int xpos, int ypos)
{
if (valid_x(session, xpos) && valid_y(session, ypos))
{
return session->assigned_area[ypos][xpos].chr;
}
 
return 0;
}
 
char read_alt_assigned_fg(struct session_struct *session, int xpos, int ypos)
{
if (valid_x(session, xpos) && valid_alt_y(session, ypos))
{
return session->alternate_area[ypos][xpos].fg;
}
 
return 0;
}
 
char read_alt_assigned_bg(struct session_struct *session, int xpos, int ypos)
{
if (valid_x(session, xpos) && valid_alt_y(session, ypos))
{
return session->alternate_area[ypos][xpos].bg;
}
 
return 0;
}
 
char read_alt_assigned_flags(struct session_struct *session, int xpos, int ypos)
{
if (valid_x(session, xpos) && valid_alt_y(session, ypos))
{
return session->alternate_area[ypos][xpos].flags;
}
 
return 0;
}
 
char read_alt_assigned_character(struct session_struct *session, int xpos, int ypos)
{
if (valid_x(session, xpos) && valid_alt_y(session, ypos))
{
return session->alternate_area[ypos][xpos].chr;
}
 
return 0;
}
 
void write_assigned_flags(struct session_struct *session, int xpos, int ypos, char flags)
{
if (valid_x(session, xpos) && valid_y(session, ypos))
{
session->assigned_area[ypos][xpos].flags = flags;
}
}
 
void write_assigned_character(struct session_struct *session, int xpos, int ypos, char character)
{
if (valid_x(session, xpos) && valid_y(session, ypos))
{
session->assigned_area[ypos][xpos].chr = character;
}
}
 
void create_terminal(struct session_struct *session, struct coords terminal_size,
int scrollback)
{
int loop;
 
session->assigned_area=malloc((terminal_size.y+scrollback)*sizeof (int *));
assert(session->assigned_area);
 
for (loop=0; loop<terminal_size.y+scrollback; loop++)
{
session->assigned_area[loop]=malloc(terminal_size.x*sizeof (struct term_char));
assert(session->assigned_area[loop]);
}
 
session->alternate_area=malloc(terminal_size.y*sizeof (int *));
 
if (session->alternate_area)
{
for (loop=0; loop<terminal_size.y; loop++)
{
session->alternate_area[loop]=malloc(terminal_size.x*sizeof (struct term_char));
assert(session->alternate_area[loop]);
}
}
 
session->terminal_size=terminal_size;
session->scrollback=scrollback;
}
 
void delete_terminal(struct session_struct *session)
{
int loop;
 
for (loop=0; loop<session->terminal_size.y+session->scrollback; loop++)
{
free(session->assigned_area[loop]);
}
 
free(session->assigned_area);
 
if (session->alternate_area)
{
for (loop=0; loop<session->terminal_size.y; loop++)
{
free(session->alternate_area[loop]);
}
 
free(session->alternate_area);
}
}
 
 
 
static void resize_terminal_dimensions(struct session_struct *session,
struct coords terminal_size, int scrollback)
{
struct coords old_terminal_size = session->terminal_size;
int total_old_y = old_terminal_size.y + session->scrollback;
int total_new_y = terminal_size.y + scrollback;
bool bigger_y = (bool)(total_new_y > total_old_y);
int area;
struct term_char clear_char =
{ NETTLE_COLOUR_NORMAL_WHITE, NETTLE_COLOUR_NORMAL_BLACK, 0, ' '};
 
session->terminal_size = terminal_size;
session->scrollback = scrollback;
 
for (area = 0; area < ((session->alternate_area != NULL) ? 2 : 1); area++)
{
struct term_char **new_area;
struct term_char **old_area;
int split;
int loop;
 
if (area == 0)
{
old_area = session->assigned_area;
new_area = session->assigned_area =
malloc((terminal_size.y + scrollback) * sizeof(int *));
assert(session->assigned_area);
 
split = total_new_y - total_old_y;
}
else
{
old_area = session->alternate_area;
new_area = session->alternate_area =
malloc((terminal_size.y) * sizeof(int *));
assert(session->alternate_area);
 
split = terminal_size.y - old_terminal_size.y;
}
 
/* Copy (total_old_y) lines */
 
if (area == 1)
{
total_new_y = terminal_size.y;
total_old_y = old_terminal_size.y;
}
 
if (bigger_y)
{
for (loop = total_new_y - 1; loop >= 0; loop--)
{
int loop2;
int old_loop;
 
if (area == 0)
{
old_loop = loop - (total_new_y - total_old_y);
}
else
{
old_loop = loop - (terminal_size.y - old_terminal_size.y);
}
 
if (loop >= split)
{
new_area[loop ] = realloc(old_area[old_loop],
terminal_size.x * sizeof(struct term_char));
 
/* Clear the rest of the line */
for (loop2 = old_terminal_size.x; loop2 < terminal_size.x; loop2++)
{
new_area[loop][loop2] = clear_char;
}
}
else
{
new_area[loop] = malloc(terminal_size.x * sizeof(struct term_char));
assert(new_area[loop]);
 
if (area == 0)
{
clear_screen(session, loop * terminal_size.x,
(loop + 1) * terminal_size.x,
NETTLE_COLOUR_NORMAL_WHITE,
NETTLE_COLOUR_NORMAL_BLACK,
0,
' ');
}
else
{
clear_alt_screen(session, loop * terminal_size.x,
(loop + 1) * terminal_size.x,
NETTLE_COLOUR_NORMAL_WHITE,
NETTLE_COLOUR_NORMAL_BLACK,
0,
' ');
}
}
}
}
else
{
for (loop = 0; loop < total_old_y; loop++)
{
int loop2;
int old_loop;
 
if (area == 0)
{
old_loop = loop - (total_new_y - total_old_y);
}
else
{
old_loop = loop - (terminal_size.y - old_terminal_size.y);
}
 
if (loop < total_new_y)
{
new_area[loop] = realloc(old_area[old_loop],
terminal_size.x * sizeof(struct term_char));
assert(new_area[loop]);
 
/* Clear the rest of the line */
for (loop2 = old_terminal_size.x; loop2 < terminal_size.x; loop2++)
{
new_area[loop][loop2] = clear_char;
}
}
else
{
free(old_area[old_loop - total_old_y]);
}
}
}
free(old_area);
}
}
 
 
void resize_terminal(struct session_struct *session, int terminal_size_x, int terminal_size_y,
int scrollback, bool use_naws)
{
struct coords old_terminal_size;
int old_scrollback;
 
if (terminal_size_x<12) terminal_size_x=12;
if (terminal_size_y<3) terminal_size_y=3;
if (scrollback<0) scrollback=0;
 
old_terminal_size.x = session->terminal_size.x;
old_terminal_size.y = session->terminal_size.y;
old_scrollback = session->scrollback;
 
if (terminal_size_x != old_terminal_size.x || terminal_size_y !=
old_terminal_size.y || old_scrollback != scrollback)
{
struct coords terminal_size;
 
terminal_size.x=terminal_size_x;
terminal_size.y=terminal_size_y;
 
resize_terminal_dimensions(session, terminal_size, scrollback);
 
session->scroll_start = 1;
session->scroll_end = terminal_size_y;
 
allocate_zapredraw_area(terminal_size_x, terminal_size_y, scrollback);
}
 
/* This should put the cursor back in the right place... */
session->pos.y=session->pos.y-old_scrollback-old_terminal_size.y+scrollback+terminal_size_y;
session->old_pos.y=session->old_pos.y-old_scrollback-old_terminal_size.y+scrollback+terminal_size_y;
 
#if 1
/* JRF: This is my version of the selection area fix-up.
I understand this version */
 
/* This should put the selection back in the right place... */
if (selection_session == session)
{
/* Principle:
* Decompose the selection start and end in to x/y pairs relative
* to the bottom left of the window.
* Apply boundings to both pairs for the new window size.
* Reconstruct the start and end offsets, relative to the top left
* as normal.
*/
 
struct coords start,end;
start.x = selection_start % old_terminal_size.x;
start.y = selection_start / old_terminal_size.x;
end.x = selection_end % old_terminal_size.x;
end.y = selection_end / old_terminal_size.x;
 
/* Invert y, because we're keeping relative to the bottom */
start.y = old_terminal_size.y + old_scrollback - start.y;
end.y = old_terminal_size.y + old_scrollback - end.y;
 
if (start.x > terminal_size_x)
start.x = terminal_size_x;
if (start.y > terminal_size_y+scrollback)
{
start.y = terminal_size_y+scrollback;
start.x = 0;
}
if (end.x > terminal_size_x)
end.x = terminal_size_x;
if (end.y > terminal_size_y+scrollback)
selection_session = NULL;
 
/* And invert back based on new size, so that we're in the right place */
start.y = terminal_size_y + scrollback - start.y;
end.y = terminal_size_y + scrollback - end.y;
 
selection_start = start.y * terminal_size_x + start.x;
selection_end = end.y * terminal_size_x + end.x;
}
 
#else
/* JRF: This is Alex's version of the selection area fix-up.
I think I understand it, but I can't maintain it.
It seems overly complex to me. */
 
if (session==selection_session)
{
/* selection area needs moved to accommodate new terminal size */
int selection_start_x=selection_start % old_terminal_size.x;
int selection_start_y=selection_start / old_terminal_size.x;
int selection_end_x=selection_end % old_terminal_size.x;
int selection_end_y=selection_end / old_terminal_size.x;
 
selection_start_y=selection_start_y-old_scrollback-old_terminal_size.y+scrollback+terminal_size_y;
selection_end_y=selection_end_y-old_scrollback-old_terminal_size.y+scrollback+terminal_size_y;
 
/* do range checking on terminal_size_x */
if (selection_start_x>terminal_size_x) selection_start_x=terminal_size_x;
if (selection_end_x>terminal_size_x) selection_end_x=terminal_size_x;
 
/* write the selection positions back to the variables */
selection_start=(selection_start_y*terminal_size_x)+selection_start_x;
selection_end=(selection_end_y*terminal_size_x)+selection_end_x;
 
/* do range checking on the final values of selection_start and selection_end */
 
if (selection_start<0) selection_start=0;
if (selection_end<0) selection_end=0;
 
if (selection_start>terminal_size_x*(terminal_size_y+scrollback))
selection_start=terminal_size_x*(terminal_size_y+scrollback);
if (selection_end>terminal_size_x*(terminal_size_y+scrollback))
selection_end=terminal_size_x*(terminal_size_y+scrollback);
 
/* And scrap the selection if these are the same */
if (selection_start==selection_end)
selection_session=NULL;
}
 
#endif
reopen_and_size_window(session, old_terminal_size.x, old_terminal_size.y, old_scrollback,
redraw.r_charw, redraw.r_charh);
 
if (use_naws)
{
if (session->session_resized)
{
/* Callback to the protocol */
session->session_resized(session,old_terminal_size);
}
}
}
 
void reopen_and_size_window(struct session_struct *session, int old_terminal_size_x,
int old_terminal_size_y, int old_scrollback,
int old_charw, int old_charh)
{
{
struct wimp_setextent_block block;
 
block.min.x=0;
block.min.y=-((session->terminal_size.y+session->scrollback)*redraw.r_charh << eig.y);
block.max.x=session->terminal_size.x*redraw.r_charw << eig.x;
block.max.y=0;
 
_swi(Wimp_SetExtent, _INR(0,1), session->window_handle, &block);
 
if (session->line_editor_type!=LINEEDIT_NONE)
{
block.min.x=0;
block.min.y=-48;
block.max.x=session->terminal_size.x*redraw.r_charw << eig.x;
block.max.y=0;
 
_swi(Wimp_SetExtent, _INR(0,1), session->pane_handle, &block);
}
}
 
{
struct wimp_getwindowstate_block block;
 
block.window_handle=session->window_handle;
_swi(Wimp_GetWindowState, _IN(1), &block);
 
/* If terminal at fullsize, then reopen window at fullsize, otherwise leave it */
if (block.max.x-block.min.x==(old_terminal_size_x*old_charw << eig.x))
{
block.max.x=block.min.x+(session->terminal_size.x*redraw.r_charw << eig.x);
}
if (block.max.y-block.min.y==(old_terminal_size_y*old_charh << eig.y))
{
block.min.y=block.max.y-(session->terminal_size.y*redraw.r_charh << eig.y);
}
 
/* If terminal is bigger than fullsize in the new font shrink it down to fullsize */
if ((block.max.x-block.min.x)>(session->terminal_size.x*redraw.r_charw << eig.x))
{
block.max.x=block.min.x+(session->terminal_size.x*redraw.r_charw << eig.x);
}
if ((block.max.y-block.min.y)>(session->terminal_size.y*redraw.r_charh << eig.y))
{
block.min.y=block.max.y-(session->terminal_size.y*redraw.r_charh << eig.y);
}
 
/* If scrollback has changed, then shift the scroll offset */
if (old_scrollback!=session->scrollback)
{
block.scroll.y-=(session->scrollback-old_scrollback)*old_charh << eig.y;
}
 
if (block.max.x > screensize.x)
{
block.min.x -= (block.max.x-screensize.x);
block.max.x -= (block.max.x-screensize.x);
}
 
if (block.max.y > screensize.y)
{
block.min.y -= (block.max.y-screensize.y);
block.max.y -= (block.max.y-screensize.y);
}
 
/* Scale the scroll offset according to the old font size/new font size */
block.scroll.x=(block.scroll.x*redraw.r_charw/old_charw);
block.scroll.y=(block.scroll.y*redraw.r_charh/old_charh);
 
/* wimp_openwindow_block starts the same way as wimp_getwindowstate_block */
_swi(Wimp_OpenWindow, _IN(1), &block);
 
force_redraw(session->window_handle,0,
(-session->terminal_size.y-session->scrollback)*
redraw.r_charh << eig.y,
session->terminal_size.x*redraw.r_charw << eig.x,0);
 
if (session->line_editor_type!=LINEEDIT_NONE)
open_pane_window(session, (struct wimp_openwindow_block *) &block);
}
}
 
void scroll_term (struct session_struct *session, int direction)
{
struct wimp_getwindowstate_block block;
 
block.window_handle = session->window_handle;
_swi (Wimp_GetWindowState, _IN(1), (int) &block);
block.scroll.y += direction * (block.max.y - block.min.y);
_swi (Wimp_OpenWindow, _IN(1), (int) &block);
}
 
/*************************************************** Gerph *********
Function: wimp_set_scrollbars
Description: Turn the scrollbars on or off for a session
Parameters: session-> the session to change the bars on
on = true to turn them on,
false to turn them off
Returns: none
******************************************************************/
void set_scrollbars(struct session_struct *session,bool on)
{
struct wimp_getwindowstate_block block;
/* get the window state */
block.window_handle = session->window_handle;
_swi (Wimp_GetWindowState, _IN(1), &block);
 
/* Turn on toggle, V+H scrollbars and adjust */
if (on)
{
block.window_flags |= ((1<<30) | (1<<29) |
(1<<28) | (1<<27));
}
else
{
block.window_flags &= ~((1<<30) | (1<<29) |
(1<<28) | (1<<27));
}
 
_swi (Wimp_OpenWindow, _INR(1,4), &block,
MAGIC_TASK,
-1,
(1<<0));
 
/* Now re-open the line editor pane if necessary */
if (session->line_editor_type!=LINEEDIT_NONE)
open_pane_window(session, (struct wimp_openwindow_block *) &block);
}
/vendor/v0.2023/hotlist.h
New file
0,0 → 1,25
/**
* Nettle Hotlist header
* (C) Nettle developers 2001
*
* $Id: hotlist,v 1.12 2002/01/30 02:33:45 ijeffray Exp $
*/
 
#ifndef HOTLIST_H
#define HOTLIST_H
 
extern void lose_hotlist(void);
extern void load_hotlist(void);
extern int *create_hotlist_menu(void);
extern void hotlist_draw(struct wimp_getrectangle_block *getrect_block);
extern int hotlist_num_items(void);
extern void resize_hotpane(void);
extern void win_panehot_click(int x, int y, int buttons, int icon_handle);
extern void win_hotpane_click(int x, int y, int buttons, int icon_handle);
extern void win_hotedit_click(int x, int y, int buttons, int icon_handle);
extern void fire_hotlist(int item);
extern bool finish_hotlist_editing(int dowhat); /* 0=cancel, 1=set, 2=save */
extern void hotlist_inform(int icon, int menuselection);
extern void hotlist_dragdone(void);
 
#endif /* HOTLIST_H */
/vendor/v0.2023/Makefile
New file
0,0 → 1,1151
# Acorn / NetLib Makefile for Nettle
# by A. Macfarlane Smith
# (C) Archifishal Software 2001
# Twiddled quite a bit by Justin Fletcher (sorry)
#
# $Id: Makefile,fe1,v 1.27 2002/02/02 21:45:10 ijeffray Exp $
 
 
# Uncomment /these/ to use NetLib
#NETINCLUDE = NetLib:
#NETLIBS = NetLib:o.netlib
#NETLIBFLAG =
 
# Uncomment /these/ to use TCPIPLibs
NETINCLUDE = StubsG:TCPIPLibs.
NETLIBS = StubsG:TCPIPLibs.o.socklib-32 StubsG:TCPIPLibs.o.inetlib-32
NETLIBFLAG = -DUSE_TCPIPLIB
 
CLIBPATH = StubsG:Clib.
 
SSHINCLUDES = -Issh.bn. -Issh.putty. -Issh.interfaces.
#FORTIFY = -DFORTIFY
THROWBACK = -throwback
 
CC = cc
CFLAGS = -Wc -c -strict -j$(CLIBPATH) -I$(NETINCLUDE) $(SSHINCLUDES) -fa $(THROWBACK) -depend !Depend $(NETLIBFLAG) $(FORTIFY) -apcs 3/32bit/fpe2/swstackcheck/fp/nofpregargs #-g
 
LINK = link
LINKFLAGS = #-d
 
MKDIR = cdir
CD = dir
RM = remove
 
WIPE = wipe
WIPEFLAGS = ~CFR~V
 
ASM = objasm
ASMFLAGS =
 
TEMPLATES = !NettleSSH.Resources.UK.Templates
 
SSHOBJS = \
ssh.putty.o.putty \
ssh.interfaces.o.interfaces \
ssh.bn.o.bn \
 
OBJS = chardefn.o choices.o dnslib.o globals.o init.o keyboard.o lineedit.o \
main.o misc.o hotlist.o nettle.o process.o socket.o quit.o seln.o \
wimp.o zapgen.o fortify.o sockwatch.o messages.o termlist.o url.o \
wimputil.o spool.o mouse.o scripts.o processesc.o processiac.o \
procesescx.o \
p_rlogin.o p_rexec.o p_taskwindow.o p_telnet.o p_ssh.o \
protocols.o timers.o
 
all: !NettleSSH.!RunImage
 
templheadr: templheadr.o
$(LINK) -rescan -o $@ $(LINKFLAGS) $? $(CLIBPATH)o.stubsG
 
!NettleSSH.!RunImage: $(OBJS) $(SSHOBJS)
$(LINK) -o $@ $(LINKFLAGS) $(OBJS) $(SSHOBJS) $(CLIBPATH)o.stubsG $(NETLIBS)
|squeeze $@
 
clean:
create o.dummy
$(WIPE) o.* $(WIPEFLAGS)
$(CD) ssh.putty
$(MAKE) $(MAKEFLAGS) clean
$(CD) ^.^
$(CD) ssh.interfaces
$(MAKE) $(MAKEFLAGS) clean
$(CD) ^.^
$(CD) ssh.bn
$(MAKE) $(MAKEFLAGS) clean
$(CD) ^.^
 
templ.h: templheadr $(TEMPLATES)
If "<Prefix$Dir>" <> "" Then /<Prefix$Dir>.templheadr $(TEMPLATES) $@
If "<Prefix$Dir>" = "" Then /templheadr $(TEMPLATES) $@
 
.SUFFIXES: .o .s .c
 
.s.o:
$(MKDIR) o
$(ASM) $(ASMFLAGS) $< -o $@
 
.c.o:
$(MKDIR) o
$(CC) $(CFLAGS) -o $@ $<
 
o.wimp: templ.h
o.spool: templ.h
 
MAKEFLAGS = NETINCLUDE=$(NETINCLUDE) NETLIBFLAG=$(NETLIBFLAG) FORTIFY=$(FORTIFY) THROWBACK=$(THROWBACK)
 
# Libraries:
ssh.putty.o.putty:
$(CD) ssh.putty
$(MAKE) $(MAKEFLAGS)
$(CD) ^.^
ssh.interfaces.o.interfaces:
$(CD) ssh.interfaces
$(MAKE) $(MAKEFLAGS)
$(CD) ^.^
ssh.bn.o.bn:
$(CD) ssh.bn
$(MAKE) $(MAKEFLAGS)
$(CD) ^.^
 
# Clean the libraries
cleanlibs:
$(RM) ssh.putty.o.putty
$(RM) ssh.interfaces.o.interfaces
$(RM) ssh.bn.o.bn
 
# Dynamic dependencies:
o.procesescx: c.procesescx
o.procesescx: StubsG:Clib.h.stddef
o.procesescx: h.generic
o.procesescx: h.fortify
o.procesescx: StubsG:Clib.h.stdlib
o.procesescx: StubsG:Clib.h.string
o.procesescx: h.ufortify
o.procesescx: StubsG:Clib.h.assert
o.procesescx: StubsG:Clib.h.stdio
o.procesescx: StubsG:Clib.h.stdarg
o.procesescx: StubsG:Clib.h.stdlib
o.procesescx: StubsG:Clib.h.string
o.procesescx: StubsG:Clib.h.math
o.procesescx: StubsG:Clib.h.kernel
o.procesescx: StubsG:Clib.h.swis
o.procesescx: h.globals
o.procesescx: h.nettle
o.procesescx: h.dnslib
o.procesescx: h.options
o.procesescx: h.misc
o.procesescx: StubsG:Clib.h.string
o.procesescx: h.mouse
o.procesescx: h.wimputil
o.procesescx: h.nettle
o.procesescx: h.messages
o.procesescx: h.process
o.procesescx: h.timers
o.p_rlogin: c.p_rlogin
o.p_rlogin: h.generic
o.p_rlogin: h.fortify
o.p_rlogin: StubsG:Clib.h.stdlib
o.p_rlogin: StubsG:Clib.h.string
o.p_rlogin: h.ufortify
o.p_rlogin: StubsG:Clib.h.assert
o.p_rlogin: StubsG:Clib.h.stdio
o.p_rlogin: StubsG:Clib.h.stdarg
o.p_rlogin: StubsG:Clib.h.stdlib
o.p_rlogin: StubsG:Clib.h.string
o.p_rlogin: StubsG:Clib.h.math
o.p_rlogin: StubsG:Clib.h.kernel
o.p_rlogin: StubsG:Clib.h.swis
o.p_rlogin: h.globals
o.p_rlogin: h.nettle
o.p_rlogin: h.dnslib
o.p_rlogin: h.options
o.p_rlogin: h.messages
o.p_rlogin: h.p_rlogin
o.p_rlogin: h.protocols
o.p_rlogin: h.socket
o.p_rexec: c.p_rexec
o.p_rexec: h.generic
o.p_rexec: h.fortify
o.p_rexec: StubsG:Clib.h.stdlib
o.p_rexec: StubsG:Clib.h.string
o.p_rexec: h.ufortify
o.p_rexec: StubsG:Clib.h.assert
o.p_rexec: StubsG:Clib.h.stdio
o.p_rexec: StubsG:Clib.h.stdarg
o.p_rexec: StubsG:Clib.h.stdlib
o.p_rexec: StubsG:Clib.h.string
o.p_rexec: StubsG:Clib.h.math
o.p_rexec: StubsG:Clib.h.kernel
o.p_rexec: StubsG:Clib.h.swis
o.p_rexec: h.globals
o.p_rexec: h.nettle
o.p_rexec: h.dnslib
o.p_rexec: h.options
o.p_rexec: h.messages
o.p_rexec: h.p_rexec
o.p_rexec: h.protocols
o.p_rexec: h.socket
o.p_taskwindow: c.p_taskwindow
o.p_taskwindow: h.generic
o.p_taskwindow: h.fortify
o.p_taskwindow: StubsG:Clib.h.stdlib
o.p_taskwindow: StubsG:Clib.h.string
o.p_taskwindow: h.ufortify
o.p_taskwindow: StubsG:Clib.h.assert
o.p_taskwindow: StubsG:Clib.h.stdio
o.p_taskwindow: StubsG:Clib.h.stdarg
o.p_taskwindow: StubsG:Clib.h.stdlib
o.p_taskwindow: StubsG:Clib.h.string
o.p_taskwindow: StubsG:Clib.h.math
o.p_taskwindow: StubsG:Clib.h.kernel
o.p_taskwindow: StubsG:Clib.h.swis
o.p_taskwindow: h.globals
o.p_taskwindow: h.nettle
o.p_taskwindow: h.dnslib
o.p_taskwindow: h.options
o.p_taskwindow: h.messages
o.p_taskwindow: h.wimputil
o.p_taskwindow: h.nettle
o.p_taskwindow: h.messages
o.p_taskwindow: h.p_taskwindow
o.p_taskwindow: h.generic
o.p_taskwindow: h.globals
o.p_taskwindow: h.protocols
o.p_telnet: c.p_telnet
o.p_telnet: h.generic
o.p_telnet: h.fortify
o.p_telnet: StubsG:Clib.h.stdlib
o.p_telnet: StubsG:Clib.h.string
o.p_telnet: h.ufortify
o.p_telnet: StubsG:Clib.h.assert
o.p_telnet: StubsG:Clib.h.stdio
o.p_telnet: StubsG:Clib.h.stdarg
o.p_telnet: StubsG:Clib.h.stdlib
o.p_telnet: StubsG:Clib.h.string
o.p_telnet: StubsG:Clib.h.math
o.p_telnet: StubsG:Clib.h.kernel
o.p_telnet: StubsG:Clib.h.swis
o.p_telnet: h.globals
o.p_telnet: h.nettle
o.p_telnet: h.dnslib
o.p_telnet: h.options
o.p_telnet: h.messages
o.p_telnet: h.wimputil
o.p_telnet: h.nettle
o.p_telnet: h.messages
o.p_telnet: h.process
o.p_telnet: h.p_telnet
o.p_telnet: h.generic
o.p_telnet: h.globals
o.p_telnet: h.protocols
o.p_ssh: c.p_ssh
o.p_ssh: h.generic
o.p_ssh: h.fortify
o.p_ssh: StubsG:Clib.h.stdlib
o.p_ssh: StubsG:Clib.h.string
o.p_ssh: h.ufortify
o.p_ssh: StubsG:Clib.h.assert
o.p_ssh: StubsG:Clib.h.stdio
o.p_ssh: StubsG:Clib.h.stdarg
o.p_ssh: StubsG:Clib.h.stdlib
o.p_ssh: StubsG:Clib.h.string
o.p_ssh: StubsG:Clib.h.math
o.p_ssh: StubsG:Clib.h.kernel
o.p_ssh: StubsG:Clib.h.swis
o.p_ssh: h.globals
o.p_ssh: h.nettle
o.p_ssh: h.dnslib
o.p_ssh: h.options
o.p_ssh: h.messages
o.p_ssh: h.p_ssh
o.p_ssh: h.protocols
o.p_ssh: h.socket
o.p_ssh: ssh.interfaces.h.sshif
o.p_ssh: ssh.interfaces.h.def
o.p_ssh: ssh.interfaces.h.syslogif
o.p_ssh: ssh.interfaces.h.syslogDS
o.p_ssh: StubsG:Clib.h.kernel
o.p_ssh: ssh.putty.h.sshdef
o.p_ssh: ssh.interfaces.h.defstruc
o.p_ssh: ssh.putty.h.windows
o.p_ssh: ssh.putty.h.putty
o.p_ssh: ssh.putty.h.sshstrc
o.protocols: c.protocols
o.protocols: h.generic
o.protocols: h.fortify
o.protocols: StubsG:Clib.h.stdlib
o.protocols: StubsG:Clib.h.string
o.protocols: h.ufortify
o.protocols: StubsG:Clib.h.assert
o.protocols: StubsG:Clib.h.stdio
o.protocols: StubsG:Clib.h.stdarg
o.protocols: StubsG:Clib.h.stdlib
o.protocols: StubsG:Clib.h.string
o.protocols: StubsG:Clib.h.math
o.protocols: StubsG:Clib.h.kernel
o.protocols: StubsG:Clib.h.swis
o.protocols: h.globals
o.protocols: h.nettle
o.protocols: h.dnslib
o.protocols: h.options
o.protocols: h.messages
o.protocols: h.nettle
o.protocols: h.misc
o.protocols: StubsG:Clib.h.string
o.protocols: h.protocols
o.protocols: h.wimputil
o.protocols: h.nettle
o.protocols: h.messages
o.protocols: h.url
o.protocols: StubsG:Clib.h.ctype
o.protocols: h.p_telnet
o.protocols: h.generic
o.protocols: h.globals
o.protocols: h.protocols
o.protocols: h.p_rlogin
o.protocols: h.protocols
o.protocols: h.p_rexec
o.protocols: h.protocols
o.protocols: h.p_taskwindow
o.protocols: h.generic
o.protocols: h.globals
o.protocols: h.protocols
o.protocols: h.p_ssh
o.protocols: h.protocols
o.timers: c.timers
o.timers: StubsG:Clib.h.stdio
o.timers: StubsG:Clib.h.stdlib
o.timers: StubsG:Clib.h.assert
o.timers: StubsG:Clib.h.swis
o.timers: StubsG:Clib.h.kernel
o.timers: h.timers
o.chardefn: c.chardefn
o.chardefn: h.generic
o.chardefn: h.fortify
o.chardefn: StubsG:Clib.h.stdlib
o.chardefn: StubsG:Clib.h.string
o.chardefn: h.ufortify
o.chardefn: StubsG:Clib.h.assert
o.chardefn: StubsG:Clib.h.stdio
o.chardefn: StubsG:Clib.h.stdarg
o.chardefn: StubsG:Clib.h.stdlib
o.chardefn: StubsG:Clib.h.string
o.chardefn: StubsG:Clib.h.math
o.chardefn: StubsG:Clib.h.kernel
o.chardefn: StubsG:Clib.h.swis
o.chardefn: h.globals
o.chardefn: h.nettle
o.chardefn: h.dnslib
o.chardefn: h.options
o.chardefn: h.chardefn
o.chardefn: h.misc
o.chardefn: StubsG:Clib.h.string
o.chardefn: h.zapredraw
o.choices: c.choices
o.choices: h.generic
o.choices: h.fortify
o.choices: StubsG:Clib.h.stdlib
o.choices: StubsG:Clib.h.string
o.choices: h.ufortify
o.choices: StubsG:Clib.h.assert
o.choices: StubsG:Clib.h.stdio
o.choices: StubsG:Clib.h.stdarg
o.choices: StubsG:Clib.h.stdlib
o.choices: StubsG:Clib.h.string
o.choices: StubsG:Clib.h.math
o.choices: StubsG:Clib.h.kernel
o.choices: StubsG:Clib.h.swis
o.choices: h.globals
o.choices: h.nettle
o.choices: h.dnslib
o.choices: h.options
o.choices: h.choices
o.choices: h.hotlist
o.choices: h.lineedit
o.choices: h.messages
o.choices: h.misc
o.choices: StubsG:Clib.h.string
o.choices: h.templ
o.choices: h.wimp
o.choices: h.nettle
o.choices: h.wimputil
o.choices: h.nettle
o.choices: h.messages
o.choices: h.zapredraw
o.choices: StubsG:TCPIPLibs.h.errno
o.choices: StubsG:TCPIPLibs.sys.h.errno
o.choices: StubsG:Clib.h.kernel
o.choices: StubsG:Clib.h.time
o.dnslib: c.dnslib
o.dnslib: h.generic
o.dnslib: h.fortify
o.dnslib: StubsG:Clib.h.stdlib
o.dnslib: StubsG:Clib.h.string
o.dnslib: h.ufortify
o.dnslib: StubsG:Clib.h.assert
o.dnslib: StubsG:Clib.h.stdio
o.dnslib: StubsG:Clib.h.stdarg
o.dnslib: StubsG:Clib.h.stdlib
o.dnslib: StubsG:Clib.h.string
o.dnslib: StubsG:Clib.h.math
o.dnslib: StubsG:Clib.h.kernel
o.dnslib: StubsG:Clib.h.swis
o.dnslib: StubsG:TCPIPLibs.sys.h.types
o.dnslib: StubsG:TCPIPLibs.sys.h.cdefs
o.dnslib: StubsG:TCPIPLibs.machine.h.endian
o.dnslib: StubsG:TCPIPLibs.machine.h.ansi
o.dnslib: StubsG:TCPIPLibs.machine.h.types
o.dnslib: StubsG:Clib.h.time
o.dnslib: StubsG:TCPIPLibs.netinet.h.in
o.dnslib: StubsG:TCPIPLibs.arpa.h.inet
o.dnslib: StubsG:TCPIPLibs.sys.h.cdefs
o.dnslib: StubsG:TCPIPLibs.h.netdb
o.dnslib: StubsG:TCPIPLibs.sys.h.cdefs
o.dnslib: StubsG:TCPIPLibs.sys.h.errno
o.dnslib: StubsG:Clib.h.kernel
o.dnslib: StubsG:TCPIPLibs.sys.h.socket
o.dnslib: StubsG:TCPIPLibs.sys.h.cdefs
o.dnslib: h.dnslib
o.dnslib: h.misc
o.dnslib: StubsG:Clib.h.string
o.globals: c.globals
o.globals: h.generic
o.globals: h.fortify
o.globals: StubsG:Clib.h.stdlib
o.globals: StubsG:Clib.h.string
o.globals: h.ufortify
o.globals: StubsG:Clib.h.assert
o.globals: StubsG:Clib.h.stdio
o.globals: StubsG:Clib.h.stdarg
o.globals: StubsG:Clib.h.stdlib
o.globals: StubsG:Clib.h.string
o.globals: StubsG:Clib.h.math
o.globals: StubsG:Clib.h.kernel
o.globals: StubsG:Clib.h.swis
o.globals: h.globals
o.globals: h.nettle
o.globals: h.dnslib
o.globals: h.options
o.globals: h.nettle
o.globals: h.zapredraw
o.init: c.init
o.init: h.generic
o.init: h.fortify
o.init: StubsG:Clib.h.stdlib
o.init: StubsG:Clib.h.string
o.init: h.ufortify
o.init: StubsG:Clib.h.assert
o.init: StubsG:Clib.h.stdio
o.init: StubsG:Clib.h.stdarg
o.init: StubsG:Clib.h.stdlib
o.init: StubsG:Clib.h.string
o.init: StubsG:Clib.h.math
o.init: StubsG:Clib.h.kernel
o.init: StubsG:Clib.h.swis
o.init: h.globals
o.init: h.nettle
o.init: h.dnslib
o.init: h.options
o.init: h.choices
o.init: h.hotlist
o.init: h.init
o.init: h.messages
o.init: h.misc
o.init: StubsG:Clib.h.string
o.init: h.nettle
o.init: h.scripts
o.init: h.quit
o.init: h.sockwatch
o.init: h.templ
o.init: h.timers
o.init: h.url
o.init: h.wimp
o.init: h.nettle
o.init: h.wimputil
o.init: h.nettle
o.init: h.messages
o.init: h.zapredraw
o.keyboard: c.keyboard
o.keyboard: h.generic
o.keyboard: h.fortify
o.keyboard: StubsG:Clib.h.stdlib
o.keyboard: StubsG:Clib.h.string
o.keyboard: h.ufortify
o.keyboard: StubsG:Clib.h.assert
o.keyboard: StubsG:Clib.h.stdio
o.keyboard: StubsG:Clib.h.stdarg
o.keyboard: StubsG:Clib.h.stdlib
o.keyboard: StubsG:Clib.h.string
o.keyboard: StubsG:Clib.h.math
o.keyboard: StubsG:Clib.h.kernel
o.keyboard: StubsG:Clib.h.swis
o.keyboard: h.globals
o.keyboard: h.nettle
o.keyboard: h.dnslib
o.keyboard: h.options
o.keyboard: h.keyboard
o.keyboard: h.seln
o.keyboard: h.wimp
o.keyboard: h.nettle
o.lineedit: c.lineedit
o.lineedit: h.generic
o.lineedit: h.fortify
o.lineedit: StubsG:Clib.h.stdlib
o.lineedit: StubsG:Clib.h.string
o.lineedit: h.ufortify
o.lineedit: StubsG:Clib.h.assert
o.lineedit: StubsG:Clib.h.stdio
o.lineedit: StubsG:Clib.h.stdarg
o.lineedit: StubsG:Clib.h.stdlib
o.lineedit: StubsG:Clib.h.string
o.lineedit: StubsG:Clib.h.math
o.lineedit: StubsG:Clib.h.kernel
o.lineedit: StubsG:Clib.h.swis
o.lineedit: h.globals
o.lineedit: h.nettle
o.lineedit: h.dnslib
o.lineedit: h.options
o.lineedit: h.lineedit
o.lineedit: h.misc
o.lineedit: StubsG:Clib.h.string
o.lineedit: h.wimp
o.lineedit: h.nettle
o.lineedit: h.wimputil
o.lineedit: h.nettle
o.lineedit: h.messages
o.lineedit: h.zapredraw
o.main: c.main
o.main: h.generic
o.main: h.fortify
o.main: StubsG:Clib.h.stdlib
o.main: StubsG:Clib.h.string
o.main: h.ufortify
o.main: StubsG:Clib.h.assert
o.main: StubsG:Clib.h.stdio
o.main: StubsG:Clib.h.stdarg
o.main: StubsG:Clib.h.stdlib
o.main: StubsG:Clib.h.string
o.main: StubsG:Clib.h.math
o.main: StubsG:Clib.h.kernel
o.main: StubsG:Clib.h.swis
o.main: h.globals
o.main: h.nettle
o.main: h.dnslib
o.main: h.options
o.main: h.init
o.main: h.main
o.main: h.misc
o.main: StubsG:Clib.h.string
o.main: h.quit
o.main: h.sockwatch
o.main: h.url
o.main: h.wimp
o.main: h.nettle
o.main: h.timers
o.misc: c.misc
o.misc: h.generic
o.misc: h.fortify
o.misc: StubsG:Clib.h.stdlib
o.misc: StubsG:Clib.h.string
o.misc: h.ufortify
o.misc: StubsG:Clib.h.assert
o.misc: StubsG:Clib.h.stdio
o.misc: StubsG:Clib.h.stdarg
o.misc: StubsG:Clib.h.stdlib
o.misc: StubsG:Clib.h.string
o.misc: StubsG:Clib.h.math
o.misc: StubsG:Clib.h.kernel
o.misc: StubsG:Clib.h.swis
o.misc: h.globals
o.misc: h.nettle
o.misc: h.dnslib
o.misc: h.options
o.misc: h.misc
o.misc: StubsG:Clib.h.string
o.misc: h.wimputil
o.misc: h.nettle
o.misc: h.messages
o.hotlist: c.hotlist
o.hotlist: h.generic
o.hotlist: h.fortify
o.hotlist: StubsG:Clib.h.stdlib
o.hotlist: StubsG:Clib.h.string
o.hotlist: h.ufortify
o.hotlist: StubsG:Clib.h.assert
o.hotlist: StubsG:Clib.h.stdio
o.hotlist: StubsG:Clib.h.stdarg
o.hotlist: StubsG:Clib.h.stdlib
o.hotlist: StubsG:Clib.h.string
o.hotlist: StubsG:Clib.h.math
o.hotlist: StubsG:Clib.h.kernel
o.hotlist: StubsG:Clib.h.swis
o.hotlist: h.globals
o.hotlist: h.nettle
o.hotlist: h.dnslib
o.hotlist: h.options
o.hotlist: h.hotlist
o.hotlist: h.lineedit
o.hotlist: h.misc
o.hotlist: StubsG:Clib.h.string
o.hotlist: h.messages
o.hotlist: h.nettle
o.hotlist: h.protocols
o.hotlist: h.templ
o.hotlist: h.wimp
o.hotlist: h.nettle
o.hotlist: h.wimputil
o.hotlist: h.nettle
o.hotlist: h.messages
o.hotlist: StubsG:Clib.h.time
o.hotlist: StubsG:Clib.h.ctype
o.nettle: c.nettle
o.nettle: h.generic
o.nettle: h.fortify
o.nettle: StubsG:Clib.h.stdlib
o.nettle: StubsG:Clib.h.string
o.nettle: h.ufortify
o.nettle: StubsG:Clib.h.assert
o.nettle: StubsG:Clib.h.stdio
o.nettle: StubsG:Clib.h.stdarg
o.nettle: StubsG:Clib.h.stdlib
o.nettle: StubsG:Clib.h.string
o.nettle: StubsG:Clib.h.math
o.nettle: StubsG:Clib.h.kernel
o.nettle: StubsG:Clib.h.swis
o.nettle: h.globals
o.nettle: h.nettle
o.nettle: h.dnslib
o.nettle: h.options
o.nettle: h.lineedit
o.nettle: h.main
o.nettle: h.messages
o.nettle: h.misc
o.nettle: StubsG:Clib.h.string
o.nettle: h.mouse
o.nettle: h.nettle
o.nettle: h.process
o.nettle: h.protocols
o.nettle: h.p_rexec
o.nettle: h.protocols
o.nettle: h.p_rlogin
o.nettle: h.protocols
o.nettle: h.p_taskwindow
o.nettle: h.generic
o.nettle: h.globals
o.nettle: h.protocols
o.nettle: h.p_telnet
o.nettle: h.generic
o.nettle: h.globals
o.nettle: h.protocols
o.nettle: h.seln
o.nettle: h.socket
o.nettle: h.spool
o.nettle: h.templ
o.nettle: h.timers
o.nettle: h.wimp
o.nettle: h.nettle
o.nettle: h.wimputil
o.nettle: h.nettle
o.nettle: h.messages
o.nettle: h.zapredraw
o.process: c.process
o.process: StubsG:Clib.h.stddef
o.process: h.generic
o.process: h.fortify
o.process: StubsG:Clib.h.stdlib
o.process: StubsG:Clib.h.string
o.process: h.ufortify
o.process: StubsG:Clib.h.assert
o.process: StubsG:Clib.h.stdio
o.process: StubsG:Clib.h.stdarg
o.process: StubsG:Clib.h.stdlib
o.process: StubsG:Clib.h.string
o.process: StubsG:Clib.h.math
o.process: StubsG:Clib.h.kernel
o.process: StubsG:Clib.h.swis
o.process: h.globals
o.process: h.nettle
o.process: h.dnslib
o.process: h.options
o.process: h.graphics
o.process: h.keyboard
o.process: h.lineedit
o.process: h.main
o.process: h.messages
o.process: h.misc
o.process: StubsG:Clib.h.string
o.process: h.mouse
o.process: h.nettle
o.process: h.process
o.process: h.seln
o.process: h.socket
o.process: h.spool
o.process: h.wimp
o.process: h.nettle
o.process: h.wimputil
o.process: h.nettle
o.process: h.messages
o.process: h.zapredraw
o.process: h.timers
o.socket: c.socket
o.socket: h.generic
o.socket: h.fortify
o.socket: StubsG:Clib.h.stdlib
o.socket: StubsG:Clib.h.string
o.socket: h.ufortify
o.socket: StubsG:Clib.h.assert
o.socket: StubsG:Clib.h.stdio
o.socket: StubsG:Clib.h.stdarg
o.socket: StubsG:Clib.h.stdlib
o.socket: StubsG:Clib.h.string
o.socket: StubsG:Clib.h.math
o.socket: StubsG:Clib.h.kernel
o.socket: StubsG:Clib.h.swis
o.socket: h.globals
o.socket: h.nettle
o.socket: h.dnslib
o.socket: h.options
o.socket: StubsG:TCPIPLibs.sys.h.types
o.socket: StubsG:TCPIPLibs.sys.h.cdefs
o.socket: StubsG:TCPIPLibs.machine.h.endian
o.socket: StubsG:TCPIPLibs.machine.h.ansi
o.socket: StubsG:TCPIPLibs.machine.h.types
o.socket: StubsG:Clib.h.time
o.socket: StubsG:TCPIPLibs.sys.h.errno
o.socket: StubsG:Clib.h.kernel
o.socket: StubsG:TCPIPLibs.sys.h.ioctl
o.socket: StubsG:TCPIPLibs.sys.h.ttycom
o.socket: StubsG:TCPIPLibs.sys.h.ioccom
o.socket: StubsG:TCPIPLibs.sys.h.ioccom
o.socket: StubsG:TCPIPLibs.sys.h.filio
o.socket: StubsG:TCPIPLibs.sys.h.ioccom
o.socket: StubsG:TCPIPLibs.sys.h.sockio
o.socket: StubsG:TCPIPLibs.sys.h.ioccom
o.socket: StubsG:TCPIPLibs.sys.h.cdefs
o.socket: StubsG:TCPIPLibs.sys.h.socket
o.socket: StubsG:TCPIPLibs.sys.h.cdefs
o.socket: StubsG:TCPIPLibs.h.socklib
o.socket: StubsG:TCPIPLibs.sys.h.types
o.socket: StubsG:TCPIPLibs.sys.h.socket
o.socket: StubsG:TCPIPLibs.sys.h.stat
o.socket: StubsG:TCPIPLibs.sys.h.time
o.socket: StubsG:Clib.h.time
o.socket: StubsG:TCPIPLibs.sys.h.cdefs
o.socket: StubsG:TCPIPLibs.sys.h.cdefs
o.socket: StubsG:TCPIPLibs.sys.h.time
o.socket: StubsG:TCPIPLibs.sys.h.uio
o.socket: StubsG:TCPIPLibs.sys.h.cdefs
o.socket: StubsG:Clib.h.kernel
o.socket: StubsG:TCPIPLibs.sys.h.select
o.socket: StubsG:TCPIPLibs.sys.h.time
o.socket: StubsG:TCPIPLibs.netinet.h.in
o.socket: StubsG:TCPIPLibs.arpa.h.inet
o.socket: StubsG:TCPIPLibs.sys.h.cdefs
o.socket: StubsG:TCPIPLibs.h.netdb
o.socket: StubsG:TCPIPLibs.sys.h.cdefs
o.socket: h.socket
o.socket: h.sockwatch
o.quit: c.quit
o.quit: h.generic
o.quit: h.fortify
o.quit: StubsG:Clib.h.stdlib
o.quit: StubsG:Clib.h.string
o.quit: h.ufortify
o.quit: StubsG:Clib.h.assert
o.quit: StubsG:Clib.h.stdio
o.quit: StubsG:Clib.h.stdarg
o.quit: StubsG:Clib.h.stdlib
o.quit: StubsG:Clib.h.string
o.quit: StubsG:Clib.h.math
o.quit: StubsG:Clib.h.kernel
o.quit: StubsG:Clib.h.swis
o.quit: h.globals
o.quit: h.nettle
o.quit: h.dnslib
o.quit: h.options
o.quit: h.hotlist
o.quit: h.init
o.quit: h.messages
o.quit: h.misc
o.quit: StubsG:Clib.h.string
o.quit: h.nettle
o.quit: h.quit
o.quit: h.scripts
o.quit: h.sockwatch
o.quit: h.termlist
o.quit: h.zapredraw
o.quit: h.wimp
o.quit: h.nettle
o.quit: ssh.interfaces.h.sshif
o.quit: ssh.interfaces.h.def
o.quit: ssh.interfaces.h.syslogif
o.quit: ssh.interfaces.h.syslogDS
o.quit: StubsG:Clib.h.kernel
o.quit: ssh.putty.h.sshdef
o.quit: ssh.interfaces.h.defstruc
o.quit: ssh.putty.h.windows
o.quit: ssh.putty.h.putty
o.quit: ssh.putty.h.sshstrc
o.seln: c.seln
o.seln: h.generic
o.seln: h.fortify
o.seln: StubsG:Clib.h.stdlib
o.seln: StubsG:Clib.h.string
o.seln: h.ufortify
o.seln: StubsG:Clib.h.assert
o.seln: StubsG:Clib.h.stdio
o.seln: StubsG:Clib.h.stdarg
o.seln: StubsG:Clib.h.stdlib
o.seln: StubsG:Clib.h.string
o.seln: StubsG:Clib.h.math
o.seln: StubsG:Clib.h.kernel
o.seln: StubsG:Clib.h.swis
o.seln: h.globals
o.seln: h.nettle
o.seln: h.dnslib
o.seln: h.options
o.seln: h.messages
o.seln: h.misc
o.seln: StubsG:Clib.h.string
o.seln: h.nettle
o.seln: h.process
o.seln: h.seln
o.seln: h.socket
o.seln: h.wimp
o.seln: h.nettle
o.seln: h.wimputil
o.seln: h.nettle
o.seln: h.messages
o.seln: h.zapredraw
o.wimp: c.wimp
o.wimp: h.generic
o.wimp: h.fortify
o.wimp: StubsG:Clib.h.stdlib
o.wimp: StubsG:Clib.h.string
o.wimp: h.ufortify
o.wimp: StubsG:Clib.h.assert
o.wimp: StubsG:Clib.h.stdio
o.wimp: StubsG:Clib.h.stdarg
o.wimp: StubsG:Clib.h.stdlib
o.wimp: StubsG:Clib.h.string
o.wimp: StubsG:Clib.h.math
o.wimp: StubsG:Clib.h.kernel
o.wimp: StubsG:Clib.h.swis
o.wimp: h.globals
o.wimp: h.nettle
o.wimp: h.dnslib
o.wimp: h.options
o.wimp: StubsG:Clib.h.ctype
o.wimp: StubsG:TCPIPLibs.h.errno
o.wimp: StubsG:TCPIPLibs.sys.h.errno
o.wimp: StubsG:Clib.h.kernel
o.wimp: StubsG:TCPIPLibs.sys.h.errno
o.wimp: StubsG:TCPIPLibs.h.socklib
o.wimp: StubsG:TCPIPLibs.sys.h.types
o.wimp: StubsG:TCPIPLibs.sys.h.cdefs
o.wimp: StubsG:TCPIPLibs.machine.h.endian
o.wimp: StubsG:TCPIPLibs.machine.h.ansi
o.wimp: StubsG:TCPIPLibs.machine.h.types
o.wimp: StubsG:Clib.h.time
o.wimp: StubsG:TCPIPLibs.sys.h.socket
o.wimp: StubsG:TCPIPLibs.sys.h.cdefs
o.wimp: StubsG:TCPIPLibs.sys.h.stat
o.wimp: StubsG:TCPIPLibs.sys.h.time
o.wimp: StubsG:Clib.h.time
o.wimp: StubsG:TCPIPLibs.sys.h.cdefs
o.wimp: StubsG:TCPIPLibs.sys.h.cdefs
o.wimp: StubsG:TCPIPLibs.sys.h.time
o.wimp: StubsG:TCPIPLibs.sys.h.uio
o.wimp: StubsG:TCPIPLibs.sys.h.cdefs
o.wimp: StubsG:Clib.h.kernel
o.wimp: StubsG:TCPIPLibs.h.unixlib
o.wimp: StubsG:Clib.h.stdio
o.wimp: StubsG:TCPIPLibs.sys.h.select
o.wimp: StubsG:TCPIPLibs.sys.h.time
o.wimp: StubsG:TCPIPLibs.h.netdb
o.wimp: StubsG:TCPIPLibs.sys.h.cdefs
o.wimp: h.choices
o.wimp: h.hotlist
o.wimp: h.keyboard
o.wimp: h.lineedit
o.wimp: h.messages
o.wimp: h.main
o.wimp: h.misc
o.wimp: StubsG:Clib.h.string
o.wimp: h.mouse
o.wimp: h.nettle
o.wimp: h.process
o.wimp: h.protocols
o.wimp: h.p_taskwindow
o.wimp: h.generic
o.wimp: h.globals
o.wimp: h.protocols
o.wimp: h.scripts
o.wimp: h.seln
o.wimp: h.socket
o.wimp: h.sockwatch
o.wimp: h.spool
o.wimp: h.templ
o.wimp: h.termlist
o.wimp: h.timers
o.wimp: h.url
o.wimp: h.wimp
o.wimp: h.nettle
o.wimp: h.wimputil
o.wimp: h.nettle
o.wimp: h.messages
o.wimp: h.zapredraw
o.zapgen: c.zapgen
o.zapgen: h.generic
o.zapgen: h.fortify
o.zapgen: StubsG:Clib.h.stdlib
o.zapgen: StubsG:Clib.h.string
o.zapgen: h.ufortify
o.zapgen: StubsG:Clib.h.assert
o.zapgen: StubsG:Clib.h.stdio
o.zapgen: StubsG:Clib.h.stdarg
o.zapgen: StubsG:Clib.h.stdlib
o.zapgen: StubsG:Clib.h.string
o.zapgen: StubsG:Clib.h.math
o.zapgen: StubsG:Clib.h.kernel
o.zapgen: StubsG:Clib.h.swis
o.zapgen: h.globals
o.zapgen: h.nettle
o.zapgen: h.dnslib
o.zapgen: h.options
o.zapgen: h.chardefn
o.zapgen: h.messages
o.zapgen: h.misc
o.zapgen: StubsG:Clib.h.string
o.zapgen: h.nettle
o.zapgen: h.wimp
o.zapgen: h.nettle
o.zapgen: h.wimputil
o.zapgen: h.nettle
o.zapgen: h.messages
o.zapgen: h.zapredraw
o.fortify: c.fortify
o.sockwatch: c.sockwatch
o.sockwatch: StubsG:Clib.h.stdio
o.sockwatch: StubsG:Clib.h.kernel
o.sockwatch: StubsG:Clib.h.swis
o.sockwatch: h.sockwatch
o.messages: c.messages
o.messages: h.generic
o.messages: h.fortify
o.messages: StubsG:Clib.h.stdlib
o.messages: StubsG:Clib.h.string
o.messages: h.ufortify
o.messages: StubsG:Clib.h.assert
o.messages: StubsG:Clib.h.stdio
o.messages: StubsG:Clib.h.stdarg
o.messages: StubsG:Clib.h.stdlib
o.messages: StubsG:Clib.h.string
o.messages: StubsG:Clib.h.math
o.messages: StubsG:Clib.h.kernel
o.messages: StubsG:Clib.h.swis
o.messages: h.globals
o.messages: h.nettle
o.messages: h.dnslib
o.messages: h.options
o.messages: h.messages
o.messages: h.misc
o.messages: StubsG:Clib.h.string
o.termlist: c.termlist
o.termlist: h.generic
o.termlist: h.fortify
o.termlist: StubsG:Clib.h.stdlib
o.termlist: StubsG:Clib.h.string
o.termlist: h.ufortify
o.termlist: StubsG:Clib.h.assert
o.termlist: StubsG:Clib.h.stdio
o.termlist: StubsG:Clib.h.stdarg
o.termlist: StubsG:Clib.h.stdlib
o.termlist: StubsG:Clib.h.string
o.termlist: StubsG:Clib.h.math
o.termlist: StubsG:Clib.h.kernel
o.termlist: StubsG:Clib.h.swis
o.termlist: h.globals
o.termlist: h.nettle
o.termlist: h.dnslib
o.termlist: h.options
o.termlist: h.messages
o.termlist: h.nettle
o.termlist: h.termlist
o.termlist: h.wimp
o.termlist: h.nettle
o.termlist: h.protocols
o.termlist: StubsG:Clib.h.ctype
o.url: c.url
o.url: StubsG:Clib.h.ctype
o.url: h.generic
o.url: h.fortify
o.url: StubsG:Clib.h.stdlib
o.url: StubsG:Clib.h.string
o.url: h.ufortify
o.url: StubsG:Clib.h.assert
o.url: StubsG:Clib.h.stdio
o.url: StubsG:Clib.h.stdarg
o.url: StubsG:Clib.h.stdlib
o.url: StubsG:Clib.h.string
o.url: StubsG:Clib.h.math
o.url: StubsG:Clib.h.kernel
o.url: StubsG:Clib.h.swis
o.url: h.globals
o.url: h.nettle
o.url: h.dnslib
o.url: h.options
o.url: h.url
o.url: h.wimp
o.url: h.nettle
o.url: h.wimputil
o.url: h.nettle
o.url: h.messages
o.wimputil: c.wimputil
o.wimputil: StubsG:TCPIPLibs.sys.h.errno
o.wimputil: StubsG:Clib.h.kernel
o.wimputil: StubsG:Clib.h.stdarg
o.wimputil: h.generic
o.wimputil: h.fortify
o.wimputil: StubsG:Clib.h.stdlib
o.wimputil: StubsG:Clib.h.string
o.wimputil: h.ufortify
o.wimputil: StubsG:Clib.h.assert
o.wimputil: StubsG:Clib.h.stdio
o.wimputil: StubsG:Clib.h.stdarg
o.wimputil: StubsG:Clib.h.stdlib
o.wimputil: StubsG:Clib.h.string
o.wimputil: StubsG:Clib.h.math
o.wimputil: StubsG:Clib.h.kernel
o.wimputil: StubsG:Clib.h.swis
o.wimputil: h.globals
o.wimputil: h.nettle
o.wimputil: h.dnslib
o.wimputil: h.options
o.wimputil: h.misc
o.wimputil: StubsG:Clib.h.string
o.wimputil: h.wimp
o.wimputil: h.nettle
o.wimputil: h.wimputil
o.wimputil: h.nettle
o.wimputil: h.messages
o.spool: c.spool
o.spool: h.generic
o.spool: h.fortify
o.spool: StubsG:Clib.h.stdlib
o.spool: StubsG:Clib.h.string
o.spool: h.ufortify
o.spool: StubsG:Clib.h.assert
o.spool: StubsG:Clib.h.stdio
o.spool: StubsG:Clib.h.stdarg
o.spool: StubsG:Clib.h.stdlib
o.spool: StubsG:Clib.h.string
o.spool: StubsG:Clib.h.math
o.spool: StubsG:Clib.h.kernel
o.spool: StubsG:Clib.h.swis
o.spool: h.globals
o.spool: h.nettle
o.spool: h.dnslib
o.spool: h.options
o.spool: h.misc
o.spool: StubsG:Clib.h.string
o.spool: h.spool
o.spool: h.templ
o.spool: h.wimputil
o.spool: h.nettle
o.spool: h.messages
o.templheadr: c.templheadr
o.templheadr: StubsG:Clib.h.stdio
o.templheadr: StubsG:Clib.h.string
o.templheadr: StubsG:Clib.h.stdlib
o.mouse: c.mouse
o.mouse: h.generic
o.mouse: h.fortify
o.mouse: StubsG:Clib.h.stdlib
o.mouse: StubsG:Clib.h.string
o.mouse: h.ufortify
o.mouse: StubsG:Clib.h.assert
o.mouse: StubsG:Clib.h.stdio
o.mouse: StubsG:Clib.h.stdarg
o.mouse: StubsG:Clib.h.stdlib
o.mouse: StubsG:Clib.h.string
o.mouse: StubsG:Clib.h.math
o.mouse: StubsG:Clib.h.kernel
o.mouse: StubsG:Clib.h.swis
o.mouse: h.globals
o.mouse: h.nettle
o.mouse: h.dnslib
o.mouse: h.options
o.mouse: h.keyboard
o.mouse: h.main
o.mouse: h.mouse
o.mouse: h.nettle
o.mouse: h.wimputil
o.mouse: h.nettle
o.mouse: h.messages
o.mouse: h.zapredraw
o.scripts: c.scripts
o.scripts: h.generic
o.scripts: h.fortify
o.scripts: StubsG:Clib.h.stdlib
o.scripts: StubsG:Clib.h.string
o.scripts: h.ufortify
o.scripts: StubsG:Clib.h.assert
o.scripts: StubsG:Clib.h.stdio
o.scripts: StubsG:Clib.h.stdarg
o.scripts: StubsG:Clib.h.stdlib
o.scripts: StubsG:Clib.h.string
o.scripts: StubsG:Clib.h.math
o.scripts: StubsG:Clib.h.kernel
o.scripts: StubsG:Clib.h.swis
o.scripts: h.globals
o.scripts: h.nettle
o.scripts: h.dnslib
o.scripts: h.options
o.scripts: h.misc
o.scripts: StubsG:Clib.h.string
o.scripts: h.scripts
o.scripts: h.wimputil
o.scripts: h.nettle
o.scripts: h.messages
o.processesc: c.processesc
o.processesc: StubsG:Clib.h.stddef
o.processesc: h.generic
o.processesc: h.fortify
o.processesc: StubsG:Clib.h.stdlib
o.processesc: StubsG:Clib.h.string
o.processesc: h.ufortify
o.processesc: StubsG:Clib.h.assert
o.processesc: StubsG:Clib.h.stdio
o.processesc: StubsG:Clib.h.stdarg
o.processesc: StubsG:Clib.h.stdlib
o.processesc: StubsG:Clib.h.string
o.processesc: StubsG:Clib.h.math
o.processesc: StubsG:Clib.h.kernel
o.processesc: StubsG:Clib.h.swis
o.processesc: h.globals
o.processesc: h.nettle
o.processesc: h.dnslib
o.processesc: h.options
o.processesc: h.process
o.processiac: c.processiac
o.processiac: StubsG:Clib.h.stddef
o.processiac: h.generic
o.processiac: h.fortify
o.processiac: StubsG:Clib.h.stdlib
o.processiac: StubsG:Clib.h.string
o.processiac: h.ufortify
o.processiac: StubsG:Clib.h.assert
o.processiac: StubsG:Clib.h.stdio
o.processiac: StubsG:Clib.h.stdarg
o.processiac: StubsG:Clib.h.stdlib
o.processiac: StubsG:Clib.h.string
o.processiac: StubsG:Clib.h.math
o.processiac: StubsG:Clib.h.kernel
o.processiac: StubsG:Clib.h.swis
o.processiac: h.globals
o.processiac: h.nettle
o.processiac: h.dnslib
o.processiac: h.options
o.processiac: h.process
/vendor/v0.2023/lineedit.c
New file
0,0 → 1,242
/**
* Line editor code
* (C) Nettle developers 2000-2001
*
* $Id: lineedit,v 1.27 2002/02/10 21:26:37 ijeffray Exp $
*/
 
#include "generic.h"
#include "globals.h"
 
#include "lineedit.h"
#include "misc.h"
#include "wimp.h"
#include "wimputil.h"
#include "zapredraw.h"
 
static char line_editor_buffer_indirected[]="Pptr_write";
static char line_editor_icon_text[]="";
static char line_editor_icon_sprite[]="Soptoff,opton";
 
static void resize_line_editor_icons(struct session_struct *session, int width)
{
struct wimp_geticonstate_block iconstate;
struct wimp_getcaretposition_block caret;
bool has_checkbox = BOOL(session->line_editor_type==LINEEDIT_CHECKBOX_OFF || session->line_editor_type==LINEEDIT_CHECKBOX_ON);
int checkbox_chop = has_checkbox ? 56 : 0;
 
if (session->line_editor_type==LINEEDIT_NONE)
return;
 
iconstate.window_handle=session->pane_handle;
iconstate.icon_handle=0;
_swi(Wimp_GetIconState, _IN(1), &iconstate);
 
if (width==(iconstate.max.x-4) + checkbox_chop )
return;
 
_swi(Wimp_GetCaretPosition, _IN(1), &caret);
_swix( Wimp_ResizeIcon, _INR(0,5), session->pane_handle, 0, -4, -52, (width+4)-checkbox_chop, 4 );
 
if (has_checkbox)
_swix( Wimp_ResizeIcon, _INR(0,5), session->pane_handle, 1, width-48, -48, width, 0 );
 
force_redraw(session->pane_handle, 0, -48, 1<<24, 0);
 
if (caret.window_handle==session->pane_handle)
{
set_caret_position(caret.window_handle, 0, -1, caret.index);
}
 
}
 
 
void open_pane_window(struct session_struct *session, struct wimp_openwindow_block *main_block)
{
int toolheight=-1;
struct wimp_getwindowoutline_block gwo_block;
struct wimp_openwindow_block window;
struct wimp_getwindowstate_block gws_block;
int width,height=0;
 
width=main_block->max.x-main_block->min.x;
 
if (width>session->terminal_size.x*redraw.r_charw << eig.x)
width=session->terminal_size.x*redraw.r_charw << eig.x;
 
gws_block.window_handle=session->window_handle;
_swi(Wimp_GetWindowState, _IN(1), &gws_block);
if (gws_block.window_flags & (1<<30))
height=toolheight;
 
gwo_block.window_handle=session->window_handle;
_swi(Wimp_GetWindowOutline, _IN(1), &gwo_block);
 
window.window_handle=session->pane_handle;
window.min.x=main_block->min.x;
window.min.y=(main_block->min.y)-height-48;
window.max.x=window.min.x+width;
 
window.max.y=(main_block->min.y)-height;
window.scroll.x=0;
window.scroll.y=0;
window.handle_behind=main_block->handle_behind;
 
resize_line_editor_icons(session, width);
 
_swi(Wimp_OpenWindow, _IN(1), &window);
}
 
 
bool line_editor_active(struct session_struct *session)
{
switch (session->line_editor_type)
{
case LINEEDIT_CHECKBOX_OFF:
case LINEEDIT_CHECKBOX_ON:
{
struct wimp_geticonstate_block block;
 
block.window_handle=session->pane_handle;
block.icon_handle =0;
 
_swi(Wimp_GetIconState, _IN(1), &block);
 
if ( (block.icon_flags & WIMP_ICON_DELETED_BIT) == 0)
return true;
 
}
break;
case LINEEDIT_ANTTERM:
return true; /* antterm style is always on */
break;
}
 
return false;
}
 
void lineedit_allocate_space(struct session_struct *session)
{
int loop,width;
struct wimp_createwindow_block window;
struct wimp_createicon_block icon;
bool has_checkbox = BOOL(session->line_editor_type==LINEEDIT_CHECKBOX_OFF || session->line_editor_type==LINEEDIT_CHECKBOX_ON);
 
/* Note - this *must* be called if the lineeditor is turned on at any point */
session->line_editor_history=malloc(line_editor_size*512*sizeof(char));
assert(session->line_editor_history != NULL);
session->line_editor_position=0;
session->line_editor_total=1;
 
for (loop=0; loop<line_editor_size; loop++)
{
strcpy(session->line_editor_history+(loop*512),"");
}
 
strcpy(session->line_editor_buffer,"");
 
/* Create new pane window */
window.min.x=102;
window.min.y=1088-(session->terminal_size.y*redraw.r_charh << eig.y)-40;
window.max.x=102+(session->terminal_size.x*redraw.r_charw << eig.x);
window.max.y=1088-(session->terminal_size.y*redraw.r_charh << eig.y);
 
window.scroll.x=0;
window.scroll.y=0;
 
window.handle_behind=-1;
window.window_flags =0x80080162;
 
window.title_fg =7;
window.title_bg =2;
window.work_fg =7;
window.work_bg =1;
 
window.scroll_outer_colour=3;
window.scroll_inner_colour=1;
window.title_focus_colour =12;
window.flags =0;
 
window.work_min.x=0;
window.work_min.y=-48;
window.work_max.x=session->terminal_size.x*redraw.r_charw << eig.x;
window.work_max.y=0;
 
window.icon_flags =0x00000000;
window.workarea_flags=0<<12;
 
window.sprite_area=(struct os_spriteop_area *) 1;
window.min_width =4;
window.min_height =4;
 
window.title.it.text =0;
window.title.it.validation=0;
window.title.it.text_len =0;
 
window.number_of_icons =0;
 
session->pane_handle=_swi(Wimp_CreateWindow, _IN(1)|_RETURN(0), &window);
 
width = window.work_max.x - window.work_min.x;
 
icon.window_handle=session->pane_handle;
icon.min.x =-4;
icon.min.y =-52;
icon.max.x =width+4;
icon.max.y =4;
 
if (has_checkbox)
icon.max.x -= 56;
 
icon.icon_flags =WIMP_ICON_FGCOL(7) | WIMP_ICON_TYPE(15) | \
WIMP_ICON_INDIRECTED_BIT | WIMP_ICON_FILLED_BIT | \
WIMP_ICON_VCENT_BIT | WIMP_ICON_BORDER_BIT | WIMP_ICON_TEXT_BIT;
 
icon.contents.it.text =session->line_editor_buffer;
icon.contents.it.validation=line_editor_buffer_indirected;
icon.contents.it.text_len =sizeof(session->line_editor_buffer);
 
_swi(Wimp_CreateIcon, _IN(1), &icon);
 
if (has_checkbox)
{
icon.window_handle=session->pane_handle;
icon.min.x =width-48;
icon.min.y =-48;
icon.max.x =width;
icon.max.y =0;
icon.icon_flags =WIMP_ICON_BGCOL(1) | WIMP_ICON_TYPE(11) | WIMP_ICON_INDIRECTED_BIT | \
WIMP_ICON_VCENT_BIT | WIMP_ICON_TEXT_BIT | WIMP_ICON_SPRITE_BIT;
 
if ( session->line_editor_type==LINEEDIT_CHECKBOX_ON )
{
icon.icon_flags |= WIMP_ICON_SELECTED_BIT;
}
icon.contents.it.text =line_editor_icon_text;
icon.contents.it.validation =line_editor_icon_sprite;
icon.contents.it.text_len =sizeof(line_editor_icon_text);
 
_swi(Wimp_CreateIcon, _IN(1), &icon);
}
 
if ( session->line_editor_type==LINEEDIT_CHECKBOX_OFF )
set_icon_state(session->pane_handle, 0, WIMP_ICON_DELETED_BIT, WIMP_ICON_DELETED_BIT);
 
}
 
void lineedit_free_space(struct session_struct *session)
{
/* Note - this *must* be called if the lineeditor is turned off at any point */
struct wimp_deletewindow_block block;
 
if (session->line_editor_type == LINEEDIT_NONE)
return;
 
block.window_handle=session->pane_handle;
 
_swix(Wimp_DeleteWindow, _IN(1), &block);
session->pane_handle = 0;
 
free(session->line_editor_history);
session->line_editor_history = NULL;
}
/vendor/v0.2023/nettle.h
New file
0,0 → 1,243
/*
* Nettle specific code headers
* (C) Nettle developers 2000-2002
*
* $Id: nettle,v 1.36 2002/02/21 23:15:32 ijeffray Exp $
*/
 
#ifndef NETTLE_H
#define NETTLE_H
 
/* JRF: These are now FIXED numbers, because they are used as indices into
arrays for sprite names in termlist and hotlist */
#define NETTLE_TELNET 1
#define NETTLE_SSH 2
#define NETTLE_TASKWINDOW 3
#define NETTLE_RLOGIN 4
#define NETTLE_REXEC 5
 
#define NETTLE_SESSION_NONE 0
#define NETTLE_SESSION_RESOLVE 1
#define NETTLE_SESSION_CONNECT 2
#define NETTLE_SESSION_CONNECTED 3
 
#define NETTLE_ESCAPE_NONE 0
#define NETTLE_ESCAPE_ESCAPE 1
 
#define NETTLE_FLAG_CURSOR (1<<0)
#define NETTLE_FLAG_NO_INPUT (1<<1)
#define NETTLE_FLAG_INVERTED (1<<2)
#define NETTLE_FLAG_PLUS100 (1<<3)
#define NETTLE_FLAG_BLINK (1<<4)
#define NETTLE_FLAG_VALID (1<<5)
#define NETTLE_FLAG_UNDERLINE (1<<6)
 
/* Options */
#define NETTLE_OTHER_VT52_MODE (1<<0)
#define NETTLE_OTHER_INSERT_MODE (1<<1)
#define NETTLE_OTHER_KEYLOCK_MODE (1<<2)
#define NETTLE_OTHER_LINEFEED_MODE (1<<3)
#define NETTLE_OTHER_ORIGIN_MODE (1<<5)
#define NETTLE_OTHER_WRAP_MODE (1<<6)
#define NETTLE_OTHER_APPLI_MODE (1<<8)
#define NETTLE_OTHER_BACKSPACE_MODE (1<<9)
#define NETTLE_OTHER_SCREEN_MODE (1<<10)
#define NETTLE_OTHER_COLUMN_MODE (1<<11)
#define NETTLE_OTHER_VISUAL_BELL_MODE (1<<13)
/* Flags */
#define NETTLE_OTHER_CURSOR_VIS (1<<4)
#define NETTLE_OTHER_REVERSE_VIDEO (1<<7)
#define NETTLE_OTHER_VISUAL_BELL (1<<12)
#define NETTLE_OTHER_BLINK_HIDE (1<<14)
 
#define NETTLE_COLOUR_NORMAL_BLACK 0
#define NETTLE_COLOUR_NORMAL_RED 1
#define NETTLE_COLOUR_NORMAL_GREEN 2
#define NETTLE_COLOUR_NORMAL_YELLOW 3
#define NETTLE_COLOUR_NORMAL_BLUE 4
#define NETTLE_COLOUR_NORMAL_MAGENTA 5
#define NETTLE_COLOUR_NORMAL_CYAN 6
#define NETTLE_COLOUR_NORMAL_WHITE 7
#define NETTLE_COLOUR_BRIGHT_BLACK 8
#define NETTLE_COLOUR_BRIGHT_RED 9
#define NETTLE_COLOUR_BRIGHT_GREEN 10
#define NETTLE_COLOUR_BRIGHT_YELLOW 11
#define NETTLE_COLOUR_BRIGHT_BLUE 12
#define NETTLE_COLOUR_BRIGHT_MAGENTA 13
#define NETTLE_COLOUR_BRIGHT_CYAN 14
#define NETTLE_COLOUR_BRIGHT_WHITE 15
 
enum nettle_terminal {
NETTLE_TERMINAL_VT100,
NETTLE_TERMINAL_VT102,
NETTLE_TERMINAL_VT220,
NETTLE_TERMINAL_VT320,
NETTLE_TERMINAL_VT420,
NETTLE_TERMINAL_VT510,
NETTLE_TERMINAL_RXVT,
NETTLE_TERMINAL_XTERM,
NETTLE_TERMINAL_XTERM_COLOR,
NETTLE_TERMINAL_LINUX
};
 
 
#define NETTLE_CHSET_G0 0
#define NETTLE_CHSET_G1 1
#define NETTLE_CHSET_G2 2
#define NETTLE_CHSET_G3 3
 
#define NETTLE_CHSET_ASCII 1
#define NETTLE_CHSET_DEC_SUPPLEMENTAL_GRAPHICS 2
#define NETTLE_CHSET_UK_NATIONAL 3
#define NETTLE_CHSET_DEC_SPECIAL_GRAPHICS 4
#define NETTLE_CHSET_DOWNLINE_LOADABLE 5
 
/* Maximum length for connection type - telnet, ssh, etc */
#define MESSAGE_MAX_CONNECTION 20
 
/* Maximum length for terminal type - vt100, vt102, etc */
#define MESSAGE_MAX_TERMINAL 12
 
/* Maximum length of menu entries */
#define MESSAGE_MAX_MENU 20
 
struct session_struct;
 
struct connection_params
{
int connection_type;
enum nettle_terminal terminal_type;
const char *host;
int port;
const char *command;
int width;
int height;
int scrollback;
char line_editor_type;
char label[150]; /**< appears on session menu and in title bar */
 
const char *login_user;
const char *login_pass;
};
 
bool start_connection_fromwindow(void);
bool start_connection_friedport(struct connection_params *params );
void start_connection (struct connection_params *params );
 
/*
* Description: Decode a host string into user, pass, host, port
* Parameters: string-> the string to parse
* tempbuf-> the string to use for holding password
* and user name in (guarenteed as long as
* string+4)
* host-> hostname to update (pointer into tempbuf)
* port-> the port to connect on, or -1 if unset
* user-> user name to update (pointer into tempbuf)
* pass-> pointer to password to update (pointer into tempbuf)
*
* user,pass,host will be set to NULL if not supplied
*
* Returns: true if we succeeded, false otherwise
*/
bool decode_host_string (const char *string, char *tempbuf,
char **host, int *port,
char **user, char **pass);
 
#if 0
/**
* Start a telnet connection with default choices
*
* @param host Hostname to connect to
* @param port Port number to connect on
*
* @return true if connection started successfully, false otherwise
*/
bool nettle_start_telnet_connection(const char *host, int port);
bool nettle_start_telnet_connection_friedport(const char *host);
 
/**
* Start a rlogin connection with default choices
*
* @param remoteuser User to connect as
* @param host Hostname to connect to
* @param port Port number to connect on
*
* @return true if connection started successfully, false otherwise
*/
bool nettle_start_rlogin_connection(const char *remoteuser,
const char *host, int port);
 
/**
* Start a taskwindow command with default choices
*
* @param cmd Command to run in taskwindow
*
* @return true if taskwindow started successfully, false otherwise
*/
bool nettle_start_taskwindow(const char *cmd);
#endif
 
void write_out_string(struct session_struct *, const char *);
void write_out_strings(struct session_struct *, ...); /* term with NUL ptr */
void write_out_data(struct session_struct *, const char *, int);
/* Note: Limit of 1k on this function */
void write_out_formatted (struct session_struct *session, const char *format,
...);
 
void close_session(struct session_struct *);
void remove_session(struct session_struct *);
int nettle_senddata(struct session_struct *, const char *, int);
void reset_terminal(struct session_struct *);
 
bool valid_x(struct session_struct *, int);
bool valid_y(struct session_struct *, int);
bool valid_alt_y(struct session_struct *, int);
 
void write_assigned(struct session_struct *, int, int, char, char, char, char);
void write_alt_assigned(struct session_struct *, int, int, char, char, char, char);
 
char read_assigned_fg(struct session_struct *, int, int);
char read_assigned_bg(struct session_struct *, int, int);
char read_assigned_flags(struct session_struct *, int, int);
char read_assigned_character(struct session_struct *, int, int);
 
char read_alt_assigned_fg(struct session_struct *, int, int);
char read_alt_assigned_bg(struct session_struct *, int, int);
char read_alt_assigned_flags(struct session_struct *, int, int);
char read_alt_assigned_character(struct session_struct *, int, int);
 
void write_assigned_flags(struct session_struct *, int, int, char);
void write_assigned_character(struct session_struct *, int, int, char);
 
void create_terminal(struct session_struct *, struct coords, int);
void delete_terminal(struct session_struct *);
 
void resize_terminal(struct session_struct *, int, int, int, bool);
void reopen_and_size_window(struct session_struct *, int, int, int, int, int);
 
void scroll_term(struct session_struct *, int);
 
/*************************************************** Gerph *********
Function: wimp_set_scrollbars
Description: Turn the scrollbars on or off for a session
Parameters: session-> the session to change the bars on
on = true to turn them on,
false to turn them off
Returns: none
Note: Does NOT take account of the window size - you get
the scrollbars turned off *now*.
******************************************************************/
void set_scrollbars(struct session_struct *session,bool on);
 
/*************************************************** Gerph *********
Function: nettle_senddata_socket
Description: Send data on to the socket
Parameters: session-> the session we're processing
data-> the data to send
length-> the length to send
Returns: length sent
******************************************************************/
int nettle_senddata_socket(struct session_struct *session,
const char *data, int length);
 
#endif
/vendor/v0.2023/License
New file
0,0 → 1,51
Original Nettle source code is under Licence from the Nettle developers, see
below. Additional code by Justin Fletcher is released under the following
licence :
 
NettleSSH is a derived work, based upon that of the Nettle developers. Newly
added code is Copyright (c) Justin Fletcher. The license below for Nettle
applies to this code in its entirety. That is, the source and binaries for
NettleSSH are under the same licence, with the exception of the copyright
attribution which is extended to include Justin Fletcher. This ensures that
no greater nor lesser restriction is imposed on this code over that which
it is based on.
 
SSH components of the client are based on work by Theo Markettos, Simon
Tatham, Gary S Brown, Eric Young and others. The license for this section
of NettleSSH can be found in the file 'LicenseSSH'.
 
-----------------------------------------------------------------------------
Copyright (c) 2000-2002, Nettle developers
All rights reserved.
 
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
 
 
o Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
 
o Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
 
o This product may not be redistributed for commercial purposes without
the express permission of the developer(s).
o Neither the name of the organisation nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
 
 
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/vendor/v0.2023/lineedit.h
New file
0,0 → 1,24
/**
* Line editor code
* (C) Nettle developers 2000-2001
*
* $Id: lineedit,v 1.10 2002/01/08 13:39:16 archifishal Exp $
*/
 
#ifndef LINEEDIT_H
#define LINEEDIT_H
 
#define LINEEDIT_NONE 0
#define LINEEDIT_CHECKBOX_OFF 1
#define LINEEDIT_CHECKBOX_ON 2
#define LINEEDIT_ANTTERM 3
 
#define LINEEDIT_NUM_TYPES 4
 
void open_pane_window(struct session_struct *, struct wimp_openwindow_block *);
bool line_editor_active(struct session_struct *);
 
void lineedit_allocate_space(struct session_struct *);
void lineedit_free_space(struct session_struct *);
 
#endif
/vendor/v0.2023/p_rlogin.c
New file
0,0 → 1,227
/**
* Protocol RLogin specific support code
* (C) Nettle developers 2002
*
* $Id$
*/
 
#include "generic.h"
#include "globals.h"
#include "messages.h"
#include "p_rlogin.h"
#include "socket.h"
 
#define INITIAL_PORT (512)
#define MAXIMUM_PORT (600) /* JRF: Arbitrary */
 
/* Prototypes */
char *rlogin_session_setup(struct session_struct *);
char *rlogin_session_shutdown(struct session_struct *);
 
protocol_t protocol_rlogin = {
"rlogin", /* Protocol name in Choices file */
"snettle_rlogn", /* Sprite to use to indicate this protocol */
"RLogin", /* Token for this protocol name in messages file */
"x-rlogin:", /* URI scheme prefix, or NULL if none */
513, /* Default port, or -1 if no port */
NETTLE_RLOGIN, /* Protocol type number */
 
/* Protocol flags */
PROTOCOL_HAS_HOST |
PROTOCOL_HAS_USER |
PROTOCOL_NEEDS_USER,
 
rlogin_session_setup,
rlogin_session_shutdown
};
 
/* RLogin protocol (based on rcmd) :
Connect to server on port 513, from port 512-1023
Send 0,
<local user>, 0,
<remote user>, 0,
<terminal type>, 0
Read 1 byte:
0 = connection successful;
connection established, the remote end may challenge
as it sees fit
other = connection failed;
the next string to a newline or connection close is an
error message
*/
 
/*************************************************** Gerph *********
Function: rlogin_initialdata
Description: Data has been received; we process it and return.
We need to check the first byte and hand the rest
of the data on to the normal handlers
Parameters: session-> the session from which the data arrives
data-> the data
datalen = the length of the data
Returns: none
******************************************************************/
void rlogin_initialdata(struct session_struct *session,const char *data,
int datalen)
{
if (datalen==0)
return;
 
datalen--;
if (*data++)
{
const char *prefix = lookup_static("rloginrejected");
/* An error occurred at the remote end */
session->session_data = write_out_data;
write_out_data(session,prefix,strlen(prefix));
write_out_data(session,data,datalen);
 
/* The remote end will close the connection; we don't need to do
anything */
}
else
{
/* RLogin request accepted; from now on, the remote end is performing
validation and normal terminal handling */
session->session_data = write_out_data;
write_out_data(session,data,datalen);
 
/* Must remember to unlock the keyboard, now that we're connected */
session->other_session_flags &= ~NETTLE_OTHER_KEYLOCK_MODE;
/* They don't like us echoing */
session->local_echo = false;
}
}
 
/*************************************************** Gerph *********
Function: rlogin_connected
Description: Socket has now connected; we must send our initial
negotiation data to the remote.
Parameters: session-> the session we are connecting
Returns: none
******************************************************************/
void rlogin_connected(struct session_struct *session)
{
char *localuser = getenv("Choices$User");
 
if (localuser == NULL)
localuser = "user"; /* JRF: Look this up ? Read from CLI ? */
 
/* This is a short data block; I'm assuming it will all transmit
without giving any errors */
nettle_senddata(session,"",1);
nettle_senddata(session,localuser,strlen(localuser)+1);
if (session->login_user==NULL)
{
write_out_string(session,"rlogin: Internal error (user was unset on connect)\r\n");
}
else
{
nettle_senddata(session,session->login_user,strlen(session->login_user)+1);
nettle_senddata(session,terminal_name[session->terminal_type],
strlen(terminal_name[session->terminal_type])+1);
 
free(session->login_user);
session->login_user = NULL;
 
session->session_data = rlogin_initialdata;
}
}
 
 
/*************************************************** Gerph *********
Function: rlogin_resolved
Description: Connection has resolved, socket is created and ready
for connecting; we must set up socket options. In this
case, we're going to bind to a low port. We must do
this because rlogind expects the connection to come
from ports between 512 and 1024.
Parameters: session-> the session we're operating on
Returns: none (may be error in future)
******************************************************************/
void rlogin_resolved(struct session_struct *session)
{
int port=INITIAL_PORT;
while (socket_bind(session->socket_handle,port) &&
(port < MAXIMUM_PORT))
port++;
 
/* FIXME: Should report error */
}
 
/*************************************************** Gerph *********
Function: rlogin_resized
Description: Window has been resized; we need to inform the remote
end of this fact
Parameters: session-> the session that has changed (new size in
terminal_size)
old_size = the old size coord structure, in case it
is needed
Returns: none
******************************************************************/
void rlogin_resized(struct session_struct *session,
struct coords old_size)
{
/* Should check whether they want this data */
 
/*
The window change control sequence is 12 bytes in length, consisting
of a magic cookie (two consecutive bytes of hex FF), followed by two
bytes containing lower-case ASCII "s", then 8 bytes containing the
16-bit values for the number of character rows, the number of
characters per row, the number of pixels in the X direction, and the
number of pixels in the Y direction, in network byte order. Thus:
 
FF FF s s rr cc xp yp
*/
 
char block[12];
 
/* JRF: Note: We lie about the size of characters */
int charw=8;
int charh=8;
 
block[0] =0xff;
block[1] =0xff;
block[2] ='s';
block[3] ='s';
block[4] =session->terminal_size.y / 256;
block[5] =session->terminal_size.y % 256;
block[6] =session->terminal_size.x / 256;
block[7] =session->terminal_size.x % 256;
block[8] =(session->terminal_size.x*charw) / 256;
block[9] =(session->terminal_size.x*charw) % 256;
block[10]=(session->terminal_size.y*charh) / 256;
block[11]=(session->terminal_size.y*charh) % 256;
nettle_senddata(session, block, 12);
}
 
/*************************************************** Gerph *********
Function: rlogin_session_setup
Description: Set up a protocol session
Parameters: session-> the session we're constructing
Returns: pointer to token to return as an error, or NULL if none
******************************************************************/
char *rlogin_session_setup(struct session_struct *session)
{
session->session_data = write_out_data;
session->session_connected = rlogin_connected;
session->session_resolved = rlogin_resolved;
session->session_send = nettle_senddata_socket;
session->session_resized = rlogin_resized;
 
/* Initially we want NO input from the user; this is the simplest
way in which to assert this */
session->other_session_flags |= NETTLE_OTHER_KEYLOCK_MODE;
return NULL;
}
 
/*************************************************** Gerph *********
Function: rlogin_session_shutdown
Description: Shut down a protocol session
Parameters: session-> the session we're constructing
Returns: pointer to token to return as an error, or NULL if none
******************************************************************/
char *rlogin_session_shutdown(struct session_struct *session)
{
return NULL;
}
/vendor/v0.2023/choices.c
New file
0,0 → 1,921
/**
* Nettle Choices code
* (C) Nettle developers 2000-2001
*
* $Id: choices,v 1.33 2002/02/01 23:52:23 ijeffray Exp $
*/
 
#include "generic.h"
#include "globals.h"
 
#include "choices.h"
#include "hotlist.h"
#include "lineedit.h"
#include "messages.h"
#include "misc.h"
#include "templ.h"
#include "wimp.h"
#include "wimputil.h"
#include "zapredraw.h"
 
#include <errno.h>
#include <time.h>
 
static colour_t get_colour_icon(int colour_handle, bool is_an_icon);
 
static void read_choice(char *variable, const char *line, const char *lookfor)
{
int len=strlen(lookfor);
 
if (strncmp(line,lookfor,len)==0)
{
strcpy(variable, line+len);
}
}
 
 
 
static void read_boolean_choice(bool *var, const char *line, const char *lookfor)
{
int len = strlen(lookfor);
 
if (strncmp(line,lookfor,len)==0)
{
if (strncmp(line+len,"1",1) == 0)
{
*var=true;
}
else
{
*var=false;
}
}
}
 
 
 
static void read_integer_choice(int *var, const char *line, const char *lookfor)
{
int len=strlen(lookfor);
 
if (strncmp(line,lookfor,len)==0)
{
*var=atoi(line+len);
}
}
 
static void read_terminal_choice(enum nettle_terminal *var, const char *line,const char *lookfor)
{
int len=strlen(lookfor);
 
if (strncmp(line,lookfor,len)==0)
{
*var=(enum nettle_terminal) atoi(line+len);
}
}
 
 
static void read_character_choice(char *var, const char *line, const char *lookfor)
{
int len=strlen(lookfor);
 
if (strncmp(line,lookfor,len)==0)
{
*var=atoi(line+len);
}
}
 
 
void load_choices(void)
{
FILE *file_handle;
char choices_path[256];
char string[256];
struct coords new_termsize = defaultsize;
int new_scrollback = defaultscroll;
int new_line_editor_size = line_editor_size;
enum nettle_terminal new_default_terminal = default_terminal;
colour_t new_palette[16];
bool valid_palette=true;
 
memcpy(new_palette, default_palette, sizeof(default_palette));
 
get_system_variable(choices_path, "Choices$Write", sizeof(choices_path));
 
if (choices_path[0]=='\0')
{
sprintf(string, "<%s$Dir>.Choices", application_name);
}
else
{
sprintf(string, "Choices:%s", application_name);
}
 
strcat(string, ".Choices");
 
file_handle=fopen(string,"r");
if (file_handle==NULL)
{
/* If the file doesn't exist, drop back to using default choices file */
sprintf(string, "<%s$Dir>.Choices.Default", application_name);
file_handle=fopen(string, "r");
if (file_handle==NULL)
return;
}
 
while (true)
{
char *str=fgets(string, sizeof(string), file_handle);
int len;
 
if (!str)
break;
 
len=strlen(string);
if (string[len-1]=='\n')
string[len-1]='\0';
 
read_integer_choice(&choices_file_version_number, string, "Version:");
if (choices_file_version_number>CHOICES_VERSION_KNOWN)
break;
 
read_choice(zap_font, string, "ZapFontHi:");
read_choice(zap_lowres_font, string, "ZapFontLo:");
 
read_boolean_choice(&logging, string, "Logging:");
read_character_choice(&line_editor, string, "LineEditor:");
read_boolean_choice(&pass_f12, string, "PassF12:");
read_boolean_choice(&cursor_blink, string, "CursorBlink:");
read_boolean_choice(&blinking, string, "Blinking:");
read_boolean_choice(&dont_require_ctrl, string, "DontRequireCtrl:");
read_integer_choice((int*)&cursor_type, string, "CursorType:");
 
read_terminal_choice(&new_default_terminal, string, "TerminalType:");
read_integer_choice(&new_termsize.x, string, "TerminalWidth:");
read_integer_choice(&new_termsize.y, string, "TerminalHeight:");
read_integer_choice(&new_scrollback, string, "TerminalScroll:");
read_integer_choice(&new_line_editor_size, string, "LineEditorSize:");
 
if (!strncmp(string, "Palette:", 8))
{
int loop;
str = string+8;
for (loop=0; loop<16; loop++)
{
errno=0;
new_palette[loop]=strtoul(str, &str, 16) << 8;
if (errno)
{
valid_palette=false; /* invalid */
break;
}
}
}
}
 
if (choices_file_version_number>CHOICES_VERSION_KNOWN)
{
char buffer[128];
sprintf(string,"%s %d %s",lookup("ChoicesNotKnown", buffer, sizeof(buffer)),choices_file_version_number, lookup_static("ChoicesRevert"));
generror(string, false);
}
else
{
switch (choices_file_version_number)
{
case 0:
if (line_editor==LINEEDIT_CHECKBOX_OFF)
line_editor=LINEEDIT_CHECKBOX_ON;
else if (line_editor==LINEEDIT_CHECKBOX_ON)
line_editor=LINEEDIT_ANTTERM;
 
break;
}
 
fclose(file_handle);
 
/* sanity checking in case of breakage through direct edit */
/* May sanity check fonts, although if they're wrong, it'll default back to 08x16/08x08 */
if (new_termsize.x >= MIN_TERMINAL_WIDTH && new_termsize.x <= MAX_TERMINAL_WIDTH)
defaultsize.x = new_termsize.x;
 
if (new_termsize.y >= MIN_TERMINAL_HEIGHT && new_termsize.y <= MAX_TERMINAL_HEIGHT)
defaultsize.y = new_termsize.y;
 
if (new_scrollback >= 0 && new_scrollback <= MAX_SCROLLBACK_SIZE)
defaultscroll=new_scrollback;
 
if (new_line_editor_size > 0 && new_line_editor_size <= MAX_LINE_EDITOR_SIZE)
line_editor_size = new_line_editor_size;
 
if (new_default_terminal >= 0 && new_default_terminal < NO_OF_TERMINAL_TYPES)
default_terminal = new_default_terminal;
 
/* Check that the cursor type is known */
{
char cstring[16];
sprintf(cstring,"Cursor%d",cursor_type);
if (lookup_inbuffer(cstring) == NULL)
cursor_type = cursor_solid; /* Reset to solid, if invalid */
}
 
/* If palette is valid then copy it as the default */
if (valid_palette)
memcpy(palette, new_palette, sizeof(palette));
}
}
 
bool save_choices(void)
{
char choices_path[256];
char string[512];
 
get_system_variable(choices_path, "Choices$Write", sizeof(choices_path));
 
if (choices_path[0]=='\0')
{
sprintf(string, "<%s$Dir>.Choices", application_name);
}
else
{
sprintf(string, "<Choices$Write>.%s", application_name);
}
 
_swi(OS_File, _INR(0,1)|_IN(4), 8, string, 0);
strcat(string, ".Choices");
 
_kernel_last_oserror();
 
{
bool error=false;
FILE *file_handle=fopen(string, "w");
 
if (file_handle==NULL)
{
/* Couldn't open the file for writing */
error=true;
}
else
{
int loop;
time_t current_time;
 
time(&current_time);
 
fprintf(file_handle, "# NettleSSH choices file\n");
fprintf(file_handle, "# Created on %s\n", ctime(&current_time));
fprintf(file_handle, "Version:1\n");
fprintf(file_handle, "ZapFontHi:%s\n", zap_font);
fprintf(file_handle, "ZapFontLo:%s\n", zap_lowres_font);
 
fprintf(file_handle, "Logging:%d\n", (logging==true) ? 1 : 0);
fprintf(file_handle, "PassF12:%d\n", (pass_f12==true) ? 1 : 0);
fprintf(file_handle, "CursorBlink:%d\n", (cursor_blink==true) ? 1 : 0);
fprintf(file_handle, "Blinking:%d\n", (blinking==true) ? 1 : 0);
fprintf(file_handle, "DontRequireCtrl:%d\n", (dont_require_ctrl==true) ? 1 : 0);
fprintf(file_handle, "CursorType:%d\n", cursor_type);
 
fprintf(file_handle, "TerminalType:%d\n", default_terminal);
fprintf(file_handle, "TerminalWidth:%d\n", defaultsize.x);
fprintf(file_handle, "TerminalHeight:%d\n", defaultsize.y);
fprintf(file_handle, "TerminalScroll:%d\n", defaultscroll);
fprintf(file_handle, "LineEditor:%d\n", line_editor);
fprintf(file_handle, "LineEditorSize:%d\n", line_editor_size);
 
fputs("Palette:", file_handle);
 
for (loop=0; loop<16; loop++)
fprintf(file_handle, "%06lX ", palette[loop] >> 8);
 
fputc('\n', file_handle);
 
if (!ferror(file_handle))
{
if (fclose(file_handle))
error=true;
 
file_handle=NULL;
}
}
 
if (error)
{
gensaveerror(file_handle, "CantSaveChoices");
return false;
}
 
return true;
}
}
 
 
 
 
void close_choices_window(void)
{
if (win_is_open(win_paneterm))
close_window(win_paneterm);
 
if (win_is_open(win_panecols))
close_window(win_panecols);
 
if (win_is_open(win_panehot))
close_window(win_panehot);
 
if (win_is_open(win_panemisc))
close_window(win_panemisc);
 
close_window(win_choices);
}
 
 
void open_choices_window(void)
{
char string[32];
 
/* Select paneterm */
set_icon_state(win_choices, icon_choices_size, WIMP_ICON_SELECTED_BIT, WIMP_ICON_SELECTED_BIT);
set_icon_state(win_choices, icon_choices_colour, 0, WIMP_ICON_SELECTED_BIT);
set_icon_state(win_choices, icon_choices_hotlist, 0, WIMP_ICON_SELECTED_BIT);
set_icon_state(win_choices, icon_choices_misc, 0, WIMP_ICON_SELECTED_BIT);
 
/* Set paneterm type options */
set_icon_data(win_paneterm, icon_paneterm_termtype, terminal_name[default_terminal]);
set_termsize_icons(win_paneterm, icon_paneterm_termwidth, icon_paneterm_termheight, icon_paneterm_scrollback, defaultsize, defaultscroll);
sprintf(string, "%d", line_editor_size);
set_icon_data(win_paneterm, icon_paneterm_lineeditor, string);
 
{
char string_lineedit[32];
 
sprintf(string_lineedit,"LineEd%d",line_editor);
set_icon_data(win_paneterm, icon_paneterm_lineedittype, lookup(string_lineedit, string, sizeof(string)));
}
 
{
char string_cursortype[32];
 
sprintf(string_cursortype,"Cursor%d",cursor_type);
set_icon_data(win_panemisc, icon_panemisc_cursortype, lookup(string_cursortype, string, sizeof(string)));
}
 
set_icon_data(win_paneterm, icon_paneterm_hifont, zap_font);
set_icon_data(win_paneterm, icon_paneterm_lofont, zap_lowres_font);
 
/* Set panecol type options */
{
int loop;
 
for (loop = 15; loop >= 0; --loop)
set_colour_icon (loop, palette[loop], false);
}
 
/* Set panemisc type options */
set_icon_state(win_panemisc, icon_panemisc_passf12, (pass_f12==true) ? WIMP_ICON_SELECTED_BIT : 0, WIMP_ICON_SELECTED_BIT);
set_icon_state(win_panemisc, icon_panemisc_blinking, (blinking==true) ? WIMP_ICON_SELECTED_BIT : 0, WIMP_ICON_SELECTED_BIT);
set_icon_state(win_panemisc, icon_panemisc_cursorblink, (cursor_blink==true) ? WIMP_ICON_SELECTED_BIT : 0, WIMP_ICON_SELECTED_BIT);
set_icon_state(win_panemisc, icon_panemisc_dontrequirectrl, (dont_require_ctrl==true) ? WIMP_ICON_SELECTED_BIT : 0, WIMP_ICON_SELECTED_BIT);
 
 
if (win_is_open(win_choices))
open_window(NULL, win_choices);
else
{
open_window_centred(win_choices);
set_caret_position(win_paneterm, icon_paneterm_termwidth, -1, get_icon_data_length(win_paneterm, icon_paneterm_termwidth));
}
 
resize_hotpane();
close_window(win_panehot);
close_window(win_panecols);
close_window(win_panemisc);
}
 
 
bool win_choices_read(int save)
{
struct coords new_termsize;
int new_scrollback;
int new_line_editor_size;
enum nettle_terminal new_default_terminal;
char new_zap_font[256];
char new_zap_lowres_font[256];
char string[32];
bool changed = false;
int old_charw=redraw.r_charw;
int old_charh=redraw.r_charh;
 
/* Read paneterm type options */
{
char terminal_type_string[MESSAGE_MAX_TERMINAL];
int counter=0;
 
read_icon_data(win_paneterm, icon_paneterm_termtype, terminal_type_string,
MESSAGE_MAX_TERMINAL);
 
while (counter<NO_OF_TERMINAL_TYPES &&
strcmp(terminal_type_string, terminal_name[counter]))
{
counter++;
}
 
if (counter!=NO_OF_TERMINAL_TYPES)
{
new_default_terminal=(enum nettle_terminal) counter;
}
else
{
generror("BadTermType", true);
return false;
}
}
 
if (!read_termsize_icons (win_paneterm, icon_paneterm_termwidth, icon_paneterm_termheight,
icon_paneterm_scrollback, &new_termsize, &new_scrollback))
return false;
 
new_line_editor_size = atoi (read_icon_data (win_paneterm, icon_paneterm_lineeditor, string, sizeof (string)));
 
 
if (new_line_editor_size < 1 || new_line_editor_size > MAX_LINE_EDITOR_SIZE)
{
generror ("BadLineEdSize", true);
return false;
}
 
strcpy(new_zap_font, read_icon_data(win_paneterm, icon_paneterm_hifont, string, sizeof(string)));
strcpy(new_zap_lowres_font, read_icon_data(win_paneterm, icon_paneterm_lofont, string, sizeof(string)));
 
line_editor=read_lineeditor_type(win_paneterm, icon_paneterm_lineedittype);
 
/* Read panecols type options */
{
int loop;
for (loop=15; loop>=0; loop--)
{
colour_t colour = get_colour_icon (loop, false);
if (colour != palette[loop])
{
palette[loop] = colour;
changed=true;
}
}
 
}
 
/* Read panemisc type options */
if (read_icon_ticked(win_panemisc, icon_panemisc_passf12))
pass_f12=true;
else
pass_f12=false;
 
if (read_icon_ticked(win_panemisc, icon_panemisc_blinking))
blinking=true;
else
blinking=false;
 
if (read_icon_ticked(win_panemisc, icon_panemisc_cursorblink))
cursor_blink=true;
else
cursor_blink=false;
 
if (read_icon_ticked(win_panemisc, icon_panemisc_dontrequirectrl))
dont_require_ctrl=true;
else
dont_require_ctrl=false;
 
/* Read the cursor type in use */
{
char cursor_type_string[32];
int counter=0;
 
read_icon_data(win_panemisc, icon_panemisc_cursortype, cursor_type_string,
sizeof(cursor_type_string));
 
while (1)
{
char cursor_tok[32];
const char *name;
sprintf(cursor_tok,"Cursor%d",counter);
name = lookup_static(cursor_tok);
 
if (name == NULL)
{
counter=-1;
break;
}
 
if (strcmp(cursor_type_string,name) == 0)
break;
 
counter++;
}
 
if (counter==-1)
counter=0; /* default to block cursor - should never happen */
 
if (cursor_type != (cursor_t) counter)
{
changed = true;
cursor_type = (cursor_t) counter;
/* Updating the cursors here may result in the cursors being
* written twice if the font is also changed; it's not a
* stressful operation anyhow
*/
update_cursors(zap_font_area);
update_cursors(zap_lowres_font_area);
}
}
 
/* make the choices in the new_* variables permanent */
default_terminal = new_default_terminal;
defaultsize = new_termsize;
defaultscroll = new_scrollback;
 
/* Load in new zap fonts */
if (strcmp(zap_font, new_zap_font)!=0)
{
free(zap_font_area);
strcpy(zap_font, new_zap_font);
zap_font_area=load_font(zap_font);
changed = true;
}
 
if (strcmp(zap_lowres_font, new_zap_lowres_font)!=0)
{
free(zap_lowres_font_area);
strcpy(zap_lowres_font, new_zap_lowres_font);
zap_lowres_font_area=load_font(zap_lowres_font);
changed = true;
}
 
/* Resize & redraw; also updates the palette */
if (changed)
{
struct session_struct *session = sessions;
 
mode_change();
while (session)
{
reopen_and_size_window(session, session->terminal_size.x, session->terminal_size.y,
session->scrollback, old_charw, old_charh);
session->window_needs_resized=false;
session=session->next;
}
}
 
if (save == false)
return finish_hotlist_editing(1);
 
/* if we're saving, save now */
if (save_choices() == false)
return false;
 
return finish_hotlist_editing(2);
}
 
void set_colour_icon(int colour_handle, colour_t colour, bool is_an_icon)
{
int icon_handle=-1;
char *validation;
 
if (is_an_icon)
{
icon_handle=colour_handle;
}
else
{
if (colour_handle>=0 && colour_handle<=7)
icon_handle=colour_handle;
 
if (colour_handle>=8 && colour_handle<=15)
icon_handle=colour_handle-8+icon_panecols_bold0;
}
 
if (icon_handle==-1)
{
char string[128];
 
sprintf(string,"Failed to set icon handle for set_colour_icon (colour_handle %d)",colour_handle);
generror(string,false);
return;
}
 
validation = get_icon_validation(win_panecols, icon_handle);
 
sprintf(validation, "R2;C/%06X", ((unsigned int) colour) >> 8);
 
set_icon_state (win_panecols, icon_handle, 0, 0);
}
 
static colour_t get_colour_icon(int colour_handle, bool is_an_icon)
{
int icon_handle=-1;
const char *validation;
colour_t colour;
 
if (is_an_icon)
{
icon_handle=colour_handle;
}
else
{
if (colour_handle>=0 && colour_handle<=7)
icon_handle=colour_handle;
 
if (colour_handle>=8 && colour_handle<=15)
icon_handle=colour_handle-8+icon_panecols_bold0;
}
 
if (icon_handle==-1)
{
generror("Failed to set icon handle for get_colour_icon",false);
return (colour_t) 0;
}
 
validation = get_icon_validation (win_panecols, icon_handle);
 
colour = strtoul(validation + 5, NULL, 16);
return (colour << 8);
}
 
 
/*************************************************** Gerph *********
Function: keypress_choices_window
Description: Process a key pressed in a window owned by the Choices
group
Parameters: window_handle = window pressed in
icon_handle = icon pressed in
key = wimp key number
Returns: true if handled, false if not handled
******************************************************************/
bool keypress_choices_window(int window_handle,int icon_handle,int key)
{
bool handled = false;
if (window_handle==win_paneterm)
{
switch (icon_handle)
{
case icon_paneterm_lineeditor:
if (key==13)
{
if (win_choices_read(false))
close_choices_window();
handled=true;
}
break;
}
 
/* Escape anywhere kills the window */
if (key==27)
{
close_choices_window();
handled=true;
}
}
else if (window_handle==win_panecols)
{
/* No writable icons in the colour window */
}
else if (window_handle==win_panehot)
{
/* No writable icons in the hotlist window */
}
else if (window_handle==win_panemisc)
{
/* No writable icons in the misc window */
}
 
 
return handled;
}
 
 
void win_choices_click (int x, int y, int buttons, int icon_handle)
{
close_window(win_hotedit);
 
switch (icon_handle)
{
case icon_choices_size:
if (win_is_open(win_panecols))
close_window(win_panecols);
 
if (win_is_open(win_panehot))
close_window(win_panehot);
 
if (win_is_open(win_panemisc))
close_window(win_panemisc);
 
set_icon_state(win_choices, icon_choices_size, WIMP_ICON_SELECTED_BIT, WIMP_ICON_SELECTED_BIT);
set_icon_state(win_choices, icon_choices_colour, 0, WIMP_ICON_SELECTED_BIT);
set_icon_state(win_choices, icon_choices_hotlist, 0, WIMP_ICON_SELECTED_BIT);
set_icon_state(win_choices, icon_choices_misc, 0, WIMP_ICON_SELECTED_BIT);
 
{
struct wimp_getwindowstate_block block;
 
block.window_handle=win_choices;
_swi(Wimp_GetWindowState, _IN(1), &block);
 
open_window((struct wimp_openwindow_block *) &block, win_choices);
}
 
break;
 
case icon_choices_colour:
if (win_is_open(win_paneterm))
close_window(win_paneterm);
 
if (win_is_open(win_panehot))
close_window(win_panehot);
 
if (win_is_open(win_panemisc))
close_window(win_panemisc);
 
set_icon_state(win_choices, icon_choices_size, 0, WIMP_ICON_SELECTED_BIT);
set_icon_state(win_choices, icon_choices_colour, WIMP_ICON_SELECTED_BIT, WIMP_ICON_SELECTED_BIT);
set_icon_state(win_choices, icon_choices_hotlist, 0, WIMP_ICON_SELECTED_BIT);
set_icon_state(win_choices, icon_choices_misc, 0, WIMP_ICON_SELECTED_BIT);
 
{
struct wimp_getwindowstate_block block;
 
block.window_handle=win_choices;
_swi(Wimp_GetWindowState, _IN(1), &block);
 
open_window((struct wimp_openwindow_block *) &block, win_choices);
}
 
break;
 
case icon_choices_hotlist:
if (win_is_open(win_paneterm))
close_window(win_paneterm);
 
if (win_is_open(win_panecols))
close_window(win_panecols);
 
if (win_is_open(win_panemisc))
close_window(win_panemisc);
 
set_icon_state(win_choices, icon_choices_size, 0, WIMP_ICON_SELECTED_BIT);
set_icon_state(win_choices, icon_choices_colour, 0, WIMP_ICON_SELECTED_BIT);
set_icon_state(win_choices, icon_choices_hotlist, WIMP_ICON_SELECTED_BIT, WIMP_ICON_SELECTED_BIT);
set_icon_state(win_choices, icon_choices_misc, 0, WIMP_ICON_SELECTED_BIT);
 
{
struct wimp_getwindowstate_block block;
 
block.window_handle=win_choices;
_swi(Wimp_GetWindowState, _IN(1), &block);
 
open_window((struct wimp_openwindow_block *) &block, win_choices);
}
 
break;
 
case icon_choices_misc:
if (win_is_open(win_paneterm))
close_window(win_paneterm);
 
if (win_is_open(win_panecols))
close_window(win_panecols);
 
if (win_is_open(win_panehot))
close_window(win_panehot);
 
set_icon_state(win_choices, icon_choices_size, 0, WIMP_ICON_SELECTED_BIT);
set_icon_state(win_choices, icon_choices_colour, 0, WIMP_ICON_SELECTED_BIT);
set_icon_state(win_choices, icon_choices_hotlist, 0, WIMP_ICON_SELECTED_BIT);
set_icon_state(win_choices, icon_choices_misc, WIMP_ICON_SELECTED_BIT, WIMP_ICON_SELECTED_BIT);
 
{
struct wimp_getwindowstate_block block;
 
block.window_handle=win_choices;
_swi(Wimp_GetWindowState, _IN(1), &block);
 
open_window((struct wimp_openwindow_block *) &block, win_choices);
}
 
break;
 
case icon_choices_save:
if (win_choices_read(true) && save_choices() && (buttons & 1) == 0)
close_choices_window();
break;
 
case icon_choices_cancel:
if ((buttons & 1) == 0)
close_choices_window();
else
open_choices_window();
 
finish_hotlist_editing(0);
break;
 
case icon_choices_set:
if (win_choices_read(false) && (buttons & 1) == 0)
close_choices_window();
break;
}
}
 
 
void win_paneterm_click(int x, int y, int buttons, int icon_handle)
{
switch (icon_handle)
{
case icon_paneterm_termtypebut:
create_terminal_type_menu(win_paneterm, icon_paneterm_termtype, icon_paneterm_termtypebut);
break;
 
case icon_paneterm_lineeditbut:
create_lineeditor_type_menu(win_paneterm, icon_paneterm_lineedittype, icon_paneterm_lineeditbut);
break;
 
case icon_paneterm_hifontbut:
case icon_paneterm_lofontbut:
if (create_zap_font_menu (win_paneterm, icon_handle))
{
menu_window = win_paneterm;
 
if (icon_handle==icon_paneterm_hifontbut)
menu_icon = icon_paneterm_hifont;
else
menu_icon = icon_paneterm_lofont;
 
menu_open = MENU_ZAPFONTLIST;
}
break;
}
}
 
 
void win_panecols_click(int x, int y, int buttons, int icon_handle)
{
/* Not terribly optimal */
if ((icon_handle>=icon_panecols_col0but && icon_handle<=icon_panecols_col7but) ||
(icon_handle>=icon_panecols_bold0but && icon_handle<=icon_panecols_bold7but))
{
/* open a ColourPicker window (as a menu) */
static char title[64];
struct colourpicker_block block;
struct wimp_geticonstate_block icon;
struct wimp_getwindowstate_block window;
 
strcpy(title, lookup_static("SelColour"));
 
window.window_handle = win_panecols;
icon.window_handle = win_panecols;
icon.icon_handle = icon_handle;
_swi (Wimp_GetWindowState, _IN(1), &window);
_swi (Wimp_GetIconState, _IN(1), &icon);
 
block.flags = 0;
block.title = title;
block.bl.x = window.min.x + icon.max.x;
block.bl.y = 0x80000000;
block.tr.x = 0x7FFFFFFF;
block.tr.y = window.max.y + icon.max.y;
block.zero1 = block.zero0 = 0;
block.colour = get_colour_icon(icon_handle-8, true);
block.extsize = block.exttype = 0;
colourpicker_handle = _swi (ColourPicker_OpenDialogue,
_INR(0,1) | _OUT(1), 1, &block, &menu_window);
 
menu_icon = icon_handle-8; /* icon_handle-8 may change */
menu_open = MENU_NONE;
}
 
if (icon_handle==icon_panecols_default)
{
int loop;
for (loop=15; loop>=0; loop--)
{
set_colour_icon (loop, default_palette[loop], false);
}
}
else if (icon_handle==icon_panecols_invertall)
{
int loop;
for (loop=15; loop>=0; loop--)
{
/* It's important to invert the colour in the icon here, NOT the palette[] value */
unsigned long colour = get_colour_icon(loop, false);
set_colour_icon (loop, colour^0xffffff00, false);
}
}
}
 
void win_panemisc_click(int x, int y, int buttons, int icon_handle)
{
switch (icon_handle)
{
case icon_panemisc_cursortypebut:
create_cursor_type_menu(win_panemisc, icon_panemisc_cursortype, icon_panemisc_cursortypebut);
break;
}
}
 
/vendor/v0.2023/p_rlogin.h
New file
0,0 → 1,24
/**
* Protocol RLogin specific support code
* (C) Nettle developers 2002
*
* $Id$
*/
 
#ifndef RLOGIN_H
#define RLOGIN_H
 
#include "protocols.h"
 
extern protocol_t protocol_rlogin;
 
/*************************************************** Gerph *********
Function: rlogin_connected
Description: Socket has now connected; we must send our initial
negotiation data to the remote.
Parameters: session-> the session we are connecting
Returns: none
******************************************************************/
void rlogin_connected(struct session_struct *session);
 
#endif
/vendor/v0.2023/choices.h
New file
0,0 → 1,34
/**
* Nettle Choices code
* by A. Macfarlane Smith
* (C) Archifishal Software 2001
*
* $Id: choices,v 1.6 2002/01/08 13:39:15 archifishal Exp $
*/
 
#ifndef CHOICES_H
#define CHOICES_H
 
extern void load_choices(void);
extern bool save_choices(void);
extern void close_choices_window(void);
extern void open_choices_window(void);
extern bool win_choices_read(int save);
extern void win_choices_click (int x, int y, int buttons, int icon_handle);
extern void win_paneterm_click(int x, int y, int buttons, int icon_handle);
extern void win_panecols_click(int x, int y, int buttons, int icon_handle);
extern void win_panemisc_click(int x, int y, int buttons, int icon_handle);
extern void set_colour_icon(int colour_handle, colour_t colour, bool is_an_icon);
 
/*************************************************** Gerph *********
Function: keypress_choices_window
Description: Process a key pressed in a window owned by the Choices
group
Parameters: window_handle = window pressed in
icon_handle = icon pressed in
key = wimp key number
Returns: true if handled, false if not handled
******************************************************************/
bool keypress_choices_window(int window_handle,int icon_handle,int key);
 
#endif /* CHOICES_H */
/vendor/v0.2023/zapgen.c
New file
0,0 → 1,860
/*
* Nettle zapgen code
* (C) Nettle developers 2000-2002
* $Id: zapgen,v 1.33 2002/02/02 21:36:48 ijeffray Exp $
*/
 
 
#include "generic.h"
#include "globals.h"
 
#include "chardefn.h"
#include "messages.h"
#include "misc.h"
#include "nettle.h"
#include "wimp.h"
#include "wimputil.h"
#include "zapredraw.h"
 
#define ZR_CTRL 0
 
#define ZR_CTRL_FGBGCOLS 1
#define ZR_CTRL_END 2
#define ZR_CTRL_EXTEND 3
#define ZR_CTRL_MERGE 4
#define ZR_CTRL_FGCOL 6
#define ZR_CTRL_BGCOL 7
#define ZR_CTRL_CURSORM 8
 
#define REDRAW_FLAGS_MASK (NETTLE_FLAG_INVERTED | NETTLE_FLAG_SELECTED)
 
/* These used to be functions, and were fine in gcc... */
/* ...but Norcroft doesn't do inlines in C!! :-( */
 
#define ZAP_WRITE_MULTIBYTE(write, chr) \
{ \
*write++ = ZR_CTRL; \
*write++ = ZR_CTRL_EXTEND; \
*write++ = (char) (chr); \
*write++ = (char) ((chr) >> 8); \
}
 
#define ZAP_WRITE_CHAR(write, input) \
{ \
if (input->flags & NETTLE_FLAG_PLUS100) \
{ \
/* ZAP_WRITE_MULTIBYTE, but we know that the */ \
/* top byte is 1, so we shortcut it */ \
*write++ = ZR_CTRL; \
*write++ = ZR_CTRL_EXTEND; \
*write++ = (char) (input->chr); \
*write++ = (char) (1); \
} \
else \
{ \
int c=input->chr; \
*write++ = c; \
if (c == ZR_CTRL) \
*write++ = 0; \
} \
}
 
static int *bitmaps_area=0;
static int bitmaps_area_number=0;
 
 
char * zapgen_code (int *output_buffer, struct term_char **input_line_offsets,
int width, int first_line, int last_line, int session_flags,
int selection_start_line, int selection_start_x,
int selection_end_line, int selection_end_x)
{
int *line_offsets = output_buffer;
char *write = (char *)(line_offsets + last_line + 1);
const struct term_char *input;
int line_number = 0;
bool selected = false;
const struct term_char *startoffset, *endoffset;
 
/* line_offsets -> list of offsets of lines (in the data block) */
/* write -> next location at which to place data in the output buffer */
 
if (first_line)
{
*write++ = ZR_CTRL;
*write++ = ZR_CTRL_END;
}
 
/* Why isn't this lot a tautology? */
if (selection_start_line > selection_end_line)
{
int tmp = selection_start_line;
selection_start_line = selection_end_line;
selection_end_line = tmp;
tmp = selection_start_x;
selection_start_x = selection_end_x;
selection_end_x = tmp;
}
else if (selection_start_line == selection_end_line)
{
if (selection_start_x > selection_end_x)
{
int tmp = selection_start_x;
selection_start_x = selection_end_x;
selection_end_x = tmp;
}
else if (selection_start_x == selection_end_x)
{
selection_start_x = selection_end_x = -1;
}
}
/* End tautological moan */
 
if (selection_start_line < first_line && selection_end_line >= first_line)
selected = true;
 
startoffset = input_line_offsets[selection_start_line]+selection_start_x;
endoffset = input_line_offsets[selection_end_line]+selection_end_x;
 
for (; line_number < last_line; line_number++)
{
int loop = width;
int current_fg = redraw.r_for;
int current_bg = redraw.r_bac;
 
input=input_line_offsets[line_number];
 
if (line_number < first_line)
{
/* if not in the window, mark the line as blank and move on */
/* (this is done by pointing the line at the previous EOL marker) */
*line_offsets++ = write - 2 - (char *) output_buffer;
continue;
}
 
*line_offsets++ = write - ((char *) output_buffer);
 
for (; loop; --loop)
{
register char colour_type;
int fg = input->fg;
int bg = input->bg;
bool invert=false;
 
/* swap foreground and background if inverted or selected or inverse video etc. */
if (input->flags & NETTLE_FLAG_INVERTED)
invert=NOT(invert);
 
if (input == startoffset || input == endoffset)
selected=NOT(selected);
 
if (selected)
invert=NOT(invert);
 
if ((session_flags & NETTLE_OTHER_REVERSE_VIDEO))
invert=NOT(invert);
 
if ((session_flags & NETTLE_OTHER_VISUAL_BELL))
invert=NOT(invert);
 
if (invert)
{
fg ^= bg;
bg ^= fg;
fg ^= bg;
}
 
if ((input->flags & NETTLE_FLAG_BLINK) &&
(session_flags & NETTLE_OTHER_BLINK_HIDE))
fg = bg;
 
if (fg != current_fg || bg != current_bg)
{
*write++ = ZR_CTRL;
colour_type = (fg == current_fg) ? ZR_CTRL_BGCOL /* bg only if fg unchanged */
: (bg == current_bg) ? ZR_CTRL_FGCOL /* fg only if bg unchanged */
: ZR_CTRL_FGBGCOLS; /* both if neither unchanged */
*write++ = colour_type;
 
if (colour_type != ZR_CTRL_BGCOL)
*write++ = fg;
 
if (colour_type != ZR_CTRL_FGCOL)
*write++ = bg;
 
/* save the current settings */
current_fg = fg;
current_bg = bg;
}
 
if (input->flags & NETTLE_FLAG_CURSOR)
{
/* drawing the cursor... */
int blink;
if (cursor_blink)
blink = (cursor_state || input->flags & NETTLE_FLAG_NO_INPUT) ? bg : fg;
else
blink = bg;
 
*write++ = ZR_CTRL;
*write++ = ZR_CTRL_MERGE; /* character merge */
*write++ = blink; /* foreground colour */
*write++ = ((blink & 2) ? 0 : 7) | (8 & ~blink);
/* contrasting background, inverted bright */
ZAP_WRITE_CHAR(write, input);
 
if (input->flags & NETTLE_FLAG_NO_INPUT)
{
ZAP_WRITE_MULTIBYTE(write, 0x101); /* square/hatched cursor */
}
else
{
ZAP_WRITE_MULTIBYTE(write, 0x100); /* block/underline cursor */
}
}
else
{
if (input->flags & NETTLE_FLAG_UNDERLINE)
{
*write++ = ZR_CTRL;
*write++ = ZR_CTRL_MERGE; /* character merge */
*write++ = fg; /* foreground colour */
*write++ = fg; /* background colour */
ZAP_WRITE_CHAR(write, input);
ZAP_WRITE_MULTIBYTE(write, 0x11D); /* The underline itself! */
}
else
{
ZAP_WRITE_CHAR(write, input);
}
}
 
input++;
}
 
*write++ = ZR_CTRL;
*write++ = ZR_CTRL_END; /* end of line marker */
}
*line_offsets = 0;
 
return write; /* return ptr to the first unused byte */
}
 
 
void allocate_zapredraw_area(int terminal_size_x, int terminal_size_y, int scrollback)
{
int size_of_row_pointers = ( terminal_size_y+scrollback+1 ) * 4;
int size_of_one_char = 4 /* A colour change */
+ 4 /* Multibyte char */
+ 5+3; /* Underline (merge+multibyte)*/
int size_of_body = ( terminal_size_x*(terminal_size_y+1) ) * size_of_one_char;
int size_of_eols = ( terminal_size_y+1 )*2;
int size_of_cursor = 8; /* 4bytes mb cursor, 4 bytes control */
 
int calculate_new_size = size_of_row_pointers + size_of_body + size_of_eols + size_of_cursor;
 
if (size_of_zapredraw_area < calculate_new_size)
{
int *new_zapredraw_area;
 
size_of_zapredraw_area = calculate_new_size;
 
if (dynamic_areas_available())
{
if (zapredraw_area_number==0)
{
char string[]="Nettle ZapRedraw area";
 
/* Note maximum size is -1 since potentially could be any size */
_swi(OS_DynamicArea, _INR(0,8)|_OUT(1)|_OUT(3), 0, -1, size_of_zapredraw_area,
-1, 0x80, -1, 0, -1, string, &zapredraw_area_number,
&new_zapredraw_area);
 
assert(new_zapredraw_area != NULL);
zapredraw_area = new_zapredraw_area;
}
else
{
int current_size;
 
_swi(OS_DynamicArea, _INR(0,1)|_OUT(2), 2, zapredraw_area_number, &current_size);
 
if (size_of_zapredraw_area-current_size!=0)
{
_swi(OS_ChangeDynamicArea, _INR(0,1), zapredraw_area_number, size_of_zapredraw_area-current_size);
}
}
}
else
{
new_zapredraw_area = realloc(zapredraw_area, size_of_zapredraw_area);
assert(new_zapredraw_area != NULL);
zapredraw_area = new_zapredraw_area;
}
}
}
 
 
void lose_zapredraw_area(void)
{
if (dynamic_areas_available())
{
if (zapredraw_area_number!=0)
{
_swi(OS_DynamicArea, _INR(0,1), 1, zapredraw_area_number);
}
}
else
{
free(zapredraw_area);
}
}
 
 
/*
* Description: Update the cursors in a given font_area
* Parameters: font_area-> the area, as returned from load_font
* Returns: none
* Note: Will also update all the other special characters;
* this is not intentional and should be replaced with
* /just/ the cursors being updated.
*/
void update_cursors(int *font_area)
{
int width = font_area[2];
int height = font_area[3];
int char_size = ((width+ 7) & ~7)*height/8;
 
/* fill in graphics chars */
define_zap_chars(font_area+8, char_size, width, height);
}
 
 
int *load_font(char *font)
{
char string[5]="ZFLK";
int *zap_load_area = 0;
int width;
int height;
int last_char;
int first_char;
int char_size;
FILE *file_handle=0;
char file_end[256];
char file_start[256];
char file_name[1024];
int object_type;
 
get_system_variable(file_name,"ZapFonts$Path",sizeof(file_name));
if (strlen(file_name)!=0)
{
strcpy(file_start,"ZapFonts:");
}
else
{
strcpy(file_start,"<NettleSSH$Dir>.Fonts.");
}
 
strcpy(file_end, font);
 
/* if string is ZFLK, then this is a redirection font */
while (strcmp(string,"ZFLK")==0)
{
sprintf(file_name,"%s%s",file_start,file_end);
 
/* if it's there, what sort of object is it */
if (_swix(OS_File, _INR(0,1)|_OUT(0), 17, file_name, &object_type)==0)
{
if (object_type == 0)
{
strcpy(string,"");
}
else if (object_type == 2)
{
/* If it's a directory, plonk .0 on the end */
strcat(file_end,".0");
strcat(file_name,".0");
 
/* and pretend it's a file */
object_type = 1;
}
 
if (object_type == 1)
{
file_handle=fopen(file_name,"rb");
 
if (file_handle != NULL)
{
fread(&string[0],1,5,file_handle);
string[4]='\0';
 
/* if it's redirection then */
if (strcmp(string,"ZFLK")==0)
{
size_t chrs;
 
/* get the redirection font */
chrs = fread(&file_end[0], 1, sizeof(file_end)-1, file_handle);
file_end[chrs]='\0';
 
fclose(file_handle);
}
}
}
}
else
{
strcpy(string,"");
}
}
 
if (file_handle==0)
{
/* if we didn't find a font, use Nettle's internal ones */
/* (This may not be necessary if it uses <Nettle$Dir>.Fonts from above, but leave it for */
/* now) */
 
if (eig.y >1)
strcpy(file_name,"<NettleSSH$Dir>.Fonts.08x08.0");
else
strcpy(file_name,"<NettleSSH$Dir>.Fonts.08x16.0");
file_handle=fopen(file_name,"rb");
}
 
assert(file_handle);
 
fseek(file_handle,8,SEEK_SET);
 
/* Get font information */
fread((char *) &width, 1, 4, file_handle);
fread((char *) &height, 1, 4, file_handle);
fread((char *) &first_char, 1, 4, file_handle);
fread((char *) &last_char, 1, 4, file_handle);
 
/* Set real character size (will be needed to implement graphics characters) */
char_size=((width+ 7) & ~7)*height/8;
 
if (first_char > 256)
first_char = 256;
if (last_char > 256)
last_char = 256;
 
if (first_char != last_char)
{
zap_load_area=malloc(char_size*(0x100+EXTRA_ZAP_CHARS)+0x20);
assert(zap_load_area != NULL);
memset (zap_load_area, 0, char_size*(0x100+EXTRA_ZAP_CHARS) + 0x20);
fseek(file_handle,0,SEEK_SET);
fread ((char *) zap_load_area, 1, 0x20, file_handle);
fread ((char *) zap_load_area + 0x20 + first_char * char_size,
1, (last_char - first_char) * char_size, file_handle);
}
 
if (ferror (file_handle) || first_char == last_char)
{
/* Eek! Fall back on system font... */
width = 8;
char_size = height = (eig.y > 1) ? 8 : 16;
zap_load_area = realloc (zap_load_area, char_size * (0x100+EXTRA_ZAP_CHARS) + 0x20);
assert(zap_load_area);
zap_load_area[2] = width;
zap_load_area[3] = height;
zap_load_area[4] = first_char = 32;
zap_load_area[5] = last_char = 32;
}
 
fclose(file_handle);
 
/* fill in graphics chars */
define_zap_chars(zap_load_area+8, char_size, width, height);
 
/* fill in some undefined characters in range 0x00-0xFF*/
define_zap_undef_chars (zap_load_area+8, first_char, last_char,
char_size, width, height);
 
zap_load_area[4]=0;
zap_load_area[5]=0x100+EXTRA_ZAP_CHARS;
 
return zap_load_area;
}
 
 
/***************************
* Zap fonts menu creation *
***************************/
 
static int zapfont_depth = 0; /* Nesting level */
static int *zapfont_menu[8] = {0}; /* Menu data */
static char *zapfont_menu_entries[8] = {0}; /* Menu data */
 
static char font_path[512];
static int font_path_base;
 
 
bool
read_zap_font_selection (const int *selection, char *string, int length)
{
/* returns true if the object is a file or contains a file named "0" */
int loop = 0;
int sum = 0;
int type;
int reason;
 
*string = 0;
for (;;)
{
const char *item = (char *) zapfont_menu[loop][7+3+6*selection[loop]];
sum += strlen (item) + (sum > 0);
if (sum >= length - 2)
break; /* silently truncate */
 
strcat (string, item);
if (selection[++loop] == -1)
break;
 
strcat (string, "."); /* more to do... */
}
 
if (string != font_path + font_path_base)
{
font_path[font_path_base] = '\0';
reason = 13;
}
else
{
string = font_path;
reason = 17;
}
 
/* Return true if the extracted name points to a file */
if (_swix (OS_File, _INR(0,1) | _IN(4) | _OUT(0),
reason, string, font_path, &type))
return false;
 
if (type == 1)
return true;
 
/* Append ".0" and return true if it points to a file; else return false */
strcat (string, ".0");
if (_swix (OS_File, _INR(0,1) | _IN(4) | _OUT(0),
reason, string, font_path, &type))
type = 0;
 
string[strlen (string) - 2] = '\0';
return (type == 1) ? true : false;
}
 
 
static int
menu_strcoll (const void *s1, const void *s2)
{
return strcoll (*((const char **)s1 + 3), *((const char **)s2 + 3));
}
 
 
static bool
create_zap_font_menu_internal (int **menu_block_p, char **menu_entries_p,
bool root_menu)
{
int *menu_block = 0;
char *menu_entries;
int allocated = 1024;
int items = 0;
int entry_offset = 0;
int dir_offset = 0;
 
/* Hit the maximum menu depth? */
if (zapfont_depth == 8)
return false;
 
menu_entries = malloc (allocated);
if (!menu_entries)
return false;
 
/* Build the menu... */
do
{
struct
{
int load, exec, length, attr, object_type;
char name[256];
} dir_entry;
int count;
_kernel_oserror *error;
 
error = _swix (OS_GBPB, _INR(0,6) | _OUTR(3,4),
10, font_path, &dir_entry, 1, dir_offset, sizeof (dir_entry), 0,
&count, &dir_offset);
if (error)
{
generror (error->errmess, false);
goto done;
}
 
/* if we have an object and it's a directory (root menu) or a directory
* or a file (submenu), process it */
if (count && (dir_entry.object_type & (root_menu ? 2 : 3)))
{
/* got a directory entry - buffer it */
if (strcmp("CVS", dir_entry.name) != 0)
{
if ( (entry_offset + strlen (dir_entry.name) + 2) >= allocated)
{
menu_entries = realloc (menu_entries, allocated += 1024);
if (!menu_entries)
goto done;
}
menu_entries[entry_offset++] = (char) dir_entry.object_type;
strcpy (menu_entries + entry_offset, dir_entry.name);
entry_offset += strlen (menu_entries + entry_offset) + 1;
items++;
}
}
} while (dir_offset != -1);
 
if (items)
{
/* we know how much memory we need - now build the menu */
int index_loop = 7;
int loop;
 
/* free up a small amount of memory */
menu_entries = realloc (menu_entries, entry_offset);
if (!menu_entries)
goto done;
 
/* claim space for the menu */
menu_block = malloc (28 + 24 * items);
if (!menu_block)
goto done;
 
/* set up the menu header */
if (root_menu)
{
lookup ("MenuFont", (char *) menu_block, 12);
}
else
{
/* use the leafname as the title */
char *dot = strrchr (font_path, '.');
if (!dot)
dot = strrchr (font_path, ':');
strcpy ((char *) menu_block, dot + 1);
}
menu_block[3] = 0x70207; /* standard menu colours */
menu_block[4] = 0;
menu_block[5] = 44;
menu_block[6] = 0;
 
/* now add the menu items */
entry_offset = 0;
for (loop = 0; loop < items; ++loop)
{
int length = strlen (menu_entries + entry_offset + 1);
 
if (menu_entries[entry_offset++] & 2)
{
menu_block[index_loop++] = 8; /* menu warn bit */
menu_block[index_loop++] = MENU_ZAPFONTLIST;
}
else
{
menu_block[index_loop++] = 0;
menu_block[index_loop++] = -1;
}
 
menu_block[index_loop++] = WIMP_ICON_FGCOL(7) | WIMP_ICON_VCENT_BIT |
WIMP_ICON_FILLED_BIT | WIMP_ICON_TEXT_BIT |
WIMP_ICON_INDIRECTED_BIT;
menu_block[index_loop++] = (int) (menu_entries + entry_offset);
menu_block[index_loop++] = (int) (menu_entries + entry_offset + length);
menu_block[index_loop++] = length + 1;
entry_offset += length + 1;
}
 
/* sort the entries (in case the list was read from, e.g., NFS) */
qsort (menu_block + 7, (index_loop - 7) / 6, 6 * sizeof (int), menu_strcoll);
 
menu_block[index_loop - 6] |= 128; /* last entry */
 
/* done: return the pointers */
*menu_block_p = menu_block;
*menu_entries_p = menu_entries;
 
return true;
}
 
/* Error or no menu entries */
done:
free (menu_block);
free (menu_entries);
return false;
}
 
 
bool create_zap_font_menu(int window_handle, int icon_handle)
{
get_system_variable(font_path, "ZapFonts$Path", sizeof (font_path));
strcpy(font_path, *font_path ? "ZapFonts:" : "NettleFonts:");
font_path_base = strlen (font_path);
 
if(create_zap_font_menu_internal (zapfont_menu, zapfont_menu_entries, true))
{
zapfont_depth = 1;
create_menu_by_icon (zapfont_menu[0], window_handle, icon_handle);
return true;
}
return false;
}
 
 
void create_zap_font_submenu (const int *selection, struct coords open_at)
{
int loop;
 
/* get the directory path (from the menu) */
if (font_path[font_path_base - 1] == ' ')
font_path[font_path_base - 1] = '.';
read_zap_font_selection (selection, font_path + font_path_base,
sizeof (font_path) - font_path_base);
 
loop = 0;
while (selection[loop] != -1)
loop++;
 
zapfont_depth = loop;
while (loop < 8)
{
free (zapfont_menu[loop]);
free (zapfont_menu_entries[loop]);
zapfont_menu[loop] = 0;
zapfont_menu_entries[loop] = 0;
loop++;
}
 
if (create_zap_font_menu_internal (zapfont_menu + zapfont_depth,
zapfont_menu_entries + zapfont_depth,
false))
{
_swi(Wimp_CreateSubMenu, _INR(1,3), zapfont_menu[zapfont_depth++],
open_at.x, open_at.y);
}
}
 
 
void reopen_zap_font_menu (void)
{
_swi (Wimp_CreateMenu, _INR(1,3), zapfont_menu[0], 0, 0);
}
 
 
void delete_zap_font_menu (void)
{
int loop;
/* make sure that we've freed any memory that we may have allocated */
for (loop = 7; loop >= 0; loop--)
{
free (zapfont_menu[loop]);
free (zapfont_menu_entries[loop]);
zapfont_menu[loop] = 0;
zapfont_menu_entries[loop] = 0;
}
zapfont_depth = 0;
}
 
void recache_bitmaps(void)
{
int *zap_font_used;
int mem_required;
int a;
int b;
 
/* work out which font we should be using */
zap_font_used = (eig.y == 1) ? zap_font_area : zap_lowres_font_area;
 
_swi(ZapRedraw_ReadVduVars, _IN(1), &redraw);
 
mem_required=((zap_font_used[2]+7) & ~7)*zap_font_used[3]*(zap_font_used[5]-zap_font_used[4]);
 
switch (redraw.r_bpp)
{
case 0:mem_required/=8;break;
case 1:mem_required/=4;break;
case 2:mem_required/=2;break;
case 4:mem_required*=2;break;
case 5:mem_required*=4;break;
}
 
/* Reallocate the bitmaps area */
if (dynamic_areas_available())
{
if (bitmaps_area_number==0)
{
const char string[]="Nettle bitmaps area";
 
/* Currently, in a 32bpp mode, with the biggest available ZapFont (14x12.Luc)
we can use up to 444K of space, so we set a 1MB max area size here. If we
don't, then the OS_ChangeDynamicArea below will die and we will all be upset */
 
_swi(OS_DynamicArea, _INR(0,8)|_OUT(1)|_OUT(3), 0, -1, mem_required, -1, 0x80,
1024*1024 /* allow room for loading bigger fonts later */,
0, -1, string, &bitmaps_area_number, &bitmaps_area);
}
else
{
int current_size;
 
_swi(OS_DynamicArea, _INR(0,1)|_OUT(2), 2, bitmaps_area_number, &current_size);
 
if (mem_required-current_size!=0)
{
_swi(OS_ChangeDynamicArea, _INR(0,1), bitmaps_area_number, mem_required-current_size);
}
}
}
else
{
int *tmp=(int *) realloc(bitmaps_area, mem_required);
if (tmp)
bitmaps_area=tmp;
else
assert(0); /* Duh. Panic! */
}
 
redraw.r_flags=0;
redraw.r_charw=zap_font_used[2];
redraw.r_charh=zap_font_used[3];
redraw.r_caddr=bitmaps_area;
 
_swi(ZapRedraw_CachedCharSize, _INR(0,3)|_OUTR(2,3),
redraw.r_bpp, 0, redraw.r_charw, redraw.r_charh, &a, &b);
 
redraw.r_cbpl=a;
redraw.r_cbpc=b;
redraw.r_linesp=0;
 
_swi(ZapRedraw_ConvertBitmap, _INR(1,4), &redraw, 0, 0x100+EXTRA_ZAP_CHARS,
((char *) zap_font_used)+32);
 
redraw.r_palette=zap_palette;
 
_swi(ZapRedraw_CreatePalette, _INR(0,4), 2, &redraw, palette, zap_palette, 16);
 
redraw.r_for=7;
redraw.r_bac=0;
}
 
 
void lose_bitmaps(void)
{
if (dynamic_areas_available())
{
if (bitmaps_area_number!=0)
{
_swi(OS_DynamicArea, _INR(0,1), 1, bitmaps_area_number);
}
}
else
{
free(bitmaps_area);
}
}
/vendor/v0.2023/timers.c
New file
0,0 → 1,275
/**
* Session-specific timer handling
* (C) Nettle developers 2002
*
* $Id$
*/
 
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "swis.h"
#include "timers.h"
 
typedef struct timer_s timer_t;
 
struct timer_s {
timer_t *next; /* pointer to next timer*/
unsigned long time; /* monotonic time for this timer */
timer_f func; /* pointer to function to process this timer */
void *private; /* private value to pass to function */
struct session_struct *session;
/* session which this applies to */
int delay; /* delay between triggers, or 0 for no retrigger */
};
 
static timer_t *list=NULL;
 
/*************************************************** Gerph *********
Function: timer_init
Description: Initialise the timer module, setting up variables and
other such rubbish
Parameters: none
Returns: none
******************************************************************/
void timer_init(void)
{
list = NULL;
}
 
/*************************************************** Gerph *********
Function: timer_add
Description: Add a session timer (similar to CallAfter or
AddCallBack)
Parameters: session-> the session we're acting upon
delay = delay until timer should go off in cs
private = some private value to pass to the
function
func = function pointer to be triggered when time
is reached
retrigger = 1 if the event should be retriggered
Returns: none
******************************************************************/
void timer_add(const struct session_struct *session, int delay, void *private,
timer_f func, int retrigger)
{
unsigned long time;
unsigned long now;
timer_t *timer = malloc(sizeof(timer_t));
 
/* If we couldn't allocate space, we're screwed */
assert(timer != NULL);
 
/* If they asked for no delay (ie OS_AddCallBack equivilent) and to
retrigger, we would be sitting calling that routine forever, so
disallow it */
assert(delay != 0 || retrigger == 0);
 
now = _swi(OS_ReadMonotonicTime,_RETURN(0));
 
/* Create the timer structure */
timer->session = (struct session_struct *)session;
timer->time = time = now + delay;
timer->private = private;
timer->delay = retrigger ? delay : 0;
timer->func = func;
 
/* Now link us in to the chain, in the right place */
{
timer_t **lastp=&list;
timer_t *this=list;
while (this && this->time < time)
{
lastp=&this->next;
this=this->next;
}
 
/* We're found our insertion point, between the lastp and this */
timer->next = this;
*lastp = timer;
}
}
 
/*************************************************** Gerph *********
Function: timer_remove
Description: Remove a timer from the queue
Parameters: session-> the session we're acting upon
private = some private value to pass to the
function
func = function pointer to be triggered when time
is reached
retrigger = 1 if the event should be retriggered
Returns: none
Note: All timers which match these characteristics will be
removed.
******************************************************************/
void timer_remove(const struct session_struct *session, void *private,
timer_f func)
{
timer_t **lastp=&list;
timer_t *this=list;
while (this)
{
void *next = this->next;
if (this->session == session &&
this->private == private &&
this->func == func)
{
*lastp=next;
free(this);
}
else
lastp=&this->next;
this=next;
}
}
 
/*************************************************** Gerph *********
Function: timer_removesession
Description: Remove all timer for a session from the queue
Parameters: session-> the session we're acting upon
Returns: none
Note: No workspace will be freed based on the private word -
Users of the timer library should ensure that they
use timer_remove to remove timers themselves.
timer_removesession is really just a catch all to
prevent timers going off for defunct sessions.
******************************************************************/
void timer_removesession(const struct session_struct *session)
{
timer_t **lastp=&list;
timer_t *this=list;
while (this)
{
void *next = this->next;
if (this->session == session)
{
*lastp=next;
free(this);
}
else
lastp=&this->next;
this=next;
}
}
 
/*************************************************** Gerph *********
Function: timer_nextevent
Description: Read the monotonic time of the next event in the queue
Parameters: none
Returns: time of next event, or &FFFFFFFF if no others
******************************************************************/
unsigned long timer_nextevent(void)
{
return list ? list->time : 0xffffffff;
}
 
/*************************************************** Gerph *********
Function: timer_poll
Description: Poll for any timer routines which need to go off
Parameters: none
Returns: none
******************************************************************/
void timer_poll(void)
{
unsigned long now;
 
/* Because this is an ordered list, we only ever need look at the head */
while (list)
{
timer_t *timer = list;
 
int overdue;
void *private;
struct session_struct *session;
timer_f func;
 
/* Read the current time, because we may have spent a while in the
previous timer routine */
now = _swi(OS_ReadMonotonicTime,_RETURN(0));
 
if (now <= timer->time)
return; /* Done - no more to do */
 
/* Remember details - we may free them in a moment */
func = timer->func;
session = timer->session;
private = timer->private;
overdue = now - timer->time;
 
if (timer->delay == 0)
{
/* no retrigger, so we unlink and free this block right now */
list = timer->next;
free(timer);
}
else
{
/* We are retriggering; we need to move this block */
unsigned long time;
 
list = timer->next;
 
/* JRF: Consider the implications of :
timer->time = time = timer->time + delay
(would cause very long delays to have multiple retriggers
immediately after the delay was removed, possibly locking
the machine for longer... might not be desirable... needs
thought)
*/
timer->time = time = now + timer->delay;
 
/* NOTE: same code as in timer_add; easier to inline than to make
a function */
/* Now link us in to the chain, in the right place */
{
timer_t **lastp=&list;
timer_t *this=list;
while (this && this->time < time)
{
lastp=&this->next;
this=this->next;
}
 
/* We're found our insertion point, between the lastp and this */
timer->next = this;
*lastp = timer;
}
}
 
/* Call the timer callback routine */
func((void *)session,private,overdue);
}
}
 
/*************************************************** Gerph *********
Function: timer_showall
Description: Display all timers to the file specified
Parameters: f-> the file to write to
Returns: none
******************************************************************/
void timer_showall(FILE *f)
{
timer_t *this=list;
 
fprintf(f," Time now : %08x\n",_swi(OS_ReadMonotonicTime,_RETURN(0)));
fprintf(f,"Next event : %08lx\n",timer_nextevent());
fprintf(f,"\n");
fprintf(f,"%8s %8s %8s %8s %8s\n",
"Time",
"Session",
"Delay",
"Private",
"Function");
while (this)
{
fprintf(f,"%08lx %8p %8i %8p %8p\n",
this->time,
this->session,
this->delay,
this->private,
this->func);
this=this->next;
}
 
}
/vendor/v0.2023/graphics.h
New file
0,0 → 1,29
/**
* Nettle graphics table
*
* $Id: graphics,v 1.3 2001/08/05 10:06:16 archifishal Exp $
*/
 
/* Graphics character lookup table mappings */
 
int dec_graphics_table[257]=
{0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,
0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,
0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F,
0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F,
0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F,
0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x5B,0x5C,0x5D,0x5E,
 
0x20,0x102,0x103,0x104,0x105,0x106,0x107,0xB0,0xB1,0x108,0x109,0x10A,0x10B,0x10C,0x10D,
0x10E,0x10F,0x110,0x111,0x112,0x113,0x114,0x115,0x116,0x117,0x118,0x119,0x11A,0x11B,
0x11C,0xA3,0xB7,
 
0x7F,
0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,
0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F,
0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,
0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF,
0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,
0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF,
0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,
0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF};
/vendor/v0.2023/timers.h
New file
0,0 → 1,142
/**
* Session-specific timer handling
* (C) Nettle developers 2002
*
* $Id$
*/
 
#ifndef TIMERS_H
#define TIMERS_H
 
/*
Generic recurrent timer routines for Nettle
 
These routines are intended to provide a very simple interface to
replace the 'hack and slash' that was necessary to trigger an action
in a delayed manner.
 
Requirements are thus :
 
- Protocols may trigger delayed events. They must have a mechanism to
do so.
- Scripts, when they arrive, may require a mechanism to deliver events
on a timed basis.
- Timers must be controlled and must not exert an undue overhead on
the core system.
- Timers will be tied to sessions; there will be no such thing as a
global timer.
- Timers may be 'one shot' or 'retriggering'.
- Retriggering timers use the same delay as they did originally, from
the time they were triggered.
- Timers should be addable from within a timer triggered routine.
- Timers will always be triggered at a 'safe' point - eg a null
poll to remove reentrancy issues.
 
Implementation is thus :
 
- The timer_t structure holds details about a single timed event.
- The 'list' contains a sorted list (sorted by time in ascending order)
which contains the timers presently registered.
- timer_init will be called initially to set up the timer subsystem
and to deal with any workspace it requires
- timer_add will be called by routines wishing to register a timer
with the subsystem.
- timer_poll will be called to trigger timed events. This should be
done at a safe point, such as a null wimp poll.
- timer_nextevent will return the Monotonic time value of the next
event in its queue, for use by PollIdle.
- timer_remove will be called by routines wishing to deregister a
timer.
- timer_removesession will be called to destroy all timers associated
with a session.
- a timer handler has the following prototype :
void func(struct session_struct *session, void *private, int late)
session-> the session for which the timer has been triggered
private = the private value passed when registered
late = the number of cs late that the call is
*/
 
struct session_struct;
 
typedef void (*timer_f)(struct session_struct *, void *, int);
 
/*************************************************** Gerph *********
Function: timer_init
Description: Initialise the timer module, setting up variables and
other such rubbish
Parameters: none
Returns: none
******************************************************************/
void timer_init(void);
 
/*************************************************** Gerph *********
Function: timer_add
Description: Add a session timer (similar to CallAfter or
AddCallBack)
Parameters: session-> the session we're acting upon
delay = delay until timer should go off in cs
private = some private value to pass to the
function
func = function pointer to be triggered when time
is reached
retrigger = 1 if the event should be retriggered
Returns: none
******************************************************************/
void timer_add(const struct session_struct *session, int delay, void *private,
timer_f func, int retrigger);
 
/*************************************************** Gerph *********
Function: timer_remove
Description: Remove a timer from the queue
Parameters: session-> the session we're acting upon
private = some private value to pass to the
function
func = function pointer to be triggered when time
is reached
retrigger = 1 if the event should be retriggered
Returns: none
Note: All timers which match these characteristics will be
removed.
******************************************************************/
void timer_remove(const struct session_struct *session, void *private,
timer_f func);
 
/*************************************************** Gerph *********
Function: timer_removesession
Description: Remove all timer for a session from the queue
Parameters: session-> the session we're acting upon
Returns: none
Note: No workspace will be freed based on the private word -
Users of the timer library should ensure that they
use timer_remove to remove timers themselves.
timer_removesession is really just a catch all to
prevent timers going off for defunct sessions.
******************************************************************/
void timer_removesession(const struct session_struct *session);
 
/*************************************************** Gerph *********
Function: timer_nextevent
Description: Read the monotonic time of the next event in the queue
Parameters: none
Returns: time of next event, or &FFFFFFFF if no others
******************************************************************/
unsigned long timer_nextevent(void);
 
/*************************************************** Gerph *********
Function: timer_poll
Description: Poll for any timer routines which need to go off
Parameters: none
Returns: none
******************************************************************/
void timer_poll(void);
 
/*************************************************** Gerph *********
Function: timer_showall
Description: Display all timers to the file specified
Parameters: f-> the file to write to
Returns: none
******************************************************************/
void timer_showall(FILE *f);
 
#endif
 
/vendor/v0.2023/processesc.c
New file
0,0 → 1,397
/**
* Processing code -- ESC sequences
* (C) Nettle developers 2000-2002
*
* $Id: processesc,v 1.1 2002/02/01 23:49:22 ijeffray Exp $
*/
 
#include <stddef.h>
 
#include "generic.h"
#include "globals.h"
 
#include "process.h"
 
extern bool process_escape_length_x(struct session_struct *session);
bool process_escape_length_3(struct session_struct *session);
bool process_escape_length_2(struct session_struct *session);
 
bool process_escape(struct session_struct *session)
{
bool done=false;
 
switch (session->escape_string_length)
{
case 0:
case 1:
done=false;
break;
case 2:
done=process_escape_length_2(session);
break;
case 3:
done=process_escape_length_3(session);
default:
if (!done)
{
done=process_escape_length_x(session);
}
break;
}
 
if (done)
{
/*printf("Processed escape sequence: ");
{
int loop;
 
for (loop=0; loop<session->escape_string_length; loop++)
printf("%c",session->escape_string[loop]);
 
printf("\n");
}*/
 
session->escape_string_length=0;
session->escape_state=NETTLE_ESCAPE_NONE;
}
 
return done;
}
 
 
bool process_escape_length_2(struct session_struct *session)
{
bool done=false;
 
switch (session->escape_string[0])
{
case 27:
switch (session->escape_string[1])
{
case '=':
/* Selects application keypad mode */
session->other_session_flags |= NETTLE_OTHER_APPLI_MODE;
done=true;
break;
case '>':
/* Selects numeric keypad mode */
session->other_session_flags &= ~NETTLE_OTHER_APPLI_MODE;
done=true;
break;
case '<':
/* Enter ANSI mode */
if (session->other_session_flags & NETTLE_OTHER_VT52_MODE)
{
session->other_session_flags &= ~NETTLE_OTHER_VT52_MODE;
done=true;
}
break;
case '\\':
/* End Device Control String (no effect here - this is to allow for variants of */
/* title bar content changing) */
done=true;
break;
case '7':
/* Save cursor position */
if (!(session->other_session_flags & NETTLE_OTHER_VT52_MODE))
{
save_cursor_position (session);
done=true;
}
break;
case '8':
/* Restore cursor position */
if (!(session->other_session_flags & NETTLE_OTHER_VT52_MODE))
{
restore_cursor_position (session);
done=true;
}
break;
case 'A':
/* Cursor up (in VT52 mode) */
if (session->other_session_flags & NETTLE_OTHER_VT52_MODE)
{
if (session->pos.y>session->scrollback)
session->pos.y--;
 
done=true;
}
break;
case 'B':
/* Cursor down (in VT52 mode) */
if (session->other_session_flags & NETTLE_OTHER_VT52_MODE)
{
if (session->pos.y<session->terminal_size.y+session->scrollback-1)
session->pos.y++;
 
done=true;
}
break;
case 'C':
/* Cursor right (in VT52 mode) */
if (session->other_session_flags & NETTLE_OTHER_VT52_MODE)
{
if (session->pos.x<session->terminal_size.x-1)
session->pos.x++;
 
done=true;
}
break;
case 'D':
if (session->other_session_flags & NETTLE_OTHER_VT52_MODE)
{
/* Move cursor left (in VT52 mode) */
if (session->pos.x>0)
session->pos.x--;
}
else
{
/* Moves cursor down one line (in non-VT52 mode) */
session->pos.y++;
reprocess_position_scroll(session);
}
done=true;
break;
case 'E':
if (!(session->other_session_flags & NETTLE_OTHER_VT52_MODE))
{
/* Carriage return and line feed */
session->pos.y++;
session->pos.x=0;
reprocess_position(session);
done=true;
}
break;
case 'F':
if (session->other_session_flags & NETTLE_OTHER_VT52_MODE)
{
/* Enter "graphics" Mode */
done=true;
}
break;
case 'G':
if (session->other_session_flags & NETTLE_OTHER_VT52_MODE)
{
/* Exit "graphics" Mode */
done=true;
}
break;
case 'H':
if (session->other_session_flags & NETTLE_OTHER_VT52_MODE)
{
/* Cursor to home (VT52 mode) */
session->pos.x=0;
session->pos.y=session->scrollback;
}
else
{
/* Set tab (non-VT52 mode) */
if (session->number_of_tabs<MAX_TAB_NUMBER)
{
session->tabs[session->number_of_tabs]=session->pos.x;
session->number_of_tabs++;
}
else
{
printf("Error: too many tabs, ignored\n");
}
}
done=true;
break;
case 'I':
/* Reverse line feed */
session->pos.y--;
if (session->other_session_flags & NETTLE_OTHER_VT52_MODE)
{
reprocess_position_scroll(session);
}
done=true;
break;
case 'J':
if (session->other_session_flags & NETTLE_OTHER_VT52_MODE)
{
/* Erase to end of screen */
changedbox_update (0, session->pos.y,
session->terminal_size.x - 1,
session->scrollback + session->terminal_size.y - 1);
clear_screen(session,
 
((session->pos.y*session->terminal_size.x)+
session->pos.x),
 
(session->terminal_size.x*
(session->terminal_size.y+session->scrollback)),
 
session->current_fg,
session->current_bg,
session->current_flags,
32);
done=true;
}
break;
case 'K':
if (session->other_session_flags & NETTLE_OTHER_VT52_MODE)
{
/* Erase to end of line */
changedbox_update (session->pos.x, session->pos.y,
session->terminal_size.x - 1, session->pos.y);
clear_screen(session,
 
((session->pos.y*session->terminal_size.x)+
session->pos.x),
 
(session->pos.y+1)*session->terminal_size.x,
 
session->current_fg,
session->current_bg,
session->current_flags,
32);
done=true;
}
break;
case 'M':
if (!(session->other_session_flags & NETTLE_OTHER_VT52_MODE))
{
session->pos.y--;
reprocess_position_scroll(session);
done=true;
}
break;
case 'c':
if (!(session->other_session_flags & NETTLE_OTHER_VT52_MODE))
{
reset_terminal(session);
session->pos.x=0;
session->pos.y=session->scrollback;
done=true;
}
break;
case 'Z':
if (session->other_session_flags & NETTLE_OTHER_VT52_MODE)
{
char block[3];
block[0]='\x1B';
block[1]='/';
block[2]='Z';
nettle_senddata(session,block,3);
done=true;
}
else
{
primary_da_request(session);
done=true;
}
break;
}
break;
case 255:
switch (session->escape_string[1])
{
case TELNET_DATAMARK:
done=true;
break;
case TELNET_GA:
done=true;
break;
case TELNET_IAC:
byte_default(session, 255);
done=true;
break;
}
break;
}
 
return done;
}
 
bool process_escape_length_3(struct session_struct *session)
{
bool done=false;
 
switch (session->escape_string[0])
{
case 27:
switch (session->escape_string[1])
{
case ' ':
/* Set C1 Control Transmission */
if (session->terminal_mode==2)
{
switch (session->escape_string[2])
{
case 'F':
/* 7-bit */
session->bit_controls=false;
done=true;
break;
case 'G':
/* 8-bit */
session->bit_controls=true;
done=true;
break;
}
}
break;
case '(': case ')': case '*': case '+':
determine_character_set(session);
done=true;
break;
case '#':
switch (session->escape_string[2])
{
case '3': case '4': case '5': case '6':
/* various font size alterations - not supported */
break;
case '8':
/* Clear screen with E's */
changedbox_update_whole ();
clear_screen(session,
 
session->scrollback*session->terminal_size.x,
 
(session->terminal_size.x*
(session->terminal_size.y+session->scrollback)),
 
session->current_fg,
session->current_bg,
0,
'E');
break;
}
done=true;
break;
}
break;
case 255:
{
/* IAC */
 
int iac_type=session->escape_string[1];
 
switch (iac_type)
{
case TELNET_WILL: /* Informational/Confirmational - remote end says it will do something */
handle_iac_will(session);
done = true;
break;
case TELNET_WONT: /* Informational/Confirmational - remote end says it will NOT do something */
handle_iac_wont(session);
done = true;
break;
 
case TELNET_DO: /* Request/Ack - remote end wants us to do something */
handle_iac_do(session);
done = true;
break;
case TELNET_DONT: /* Refusal/NAck - remote end refuses to do something (which maybe we asked it to do) */
handle_iac_dont(session);
done = true;
break;
}
 
}
break; /* case iac */
}
 
return done;
}
/vendor/v0.2023/!Make,fd7
New file
0,0 → 1,3
RMEnsure DDEUtils 0.00 RMLoad System:Modules.DDEUtils
Prefix <Obey$Dir>
amu
/vendor/v0.2023/p_telnet.c
New file
0,0 → 1,94
/**
* Protocol Telnet specific support code
* (C) Nettle developers 2002
*
* $Id$
*/
 
#include "generic.h"
#include "globals.h"
#include "messages.h"
#include "wimputil.h"
#include "process.h"
#include "p_telnet.h"
 
/* Prototypes */
static char *telnet_session_setup(struct session_struct *);
static char *telnet_session_shutdown(struct session_struct *);
 
protocol_t protocol_telnet =
{
"telnet", /* Protocol name in Choices file */
"snettle_telnt", /* Sprite to use to indicate this protocol */
"Telnet", /* Token for this protocol name in messages file */
"telnet:", /* URI scheme prefix, or NULL if none */
23, /* Default port, or -1 if no port */
NETTLE_TELNET, /* Protocol type number */
 
/* Protocol flags */
PROTOCOL_HAS_HOST |
PROTOCOL_HAS_USER |
PROTOCOL_HAS_PASS,
 
telnet_session_setup,
telnet_session_shutdown,
NULL
};
 
/*************************************************** Gerph *********
Function: telnet_resized
Description: Window has been resized; we need to inform the remote
end of this fact
Parameters: session-> the session that has changed (new size in
terminal_size)
old_size = the old size coord structure, in case it
is needed
Returns: none
******************************************************************/
static void telnet_resized(struct session_struct *session,
struct coords old_size)
{
if (session->session_flags[TELOPT_NAWS])
{
/* NAWS is on */
char block[9];
 
block[0]=TELNET_IAC;
block[1]=TELNET_SB;
block[2]=TELOPT_NAWS;
block[3]=session->terminal_size.x / 256;
block[4]=session->terminal_size.x % 256;
block[5]=session->terminal_size.y / 256;
block[6]=session->terminal_size.y % 256;
block[7]=TELNET_IAC;
block[8]=TELNET_SE;
nettle_senddata(session, block, 9);
}
}
 
/*************************************************** Gerph *********
Function: telnet_session_setup
Description: Set up a protocol session
Parameters: session-> the session we're constructing
Returns: pointer to token to return as an error, or NULL if none
******************************************************************/
static char *telnet_session_setup(struct session_struct *session)
{
session->session_data = write_out_data;
session->session_connected = NULL; /* No negotiation on connect */
session->session_resolved = NULL; /* No options on resolve */
session->session_send = nettle_senddata_socket;
session->session_resized = telnet_resized;
return NULL;
}
 
/*************************************************** Gerph *********
Function: telnet_session_shutdown
Description: Shut down a protocol session
Parameters: session-> the session we're constructing
Returns: pointer to token to return as an error, or NULL if none
******************************************************************/
static char *telnet_session_shutdown(struct session_struct *session)
{
return NULL;
}
/vendor/v0.2023/wimp.c
New file
0,0 → 1,3578
/**
* Wimp_Poll / Wimp code
* (C) Nettle developers 2000-2002
*
* $Id: wimp,v 1.177 2002/06/14 08:48:30 archifishal Exp $
*/
 
#include "generic.h"
#include "globals.h"
 
#include <ctype.h>
#include <errno.h>
#include "sys/errno.h"
 
#ifdef USE_TCPIPLIB
# include "socklib.h"
# include "unixlib.h"
#else
# include "sys/socket.h"
#endif
 
#include "sys/select.h"
#include "sys/time.h"
#include "netdb.h"
 
#include "choices.h"
#include "hotlist.h"
#include "keyboard.h"
#include "lineedit.h"
#include "messages.h"
#include "main.h"
#include "misc.h"
#include "mouse.h"
#include "nettle.h"
#include "process.h"
#include "protocols.h"
#include "p_taskwindow.h"
#include "scripts.h"
#include "seln.h"
#include "socket.h"
#include "sockwatch.h"
#include "spool.h"
#include "templ.h"
#include "termlist.h"
#include "timers.h"
#include "url.h"
#include "wimp.h"
#include "wimputil.h"
#include "zapredraw.h"
 
/* Undefine this to debug the timers */
/* #define TIMERS_DEBUG */
 
static int menu_data[96];
static int menu_data2[96];
static int menu_data3[96];
static int menu_data4[96];
static char indirected[1024];
 
static struct session_struct *paste_session;
 
static int old_charw;
static int old_charh;
 
static int msg_ref;
static bool queried_user_filetype=false;
static int shutdown_flag=-1; /* 0 if closedown, not if single quit */
 
static int taskmanager_taskhandle;
 
/* Dunno what this is about - AMS 12/09/2001 */
enum ansi_colour_flag
{
SAVE_NO_ANSI,
SAVE_FLAG_ANSI,
SAVE_FORCE_ANSI
};
 
static enum ansi_colour_flag allow_ansi_colour = SAVE_FLAG_ANSI;
 
static void create_iconbar_menu(void);
static void open_open_window(bool open_window_flag);
static void create_terminal_menu(void);
static void set_cursor_session (const struct session_struct *session);
 
static bool parse_ant_url (union wimp_poll_block *);
static bool parse_acorn_uri (union wimp_poll_block *);
static bool paste_text_file (union wimp_poll_block *);
 
void open_window_centred (int window_handle)
{
struct wimp_getwindowstate_block block;
 
/* get the window state */
block.window_handle = window_handle;
_swi (Wimp_GetWindowState, _IN(1), &block);
 
/* calculate position */
block.max.x -= block.min.x;
block.min.x = screensize.x / 2 - block.max.x / 2;
block.max.x += block.min.x;
block.max.y -= block.min.y;
block.min.y = screensize.y / 2 - block.max.y / 2;
block.max.y += block.min.y;
block.handle_behind = -1; /* open on top of stack */
 
open_window((struct wimp_openwindow_block *) &block, window_handle);
}
 
 
 
/**
* start a connection to the remote host
*
* This is called once the dns lookup has succeeded
*/
static void wimp_connectsession(struct session_struct *session)
{
session->socket_handle = socket_create();
 
if (session->socket_handle == -1)
{
write_out_strings(session, lookup_static("nosocket"),
"\r\n", 0);
session->socket_state = NETTLE_SESSION_NONE;
return;
}
 
/* JRF: This 'split' has been necessary just to wedge this one
callback routine in ;-( */
if (session->session_resolved)
{
session->session_resolved(session);
/* JRF: FIXME: Should handle errors from the callback here */
}
 
if (socket_connect(session->socket_handle,
session->socket_ip,
session->socket_port))
{
/* This is a new error, and can't occur as yet; it's purely for
completeness */
/* printf("Connect failed\n"); */
write_out_strings(session, lookup_static("connecterror"),
"\r\n", 0);
close_session(session);
return;
}
 
session->socket_state = NETTLE_SESSION_CONNECT;
write_out_strings(session, lookup_static("connecting"),
socket_ip_string(session->socket_ip),
"...\r\n", 0);
/* take a null so the state machine gets kicked and wimp_pollconect
* starts taking null polls */
main_requirenull = true;
}
 
 
static void wimp_pollresolve(struct session_struct *session)
{
struct hostent *dnsanswer;
 
switch (dns_check(session->dns))
{
default:
/* still in progress */
main_requirenull = true;
break;
 
case dns_complete_failure:
set_title_bar(session->window_handle,
lookup_static("title_disconnect"));
write_out_strings(session, lookup_static("noresolv"), "\r\n", 0);
session->socket_state=NETTLE_SESSION_NONE;
break;
 
case dns_complete_success:
dnsanswer = dns_getanswer(session->dns);
assert(dnsanswer != NULL);
session->socket_ip = (unsigned int) *((int *)(void *)(*dnsanswer).h_addr);
dns_dispose(session->dns);
session->dns = NULL;
 
wimp_connectsession(session);
break;
}
}
 
 
 
static void wimp_pollconnect(struct session_struct *session)
{
int retval;
 
retval = socket_connected(session->socket_handle);
 
switch (retval)
{
case 0:
{
char string[1024];
 
sprintf(string,APPLICATION_NAME"/%s (%s%s%s,%d)",
terminal_name[session->terminal_type],
session->login_user ? session->login_user : "",
session->login_user ? "@" : "",
session->socket_host,
session->socket_port);
 
set_title_bar(session->window_handle,string);
 
session->socket_state = NETTLE_SESSION_CONNECTED;
write_out_strings(session, lookup_static("connected"),
socket_ip_string(session->socket_ip),
"\r\n", 0);
main_requirenull = true; /* read any data waiting on the socket */
 
/* Notify the socket handler that we have now successfully
connected */
if (session->session_connected)
session->session_connected(session);
break;
}
 
case -1:
/* still connecting, take null polls */
main_requirenull = true;
break;
 
default:
{
/* error, retval contains errno */
set_title_bar(session->window_handle,
lookup_static("title_noconn"));
write_out_strings(session, lookup_static("noconn"),
socket_strerror(retval), "\r\n", 0);
close_session(session);
break;
}
}
}
 
 
 
static void wimp_pollsocket(struct session_struct *session)
{
int packet_length;
char receive_block[RECEIVE_BLOCK_LENGTH];
 
packet_length = recv(session->socket_handle, receive_block,
RECEIVE_BLOCK_LENGTH, 0);
 
if (packet_length == -1 && errno == EWOULDBLOCK)
/* we've read all the available data */
return;
 
if (packet_length == 0 || packet_length == -1)
{
/* EOF or error condition */
set_title_bar(session->window_handle, lookup_static("title_disconnect"));
reset_terminal(session);
if (packet_length == 0)
{
/* EOF received */
write_out_strings(session, "\r\n", lookup_static("closed"), "\r\n", 0);
}
else
{
write_out_strings(session, "\r\n", lookup_static("socketerror"),
socket_strerror(errno), " ", 0);
write_out_strings(session, lookup_static ("occurred"), "\r\n", 0);
}
 
write_out_strings(session, lookup_static("disconn"), "\r\n", 0);
close_session(session);
return;
}
 
session->session_data(session, receive_block, packet_length);
 
/* take a null poll as there may be either more data waiting to be read
* (and sockwatch won't notify us again about data that's already been
* received), or there may be an EOF condition waiting for us to read
* it. We don't try reading again straight away, as we might end up taking
* lots of processor time if data is arriving faster than we can process
* it.
*/
main_requirenull = true;
}
 
 
 
static void wimp_pollsessions(void)
{
struct session_struct *session;
int fdupperbound; /* (exclusive) */
fd_set readfds;
struct timeval timeval;
int numberready;
 
FD_ZERO(&readfds);
fdupperbound = 0;
 
/* for each session, either poll it if necessary, or add its socket to
* the list of ones to check with select() */
for (session = sessions; session != NULL; session = session->next)
{
switch (session->socket_state)
{
case NETTLE_SESSION_RESOLVE:
wimp_pollresolve(session);
break;
 
case NETTLE_SESSION_CONNECT:
wimp_pollconnect(session);
break;
 
case NETTLE_SESSION_CONNECTED:
if (session->connection_type != NETTLE_TASKWINDOW)
{
assert(session->socket_handle >= 0 && session->socket_handle < 256);
FD_SET(session->socket_handle, &readfds);
if (session->socket_handle >= fdupperbound)
fdupperbound = session->socket_handle + 1;
}
 
/* Anything to be pasted in...? */
if (session->paste)
{
int sent = nettle_senddata (session, session->paste->data,
session->paste->length);
 
if (sent == -1)
{
generror("nettle_senddata returned -1, this is probably bad... report it to the \
authors.",false);
}
else if (sent == session->paste->length)
{
struct paste_buffer *paste = session->paste;
session->paste = paste->next;
if (! paste->next)
session->paste_head = NULL;
free (paste);
} else {
memmove (session->paste->data, session->paste->data+sent,
session->paste->length - sent);
session->paste->length -= sent;
main_requirenull = true;
}
}
 
/* Try and close the spool (if open for 5 secs without output currently) */
if (session->spool_file_name!=NULL)
spool_close(session, false);
 
break;
 
case NETTLE_SESSION_NONE:
/* do nothing */
break;
 
default:
assert(0);
}
}
 
if (fdupperbound == 0)
/* no sockets to be polled */
return;
 
timeval.tv_sec = 0;
timeval.tv_usec = 0;
 
numberready = select(fdupperbound, &readfds, NULL, NULL, &timeval);
if (numberready == 0)
/* no sockets need attention */
return;
 
if (numberready == -1 && errno != EBADF)
/* error other than an invalid descriptor, nothing we can do */
return;
 
for (session = sessions; session != NULL; session = session->next)
{
if (session->connection_type != NETTLE_TELNET &&
session->connection_type != NETTLE_SSH &&
session->connection_type != NETTLE_RLOGIN &&
session->connection_type != NETTLE_REXEC)
continue;
 
if (session->socket_state != NETTLE_SESSION_CONNECTED)
continue;
 
if (FD_ISSET(session->socket_handle, &readfds))
wimp_pollsocket(session);
}
}
 
void blink_toggle_state(struct session_struct *session,void *private, int late)
{
if (!blinking)
{
return; /* Configured blinking off, so return immediately */
}
 
if (session->want_blink)
{
session->other_session_flags ^= NETTLE_OTHER_BLINK_HIDE;
force_redraw (session->window_handle,
0,
(-session->terminal_size.y-session->scrollback) * redraw.r_charh <<eig.y,
session->terminal_size.x * redraw.r_charw << eig.x,
0);
}
else
{
/* They no longer want blinking, so we'll disable ourselves */
timer_remove(session,private,blink_toggle_state);
 
/* plus we ensure that the any text that was blinking is visible */
session->other_session_flags &= ~NETTLE_OTHER_BLINK_HIDE;
}
}
 
void wimp_nullreasoncode(void)
{
if (socketwatch_pollword != NULL)
*socketwatch_pollword = 0;
 
wimp_pollsessions();
 
close_log(false);
 
if (resize_handle)
{
int buttons;
_swi(OS_Mouse,_OUT(2),&buttons);
if( !buttons )
{
resize_handle = 0;
_swi(Wimp_CloseWindow,_IN(1),&win_sizebar);
}
}
 
if (selection_in_progress)
handle_selection_drag();
 
if (mouse_handling_session)
{
struct wimp_getpointerinfo_block block;
 
_swi(Wimp_GetPointerInfo, _IN(1), &block);
 
if (block.buttons==0 || block.window_handle!=mouse_handling_session->window_handle)
{
mouse_handle_event(mouse_handling_session,
block.pos.x,
block.pos.y,
0);
}
 
/* Need to poll regularly until event finished */
main_requirenull = true;
}
}
 
 
 
/* Redraw window */
 
void redraw_window(union wimp_poll_block *wimp_block)
{
struct session_struct *session = sessions;
int window_handle = wimp_block->redraw_window.window_handle;
 
while (session && window_handle != session->window_handle)
{
session = session->next;
}
 
if (session)
{
int first_line;
int last_line;
 
struct wimp_getwindowstate_block block;
block.window_handle = wimp_block->redraw_window.window_handle;
_swi (Wimp_GetWindowState, _IN(1), &block);
 
first_line=-(block.scroll.y >> eig.y) / redraw.r_charh;
last_line=(((block.max.y - block.min.y- block.scroll.y) >> eig.y) + redraw.r_charh - 1)
/ redraw.r_charh;
 
if (first_line<0)
first_line=0;
 
if (last_line>session->terminal_size.y+session->scrollback)
last_line=session->terminal_size.y+session->scrollback;
 
zapgen_code(zapredraw_area,
session->assigned_area,
session->terminal_size.x,
first_line,
last_line,
session->other_session_flags,
session==selection_session ? selection_start / session->terminal_size.x : -1,
session==selection_session ? selection_start % session->terminal_size.x : -1,
session==selection_session ? selection_end / session->terminal_size.x : -1,
session==selection_session ? selection_end % session->terminal_size.x : -1
);
 
redraw.r_data = zapredraw_area;
 
_swi(ZapRedraw_RedrawWindow, _INR(0,1), wimp_block, &redraw);
}
else if (colourpicker_handle == 0 || window_handle != menu_window)
{
/* *DON'T* redraw the ColourPicker window */
int more;
 
more = _swi(Wimp_RedrawWindow, _IN(1)|_RETURN(0), wimp_block);
while (more)
{
if (window_handle == win_hotpane)
hotlist_draw((struct wimp_getrectangle_block *) wimp_block);
 
more = _swi(Wimp_GetRectangle, _IN(1)|_RETURN(0), wimp_block);
}
}
}
 
 
 
/* Open window */
 
void open_window(struct wimp_openwindow_block *wimp_block, int window_handle)
{
struct wimp_getwindowstate_block local_block, *block=&local_block;
struct session_struct *session = sessions;
 
/* find out which session this window is - if any! */
 
while (session && window_handle != session->window_handle)
{
session = session->next;
}
 
if (wimp_block)
{
/* Called from Wimp_Poll, so use that block, which contains an OpenWindow struct */
block = (struct wimp_getwindowstate_block *) wimp_block;
}
else
{
/* Called from our own code, so fetch the OpenWindow block */
block->window_handle = window_handle;
 
_swi(Wimp_GetWindowState, _IN(1), block);
 
block->handle_behind = -1; /* Open on top of stack */
}
 
if (window_handle==win_choices)
{
/* Find out which pane we should be opening */
struct wimp_whichicon_block whichicon_block;
int window_id_to_open=0;
int counter=0;
 
_swi(Wimp_WhichIcon, _INR(0,3), window_handle, &whichicon_block, WIMP_ICON_SELECTED_BIT,
WIMP_ICON_SELECTED_BIT);
 
while (whichicon_block.icons[counter]!=-1)
{
switch (whichicon_block.icons[counter])
{
case icon_choices_size:
if (window_id_to_open==0)
window_id_to_open=win_paneterm;
else
generror("More than one 'window' icon set in choices.", false);
break;
 
case icon_choices_colour:
if (window_id_to_open==0)
window_id_to_open=win_panecols;
else
generror("More than one 'window' icon set in choices.", false);
break;
 
case icon_choices_hotlist:
if (window_id_to_open==0)
window_id_to_open=win_panehot;
else
generror("More than one 'window' icon set in choices.", false);
break;
 
case icon_choices_misc:
if (window_id_to_open==0)
window_id_to_open=win_panemisc;
else
generror("More than one 'window' icon set in choices.", false);
break;
}
counter++;
}
 
if (window_id_to_open!=0)
{
struct wimp_getwindowinfo_block window;
window.window_handle=window_id_to_open;
 
_swi(Wimp_GetWindowInfo, _IN(1), 1 + (int) &window); /* no icons */
 
window.max.x += block->min.x - (window.min.x-4);
window.min.x = block->min.x+4;
window.min.y = block->min.y+4;
window.max.y = block->max.y-4;
window.handle_behind=block->handle_behind;
 
if (window_id_to_open == win_panehot)
{
/* Uhoh. Need to open the hotlist pane's list pane! */
 
struct wimp_getwindowinfo_block window2;
window2.window_handle=win_hotpane;
 
_swi(Wimp_GetWindowInfo, _IN(1), 1 + (int) &window2); /* no icons */
 
window2.max.x += window.max.x - (40+12); /* Guessing the scrollbar width... */
window2.min.x = window.min.x+12;
window2.min.y = (window.max.y-12) - (window2.max.y - window2.min.y);
window2.max.y = window.max.y-12;
window2.handle_behind=block->handle_behind;
 
_swi(Wimp_OpenWindow, _IN(1), &window2);
 
window.handle_behind=win_hotpane;
 
}
 
_swi(Wimp_OpenWindow, _IN(1), &window);
 
block->handle_behind=window_id_to_open;
}
else
{
generror("No 'window' selected in choices.", false);
}
}
else if (session)
{
struct wimp_getwindowinfo_block window;
int height = block->max.y - block->min.y;
int maxheight = (session->terminal_size.y * redraw.r_charh) << eig.y;
 
if (session->window_needs_resized)
{
/* If we need to be resized, do it here - opening also happens here
* -NB this function is also used by the font change code */
reopen_and_size_window(session, session->terminal_size.x, session->terminal_size.y,
session->scrollback, old_charw, old_charh);
session->window_needs_resized=false;
 
/* We might need to show the resizer here? Unsure. */
/* resize_handle = block->window_handle; */
}
 
/* This is a main "session" window, so handle the pane, if any */
window.window_handle = block->window_handle;
_swi (Wimp_GetWindowInfo, _IN(1), 1 + (int) &window); /* no icons */
 
if (dont_require_ctrl || inkey(KEYBOARD_CTRL) )
{
/* Ctrl pressed (or not) - allow dynamic resizing */
int new_x=(((block->max.x-block->min.x)>>eig.x) + redraw.r_charw/2)/redraw.r_charw;
int new_y=(((block->max.y-block->min.y)>>eig.y) + redraw.r_charh/2)/redraw.r_charh;
 
if ( (session->terminal_size.x != new_x) || (session->terminal_size.y != new_y) )
{
resize_terminal(session, new_x, new_y, session->scrollback, true);
 
/* Refetch the window state as the Wimp may have changed it if it
* didn't fit on the screen etc.
*/
_swi(Wimp_GetWindowState, _IN(1), block);
 
resize_handle = block->window_handle;
}
 
block->max.x = block->min.x+(session->terminal_size.x)*(redraw.r_charw << eig.x);
block->min.y = block->max.y-(session->terminal_size.y)*(redraw.r_charh << eig.y);
 
/* Why did we do this? */
/* block->scroll.y =-(session->terminal_size.y+session->scrollback)*(redraw.r_charh << eig.y); */
}
else
{
/* limit to the number of rows */
 
/* if the window size is unchanged, DON'T apply this limit
* (allow for moving the window)
*/
if (height > maxheight &&
(window.max.x - window.min.x != block->max.x - block->min.x ||
window.max.y - window.min.y != block->max.y - block->min.y))
{
block->min.y = block->max.y - maxheight;
/* if the v scrollbar was at the bottom and its vpos is unchanged
* force it to the bottom
*/
if (window.scroll.y == block->scroll.y &&
window.scroll.y - window.max.y + window.min.y == window.work_min.y)
{
block->scroll.y = window.work_min.y;
}
}
}
 
if (session->line_editor_type!=LINEEDIT_NONE)
{
/* open the pane window and set the 'behind' word to behind the pane */
open_pane_window(session, (struct wimp_openwindow_block *) block);
block->handle_behind = session->pane_handle;
}
 
_swi(Wimp_OpenWindow, _IN(1), block);
 
if ( block->window_handle == resize_handle )
{
struct wimp_getwindowstate_block bar;
char size[16];
int barwidth;
 
sprintf(size, "%dx%d", session->terminal_size.x, session->terminal_size.y);
set_icon_data(win_sizebar, icon_sizebar_size, size);
 
bar.window_handle = win_sizebar;
_swi (Wimp_GetWindowState, _IN(1), &bar);
barwidth = bar.max.x - bar.min.x ;
 
bar.min.x = block->max.x - barwidth;
bar.max.x = block->max.x;
bar.min.y = block->min.y - toolheight;
bar.max.y = block->min.y - ( 2<<eig.y ) ;
 
_swix(Wimp_ResizeIcon, _INR(0,5), win_sizebar, icon_sizebar_size, 0, -(toolheight - (2<<eig.y)), barwidth, 0);
_swi(Wimp_OpenWindow, _INR(1,4), &bar, MAGIC_TASK, resize_handle, 1<<24 );
}
 
return;
}
 
_swi(Wimp_OpenWindow, _IN(1), block);
}
 
 
 
/* Close window */
 
void close_window(int window_handle)
{
struct wimp_closewindow_block block;
struct session_struct *session = sessions;
 
while (session && window_handle != session->window_handle)
{
session = session->next;
}
 
if (session)
{
if (session->socket_state == NETTLE_SESSION_CONNECTED)
{
bool status = generror_question("ConnectionOpenButtons","ConnectionOpen",0);
 
if (!status)
return;
}
remove_session(session);
}
else
{
block.window_handle = window_handle;
 
_swi(Wimp_CloseWindow, _IN(1), &block);
 
if (window_handle == win_panehot)
{
block.window_handle = win_hotpane;
_swi(Wimp_CloseWindow, _IN(1), &block);
}
}
}
 
 
 
/* Determine if there are any sessions open. If so, query the user as to whether */
/* to really quit the program. set_quit_flag is true if the user is quitting the task, */
/* or false if the Wimp is quitting us */
 
static void close_program(void)
{
struct session_struct *session = sessions;
bool connections_open=false;
 
while (session)
{
if (session->socket_state == NETTLE_SESSION_CONNECTED)
connections_open=true;
 
session = session->next;
}
 
quit_flag=true;
 
if (connections_open)
quit_flag = generror_question("ConnectionMultiOpenButtons","ConnectionMultiOpen",0);
 
if (quit_flag && shutdown_flag==0)
{
union wimp_poll_block message;
 
/* start of key press message is same as block returned by get caret position */
_swi(Wimp_GetCaretPosition, _IN(1), &message);
 
message.key_pressed.code = 0x1fc; /* scF12 */
message.key_pressed.extra = 0;
_swi(Wimp_SendMessage, _INR(0,3), 8, &message, taskmanager_taskhandle, 0);
}
}
 
 
 
static void iconbar_click(int x, int y, int buttons, int icon_handle)
{
if (icon_handle==iconbar_handle)
{
switch (buttons)
{
case 4:
open_open_window(true);
break;
case 2:
create_iconbar_menu();
break;
case 1:
{
struct wimp_getpointerinfo_block block;
int items = hotlist_num_items();
if (items)
{
_swi(Wimp_GetPointerInfo, _IN(1), &block);
_swi(Wimp_CreateMenu, _INR(1,3), create_hotlist_menu(), block.pos.x-64, 96+(items*44));
menu_open = MENU_HOTLIST;
}
}
break;
}
}
}
 
static void win_info_click(int x, int y, int buttons, int icon_handle)
{
switch (icon_handle)
{
case icon_info_website:
url_launch(NETTLE_HOME_PAGE);
 
if ((buttons & 1)==0)
_swi(Wimp_CreateMenu, _IN(1), -1);
 
break;
}
}
 
static void win_open_click(int x, int y, int buttons, int icon_handle)
{
switch (icon_handle)
{
case icon_open_cancel:
close_window(win_open);
break;
 
case icon_open_connect:
if (start_connection_fromwindow() && (buttons & 1)==0)
close_window(win_open);
break;
 
case icon_open_contypebut:
create_connection_type_menu(win_open, icon_open_contype, icon_open_contypebut);
break;
 
case icon_open_termtypebut:
create_terminal_type_menu(win_open, icon_open_termtype, icon_open_termtypebut);
break;
}
}
 
static void win_save_click(int x, int y, int buttons, int icon_handle)
{
switch (icon_handle)
{
case icon_save_cancel:
_swi(Wimp_CreateMenu, _IN(1), -1);
break;
 
case icon_save_save:
{
char save_data[1024];
 
read_icon_data(win_save, icon_save_filename, save_data, sizeof(save_data));
 
/* JRF: This check is invalid; needs to check for : or < I think */
if ((instr(save_data, ":")>=0))
{
/* if icon ticked, then we save with ANSI colour */
if (read_icon_ticked(win_save, icon_save_ansi))
{
save_selection(save_data, true);
}
else
{
save_selection(save_data, false);
}
 
if (buttons!=1)
{
_swi(Wimp_CreateMenu, _IN(1), -1);
}
}
else
{
generror("ToSaveDrag", true);
}
}
break;
 
case icon_save_drag:
switch (buttons)
{
case 64: case 16:
/* Drag */
drag_start(win_save, icon_save_drag);
break;
}
break;
}
}
 
 
static void win_spoolsave_click(int x, int y, int buttons, int icon_handle)
{
switch (icon_handle)
{
case icon_spoolsave_cancel:
_swi(Wimp_CreateMenu, _IN(1), -1);
break;
 
case icon_spoolsave_save:
if ((buttons & 1)==0 && spool_save_event())
{
_swi(Wimp_CreateMenu, _IN(1), -1);
}
break;
 
case icon_spoolsave_drag:
switch (buttons)
{
case 64: case 16:
/* Drag */
drag_start(win_spoolsave, icon_spoolsave_drag);
break;
}
break;
}
}
 
/*
* Description: Perform the 'set' action on the resize dialogue,
* with NO closing of the dialogue
* Parameters: none
* Returns: none
* Note: Assumes that terminal_menu_session is set to the
* correct terminal window, as it should be whilst
* the menu is active
*/
 
static void win_resize_set(void)
{
struct coords new_size;
int new_scrollback;
if (read_termsize_icons (win_resize,
icon_resize_width, icon_resize_height,
icon_resize_scroll,
&new_size, &new_scrollback))
{
resize_terminal(terminal_menu_session, new_size.x, new_size.y, new_scrollback, true);
}
}
 
 
static void win_resize_click(int x, int y, int buttons, int icon_handle)
{
switch (icon_handle)
{
case icon_resize_cancel:
if ((buttons & 1)==0)
_swi(Wimp_CreateMenu, _IN(1), -1);
 
break;
 
case icon_resize_set:
win_resize_set();
if ((buttons & 1)==0)
_swi(Wimp_CreateMenu, _IN(1), -1);
break;
}
}
 
/**
* Set the caret to be in the given session
*
* (Either the window or line editor, if lineeditor is on)
*
* @param session Session to place caret into
*/
static void wimp_claimcaret(struct session_struct *session)
{
if (line_editor_active(session))
{
struct wimp_getcaretposition_block block;
 
_swi(Wimp_GetCaretPosition, _IN(1), &block);
 
if (session->line_editor_type==LINEEDIT_CHECKBOX_OFF || session->line_editor_type==LINEEDIT_CHECKBOX_ON)
{
if (block.window_handle!=session->pane_handle)
{
set_caret_position(session->pane_handle, 0, -1,
get_icon_data_length(session->pane_handle, 0));
}
}
else
{
if (block.window_handle!=session->window_handle)
{
set_caret_position(session->window_handle, -1, -1, -1);
}
}
}
else
{
/* no line editor, place in window */
set_caret_position(session->window_handle,-1,-1,-1);
}
}
 
 
static void wimp_launchurl(struct session_struct *session, int x, int y)
{
#define ICHR(x,y) ((int) read_assigned_character(session,x,y))
 
char url[1024];
char *urlptr;
char *urlend;
const char *urlchars;
int ymax = session->terminal_size.y + session->scrollback;
int xmax = session->terminal_size.x;
 
struct wimp_getwindowstate_block block;
 
block.window_handle=session->window_handle;
 
_swi(Wimp_GetWindowState, _IN(1), &block);
 
y = -( (y - (block.max.y-block.scroll.y)) >> eig.y ) / redraw.r_charh;
x = ( (x - (block.min.x-block.scroll.x)) >> eig.x ) / redraw.r_charw;
 
log_f("\nclicked on '%c'\n", (char) ICHR(x,y) );
 
urlchars = lookup_static("URL_Chars");
 
log_f("\nURLChars = %s\n", urlchars);
 
if ( strchr( urlchars, ICHR(x,y) ) )
return;
 
/* go back to the start of the clicked on 'word' */
/* NOTE! We deliberately do not wrap-backwards over lines */
while ( x > 0 && strchr( urlchars, ICHR(x-1,y) )==NULL )
x--;
 
/* skip any initial space or colon or anything */
if (!isalnum( ICHR(x,y) ))
x++;
 
/* go forward to the end of the form [ie. until we find whitespace] */
/* NOTE! We currently allow the URL to flow to the next line */
urlptr = url;
urlend = url + sizeof(url) - 8; /* leave space for a '\0', and 'http://' */
while ( (urlptr < urlend) && (strchr( urlchars, ICHR(x,y) )==NULL) )
{
*urlptr++ = (char) ICHR(x,y);
x++;
if ( x >= xmax )
{
x=0;
y++;
if ( y >= ymax )
break;
}
}
*urlptr = '\0';
log_f("url = '%s'\n", url);
 
/* lower-case the protocol (if present) and site name */
{
const char *endptr = strchr (url, '/');
if (endptr > url && endptr[-1] == ':')
/* we have a protocol; find the end of the site name */
endptr = strchr (endptr + 1 + (endptr[1] == '/'), '/');
if (!endptr)
endptr = urlend;
for (urlptr = url; urlptr < endptr; urlptr++)
*urlptr = tolower (*urlptr);
}
 
/* we've got a url, check for full formedness */
urlptr = url;
while (isalpha((int) (*urlptr)))
urlptr++;
if (*urlptr != ':')
{
const char *scheme;
/* there's no scheme section */
if (strncmp(url, "ftp.", 4) == 0)
scheme = "ftp://";
else if (strchr(url, '@') != NULL)
scheme = "mailto:";
else
scheme = "http://";
 
/* prefix string we have with the scheme we've guessed */
memmove(url + strlen(scheme), url, strlen(url) + 1);
memcpy(url, scheme, strlen(scheme));
}
 
url_launch (url);
}
 
 
 
static void session_window_click(int x, int y, int buttons, int icon_handle, struct session_struct *session)
{
struct wimp_getcaretposition_block caret;
 
_swi (Wimp_GetCaretPosition, _IN(1), &caret);
 
/* if we're not pressing MENU or Ctrl */
/* (may want input focus to remain elswhere) */
if (buttons != ClickMenu && buttons != DragMenu && !inkey(KEYBOARD_CTRL))
wimp_claimcaret(session);
 
 
if (session->mouse_mode!=MOUSE_MODE_OFF && session->mouse_terminal_attached)
{
mouse_handle_event(session, x, y, buttons);
}
else
{
int x_pos;
int y_pos;
struct wimp_getwindowstate_block block;
 
block.window_handle=session->window_handle;
 
_swi(Wimp_GetWindowState, _IN(1), &block);
 
x_pos=block.min.x-block.scroll.x;
y_pos=block.max.y-block.scroll.y;
 
switch (buttons)
{
case DragSelect:
{
int seln_start;
int seln_end;
int click_point;
 
/* check to see if the drag is starting inside the current selection */
 
seln_start = MIN(selection_start, selection_end);
seln_end = MAX(selection_start, selection_end);
 
click_point = -( ( (y - y_pos) >> eig.y ) / redraw.r_charh )
* session->terminal_size.x
+ ( ( (x - x_pos) >> eig.x ) / redraw.r_charw );
 
if (selection_session == session && click_point >= seln_start &&
click_point <= seln_end)
{
int dragbox[4];
/* drag is inside selection, do a save */
dragbox[0] = x - 48 / 2;
dragbox[1] = y - 48 / 2;
dragbox[2] = x + 48 / 2;
dragbox[3] = y + 48 / 2;
_swi(DragASprite_Start, _INR(0, 4), 0xC5, 1 /* wimp sprite area */ ,
"file_fff", &dragbox, NULL);
drag_window_handle = selection_session->window_handle;
}
else
{
/* if SELECT drag, then clear the selection and work out what where the selection */
/* start is */
force_redraw_selection();
 
selection_session = session;
selection_start = click_point;
 
if (selection_start > (selection_session->terminal_size.x*
(selection_session->terminal_size.y+
selection_session->scrollback)))
{
selection_start=(selection_session->terminal_size.x*
(selection_session->terminal_size.y+
selection_session->scrollback));
}
 
if (selection_start<0)
{
selection_start=0;
}
 
selection_end=selection_start;
selection_in_progress=true;
}
}
break;
 
case DragAdjust:
/* if ADJUST drag, then if there is no selection or if it's not in this */
/* window, then start one */
if (selection_session != session)
{
force_redraw_selection();
 
selection_session = session;
selection_start = -( ( (y - y_pos) >> eig.y ) / redraw.r_charh )
* session->terminal_size.x
+ ( ( (x - x_pos) >> eig.x ) / redraw.r_charw );
 
if (selection_start>(selection_session->terminal_size.x*
(selection_session->terminal_size.y+
selection_session->scrollback)))
{
selection_start=(selection_session->terminal_size.x*
(selection_session->terminal_size.y+
selection_session->scrollback));
}
 
if (selection_start<0)
{
selection_start = 0;
}
 
selection_end=selection_start;
selection_in_progress=true;
selection_adjust_dragging=SELECTION_ADJUST_END;
}
else
{
selection_in_progress=true;
}
break;
 
case DoubleSelect:
wimp_launchurl(session, x, y);
break;
 
case ClickSelect:
/* if SELECT click, then clear the selection if the caret is already in the window */
if (selection_session &&
(caret.window_handle == session->window_handle ||
caret.window_handle == session->pane_handle))
{
selection_click(x,x_pos,y,y_pos);
}
break;
 
case ClickMenu: /* menu click */
terminal_menu_session = session;
create_terminal_menu();
break;
 
case ClickAdjust:
/* if ADJUST click, then extend the selection */
if (selection_session == session)
selection_adjust(x,x_pos,y,y_pos);
break;
}
}
}
 
 
 
static void session_pane_click(int x, int y, int buttons, int icon_handle, struct session_struct *session)
{
switch (icon_handle)
{
case 1:
{
struct wimp_geticonstate_block block;
 
block.window_handle=session->pane_handle;
block.icon_handle =icon_handle;
 
_swi(Wimp_GetIconState, _IN(1), &block);
 
if (block.icon_flags & WIMP_ICON_SELECTED_BIT)
{
set_icon_state(session->pane_handle, 0, 0, WIMP_ICON_DELETED_BIT);
check_set_caret_position(session->pane_handle, 0);
 
{
struct wimp_getcaretposition_block caret_pos;
 
_swi(Wimp_GetCaretPosition, _IN(1), &caret_pos);
 
if (caret_pos.window_handle==session->window_handle)
{
set_caret_position(session->pane_handle, 0, -1,
get_icon_data_length(session->pane_handle, 0));
}
}
}
else
{
struct wimp_getcaretposition_block caret_pos;
 
_swi(Wimp_GetCaretPosition, _IN(1), &caret_pos);
 
if (caret_pos.window_handle==session->pane_handle)
{
set_caret_position(session->window_handle,-1,-1,-1);
}
 
set_icon_state(session->pane_handle, 0, WIMP_ICON_DELETED_BIT, WIMP_ICON_DELETED_BIT);
}
 
block.window_handle=session->pane_handle;
block.icon_handle =0;
 
_swi(Wimp_GetIconState, _IN(1), &block);
 
force_redraw(session->pane_handle, block.min.x, block.min.y,
block.max.x, block.max.y);
 
}
}
}
 
 
 
/* Mouse click */
 
void wimp_mouse_click(int x, int y, int buttons, int window_handle, int icon_handle)
{
static int win_iconbar = -2;
static const struct { int *window; void (*handler)(int,int,int,int); } mousehandlers[] =
{
{&win_iconbar, iconbar_click },
{&win_info, win_info_click },
{&win_open, win_open_click },
{&win_save, win_save_click },
{&win_resize, win_resize_click },
{&win_choices, win_choices_click },
{&win_paneterm, win_paneterm_click },
{&win_panecols, win_panecols_click },
{&win_panehot, win_panehot_click },
{&win_hotpane, win_hotpane_click },
{&win_hotedit, win_hotedit_click },
{&win_panemisc, win_panemisc_click },
{&win_spoolsave, win_spoolsave_click },
{NULL,NULL}
};
int i;
 
for(i=0; mousehandlers[i].window; i++)
{
if (window_handle==*mousehandlers[i].window)
{
mousehandlers[i].handler(x, y, buttons, icon_handle);
return;
}
}
 
{
struct session_struct *session = sessions;
 
while (session)
{
if (window_handle == session->window_handle)
{
session_window_click(x,y,buttons,icon_handle,session);
return;
}
else if ((session->line_editor_type==LINEEDIT_CHECKBOX_OFF ||
session->line_editor_type==LINEEDIT_CHECKBOX_ON) &&
(window_handle == session->pane_handle))
{
session_pane_click(x,y,buttons,icon_handle,session);
return;
}
 
session = session->next;
}
}
}
 
 
 
static void wimp_initiatesave(const char *filename)
{
union wimp_poll_block block;
struct wimp_getpointerinfo_block gpi_block;
 
_swi(Wimp_GetPointerInfo, _IN(1), &gpi_block);
 
block.user_message.contents.data_save.window_handle=gpi_block.window_handle;
block.user_message.contents.data_save.icon_handle =gpi_block.icon_handle;
block.user_message.contents.data_save.pos =gpi_block.pos;
block.user_message.contents.data_save.size =selection_end-selection_start;
block.user_message.contents.data_save.filetype =0xFFF;
 
strcpy(block.user_message.contents.data_save.file_name, filename);
 
block.user_message.length =(48+strlen(filename)) & ~3;
block.user_message.your_ref =0;
block.user_message.message_code=WIMP_MESSAGE_DATASAVE;
 
_swi(Wimp_SendMessage, _INR(0,3), 18, &block,
block.user_message.contents.data_save.window_handle,
block.user_message.contents.data_save.icon_handle);
msg_ref = block.user_message.my_ref;
}
 
static void reply_to_dataload (union wimp_poll_block *block)
{
assert (block->user_message.message_code == WIMP_MESSAGE_DATALOAD);
 
block->user_message.your_ref = block->user_message.my_ref;
block->user_message.message_code = /*WIMP_MESSAGE_DATASAVE*/WIMP_MESSAGE_DATALOADACK; /*surely?*/
 
_swi (Wimp_SendMessage, _INR(0,2), 18, block, block->user_message.sender_ref);
msg_ref = block->user_message.my_ref;
}
 
/* Drag finished */
 
void drag_finished(void)
{
if (drag_window_handle==win_save)
{
char string[1024];
int loop;
 
read_icon_data(win_save, icon_save_filename, string, sizeof(string));
loop = strlen(string);
 
while (loop>=0 && string[loop]!='.' && string[loop]!=':')
{
loop--;
}
allow_ansi_colour = SAVE_FLAG_ANSI;
wimp_initiatesave(string+loop+1);
}
else if (drag_window_handle==win_hotpane)
{
hotlist_dragdone();
}
else if (drag_window_handle==win_spoolsave)
{
char string[1024];
int loop;
 
read_icon_data(win_spoolsave, icon_spoolsave_filename, string, sizeof(string));
loop = strlen(string);
 
while (loop>=0 && string[loop]!='.' && string[loop]!=':')
{
loop--;
}
wimp_initiatesave(string+loop+1);
}
else if (selection_session &&
drag_window_handle == selection_session->window_handle)
{
allow_ansi_colour = SAVE_NO_ANSI; /* This is debatable IMO */
wimp_initiatesave("Selection");
}
}
 
 
 
/* Key pressed */
 
void key_pressed(int window_handle, int icon_handle, int key, int extra)
{
int ekey = extra >> 16;
bool key_status=false;
 
if (window_handle == win_open)
{
char string[MESSAGE_MAX_CONNECTION];
int connection_type;
int protocol_flags;
 
read_icon_data(win_open, icon_open_contype, string, sizeof(string));
 
connection_type=protocol_fromname(string);
protocol_flags=protocol_toflags(connection_type);
 
switch (key)
{
case 13:
switch (icon_handle)
{
case icon_open_host:
if (protocol_flags & PROTOCOL_HAS_COMMAND)
{
set_caret_position(win_open,icon_open_command,-1, get_icon_data_length(win_open, icon_open_command));
}
else
{
if (start_connection_fromwindow())
close_window(win_open);
}
key_status=true;
break;
 
case icon_open_command:
if (start_connection_fromwindow())
close_window(win_open);
key_status=true;
break;
}
break;
 
case 27:
close_window(win_open);
break;
}
}
else if (window_handle==win_resize)
{
switch (icon_handle)
{
case icon_resize_scroll: /* The final icon in the window - scrollback */
switch (key)
{
case 13:
win_resize_set();
/* We close the menu ourselves */
_swi(Wimp_CreateMenu, _IN(1), -1);
key_status=true;
break;
}
break;
}
}
else if (window_handle==win_hotedit)
{
switch (icon_handle)
{
case icon_hotedit_scrollback: /* The final icon in the window - scrollback */
switch (key)
{
case 13:
/* Fake a click on the 'update' icon */
win_hotedit_click(0,0,4,icon_hotedit_update);
key_status=true;
break;
}
break;
}
}
else if (colourpicker_handle && window_handle == menu_window)
{
/* Keypresses in the ColourPicker window have already been handled */
key_status = true;
}
else if (window_handle == win_spoolsave)
{
switch (icon_handle)
{
case icon_spoolsave_filename:
switch (key)
{
case 13:
if (spool_save_event())
_swi(Wimp_CreateMenu, _IN(1), -1);
 
break;