home *** CD-ROM | disk | FTP | other *** search
- 7 EXEC LIBRARY
-
- 7.1 OPEN THE EXEC LIBRARY
-
- The Exec Library is automatically opened when your program is
- loaded, so you do not have to open it yorself. The functions
- listed in this fil e can therefore directly be used.
-
-
-
- 7.2 FUNCTIONS
-
- AbortIO()
-
- This function will try to abort a previously started request.
- Of course, only asynchronous commands can be aborted, and if
- the request has already been completed it can not be aborted
- any more.
-
- Synopsis: AbortIO( req )
-
- req: (struct IORequest *) Pointer to the request you
- want to abort.
-
-
-
- AddHead()
-
- This function will add a note at the head of a list.
-
- Synopsis: AddHead( list, node )
-
- list: (struct List *) Pointer to the list you wish to
- insert the node in.
-
- node: (struct Node *) Pointer to the node you want to
- insert.
-
-
-
- AddTail()
-
- This function will add a note at the tail of a list.
-
- Synopsis: AddTail( list, node )
-
- list: (struct List *) Pointer to the list you wish to
- insert the node in.
-
- node: (struct Node *) Pointer to the node you want to
- insert.
-
-
-
- AllocMem()
-
- This function allocates memory. You specifies what type and
- how much you want, and it returns a pointer to the allocated
- memory, or NULL if there did not exist enough memory.
-
- Synopsis: memory = AllocMem( size, type );
-
- memory: (void *) Pointer to the new allocated memory, or
- NULL if no memory could be allocated. Remember!
- Never use memory which you have not successfully
- allocated.
-
- size: (long) The size (in bytes) of the memory you want.
- (AllocMem() always allocates memory in multiples of
- eight bytes. So if you only ask for 9 bytes, Exec
- would actually give you 16 Bytes (2*8).)
-
- type: (long) You need to choose one of the three
- following types of memory (see chapter 0
- INTRODUCTION for more information about Chip and
- Fast memory):
-
- MEMF_CHIP Chip memory. This memory can be
- accessed by both the main processor, as
- well as the Chips. Graphics/Sound data
- MUST therefore be placed in Chip memory.
- If it does not matter what type of
- memory you get (Fast or Chip), you
- should try to allocate Fast memory
- before you allocate Chip memory. (Chip
- memory is more valuable than Fast
- memory.)
-
- MEMF_FAST Fast memory. This memory can only be
- accessed by the main processor.
- (Graphics and Sound data can NOT be
- stored in Fast memory, use Chip memory.)
- This memory is normally a little bit
- faster than Chip memory, since only the
- main processor is working with it, and
- it is not disturbed by the Chips.
-
- MEMF_PUBLIC If it does not matter what type of
- memory you get (you do not intend to
- use the memory for Graphics/Sound data),
- you should use Fast memory. However,
- all Amigas do not have Fast memory,
- since you need to by a memory expansion
- in order to get it. If want to tell
- Exec that you would like to use Fast
- memory if there is any, else use Chip
- memory, you should ask for MEMF_PUBLIC.
-
- If you want the allocated memory to be cleared
- (initialized to zeros), you should set the flag
- MEMF_CLEAR.
-
-
-
- BeginIO()
-
- This function will send request blocks to a device. This
- function is "asynchronous" which means that your program will
- continue to run while the device is executing your command.
-
- This function is very similar to SendIO(). The difference is
- that this function will not clear some values in the request
- block. If you are using the Audio Device or is using the
- "Quick Mode" you should use this function.
-
- Synopsis: BeginIO( req )
-
- req: (struct IORequest *) Pointer to the request you
- want to have executed. When you want to use the
- quick mode you have to use this low level function
- rather than SendIO() and DoIO().
-
-
-
- CheckIO()
-
- This function will check if an asynchronous request has been
- completed or not.
-
- Synopsis: ptr = CheckIO( req );
-
- ptr: (long) CheckIO() will either return NULL if the
- request have not been completed or it will return a
- pointer to the request block.
-
- req: (struct IORequest *) Pointer to the request you
- want to check.
-
-
-
- CloseDevice()
-
- This function will close a previously opened device. All
- devices you have opened must be closed before your program
- may terminate.
-
- Synopsis: CloseDevice( req );
-
- reg: (struct IORequest *) Pointer to the device's
- request block.
-
-
-
- CreateExtIO()
-
- This function will allocate and initialize an extended request
- block of any desired size (must not be smaller than a normal
- IORequest structure). The size depends on which device the
- request block should be used with.
-
- Synopsis: ext_req = CreateExtIO( msg_port, size );
-
- ext_req: (struct IORequest *) Pointer to the new extended
- request block, or NULL if the request block could
- not be created.
-
- msg_port: (struct MsgPort *) Pointer to the message port
- the device should use to communicate with you.
-
- size: (long) The number of bytes that should be allocated
- for the extended request block. Use the function
- sizeof() to find the exact number of bytes needed.
-
-
-
- CreatePort()
-
- CreatePort() allocates and initializes a MsgPort structure.
- If you give it a string as first parameter it will also make
- the port public. (A port that has a name can be found by
- other tasks and is therefore "public".) If CreatePort() of
- some reason could not create a message port it returns NULL,
- otherwise if everything is OK it returns a pointer to the
- new MsgPort structure.
-
- Synopsis: msgp = CreatePort( name, pri );
-
- msgp: (struct MsgPort *) Pointer to the new MsgPort
- structure, or NULL if something went wrong.
-
- name: (char *) Pointer to a string containing the name
- of the message port, or NULL. If it is a string
- the port will be made public (so other tasks can
- find it) else only our task can use it.
-
- msgp: (struct MsgPort *) Pointer to the MsgPort structure
- that should be allocated.
-
- pri: (BYTE) This message port's priority. Usually set
- to 0 - normal priority.
-
-
-
- CreateStdIO()
-
- This function will allocate and initialize a standard request
- block (IORequest structure).
-
- Synopsis: std_req = CreateStdIO( msg_port );
-
- std_req: (struct IORequest *) Pointer to the new standard
- request block (struct IOStdReq *), or NULL if the
- request block could not be created.
-
- msg_port: (struct MsgPort *) Pointer to the message port
- the device should use to communicate with you.
-
-
-
- DeletePort()
-
- DeletePort() will close a message port that is presently
- open. All ports that has been created must be closed before
- the program may terminate.
-
- Synopsis: DeletePort( msgp );
-
- msgp: (struct MsgPort *) Pointer to the MsgPort structure,
- that should be closed.
-
-
-
- DeleteStdIO()
-
- This function will delete a standard request block you
- previouly have created with help of the CreateStdIO()
- function. Remember that all request block you have
- allocated must be deallocated before your program
- terminates!
-
- Synopsis: DeleteStdIO( std_req );
-
- std_req: (struct IOStdReq *) Pointer to the standard
- request block you want to delete.
-
-
-
- DeleteExtIO()
-
- This function will delete an extended request block you
- previouly have created with help of the CreateExtIO()
- function. Note that the size must be set to the same value
- as when you created the request block. Remember that all
- request block you have allocated must be deallocated before
- your program terminates!
-
- Synopsis: DeleteExtIO( std_req, size );
-
- std_req: (struct IOStdReq *) Pointer to the extended
- request block you want to delete.
-
- size: (long) The size of the request block, in bytes.
-
-
-
- Disable()
-
- This function will lock out all other tasks and even
- interrupts are stopped. As long as you are in this disabled
- mode no other processes or interrupts will be executed. If
- you put your task to sleep with a Wait() call will the
- disable mode temporarily be stopped and other tasks and
- interrupts may be executed again. However, when your program
- wakes up again will the disabled mode start again. The only
- way to really stop the disabled mode is to use the Enable()
- function.
-
- Note that the disable mode will not even allow interrupts
- from being executed. This can be very dangerous since there
- are a lot of important interrupts on the Amiga that should
- not be forced to wait. You should therefore only use the
- disabled mode for very short periods.
-
- Synopsis: Disable();
-
-
-
- DoIO()
-
- This function is used to send request blocks to a device.
- This function is "synchronous" which means that your program
- will automatically be put to sleep while the device is
- executing your command. Once it has finished your program
- will wake up. Since your program is put to sleep ("task
- sleep") no processing time is waisted while you are waiting
- for your request to be completed.
-
- Synopsis: error = DoIO( req );
-
- error: (long) DoIO() will return first when the request has
- been completed or something has failed. If the
- request was successfully completed zero is returned,
- else an error number is returned. What error number
- depends on which device was used. See below for a
- complete list of standard error commands.
-
- req: (struct IORequest *) Pointer to the request you
- want to have executed.
-
-
-
- Enable()
-
- This function will permit other tasks and interrupts to be
- executed again after previously have been disabled by the
- Disable() function.
-
- Synopsis: Enable();
-
-
-
- Enqueue()
-
- This function will insert nodes into lists considering the
- node's priority. The higher priority the closer to the head
- they are placed and vice versa.
-
- NOTE! This function can of course not be used to handle mini
- lists. (Mini nodes do not have any priority field.)
-
- Synopsis: Enqueue( list, node );
-
- list: (struct List *) Pointer to the list you wish to
- insert the node in.
-
- node: (struct Node *) Pointer to the node you want to
- insert.
-
-
-
- FindName()
-
- This function will scan a list and search for nodes by their
- name. It will return a pointer to the first node with the
- specified name or NULL if no more node could be found. If it
- found a node you simply have to call it again to find the
- next.
-
- NOTE! This function can of course not be used to handle mini
- lists. (Mini nodes do not have any name field.)
-
- Synopsis: node = FindName( list, name );
-
- node: (struct Node *) If FindName() finds a node with the
- name "name" it returns a pointer to it. If no node
- was found it returns NULL.
-
- list: (struct List *) Pointer to the list you want to
- examine. If you have already found a node and want
- to search for the next you should give it a pointer
- to the last node you found.
-
- name: (char *) Pointer to a NULL terminated string that
- contains the name of the node(s) you look for.
-
-
-
- FindPort()
-
- FindPort() will try to locate an already existing message
- port. If the function finds the port it returns a pointer to
- it, else the function returns NULL.
-
- Synopsis: msgp = FindPort( name );
-
- msgp: (struct MsgPort *) FindPort() will return a pointer
- to the port we asked for, or NULL if it could not
- find it.
-
- name: (char *) Pointer to a string containing the name of
- the port we are looking for.
-
-
-
- Forbid()
-
- This function will lock out all other tasks. As long as you
- are in this forbidden mode no other processes will be
- executed. If you put your task to sleep with a Wait() call
- will the forbidden mode temporarily be stopped and other
- tasks may run again. However, when your program wakes up
- again will the forbidden mode start again. The only way to
- really stop the forbidden mode is to use the Permit()
- function.
-
- Synopsis: Forbid();
-
-
-
- FreeMem()
-
- This function deallocated previously allocated memory.
- Remember to deallocate all memory you have taken, and never
- deallocate memory which you have not taken.
-
- Synopsis: FreeMem( memory, size );
-
- memory (void *) Pointer to some memory which has
- previously been allocated. Remember! never use
- memory which has been deallocated.
-
- size (long) The size (in bytes) of the memory you want
- to deallocate.
-
-
-
- GetMsg()
-
- GetMsg() will try to remove a message from the port's
- message list, and return a pointer to the message. If it
- could not find any message it returns NULL. Before your
- program terminates it should try to collect all waiting
- messages.
-
- Synopsis: msg = GetMsg( msgp );
-
- msg: (struct Message *) If GetMsg() could find a
- message at the port it returns a pointer to the
- message, and removes the message from the queue.
- If no message was found, it returns NULL.
-
- msgp: (struct MsgPort *) Pointer to the message port you
- want to get the message from.
-
-
-
- Insert()
-
- This function is used to insert nodes into a list. If the
- node should be placed first or last in the list you should
- use the faster functions AddHead() or AddTail().
-
- Synopsis: Insert( list, node, pred );
-
- list: (struct List *) Pointer to the list you wish to
- insert the node in.
-
- node: (struct Node *) Pointer to the node you want to
- insert.
-
- pred: (struct Node *) Pointer to a node which the new
- node should be placed after. (If this field is NULL
- or points to the list header the node will be
- inserted first in the list. If this field points to
- the list's lh_Tail field the node will be inserted
- last in the list. However, if you which to insert
- a node first or last in a list you should use the
- faster functions AddHead() or AddTail().)
-
-
-
- NewList()
-
- This function initializes a list structure.
-
- Synopsis: NewList( list );
-
- list: (struct List *) Pointer to the list that should be
- initialized.
-
-
-
- OpenDevice()
-
- This function will open a specified device. Remember that you
- must always open the device before you may start to use it.
-
- Synopsis: error = OpenDevice( name, unit, req, flags );
-
- error: (long) If OpenDevice() managed to open the device
- it returns 0, else an error number is returned.
-
- name: (char *) Name of the device you want to open.
- See the following chapters for more information.
-
- unit: (long) Which unit you want to open. Some devices
- does not have several units and this field is then
- ignored.
-
- req: (struct IORequest *) Pointer to a request block.
- Note that some devices may need a larger extended
- request blocks.
-
- flags: (long) Special flags may sometimes be used here,
- otherwise this field is ignored.
-
-
-
- Permit()
-
- This function will permit other tasks to run again after
- previously have been forbidden by the Forbid() function.
-
- Synopsis: Permit();
-
-
-
- PutMsg()
-
- PutMsg() will put a message at the end of the port's queue
- of messages. Note that after you have sent a message you may
- not read or alter it until the other task has replied!
-
- Synopsis: PutMsg( msgp, message );
-
- msgp: (struct MsgPort *) Pointer to the message port
- to which you want to send a message.
-
- message: (struct Message *) Pointer to the whole message
- area.
-
-
-
- RemHead()
-
- This function will remove a note at the head of a list and
- returns a pointer to the removed node.
-
- Synopsis: node = RemHead( list )
-
- list: (struct List *) Pointer to the list you wish to
- remove the head node from.
-
- node: (struct Node *) Pointer to the node you have
- removed, or NULL if there were no more nodes to
- remove.
-
-
-
- Remove()
-
- This function is used to remove nodes from a list. If the
- node should be removed at the tail of the list you should use
- the faster functions RemHead() or RemTail().
-
- Synopsis: Remove( node );
-
- node: (struct Node *) Pointer to the node you want to
- insert.
-
- Here is an example how to remove the node "author":
-
-
-
- RemTail()
-
- This function will remove a note at the tail of a list and
- returns a pointer to the removed node.
-
- Synopsis: node = RemTail( list )
-
- list: (struct List *) Pointer to the list you wish to
- remove the tail node from.
-
- node: (struct Node *) Pointer to the node you have
- removed, or NULL if there were no more nodes to
- remove.
-
-
-
- ReplyMsg()
-
- This function tells Intuition that you have finished reading
- the message. Remember, once you have replied you may not
- examine or change the IntuiMessage structure any more.
-
- Synopsis: ReplyMsg( my_message );
-
- my_message: (struct Message *) Pointer to a Message
- structure, in this case a pointer to an
- IntuiMessage structure.
-
-
-
- SendIO()
-
- This function is used to send request blocks to a device.
- This function is "asynchronous" which means that your program
- will continue to run while the device is executing your
- command.
-
- Synopsis: SendIO( req )
-
- req: (struct IORequest *) Pointer to the request you
- want to have executed.
-
-
-
- Wait()
-
- Wait() will put the task to sleep, and will first wake up
- when one of the specified signal bits arrives. The advantage
- with this function compared to WaitPort() is that you can
- monitor several message ports at the same time. You only
- need to tell Wait() which signal you want to wait for, and
- once one or more of them arrives the task is put to work
- again.
-
- Synopsis: rsig = Wait( wsig )
-
- rsig: (ULONG) When one of the specified signal bits was
- received, the task is woken up and Wait() returns
- the signal bit value that woke it up.
-
- wsig: (ULONG) Wait() will put the task to sleep, and it
- will only wake up if one of the specified signal
- bit values is received.
-
-
-
- WaitIO()
-
- This function will put your program to sleep and wait for the
- asynchronous request to be completed. Your program will first
- wake up when the device has finished your request. WaitIO()
- will automatically remove the message at the reply port.
-
- Synopsis: error = WaitIO( req );
-
- error: (long) WaitIO() will return first when the request,
- that has previously been sent, has been completed
- or something has failed. If the request was
- successfully completed zero is returned, else an
- error number is returned. What error number depends
- on which device was used.
-
- req: (struct IORequest *) Pointer to the request you
- want to wait for to be completed. Note that the
- request must have already been sent to the device
- by either a SendIO() or BeginIO() function call. If
- the request has already been completed WaitIO()
- will immediately return.
-
-
-
- WaitPort()
-
- WaitPort() will put the task to sleep, and will first wake
- up when a message arrives. While the task is sleeping it does
- not use any computer time.
-
- Synopsis: msg = WaitPort( msgp );
-
- msg: (struct Message *) When a message arrives the task
- is woken up and WaitPort() returns a pointer to the
- first message that has arrived. (There may arrive
- several messages at the same time.)
-
- msgp: (struct MsgPort *) Pointer to the message port you
- want to wait at.
-
-
-