⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 api.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 2 页
字号:
/*- * Copyright (c) 1988, 1993 *	The Regents of the University of California.  All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software *    must display the following acknowledgement: *	This product includes software developed by the University of *	California, Berkeley and its contributors. * 4. Neither the name of the University 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 REGENTS 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. */#ifndef lintstatic char sccsid[] = "@(#)api.c	8.1 (Berkeley) 6/6/93";#endif /* not lint *//* * This file implements the API used in the PC version. */#include <stdio.h>#include "api.h"#include "../general/general.h"#include "../api/disp_asc.h"#include "screen.h"#include "hostctlr.h"#include "oia.h"#include "../general/globals.h"int apitrace = 0;/* * Some defines for things we use internally. */#define	PS_SESSION_ID	23#define	BUF_SESSION_ID	0/* * General utility routines. */#if	defined(MSDOS)#if	defined(LINT_ARGS)static void movetous(char *, int, int, int);static void movetothem(int, int, char *, int);#endif	/* defined(LINT_ARGS) */#define	access_api(foo,length,copyin)	(foo)#define	unaccess_api(foo,goo,length,copyout)static voidmovetous(parms, es, di, length)char *parms;int es, di;int length;{    char far *farparms = parms;    movedata(es, di, FP_SEG(farparms), FP_OFF(farparms), length);    if (apitrace) {	Dump('(', parms, length);    }}static voidmovetothem(es, di, parms, length)int es, di;char *parms;int length;{    char far *farparms = parms;    movedata(FP_SEG(farparms), FP_OFF(farparms), es, di, length);    if (apitrace) {	Dump(')', parms, length);    }}#endif	/* defined(MSDOS) */#if	defined(unix)extern char *access_api();extern void movetous(), movetothem(), unaccess_api();#endif	/* defined(unix) *//* * Supervisor Services. */static voidname_resolution(regs, sregs)union REGS *regs;struct SREGS *sregs;{    NameResolveParms parms;    movetous((char *) &parms, sregs->es, regs->x.di, sizeof parms);    regs->h.cl = 0;    if (memcmp((char *)&parms, NAME_SESSMGR, sizeof parms.gate_name) == 0) {	regs->x.dx = GATE_SESSMGR;    } else if (memcmp((char *)&parms, NAME_KEYBOARD,					sizeof parms.gate_name) == 0) {	regs->x.dx = GATE_KEYBOARD;    } else if (memcmp((char *)&parms, NAME_COPY, sizeof parms.gate_name) == 0) {	regs->x.dx = GATE_COPY;    } else if (memcmp((char *)&parms, NAME_OIAM, sizeof parms.gate_name) == 0) {	regs->x.dx = GATE_OIAM;    } else {	regs->h.cl = 0x2e;	/* Name not found */    }    regs->h.ch = 0x12;    regs->h.bh = 7;}/* * Session Information Services. */static voidquery_session_id(regs, sregs)union REGS *regs;struct SREGS *sregs;{    QuerySessionIdParms parms;    movetous((char *)&parms, sregs->es, regs->x.di, sizeof parms);    if ((parms.rc != 0) || (parms.function_id != 0)) {	parms.rc = 0x0c;    } else if (parms.option_code != 0x01) {	parms.rc = 0x0d;	/* Invalid option code */#ifdef	NOTOBS    } else if ((parms.data_code != 0x45) && (parms.data_code != 0x00/*OBS*/)) {	parms.rc = 0x0b;#endif	/* NOTOBS */    } else {	NameArray list;	movetous((char *)&list, FP_SEG(parms.name_array),		    FP_OFF(parms.name_array), sizeof list);	if ((list.length < 14) || (list.length > 170)) {	    parms.rc = 0x12;	} else {	    list.number_matching_session = 1;	    list.name_array_element.short_name = parms.data_code;	    list.name_array_element.type = TYPE_DFT;	    list.name_array_element.session_id = PS_SESSION_ID;	    memcpy(list.name_array_element.long_name, "ONLYSESS",			    sizeof list.name_array_element.long_name);	    movetothem(FP_SEG(parms.name_array),		FP_OFF(parms.name_array), (char *)&list, sizeof list);	    parms.rc = 0;	}    }    parms.function_id = 0x6b;    movetothem(sregs->es, regs->x.di, (char *)&parms, sizeof parms);}static voidquery_session_parameters(regs, sregs)union REGS *regs;struct SREGS *sregs;{    QuerySessionParametersParms parms;    movetous((char *)&parms, sregs->es, regs->x.di, sizeof parms);    if ((parms.rc !=0) || (parms.function_id != 0)) {	parms.rc = 0x0c;    } else if (parms.session_id != PS_SESSION_ID) {	parms.rc = 0x02;    } else {	parms.rc = 0;	parms.session_type = TYPE_DFT;	parms.session_characteristics = 0;	/* Neither EAB nor PSS */	parms.rows = MaxNumberLines;	parms.columns = MaxNumberColumns;	parms.presentation_space = 0;    }    parms.function_id = 0x6b;    movetothem(sregs->es, regs->x.di, (char *)&parms, sizeof parms);}static voidquery_session_cursor(regs, sregs)union REGS *regs;struct SREGS *sregs;{    QuerySessionCursorParms parms;    movetous((char *)&parms, sregs->es, regs->x.di, sizeof parms);    if ((parms.rc != 0) || (parms.function_id != 0)) {	parms.rc = 0x0c;    } else if (parms.session_id != PS_SESSION_ID) {	parms.rc = 0x02;    } else {	parms.rc = 0;	parms.cursor_type = CURSOR_BLINKING;	/* XXX what is inhibited? */	parms.row_address = ScreenLine(CursorAddress);	parms.column_address = ScreenLineOffset(CursorAddress);    }    parms.function_id = 0x6b;    movetothem(sregs->es, regs->x.di, (char *) &parms, sizeof parms);}/* * Keyboard Services. */static voidconnect_to_keyboard(regs, sregs)union REGS *regs;struct SREGS *sregs;{    ConnectToKeyboardParms parms;    movetous((char *)&parms, sregs->es, regs->x.di, sizeof parms);    if ((parms.rc != 0) || (parms.function_id != 0)) {	parms.rc = 0x0c;    } else if (parms.session_id != PS_SESSION_ID) {	parms.rc = 0x02;    } else if (parms.intercept_options != 0) {	parms.rc = 0x01;    } else {	parms.rc = 0;	parms.first_connection_identifier = 0;    }    parms.function_id = 0x62;    movetothem(sregs->es, regs->x.di, (char *)&parms, sizeof parms);}static voiddisconnect_from_keyboard(regs, sregs)union REGS *regs;struct SREGS *sregs;{    DisconnectFromKeyboardParms parms;    movetous((char *)&parms, sregs->es, regs->x.di, sizeof parms);    if ((parms.rc != 0) || (parms.function_id != 0)) {	parms.rc = 0x0c;    } else if (parms.session_id != PS_SESSION_ID) {	parms.rc = 0x02;    } else if (parms.connectors_task_id != 0) {	parms.rc = 04;			/* XXX */    } else {	parms.rc = 0;    }    parms.function_id = 0x62;    movetothem(sregs->es, regs->x.di, (char *)&parms, sizeof parms);}static voidwrite_keystroke(regs, sregs)union REGS *regs;struct SREGS *sregs;{    WriteKeystrokeParms parms;    movetous((char *)&parms, sregs->es, regs->x.di, sizeof parms);    if ((parms.rc != 0) || (parms.function_id != 0)) {	parms.rc = 0x0c;    } else if (parms.session_id != PS_SESSION_ID) {	parms.rc = 0x02;    } else if (parms.connectors_task_id != 0) {	parms.rc = 0x04;    } else {	parms.number_of_keys_sent = 0;	parms.rc = 0;	if (parms.options == OPTION_SINGLE_KEYSTROKE) {	    KeystrokeEntry *entry = &parms.keystroke_specifier.keystroke_entry;	    	    if (AcceptKeystroke(entry->scancode, entry->shift_state) == 0) {		parms.rc = 0x10;		/* XXX needs 0x12 too! */	    }	    parms.number_of_keys_sent++;	} else if (parms.options == OPTION_MULTIPLE_KEYSTROKES) {	    KeystrokeList		list,		far *atlist = parms.keystroke_specifier.keystroke_list;	    KeystrokeEntry		entry[10],		/* 10 at a time */		*ourentry,		far *theirentry;	    int		todo;	    movetous((char *)&list, FP_SEG(atlist),			FP_OFF(atlist), sizeof *atlist);	    todo = list.length/2;	    ourentry = entry+(highestof(entry)+1);	    theirentry = &atlist->keystrokes;	    while (todo) {		if (ourentry > &entry[highestof(entry)]) {		    int thistime;		    thistime = todo;		    if (thistime > numberof(entry)) {			thistime = numberof(entry);		    }		    movetous((char *)entry, FP_SEG(theirentry),			    FP_OFF(theirentry), thistime*sizeof *theirentry);		    theirentry += thistime;		    ourentry = entry;		}		if (AcceptKeystroke(ourentry->scancode,						ourentry->shift_state) == 0) {		    parms.rc = 0x10;		/* XXX needs 0x12 too! */		    break;		}		parms.number_of_keys_sent++;		ourentry++;		todo--;	    }	} else {	    parms.rc = 0x01;	}    }    parms.function_id = 0x62;    movetothem(sregs->es, regs->x.di, (char *)&parms, sizeof parms);/* XXX */}static voiddisable_input(regs, sregs)union REGS *regs;struct SREGS *sregs;{    DisableInputParms parms;    movetous((char *)&parms, sregs->es, regs->x.di, sizeof parms);    if ((parms.rc != 0) || (parms.function_id != 0)) {	parms.rc = 0x0c;    } else if (parms.session_id != PS_SESSION_ID) {	parms.rc = 0x02;    } else if (parms.connectors_task_id != 0) {	parms.rc = 0x04;    } else {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -