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

📄 api.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 2 页
字号:
	SetOiaApiInhibit(&OperatorInformationArea);	parms.rc = 0;    }    parms.function_id = 0x62;    movetothem(sregs->es, regs->x.di, (char *)&parms, sizeof parms);}static voidenable_input(regs, sregs)union REGS *regs;struct SREGS *sregs;{    EnableInputParms 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 {	ResetOiaApiInhibit(&OperatorInformationArea);	parms.rc = 0;    }    parms.function_id = 0x62;    movetothem(sregs->es, regs->x.di, (char *)&parms, sizeof parms);}/* * Copy Services. */staticcopy_subroutine(target, source, parms, what_is_user, length)BufferDescriptor *target, *source;CopyStringParms *parms;int what_is_user;#define	USER_IS_TARGET	0#define	USER_IS_SOURCE	1{#define	TARGET_NO_EAB		1#define	SOURCE_NO_EAB		2#define	TARGET_PC		4#define	SOURCE_PC		8#define	NO_FIELD_ATTRIBUTES	16    int needtodo = 0;    int access_length;    char far *input;    char far *output;    char far *access_pointer;    if ((target->characteristics^source->characteristics)		    &CHARACTERISTIC_EAB) {	if (target->characteristics&CHARACTERISTIC_EAB) {	    needtodo |= TARGET_NO_EAB;	/* Need to bump for EAB in target */	} else {	    needtodo |= SOURCE_NO_EAB;	/* Need to bump for EAB in source */	}    }    if (target->session_type != source->session_type) {	if (target->session_type == TYPE_PC) {	    needtodo |= TARGET_PC;	/* scan codes to PC */	} else {	    needtodo |= SOURCE_PC;	/* PC to scan codes */	}    }    if ((parms->copy_mode&COPY_MODE_FIELD_ATTRIBUTES) == 0) {	needtodo |= NO_FIELD_ATTRIBUTES;    }    access_length = length;    if (what_is_user == USER_IS_TARGET) {	if (target->characteristics&CHARACTERISTIC_EAB) {	    access_length *= 2;	}	input = (char far *) &Host[source->begin];	access_pointer = target->buffer;	output = access_api(target->buffer, access_length, 0);    } else {	if (source->characteristics&CHARACTERISTIC_EAB) {	    access_length *= 2;	}	access_pointer = source->buffer;	input = access_api(source->buffer, access_length, 1);	output = (char far *) &Host[target->begin];    }    while (length--) {	if (needtodo&TARGET_PC) {	    *output++ = disp_asc[*input++];	} else if (needtodo&SOURCE_PC) {	    *output++ = asc_disp[*input++];	} else {	    *output++ = *input++;	}	if (needtodo&TARGET_NO_EAB) {	    input++;	} else if (needtodo&SOURCE_NO_EAB) {	    *output++ = 0;		/* Should figure out good EAB? */	}    }    if (what_is_user == USER_IS_TARGET) {	unaccess_api(target->buffer, access_pointer, access_length, 1);    } else {	unaccess_api(source->buffer, access_pointer, access_length, 0);    }}static voidcopy_string(regs, sregs)union REGS *regs;struct SREGS *sregs;{    CopyStringParms parms;    BufferDescriptor *target = &parms.target, *source = &parms.source;    int length;    movetous((char *)&parms, sregs->es, regs->x.di, sizeof parms);    length = 1+parms.source_end-source->begin;    if ((parms.rc != 0) || (parms.function_id !=0)) {	parms.rc = 0x0c;    } else if (target->session_id == BUF_SESSION_ID) {	/* Target is buffer */	if (source->session_id != PS_SESSION_ID) {		/* A no-no */	    parms.rc = 0x2;	} else {	    if ((source->begin < 0) || (source->begin > highestof(Host))) {		parms.rc = 0x06;		/* invalid source definition */	    } else {		if ((source->begin+length) > highestof(Host)) {		    length = highestof(Host)-source->begin;		    parms.rc = 0x0f;	/* Truncate */		}	        if ((source->characteristics == target->characteristics) &&		    (source->session_type == target->session_type)) {		    if (source->characteristics&CHARACTERISTIC_EAB) {			length *= 2;		    }		    movetothem(FP_SEG(target->buffer),			    FP_OFF(target->buffer),			    (char *)&Host[source->begin], length);		} else {		    copy_subroutine(target, source, &parms,							USER_IS_TARGET, length);		}	    }	}    } else if (source->session_id != BUF_SESSION_ID) {	    parms.rc = 0xd;    } else {	/* Send to presentation space (3270 buffer) */	if ((target->begin < 0) || (target->begin > highestof(Host))) {	    parms.rc = 0x07;		/* invalid target definition */	} if (!UnLocked) {		parms.rc = 0x03;	/* Keyboard locked */	} else if (parms.copy_mode != 0) {		parms.rc = 0x0f;	/* Copy of field attr's not allowed */	} else if (IsProtected(target->begin) || /* Make sure no protected */		    (WhereAttrByte(target->begin) !=	/* in range */			    WhereAttrByte(target->begin+length-1))) {		parms.rc = 0x0e;	/* Attempt to write in protected */	} else {	    if ((target->begin+length) > highestof(Host)) {		length = highestof(Host)-target->begin;		parms.rc = 0x0f;	/* Truncate */	    }	    TurnOnMdt(target->begin);	/* Things have changed */	    if ((source->characteristics == target->characteristics) &&		    (source->session_type == target->session_type)) {		if (source->characteristics&CHARACTERISTIC_EAB) {		    length *= 2;		}		movetous((char *)&Host[target->begin],			    FP_SEG(source->buffer),			    FP_OFF(source->buffer), length);	    } else {		copy_subroutine(target, source, &parms, USER_IS_SOURCE, length);	    }	}    }    parms.function_id = 0x64;    movetothem(sregs->es, regs->x.di, (char *)&parms, sizeof parms);}/* * Operator Information Area Services. */static voidread_oia_group(regs, sregs)union REGS *regs;struct SREGS *sregs;{    ReadOiaGroupParms 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 {	int group = parms.oia_group_number;	char *from;	int size;	if ((group != API_OIA_ALL_GROUPS) &&		((group > API_OIA_LAST_LEGAL_GROUP) || (group < 0))) {	} else {	    if (group == API_OIA_ALL_GROUPS) {		size = API_OIA_BYTES_ALL_GROUPS;		from = (char *)&OperatorInformationArea;	    } else if (group == API_OIA_INPUT_INHIBITED) {		size = sizeof OperatorInformationArea.input_inhibited;		from = (char *)&OperatorInformationArea.input_inhibited[0];	    } else {		size = 1;		from = ((char *)&OperatorInformationArea)+group;	    }	    movetothem(FP_SEG(parms.oia_buffer), FP_OFF(parms.oia_buffer),			from, size);	}    }    parms.function_id = 0x6d;    movetothem(sregs->es, regs->x.di, (char *)&parms, sizeof parms);}/*ARGSUSED*/static voidunknown_op(regs, sregs)union REGS *regs;struct SREGS *sregs;{    regs->h.ch = 0x12;    regs->h.cl = 0x05;}handle_api(regs, sregs)union REGS *regs;struct SREGS *sregs;{/* * Do we need to log this transaction? */    if (apitrace) {	Dump('<', (char *)regs, sizeof *regs);	Dump('<', (char *)sregs, sizeof *sregs);    }    if (regs->h.ah == NAME_RESOLUTION) {	name_resolution(regs, sregs);#if	defined(unix)    } else if (regs->h.ah == PS_OR_OIA_MODIFIED) {	while ((oia_modified == 0) && (ps_modified == 0)) {	    (void) Scheduler(1);	}	oia_modified = ps_modified = 0;#endif	/* defined(unix) */    } else if (regs->h.ah != 0x09) {	regs->h.ch = 0x12;	regs->h.cl = 0x0f;		/* XXX Invalid environmental access */    } else if (regs->x.bx != 0x8020) {	regs->h.ch = 0x12;	regs->h.cl = 0x08;		/* XXX Invalid wait specified */    } else if (regs->h.ch != 0) {	regs->x.cx = 0x1206;		/* XXX Invalid priority */    } else {	switch (regs->x.dx) {	case GATE_SESSMGR:	    switch (regs->h.al) {	    case QUERY_SESSION_ID:		if (regs->h.cl != 0) {		    regs->x.cx = 0x1206;		} else {		    regs->x.cx = 0x1200;		    query_session_id(regs, sregs);		}		break;	    case QUERY_SESSION_PARAMETERS:		if (regs->h.cl != 0) {		    regs->x.cx = 0x1206;		} else {		    regs->x.cx = 0x1200;		    query_session_parameters(regs, sregs);		}		break;	    case QUERY_SESSION_CURSOR:		if ((regs->h.cl != 0xff) && (regs->h.cl != 0x00/*OBS*/)) {		    regs->x.cx = 0x1206;		} else {		    regs->x.cx = 0x1200;		    query_session_cursor(regs, sregs);		}		break;	    default:		unknown_op(regs, sregs);		break;	    }	    break;	case GATE_KEYBOARD:	    if (regs->h.cl != 00) {		regs->x.cx = 0x1206;	    } else {		regs->x.cx = 0x1200;		switch (regs->h.al) {		case CONNECT_TO_KEYBOARD:		    connect_to_keyboard(regs, sregs);		    break;		case DISABLE_INPUT:		    disable_input(regs, sregs);		    break;		case WRITE_KEYSTROKE:		    write_keystroke(regs, sregs);		    break;		case ENABLE_INPUT:		    enable_input(regs, sregs);		    break;		case DISCONNECT_FROM_KEYBOARD:		    disconnect_from_keyboard(regs, sregs);		    break;		default:		    unknown_op(regs, sregs);		    break;		}	    }	    break;	case GATE_COPY:	    if (regs->h.cl != 0xff) {		regs->x.cx = 0x1206;	    } else {		regs->x.cx = 0x1200;		switch (regs->h.al) {		case COPY_STRING:		    copy_string(regs, sregs);		    break;		default:		    unknown_op(regs, sregs);		    break;		}	    }	    break;	case GATE_OIAM:	    if (regs->h.cl != 0xff) {		regs->x.cx = 0x1206;	    } else {		regs->x.cx = 0x1200;		switch (regs->h.al) {		case READ_OIA_GROUP:		    read_oia_group(regs, sregs);		    break;		default:		    unknown_op(regs, sregs);		    break;		}	    }	    break;	default:	    regs->h.ch = 0x12;	    regs->h.cl = 0x34;		/* Invalid GATE entry */	    break;	}    }/* * Do we need to log this transaction? */    if (apitrace) {	Dump('>', (char *)regs, sizeof *regs);	Dump('>', (char *)sregs, sizeof *sregs);#ifdef	MSDOS	{ char buf[10];  gets(buf); }#endif	/* MSDOS */    }}

⌨️ 快捷键说明

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