xferrecv 5.47 KB
Newer Older
Neil Turton's avatar
Neil Turton committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
/* Copyright 1996 Acorn Computers Ltd
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/****************************************************************************
 * This source file was written by Acorn Computers Limited. It is part of   *
 * the RISCOS library for writing applications in C for RISC OS. It may be  *
 * used freely in the creation of programs for Archimedes. It should be     *
 * used with Acorn's C Compiler Release 3 or later.                         *
 *                                                                          *
 ***************************************************************************/

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

#ifndef __xferrecv_h
#define __xferrecv_h

#ifndef BOOL
#define BOOL int
#define TRUE 1
#define FALSE 0
#endif


/* -------------------------- 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.
 *
 */

int xferrecv_checkinsert(char **filename);


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

void xferrecv_insertfileok(void);


/* --------------------------- 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.
 *
 */

int xferrecv_checkprint(char **filename);


/* --------------------------- 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.
 *
 */

void xferrecv_printfileok(int type);


/* ---------------------------- 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.
 *
 */

int xferrecv_checkimport(int *estsize);


/* ------------------------- 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.
 *
 */

typedef BOOL (*xferrecv_buffer_processor)(char **buffer, int *size);



/* ---------------------------- 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.
 *
 */

int xferrecv_doimport(char *buf, int size, xferrecv_buffer_processor);



/* ---------------------- 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.
 *
 */

BOOL xferrecv_file_is_safe(void);

#endif

/* end xferrecv.h */