ReactOS  0.4.11-dev-765-g5e024bf
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

LOCAL int size_str_file __PR ( (UInt32_t starting_extent)  )
LOCAL int gen_str_path __PR ( (void )
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 }
EXPORT void set_732(void *vp, UInt32_t i)
Definition: isonum.c:108
EXPORT void set_721(void *vp, UInt32_t i)
Definition: isonum.c:46
EXPORT void set_722(void *vp, UInt32_t i)
Definition: isonum.c:61
LOCAL char * m_path
Definition: stream.c:51
EXPORT void set_731(void *vp, UInt32_t i)
Definition: isonum.c:91
#define SECTOR_SIZE
Definition: winldr.h:34
LOCAL char * l_path
Definition: stream.c:50
EXPORT void * e_malloc(size_t size)
Definition: mkisofs.c:3921
#define memset(x, y, z)
Definition: compat.h:39
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
LOCAL int size_str_file ( UInt32_t  starting_extent)

Definition at line 59 of file stream.c.

61 {
62  int n;
63 extern 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 }
int dopad
Definition: mkisofs.c:154
LOCAL unsigned int stream_extent
Definition: stream.c:47
GLuint n
Definition: s_context.h:57
#define _(X)
Definition: i386-dis.c:36
UInt32_t last_extent
Definition: mkisofs.c:76
int stream_media_size
Definition: mkisofs.c:260
LOCAL unsigned int avail_extent
Definition: stream.c:46
EXPORT void comerrno(int err, char *msg, va_alist)
Definition: comerr.c:137
LOCAL unsigned int stream_pad
Definition: stream.c:49
#define EX_BAD
Definition: standard.h:62
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 }
UInt32_t last_extent
Definition: mkisofs.c:76
unsigned int path_table[4]
Definition: mkisofs.c:79
LOCAL int write_str_dir ( FILE outfile)

Definition at line 189 of file stream.c.

191 {
192  int reclen;
193  char *buf;
194 
195  buf = e_malloc(SECTOR_SIZE); memset(buf, 0, SECTOR_SIZE);
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
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
EXPORT void xfwrite(void *buffer, int size, int count, FILE *file, int submode, BOOL islast)
Definition: write.c:168
#define free
Definition: debug_ros.c:5
time_t begun
Definition: write.c:305
LOCAL unsigned int stream_extent
Definition: stream.c:47
#define FALSE
Definition: types.h:117
#define SECTOR_SIZE
Definition: winldr.h:34
#define offsetof(TYPE, MEMBER)
EXPORT int iso9660_date(char *result, time_t crtime)
Definition: mkisofs.c:1868
int volume_sequence_number
Definition: mkisofs.c:173
#define ISO_DIRECTORY
Definition: iso9660.h:265
UInt32_t last_extent_written
Definition: write.c:303
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
EXPORT void * e_malloc(size_t size)
Definition: mkisofs.c:3921
LOCAL unsigned int stream_size
Definition: stream.c:48
Definition: name.c:36
#define memset(x, y, z)
Definition: compat.h:39
LOCAL struct iso_directory_record s_dir
Definition: stream.c:52
char * stream_filename
Definition: mkisofs.c:261
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
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 
153  buf = e_malloc(SECTOR_SIZE);
154  stream_size = 0;
155  while ((idx + SECTOR_SIZE) < (avail_extent * SECTOR_SIZE)) {
156  memset(buf, 0, SECTOR_SIZE);
157  count = fread(buf, 1, SECTOR_SIZE, stdin);
158  if (count <= 0) {
159  stream_finished = 1;
160  break;
161  }
162  idx += count;
163  xfwrite(buf, count, 1, outfile, 0, FALSE);
164  }
165 
166  stream_size = idx;
167  iso_blocks = ISO_BLOCKS(idx);
168  memset(buf, 0, SECTOR_SIZE);
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++)
175  xfwrite(buf, SECTOR_SIZE, 1, outfile, 0, FALSE);
176 
177  for (count = 0; count < stream_pad; count++)
178  xfwrite(buf, SECTOR_SIZE, 1, outfile, 0, FALSE);
179 
181  free(buf);
182  return (0);
183 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
EXPORT void xfwrite(void *buffer, int size, int count, FILE *file, int submode, BOOL islast)
Definition: write.c:168
#define free
Definition: debug_ros.c:5
FILE * stdin
_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 FALSE
Definition: types.h:117
#define SECTOR_SIZE
Definition: winldr.h:34
unsigned int idx
Definition: utils.c:41
#define ISO_BLOCKS(X)
Definition: mkisofs.h:743
GLuint GLuint GLsizei count
Definition: gl.h:1545
UInt32_t last_extent_written
Definition: write.c:303
LOCAL unsigned int avail_extent
Definition: stream.c:46
LOCAL int stream_finished
Definition: stream.c:53
EXPORT void * e_malloc(size_t size)
Definition: mkisofs.c:3921
LOCAL unsigned int stream_size
Definition: stream.c:48
#define memset(x, y, z)
Definition: compat.h:39
LOCAL unsigned int stream_pad
Definition: stream.c:49
LOCAL int write_str_path ( FILE outfile)

Definition at line 242 of file stream.c.

244 {
245  xfwrite(l_path, SECTOR_SIZE, 1, outfile, 0, FALSE);
246  xfwrite(m_path, SECTOR_SIZE, 1, outfile, 0, FALSE);
247  last_extent_written += 2;
248  free(l_path);
249  free(m_path);
250  path_table_l = NULL;
251  path_table_m = NULL;
252  return (0);
253 }
EXPORT void xfwrite(void *buffer, int size, int count, FILE *file, int submode, BOOL islast)
Definition: write.c:168
#define free
Definition: debug_ros.c:5
char * path_table_m
Definition: mkisofs.c:1632
LOCAL char * m_path
Definition: stream.c:51
#define FALSE
Definition: types.h:117
#define SECTOR_SIZE
Definition: winldr.h:34
smooth NULL
Definition: ftsmooth.c:416
LOCAL char * l_path
Definition: stream.c:50
UInt32_t last_extent_written
Definition: write.c:303
char * path_table_l
Definition: mkisofs.c:1631

Variable Documentation

LOCAL unsigned int avail_extent

Definition at line 46 of file stream.c.

time_t begun

Definition at line 305 of file write.c.

Referenced by write_one_file().

LOCAL char* l_path

Definition at line 50 of file stream.c.

LOCAL char* m_path

Definition at line 51 of file stream.c.

Definition at line 52 of file stream.c.

Referenced by write_str_dir().

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.

Definition at line 256 of file stream.c.

Referenced by main().

LOCAL unsigned int stream_extent

Definition at line 47 of file stream.c.

char* stream_filename

Definition at line 261 of file mkisofs.c.

Referenced by main(), and msi_export_stream().

LOCAL int stream_finished = 0

Definition at line 53 of file stream.c.

int stream_media_size

Definition at line 260 of file mkisofs.c.

Referenced by main(), and size_str_file().

LOCAL unsigned int stream_pad

Definition at line 49 of file stream.c.

Referenced by size_str_file(), and write_str_file().

LOCAL unsigned int stream_size

Definition at line 48 of file stream.c.

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().

Definition at line 257 of file stream.c.

Referenced by main().