-
Notifications
You must be signed in to change notification settings - Fork 2
/
output.h
163 lines (142 loc) · 5.2 KB
/
output.h
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
161
162
163
/**
* @file output.h
* Definitions for file writing functions
* @author Marko Mäkelä (marko.makela at iki.fi)
*/
/*
** Copyright © 1993-1997,2001 Marko Mäkelä
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef OUTPUT_H
# define OUTPUT_H
# include "util.h"
/* File management */
/** Writing status */
enum WrStatus
{
WrOK, /**<Success */
WrNoSpace, /**<Out of space */
WrFileExists, /**<Duplicate file name */
WrFail /**<Generic failure */
};
/** Write a file in some format
* @param name native (PETSCII) name of the file
* @param data the contents of the file
* @param length length of the file contents
* @param newname (output) the converted file name
* @param log Call-back function for diagnostic output
* @return status of the operation
*/
typedef enum WrStatus write_t (const struct Filename* name,
const byte_t* data,
size_t length,
char** newname,
log_t log);
/** Write a file in raw format */
write_t WriteNative;
/** Write a file in PC64 format (.P00, .S00 etc.) */
write_t WritePC64;
/** Write a file in raw format, using ISO 9660 compliant filenames */
write_t Write9660;
/** Write a file to a disk image
* @param name native (PETSCII) name of the file
* @param data the contents of the file
* @param length length of the file contents
* @param image the disk image
* @param log Call-back function for diagnostic output
* @return status of the operation
*/
typedef enum WrStatus write_img_t (const struct Filename* name,
const byte_t* data,
size_t length,
struct Image* image,
log_t log);
/** Write to an image in CBM DOS format */
write_img_t WriteImage;
/** Write to an image in C128 CP/M format */
write_img_t WriteCpmImage;
/* Disk image management */
/** Disk image management status */
enum ImStatus
{
ImOK, /**< No errors */
ImNoSpace, /**< Out of space on the host system */
ImFail /**< Generic failure */
};
/** Open an existing disk image or create a new one.
* @param filename name of 1541 disk image on the host system
* @param image address of the disk image buffer pointer
* (will be allocated by this function)
* @param type type of the disk image
* @param direntOpts directory entry handling options
* @return Status of the operation
*/
enum ImStatus
OpenImage (const char* filename,
struct Image** image,
enum ImageType type,
enum DirEntOpts direntOpts);
/** Write back a disk image.
* @param image address of the disk image buffer
* (will be deallocated by this function)
* @return Status of the operation
*/
enum ImStatus
CloseImage (struct Image* image);
/* Archive file management */
/** Archive management status */
enum ArStatus
{
ArOK, /**< Successful operation */
ArNoSpace, /**< Out of space */
ArFail /**< Generic failure */
};
/** Allocate an archive data structure.
* @return a newly allocated empty archive structure
*/
struct Archive*
newArchive (void);
/** Deallocate an archive data structure.
* @param archive the archive to be deallocated
*/
void
deleteArchive (struct Archive* archive);
/** Write a file to an archive.
* @param name native (PETSCII) name of the file
* @param data the contents of the file
* @param length length of the file contents
* @param archive the archive the file is written to
* @param log Call-back function for diagnostic output
* @return status of the operation
*/
enum WrStatus
WriteArchive (const struct Filename* name,
const byte_t* data,
size_t length,
struct Archive* archive,
log_t log);
/** Write an archive to a file.
* @param archive the archive to be written
* @param filename host file name of the archive file
* @return status of the operation
*/
typedef enum ArStatus write_ar_t (const struct Archive* archive,
const char* filename);
/** Write an archive in Lynx format */
write_ar_t ArchiveLynx;
/** Write an archive in Commodore C2N tape format */
write_ar_t ArchiveC2N;
#endif /* OUTPUT_H */