Edinburgh Speech Tools
2.4-release
All
Classes
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Pages
bcat_main.cc
1
/************************************************************************/
2
/* */
3
/* Centre for Speech Technology Research */
4
/* University of Edinburgh, UK */
5
/* Copyright (c) 1996,1997 */
6
/* All Rights Reserved. */
7
/* */
8
/* Permission is hereby granted, free of charge, to use and distribute */
9
/* this software and its documentation without restriction, including */
10
/* without limitation the rights to use, copy, modify, merge, publish, */
11
/* distribute, sublicense, and/or sell copies of this work, and to */
12
/* permit persons to whom this work is furnished to do so, subject to */
13
/* the following conditions: */
14
/* 1. The code must retain the above copyright notice, this list of */
15
/* conditions and the following disclaimer. */
16
/* 2. Any modifications must be clearly marked as such. */
17
/* 3. Original authors' names are not deleted. */
18
/* 4. The authors' names are not used to endorse or promote products */
19
/* derived from this software without specific prior written */
20
/* permission. */
21
/* */
22
/* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */
23
/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
24
/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
25
/* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */
26
/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
27
/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
28
/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
29
/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
30
/* THIS SOFTWARE. */
31
/* */
32
/*************************************************************************/
33
/* */
34
/* Author: Richard Caley (rjc@cstr.ed.ac.uk) */
35
/* Date: Thu Aug 14 1997 */
36
/* -------------------------------------------------------------------- */
37
/* A simple file concatenator which does everything in binary */
38
/* mode. For use in the tests on Windows etc. */
39
/* */
40
/*************************************************************************/
41
42
43
#include <cstdio>
44
#include "EST.h"
45
#include "EST_String.h"
46
#include "EST_error.h"
47
48
#define BUFFER_SIZE (1024)
49
50
51
/** @name <command>bcat</command> <emphasis>Binary safe version of cat</emphasis>
52
@id bcat-manual
53
* @toc
54
*/
55
56
//@{
57
58
59
/**@name Synopsis
60
*/
61
//@{
62
63
//@synopsis
64
65
/**
66
bcat is a trivial file concatenation program. It exists to allow testing
67
of various file splitting operations under the cygwin environment on Windows
68
where the distinction between binary and text data is important.
69
*/
70
71
//@}
72
73
/**@name OPTIONS
74
*/
75
//@{
76
77
//@options
78
79
//@}
80
81
82
int
main(
int
argc,
char
*argv[])
83
{
84
EST_StrList
files;
85
EST_Option
settings, cmd_line;
86
87
parse_command_line
88
(argc, argv,
89
EST_String
(
"-o [ofile] [files...]\n"
)+
90
"Summary; concatenate files in binary mode\n"
+
91
"-o <ofile> Ouptut file of binary data\n"
,
92
files, cmd_line);
93
94
EST_String
out_file;
95
96
if
(cmd_line.
present
(
"-o"
))
97
out_file = cmd_line.
val
(
"-o"
);
98
else
99
EST_error(
"No output file specified"
);
100
101
FILE *dest;
102
103
if
((dest=fopen(out_file,
"wb"
)) == NULL)
104
EST_sys_error(
"Can't create '%s'"
, (
const
char
*)out_file);
105
106
EST_Litem
*item;
107
108
for
(item=files.head(); item; item = item->next())
109
{
110
FILE *src;
111
112
if
((src=fopen(files(item),
"rb"
))==NULL)
113
EST_sys_error(
"can't read '%s'"
, (
const
char
*)files(item));
114
115
unsigned
int
n;
116
char
buf[BUFFER_SIZE];
117
118
while
((n=fread(buf,
sizeof
(
char
), BUFFER_SIZE, src)) >0)
119
if
(fwrite(buf,
sizeof
(
char
), n, dest) < n)
120
EST_sys_error(
"write error"
);
121
122
fclose(src);
123
}
124
125
fclose(dest);
126
127
return
0;
128
}
129
130
131
132
main
bcat_main.cc
Generated on Wed Dec 24 2014 09:16:35 for Edinburgh Speech Tools by
1.8.3.1