ASCII-Armour Module
This module provides routines to armour files and recover them from armoured
files. The routines support both many armoured blocks in one text file
and one binary file split into many armour blocks. However, it has NO file
handling. The open/creating/closing of files is the responsibility of calling
program. The file access is done using port_io
file access functions.
This module consists of the following files:-
-
armour.h: Header file
-
armour.c: Source file
Data Types
enum armour_style
This is an enumeration type indicating the ASCII-armour format. Note that
some of the values are markers for future implementation. The defined
values are:-
-
ARM_NONE
-
No armour; use when armouring to indicate that there is no armour (i.e.
the file is to remain in binary; used when decoding to indicate that no
(further) armoured blocks where found.
-
ARM_PGP_PLAIN
-
This is the armour surrounding a PGP plain-signed block. In this case,
the block starts with initial BEGIN PGP SIGNED MESSAGE line and ends with
immediately before the following signature block. Note that is module considers
that the signature block is a separate block with type ARM_PGP.
-
ARM_PGP
-
This is the normal armour type for all PGP armoured blocks except plain-signed
blocks.
-
ARM_PGP_MULTI
-
This is the same as ARM_PGP except that it implies that the armour
is a multi-part document.
-
ARM_MIME
-
This is the armour type for Multipurpose Internet Mail Extensions (MIME)
format armoured blocks (not implemented).
-
ARM_UUENCODE
-
This is the armour type for Unix-to-Unix-encoding (UUencode) format armoured
blocks.
-
ARM_BINHEX
-
This is the armour type of BinHex format armoured blocks. BinHex is used
on (and normally only on) Apple-Macintoshs (not implemented).
enum armour_return
This is the return/error code returned by certain armour routines.
-
ARM_SUCCESS
-
Successful completion.
-
ARM_LINE_LIMIT
-
Indicates that when armouring a file the line number limit has been reached.
The calling program should open a new output file for the next section
and continuing armouring from the same point in the (binary) input file.
-
ARM_USER_BREAK
-
The user has (via module userbreak) interrupted
the operation.
-
ARM_FILE_ERROR
-
The port_io module has returned an error.
-
ARM_CRC_FAILURE
-
The Cyclic-Redundancy check at the end of the armoured block is wrong.
(Not all formats have CRC checks.)
-
ARM_FORMAT_ERR
-
The armour is not in the correct format.
-
ARM_UNIMPLEMENTED
-
The requested armour algorithm is not implemented. (This specification
includes at least one format which at the time of writing is not implemented.)
struct armour_params
This structure defines the parameters for armouring a file of binary data.
-
char* block_type;
-
Text identifying type of block typically "MESSAGE" or "PUBLIC KEY"
-
char * version;
-
Text identifying software version e.g. "2.6.3ui"
-
armour_style style;
-
The type of armouring to be applied.
-
int number;
-
section number
-
int of;
-
number of sections
-
int max_lines;
-
maximum number of lines; recommend 480 or 0 (no limit).
-
char * * comments;
-
pointer to a NULL terminated array of comment strings; a Comment: line
to be generated for each.
struct armour_info
This structure describes the details of an existing ASCII-armoured block
found in a text file.
-
char name[MAX_BLOCK_NAME];
-
For formats like UUencode that include a file name for PGP takes the block_type
text
-
int number
-
section number
-
int of;
-
number of sections
-
armour_style style;
-
Functions
boolean armour_mode_avail (armour_style
style);
Reports whether or not a particular form of armour is implemented. The
use of this routine is recommended for applications building menus of the
available options.
Finds the next armoured block in inFile and returns the type of
the block and the section numbering details. The file pointer is left prepositioned
for unarmour_block. If no block is found
the values in info are undefined.
armour_return unarmour_block(DataFileP
in, DataFileP out, armour_style style);
Unarmours a block. This should normally be called after
next_armour
when destination filing decisions have been made. The armour_style should
be the value returned by next_armour. The file pointers of in
and out should be prepositioned prior to calling.
armour_return armour_block(DataFileP
in, DataFileP out, armour_params * params);
Armours a block according to the parameters in params.
webmaster@bifroest.demon.co.uk