(* Title:   xferrecv.h
 * Purpose: general purpose import of data by dragging icon
 *
 *)

#ifndef __xferrecv_h
#define __xferrecv_h


(* -------------------------- xferrecv_checkinsert -------------------------
 * Description:   Set up the acknowledge message for a MDATAOPEN or MDATALOAD
 *                and get filename to load from.
 *
 * Parameters:    char **filename -- returned pointer to filename
 * Returns:       the file's type (eg. 0x0fff for !Edit)
 * Other Info:    This function checks to see if the last wimp event was a 
 *                request to import a file. If so it returns file type and
 *                a pointer to file's name is put into *filename. If not
 *                it returns -1.   
 *
 *)
function xferrecv_checkinsert(var filename : string) : integer; extern;


(* --------------------------- xferrecv_insertfileok -----------------------
 * Description:   Deletes scrap file (if used for transfer), and sends
 *                acknowledgement of MDATALOAD message.
 *
 * Parameters:    void
 * Returns:       void.
 * Other Info:    none.
 *
 *)
procedure xferrecv_insertfileok; extern;


(* --------------------------- xferrecv_checkprint -------------------------
 * Description:   Set up acknowledge message to a MPrintTypeOdd message
 *                and get file name to print.
 *
 * Parameters:    char **filename -- returned pointer to filename
 * Returns:       The file's type (eg. 0x0fff for !Edit).
 * Other Info:    Application can either print file directly or convert it to
 *                <Printer$Temp> for printing by the printer application.
 *
 *)
function xferrecv_checkprint(var filename : string) : integer; extern;


(* --------------------------- xferrecv_printfileok ------------------------
 * Description:   Send an acknowledgement back to printer application. If
 *                file sent to <Printer$Temp> then this also fills in file
 *                type in message.
 *
 * Parameters:    int type -- type of file sent to <Printer$Temp> 
 *                            (eg. 0x0fff for !edit)
 * Returns:       void.
 * Other Info:    none.
 *
 *)
procedure xferrecv_printfileok(_type : integer); extern;


(* ---------------------------- xferrecv_checkimport -----------------------
 * Description:   Set up acknowledgement message to a MDATASAVE message.
 *
 * Parameters:    int *estsize -- sender's estimate of file size
 * Returns:       File type.
 * Other Info:    none.
 *
 *)
function xferrecv_checkimport(var estsize : integer) : integer; extern;


(* ------------------------- xferrecv_buffer_processor ---------------------
 * Description:   This is a typedef for the caller-supplied function
 *                to empty a full buffer during data transfer.
 *
 * Parameters:    char **buffer -- new buffer to be used
 *                int *size -- updated size
 * Returns:       return FALSE if unable to empty buffer or create new one.
 * Other Info:    This is the function (supplied by application,) which will
 *                be called when buffer is full. It should empty the current
 *                buffer, or create more space and modify size accordingly
 *                or return FALSE. *buffer and *size are the current buffer
 *                and its size on function entry.
 *
 *)
type xferrecv_buffer_processor = ^function buffer_processor(
                                        var buffer : pointer;
                                        var size : integer) : boolean;



(* ---------------------------- xferrecv_doimport --------------------------
 * Description:   Loads data into a buffer, and calls the caller-supplied
 *                function to empty the buffer when full.
 *
 * Parameters:    char *buf -- the buffer
 *                int size -- buffer's size
 *                xferrecv_buffer_processor -- caller-supplied function to
 *                                             be called when buffer full
 * Returns:       Number of bytes transferred on successful completion
 *                or -1 otherwise.
 * Other Info:    none.
 *
 *)
function xferrecv_doimport(buf : pointer;
                size : integer;
                p : xferrecv_buffer_processor) : integer; extern;



(* ---------------------- xferrecv_file_is_safe ----------------------------
 * Description:   Informs caller if file was recieved from a "safe" source
 *                (see below for definition of "safe").
 *
 * Parameters:    void
 * Returns:       true if file is safe.
 * Other Info:    "Safe" in this context means that the supplied filename
 *                will not change in the foreseeable future.
 *
 *)
function xferrecv_file_is_safe : boolean; extern;

#endif

(* end xferrecv.h *)
