/* vi:set ts=8 sts=4 sw=4 noet:
*
* VIM - Vi IMproved by Bram Moolenaar
* VMS port by Henk Elbers
* VMS deport by Zoltan Arpadffy
*
* Do ":help uganda" in Vim to read copying and usage conditions.
* Do ":help credits" in Vim to see a list of people who contributed.
* See README.txt for an overview of the Vim source code.
*/
#include "vim.h"
// define _generic_64 for use in time functions
#if !defined(VAX) && !defined(PROTO)
# include <gen64def.h>
#else
// based on Alpha's gen64def.h; the file is absent on VAX
typedef struct _generic_64 {
# pragma __nomember_alignment
__union { // You can treat me as...
// long long is not available on VAXen
// unsigned __int64 gen64$q_quadword; ...a single 64-bit value, or
unsigned int gen64$l_longword [2]; // ...two 32-bit values, or
unsigned short int gen64$w_word [4]; // ...four 16-bit values
} gen64$r_quad_overlay;
} GENERIC_64;
#endif
typedef struct
{
char class;
char type;
short width;
union
{
struct
{
char _basic[3];
char length;
} y;
int basic;
} x;
int extended;
} TT_MODE;
typedef struct
{
short buflen;
short itemcode;
char *bufadrs;
int *retlen;
} ITEM;
typedef struct
{
ITEM equ;
int nul;
} ITMLST1;
typedef struct
{
ITEM index;
ITEM string;
int nul;
} ITMLST2;
static TT_MODE orgmode;
static short iochan; // TTY I/O channel
static short iosb[4]; // IO status block
static int vms_match_num = 0;
static int vms_match_free = 0;
static char_u **vms_fmatch = NULL;
static char *Fspec_Rms; // rms file spec, passed implicitly between routines
static TT_MODE get_tty(void);
static void set_tty(int row, int col);
#define EXPL_ALLOC_INC 64
#define EQN(S1,S2,LN) (strncmp(S1,S2,LN) == 0)
#define SKIP_FOLLOWING_SLASHES(Str) do { while (Str[1] == '/') ++Str; } while (0)
/*
* vul_desc vult een descriptor met een string en de lengte
* hier van.
*/
static void
vul_desc(DESC *des, char *str)
{
des->dsc$b_dtype = DSC$K_DTYPE_T;
des->dsc$b_class = DSC$K_CLASS_S;
des->dsc$a_pointer = str;
des->dsc$w_length = str ? strlen(str) : 0;
}
/*
* vul_item vult een item met een aantal waarden
*/
static void
vul_item(ITEM *itm, short len, short cod, char *adr, int *ret)
{
itm->buflen = len;
itm->itemcode = cod;
itm->bufadrs = adr;
itm->retlen = ret;
}
void
mch_settmode(tmode_T tmode)
{
int status;
if ( tmode == TMODE_RAW )
set_tty(0, 0);
else
{
switch (orgmode.width)
{
case 132: OUT_STR_NF((char_u *)"\033[?3h\033>"); break;
case 80: OUT_STR_NF((char_u *)"\033[?3l\033>"); break;
default: break;
}
out_flush();
status = sys$qiow(0, iochan, IO$_SETMODE, iosb, 0, 0,
&orgmode, sizeof(TT_MODE), 0,0,0,0);
if (status!=SS$_NORMAL || (iosb[0]&0xFFFF)!=SS$_NORMAL)
return;
(void)sys$dassgn(iochan);
iochan = 0;
}
}
static void
set_tty(int row, int col)
{
int status;
TT_MODE newmode; // New TTY mode bits
static short first_time = TRUE;
if (first_time)
{
orgmode = get_tty();
first_time = FALSE;
}
newmode = get_tty();
if (col)
newmode.width = col;
if (row)
newmode.x.y.length = row;
newmode.x.basic |= (TT$M_NOECHO | TT$M_HOSTSYNC);
newmode.x.basic &= ~TT$M_TTSYNC;
newmode.extended |= TT2$M_PASTHRU;
status = sys$qiow(0, iochan, IO$_SETMODE, iosb, 0, 0,
&newmode, sizeof(newmode), 0, 0, 0, 0);
if (status!=SS$_NORMAL || (iosb[0]&0xFFFF)!=SS$_NORMAL)
return;
}
static TT_MODE
get_tty(void)
{
static $DESCRIPTOR(odsc,"SYS$OUTPUT"); // output descriptor
int status;
TT_MODE tt_mode;
if (!iochan)
status = sys$assign(&odsc,&iochan,0,0);
status = sys$qiow(0, iochan, IO$_SENSEMODE, iosb, 0, 0,
&tt_mode, sizeof(tt_mode), 0, 0, 0, 0);
if (status != SS$_NORMAL || (iosb[0] & 0xFFFF) != SS$_NORMAL)
{
tt_mode.width = 0;
tt_mode.type = 0;
tt_mode.class = 0;
tt_mode.x.basic = 0;
tt_mode.x.y.length = 0;
tt_mode.extended = 0;
}
return(tt_mode