ReactOS 0.4.16-dev-197-g92996da
stream.c File Reference
#include <schily/mconfig.h>
#include "mkisofs.h"
#include "iso9660.h"
#include <schily/schily.h>
Include dependency graph for stream.c:

Go to the source code of this file.

Functions

LOCAL int size_str_file __PR ((UInt32_t starting_extent))
 
LOCAL int gen_str_path __PR ((void))
 
LOCAL int write_str_file __PR ((FILE *outfile))
 
LOCAL int size_str_file (UInt32_t starting_extent)
 
LOCAL int size_str_dir (UInt32_t starting_extent)
 
LOCAL int size_str_path (UInt32_t starting_extent)
 
LOCAL int gen_str_path ()
 
LOCAL int write_str_file (FILE *outfile)
 
LOCAL int write_str_dir (FILE *outfile)
 
LOCAL int write_str_path (FILE *outfile)
 

Variables

static UConst char sccsid []
 
int stream_media_size
 
charstream_filename
 
time_t begun
 
LOCAL unsigned int avail_extent
 
LOCAL unsigned int stream_extent
 
LOCAL unsigned int stream_size
 
LOCAL unsigned int stream_pad
 
LOCAL charl_path
 
LOCAL charm_path
 
LOCAL struct iso_directory_record s_dir
 
LOCAL int stream_finished = 0
 
struct output_fragment strfile_desc = { NULL, size_str_file, NULL, write_str_file, "Stream File" }
 
struct output_fragment strdir_desc = { NULL, size_str_dir, NULL, write_str_dir, "Stream File Directory" }
 
struct output_fragment strpath_desc = { NULL, size_str_path, gen_str_path, write_str_path, "Stream File Path table" }
 

Function Documentation

◆ __PR() [1/3]

◆ __PR() [2/3]

LOCAL int size_str_file __PR ( (UInt32_t starting_extent)  )

◆ __PR() [3/3]

LOCAL int gen_str_path __PR ( (void )

◆ gen_str_path()

LOCAL int gen_str_path ( )

Definition at line 121 of file stream.c.

122{
123 /*
124 * Basically add the root directory entry
125 */
126 l_path = (char *)e_malloc(SECTOR_SIZE);
127 m_path = (char *)e_malloc(SECTOR_SIZE);
130 l_path[0] = 1;
131 m_path[0] = 1;
132 set_731(l_path + 2, root->extent);
133 set_732(m_path + 2, root->extent);
134 set_721(l_path + 6, 1);
135 set_722(m_path + 6, 1);
136 l_path[8] = '\0'; l_path[9] = '\0';
137 m_path[8] = '\0'; m_path[9] = '\0';
138 return (0);
139}
#define SECTOR_SIZE
Definition: fs.h:22
EXPORT void set_731(void *vp, UInt32_t i)
Definition: isonum.c:91
EXPORT void set_722(void *vp, UInt32_t i)
Definition: isonum.c:61
EXPORT void set_721(void *vp, UInt32_t i)
Definition: isonum.c:46
EXPORT void set_732(void *vp, UInt32_t i)
Definition: isonum.c:108
EXPORT void * e_malloc(size_t size)
Definition: mkisofs.c:3921
#define memset(x, y, z)
Definition: compat.h:39
LOCAL char * m_path
Definition: stream.c:51
LOCAL char * l_path
Definition: stream.c:50

◆ size_str_dir()

LOCAL int size_str_dir ( UInt32_t  starting_extent)

Definition at line 94 of file stream.c.

96{
97 root->extent = last_extent;
98 last_extent += 1;
99 return (0);
100}
UInt32_t last_extent
Definition: mkisofs.c:76

◆ size_str_file()

LOCAL int size_str_file ( UInt32_t  starting_extent)

Definition at line 59 of file stream.c.

61{
62 int n;
63extern int dopad;
64
65 stream_extent = last_extent; /* Start of stream file content */
66
68 n = last_extent; /* Room for FS blocks before file */
69 n += 1; /* Room for the directory block */
70 stream_pad = 0;
71 if (n < 50) {
72 stream_pad = 50 - n;
73 n = 50; /* Make net. size easy to compute */
74 }
75 if (dopad)
76 n += 150; /* Room for final padding */
77
78 if (n >= avail_extent) {
80 _("-stream-media-size %d but must be at least %d\n"),
81 avail_extent, n+2);
82 }
83 avail_extent -= n;
84
86
87 return (0);
88}
EXPORT void comerrno(int err, char *msg, va_alist)
Definition: comerr.c:137
GLdouble n
Definition: glext.h:7729
#define _(X)
Definition: i386-dis.c:35
int dopad
Definition: mkisofs.c:154
LOCAL unsigned int stream_pad
Definition: stream.c:49
int stream_media_size
Definition: mkisofs.c:260
LOCAL unsigned int stream_extent
Definition: stream.c:47
LOCAL unsigned int avail_extent
Definition: stream.c:46
#define EX_BAD
Definition: standard.h:62

◆ size_str_path()

LOCAL int size_str_path ( UInt32_t  starting_extent)

Definition at line 106 of file stream.c.

108{
109 path_table[0] = starting_extent;
110 path_table[1] = 0;
111 path_table[2] = path_table[0] + 1;
112 path_table[3] = 0;
113 last_extent += 2 * 1;
114 return (0);
115}
unsigned int path_table[4]
Definition: mkisofs.c:79

◆ write_str_dir()

LOCAL int write_str_dir ( FILE outfile)

Definition at line 189 of file stream.c.

191{
192 int reclen;
193 char *buf;
194
196 memset(&s_dir, 0, sizeof (struct iso_directory_record));
197 s_dir.length[0] = 34; /* BAD: Hardcoded - Will fix, MHV */
198 s_dir.ext_attr_length[0] = 0;
199 set_733((char *)s_dir.extent, root->extent);
200 set_733((char *)s_dir.size, SECTOR_SIZE);
201 iso9660_date(s_dir.date, begun);
202 s_dir.flags[0] = ISO_DIRECTORY;
203 s_dir.file_unit_size[0] = 0;
204 s_dir.interleave[0] = 0;
205 set_723((char *)s_dir.volume_sequence_number, volume_sequence_number);
206 s_dir.name_len[0] = 1;
207 s_dir.name[0] = 0; /* "." */
208 xfwrite(&s_dir, offsetof(struct iso_directory_record, name[0]) + 1, 1, outfile, 0, FALSE);
209 s_dir.name[0] = 1; /* ".." */
210 xfwrite(&s_dir, offsetof(struct iso_directory_record, name[0]) + 1, 1, outfile, 0, FALSE);
211 memset(&s_dir, 0, sizeof (struct iso_directory_record));
212 reclen = offsetof(struct iso_directory_record, name[0]) +
214 if (reclen & 1)
215 reclen++;
216 s_dir.length[0] = reclen;
217 s_dir.ext_attr_length[0] = 0;
218 set_733((char *)s_dir.extent, stream_extent);
219 set_733((char *)s_dir.size, stream_size);
220 iso9660_date(s_dir.date, begun);
221 s_dir.flags[0] = 0;
222 s_dir.file_unit_size[0] = 0;
223 set_723((char *)s_dir.volume_sequence_number, volume_sequence_number);
224 s_dir.name_len[0] = strlen(stream_filename);
225 memcpy(s_dir.name, stream_filename, s_dir.name_len[0]);
226 xfwrite(&s_dir, reclen, 1, outfile, 0, FALSE);
227
228 /*
229 * This calc is: 2 single char directory entries (34) + an additional entry
230 * with filename length stream_filename + round up for even lenght count
231 */
232 xfwrite(buf, SECTOR_SIZE - ((2 * 34) + reclen), 1, outfile, 0, FALSE);
233 free(buf);
235 return (0);
236}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define free
Definition: debug_ros.c:5
#define FALSE
Definition: types.h:117
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define ISO_DIRECTORY
Definition: iso9660.h:265
EXPORT void set_723(void *vp, UInt32_t i)
Definition: isonum.c:76
EXPORT void set_733(void *vp, UInt32_t i)
Definition: isonum.c:125
EXPORT int iso9660_date(char *result, time_t crtime)
Definition: mkisofs.c:1868
int volume_sequence_number
Definition: mkisofs.c:173
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
UInt32_t last_extent_written
Definition: write.c:303
#define offsetof(TYPE, MEMBER)
char * stream_filename
Definition: mkisofs.c:261
LOCAL struct iso_directory_record s_dir
Definition: stream.c:52
LOCAL unsigned int stream_size
Definition: stream.c:48
time_t begun
Definition: write.c:305
EXPORT void xfwrite(void *buffer, int size, int count, FILE *file, int submode, BOOL islast)
Definition: write.c:168
Definition: name.c:39
static FILE * outfile
Definition: wrjpgcom.c:81

◆ write_str_file()

LOCAL int write_str_file ( FILE outfile)

Definition at line 145 of file stream.c.

147{
148 unsigned int idx = 0;
149 unsigned int iso_blocks;
150 int count;
151 char *buf;
152
154 stream_size = 0;
155 while ((idx + SECTOR_SIZE) < (avail_extent * SECTOR_SIZE)) {
158 if (count <= 0) {
159 stream_finished = 1;
160 break;
161 }
162 idx += count;
163 xfwrite(buf, count, 1, outfile, 0, FALSE);
164 }
165
167 iso_blocks = ISO_BLOCKS(idx);
169 if (SECTOR_SIZE * iso_blocks - idx)
170 xfwrite(buf, SECTOR_SIZE * iso_blocks - idx, 1, outfile, 0, FALSE);
171 /*
172 * If we didn't fill the available area, pad to directory block
173 */
174 for (count = 0; count < (avail_extent - iso_blocks); count++)
176
177 for (count = 0; count < stream_pad; count++)
179
181 free(buf);
182 return (0);
183}
unsigned int idx
Definition: utils.c:41
GLuint GLuint GLsizei count
Definition: gl.h:1545
_Check_return_opt_ _CRTIMP size_t __cdecl fread(_Out_writes_bytes_(_ElementSize *_Count) void *_DstBuf, _In_ size_t _ElementSize, _In_ size_t _Count, _Inout_ FILE *_File)
#define stdin
Definition: stdio.h:98
#define ISO_BLOCKS(X)
Definition: mkisofs.h:743
LOCAL int stream_finished
Definition: stream.c:53

◆ write_str_path()

LOCAL int write_str_path ( FILE outfile)

Definition at line 242 of file stream.c.

244{
248 free(l_path);
249 free(m_path);
252 return (0);
253}
#define NULL
Definition: types.h:112
char * path_table_m
Definition: mkisofs.c:1632
char * path_table_l
Definition: mkisofs.c:1631

Variable Documentation

◆ avail_extent

LOCAL unsigned int avail_extent

Definition at line 46 of file stream.c.

Referenced by size_str_file(), and write_str_file().

◆ begun

time_t begun
extern

Definition at line 305 of file write.c.

Referenced by vers_write(), write_one_file(), and write_str_dir().

◆ l_path

LOCAL char* l_path

Definition at line 50 of file stream.c.

Referenced by gen_str_path(), and write_str_path().

◆ m_path

LOCAL char* m_path

Definition at line 51 of file stream.c.

Referenced by gen_str_path(), CEnumRegKey::Initialize(), and write_str_path().

◆ s_dir

Definition at line 52 of file stream.c.

Referenced by write_str_dir().

◆ sccsid

UConst char sccsid[]
static
Initial value:
=
"@(#)stream.c 1.17 15/12/08 Copyright 2002-2015 J. Schilling"

Definition at line 4 of file stream.c.

◆ strdir_desc

struct output_fragment strdir_desc = { NULL, size_str_dir, NULL, write_str_dir, "Stream File Directory" }

Definition at line 256 of file stream.c.

Referenced by main().

◆ stream_extent

LOCAL unsigned int stream_extent

Definition at line 47 of file stream.c.

Referenced by size_str_file(), and write_str_dir().

◆ stream_filename

char* stream_filename
extern

Definition at line 261 of file mkisofs.c.

Referenced by main(), and write_str_dir().

◆ stream_finished

LOCAL int stream_finished = 0

Definition at line 53 of file stream.c.

Referenced by write_str_file().

◆ stream_media_size

int stream_media_size
extern

Definition at line 260 of file mkisofs.c.

Referenced by main(), and size_str_file().

◆ stream_pad

LOCAL unsigned int stream_pad

Definition at line 49 of file stream.c.

Referenced by size_str_file(), and write_str_file().

◆ stream_size

LOCAL unsigned int stream_size

Definition at line 48 of file stream.c.

Referenced by write_str_dir(), and write_str_file().

◆ strfile_desc

struct output_fragment strfile_desc = { NULL, size_str_file, NULL, write_str_file, "Stream File" }

Definition at line 255 of file stream.c.

Referenced by main().

◆ strpath_desc

Definition at line 257 of file stream.c.

Referenced by main().