db: Override cycle multiplier for Colin McRae PAL
[pcsx_rearmed.git] / deps / libretro-common / include / file / nbio.h
CommitLineData
3719602c
PC
1/* Copyright (C) 2010-2020 The RetroArch team
2 *
3 * ---------------------------------------------------------------------------------------
4 * The following license statement only applies to this file (nbio.h).
5 * ---------------------------------------------------------------------------------------
6 *
7 * Permission is hereby granted, free of charge,
8 * to any person obtaining a copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation the rights to
10 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
11 * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
16 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 */
22
23#ifndef __LIBRETRO_SDK_NBIO_H
24#define __LIBRETRO_SDK_NBIO_H
25
26#include <stddef.h>
27#include <boolean.h>
28
29#include <retro_common_api.h>
30
31RETRO_BEGIN_DECLS
32
33#ifndef NBIO_READ
34#define NBIO_READ 0
35#endif
36
37#ifndef NBIO_WRITE
38#define NBIO_WRITE 1
39#endif
40
41#ifndef NBIO_UPDATE
42#define NBIO_UPDATE 2
43#endif
44
45/* these two are blocking; nbio_iterate always returns true, but that operation (or something earlier) may take arbitrarily long */
46#ifndef BIO_READ
47#define BIO_READ 3
48#endif
49
50#ifndef BIO_WRITE
51#define BIO_WRITE 4
52#endif
53
54typedef struct nbio_intf
55{
56 void *(*open)(const char * filename, unsigned mode);
57
58 void (*begin_read)(void *data);
59
60 void (*begin_write)(void *data);
61
62 bool (*iterate)(void *data);
63
64 void (*resize)(void *data, size_t len);
65
66 void *(*get_ptr)(void *data, size_t* len);
67
68 void (*cancel)(void *data);
69
70 void (*free)(void *data);
71
72 /* Human readable string. */
73 const char *ident;
74} nbio_intf_t;
75
76/*
77 * Creates an nbio structure for performing the
78 * given operation on the given file.
79 */
80void *nbio_open(const char * filename, unsigned mode);
81
82/*
83 * Starts reading the given file. When done, it will be available in nbio_get_ptr.
84 * Can not be done if the structure was created with {N,}BIO_WRITE.
85 */
86void nbio_begin_read(void *data);
87
88/*
89 * Starts writing to the given file. Before this, you should've copied the data to nbio_get_ptr.
90 * Can not be done if the structure was created with {N,}BIO_READ.
91 */
92void nbio_begin_write(void *data);
93
94/*
95 * Performs part of the requested operation, or checks how it's going.
96 * When it returns true, it's done.
97 */
98bool nbio_iterate(void *data);
99
100/*
101 * Resizes the file up to the given size; cannot shrink.
102 * Can not be done if the structure was created with {N,}BIO_READ.
103 */
104void nbio_resize(void *data, size_t len);
105
106/*
107 * Returns a pointer to the file data. Writable only if structure was not created with {N,}BIO_READ.
108 * If any operation is in progress, the pointer will be NULL, but len will still be correct.
109 */
110void* nbio_get_ptr(void *data, size_t* len);
111
112/*
113 * Stops any pending operation, allowing the object to be freed.
114 */
115void nbio_cancel(void *data);
116
117/*
118 * Deletes the nbio structure and its associated pointer.
119 */
120void nbio_free(void *data);
121
122RETRO_END_DECLS
123
124#endif