beautypg.com

Comtrol API (6508) for the MS-DOS User Manual

Page 27

background image

27

API Functions

aaInit

aaInit

Executes controller and

API

initialization.

aaInit()

unsigned int

NO_ERR

if no initialization
errors

ERR_ALLOCDEV

if it can not
allocate device
structure

ERR_CTLINIT

if controller
initialization
error

ERR_CHANINIT

if channel
initialization
error

ERR_DEVSIZE

if invalid number
of devices found

ERR_CTLSIZE

if invalid number
of controllers
found

This function must be called once before calling any
other

API

function except aaInstallCtrlCHandler(). The

controller initialization parameters is obtained from
the configuration file given by environment variable

ROCKETCFG

.

Once aaInit() has been called, aaExit() must be called
before exiting the application program.

If the application program can be exited using the

CTRL+C

or

CTRL+BREAK

keys, then the default

DOS

CTRL+C

handler must be replaced with a handler that

calls aaExit(). You can use the aaInstallCtrlCHandler()
function can be used for this purpose.

Function

Purpose

Call

Return

Comments

Warning

aaInstallCtrlCHandler

Installs a handler for the

CTRL+C

key interrupt.

aaInstallCtrlCHandler()

void

This function replaces the existing

CTRL+C

(interrupt

23H) handler with a handler that performs the
following actions:
1.

Calls aaExit().

2.

Sets the carry flag to signal

DOS

to terminate the

application.

3.

Executes a far return.

DOS

restores the original

CTRL+C

handler when

terminating the application.
aaInstallCtrlCHandler() is the only

API

function that can

be called before calling aaInit(). If you plan on using the
aaInstallCtrlCHandler() function, we recommend calling
it either immediately before or immediately after the
call to the aaInit() function.
If you want different

CTRL+C

processing, you must

write and install your own custom

CTRL+C

handler.

Refer to the Microsoft

MS-DOS

Programmer's Reference

for more information. To aid in writing your own
handler, the source code for aaInstallCtrlCHandler() and
the handler it installs are given below:

void aaInstallCtrlCHandler(void)
{
dos_setvect(0x23,(void (interrupt far
*)())aaCtrlCIntHandler);
}

void far aaCtrlCIntHandler(void)
{
aaExit();
asm stc;
}

If the application program can be exited using the

CTRL+C

or

CTRL+BREAK

keys, then the default

DOS

CTRL+C

handler must be replaced with a handler that

calls aaExit(). You can use the aaInstallCtrlCHandler()
function for this purpose.

Function

Purpose

Call

Return

Comments

Warning