home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 5
/
DATAFILE_PDCD5.iso
/
utilities
/
a
/
armedit
/
Docs
/
Code
< prev
next >
Wrap
Text File
|
1997-02-21
|
13KB
|
389 lines
File : Code
Date : 21-Feb-97
Author : © A.Thoukydides, 1995, 1996, 1997
Description : Description of the support for writing extra PC side utilities
using the supplied files.
INTRODUCTION
The ARMEdit suite has been designed to allow other software to developers to
add extra utilities to those supplied; all of the necessary files are
included in the standard distribution.
The PC side files were prepared using Borland Turbo C++ version 3.0 for DOS,
but they use C linkage and should be compatible with other compilers. Veneers
to allow the ARMEdit SWIs to be called from C/C++ were assembled using Acorn
ObjAsm version 3.06, and should be used in conjunction with Jonathan
Coxhead's OSLib.
FILES INCLUDED
The following header files are included in this distribution for use on the
PC side:
ARMFILE.H High level routines for copying individual files between
DOS and RISC OS. These perform the core of the GETFILE and
PUTFILE utilities. They provide an easy way of transferring
large amounts of data between the two environments.
CLI.H Functions to call RISC OS *commands with different levels of
input and output redirection.
SWI.H This provides a single function to call a RISC OS SWI by name
from the PC. This should not normally be used, because it is
very inefficient, but is useful when prototyping code.
TALK.H This is the main interface to the RISC OS services. It
provides routines for performing generally useful functions,
e.g. allocating and deallocating memory,
All of the required object files to be linked with are included in a single
library file:
ARMEDIT.LIB
The following header files are included for use under RISC OS:
h.armeditswi C interface functions to all of the SWIs provided by the
ARMEdit module. See Docs.Module for details of all the
SWIs.
A single object file is included containing the assembled veneers:
o.armeditswi
FUNCTIONS PROVIDED
The following sections give brief descriptions of the functions provided in
each header file. For more details read the comments in the header files
themselves.
The provided services should allow almost any operation to be performed.
However, please get in touch if extra features would be useful - if they are
sufficiently general they may get added in a future release of the ARMEdit
module.
ARMFILE.H
armfile_copy_dos_riscos
Copy a file from RISC OS to DOS.
armfile_copy_riscos_dos
Copy a file from DOS to RISC OS.
armfile_translate_dos_riscos
Convert a DOS filename into a RISC OS equivalent. This performs
substitutions similar to those performed by DOSFS.
armfile_translate_riscos_dos
Convert a RISC OS filename into a DOS equivalent. This performs the
opposite operation to armfile_translate_dos_riscos.
armfile_temporary
Generate the filename for a temporary RISC OS file, and ensure it is
deleted before the program exits.
armfile_create_dir
Create a RISC OS directory.
CLI.H
cli_simple
A simple *command interface. If output redirection is required then it
is performed via a file.
cli_redir
A more comprehensive *command interface. Both input and ouput can be
redirected to/from any DOS stream or file. Special action is taken if
the streams correspond to the keyboard or screen.
SWI.H
swi_swi
Call a specified RISC OS SWI by its name. As mentioned above this is a
very inefficient operation to perform, so should normally only be used
during development stages of new software.
TALK.H
talk_swi
Call a RISC OS SWI by number. It should be remembered that the SWI can
not read PC memory directly; the required data must be copied using the
other functions provided in the talk module.
talk_read
Read a block of RISC OS memory.
talk_write
Write a block of RISC OS memory.
talk_malloc
Claimed the specified amount of RISC OS memory. The memory should be
released using talk_free. However, it will automatically be freed when
the PC card is either reset or quit; ensuring that all claimed memory
is eventually deallocated even if the PC software terminates abnormally.
talk_free
Free a block of memory previously claimed using talk_malloc.
talk_ext_to_filetype
Convert a DOS file extension into a RISC OS filetype. This uses the
list of mappings set by the DOSMap command. See Docs.Module for more
details.
talk_filetype_to_ext
Convert a RISC OS filetype into a DOS file extension. This uses the
list of mappings set by the DOSMap command. See Docs.Module for more
details.
talk_file_open
Open a RISC OS file. It is possible to specify that the file should
automatically be deleted when it is closed; useful for temporary files.
The file should be closed using talk_file_close. However, it will
automatically be closed when the PC card is either reset or quit;
ensuring that all files are eventually closed (and deleted if required)
even if the PC software terminates abnormally.
talk_file_close
Close a RISC OS file previously opened using talk_file_open.
talk_file_read
Read a block of memory from a RISC OS file.
talk_file_write
Write a block of memory to a RISC OS file.
talk_comms_start
Register a communications client.
talk_comms_end
Deregister a communications client.
talk_comms_tx
Transmit a message to another client.
talk_comms_rx
Receive a message from another client.
talk_date_to_dos
Convert a date and time from RISC OS to DOS format.
talk_date_to_riscos
Convert a date and time from DOS to RISC OS format.
talk_comms_reply
Reply to a message from another client.
talk_faster
Disable multitasking for faster operations.
talk_temporary
Generate a unique filename for a temporary RISC OS file.
MESSAGE PASSING
The ARMEdit module provides a general method for PC software to communicate
with RISC OS applications or modules. The system is intentionally left
simple; many aspects are left to users of the protocol to implement as
required, e.g. detection and handling of problems, and the format and useage
of different messages.
The system allows multiple simultaneous clients, both under RISC OS and on
the PC. This makes it suitable for use in multi-tasking (or task
switching) environments such as Windows. Each client has a 4 byte ID which is
preallocated (by me, on request) and a 4 byte dynamically allocated (by the
ARMEdit module) handle. There are two special IDs: ID 0 is always used by PC
software, and ID 1 is used to broadcast messages to all clients (this is
explained in more detail below). Other IDs are allocated to different
services being provided. If a program provides a number of distinct services,
or if required for some other reason, it may have more than one ID. The range
of IDs 2 to 255 may be freely used for development purposes, but must not be
used by distributed software.
When messages are sent to ID 1 they are passed to all clients which accept
messages from the ARMEdit module (as specified when the clients register).
This is normally only used for a few specific messages (described in the
next section) which are useful to many clients. Other clients should not use
this facility except under special circumstances.
It is intended that each client provides a number of related services for a
particular ID, but it is up to the authors of clients to decide how the
message contents should be used. However, it is recommended that a service
selector field is placed at the start of all messages.
Each client has a message buffer (allocated by the ARMEdit module) used to
transmit messages. This buffer is of a fixed size (1kB) and can only contain
a single message. Attempting to send a message with one already in the buffer
overwrites the earlier message, regardless of how many clients it has been
delivered to.
To enable easy impleme