PACKET(3)

NAME
packet - manipulate raw PGP packets

SYNOPSIS
#include <pgplib.h>
int
read_packet(FILE *fd, u_char **packet);
int
find_packet_in_buffer(u_char buf, int buflen, u_char **packet);
int
packet_length(u_char *buf);

DESCRIPTION
The routines read_packet() and find_packet_in_buffer() lets you read a packet from a file or a buffer, respectively. The memory used to hold the result is obtained by means of malloc and should be freed when no longer needed. packet_length() finds the real length of a PGP packet and can be used to find the size of the packets returned by the other two routines. buf must point to the CTB and 1, 2 or 4 consecutive bytes are accessed to find the length.

RETURN VALUES
The first two routines return 0 if a packet was found and sucessfully copied into the buffer. If no packet was found, the buffer is compressed, or an error occured, -1 is returned. pgplib_errno is set to indicate the cause. packet_length() returns the length of the packet, including header.

SEE ALSO
malloc(3) free(3) PGPlib(3)

BUGS
If you call this routines with random data, they will take revenge without delay. This is particulary true for packet_length().

HISTORY
Written by Tage Stabell-Kulų. First appeared in PGPlib 0.1