blob: e22ceb50990ef0785f7b3e455340a233fb4afdd4 (
plain) (
blame)
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
|
#compdef cdrdao
# TODO: Options must come before parameters.
# Command completion and main loop {{{1
_cdrdao_commands () {
local -a commands
commands=(
'show-toc:print out a summary of a TOC'
'read-toc:create a TOC file based on a CD'
'read-cd:create a TOC file and image file based on a CD'
'read-cddb:add CD-TEXT data from a CDDB server to a TOC'
'show-data:print out samples that would be written to CD'
'read-test:check if data described in a TOC can be read from a CD'
'disk-info:show information about a CD'
'msinfo:generate mkisofs command for creating multi-session CD'
'unlock:try to unlock a recorder after a failed run'
'blank:blank a CD-RW'
'simulate:simulate a write'
'write:write a CD based on a TOC'
'copy:copy a CD'
)
_describe -t commands 'cdrdao command' commands && ret=0
}
_cdrdao () {
local curcontext=$curcontext ret=1
local context state line
typeset -A opt_args
_arguments \
':command:->command' \
'*::options:->options' && ret=0
case $state in
(command)
_cdrdao_commands
;;
(options)
curcontext="${curcontext%:*:*}:cdrdao-$words[1]:"
_call_function ret _cdrdao-$words[1]
;;
esac
}
# Common arguments {{{1
declare -ga tmpfile_args
tmpfile_args=(
'--tmpdir[directory to store temporary data in]:directory:_directories'
'--keep[do not remove temporary data when done]')
declare -ga device_args
device_args=(
'--device[set SCSI address of the CD recorder]:device:__cdrdao-device'
'--driver[use given driver for the CD recorder]:driver:__cdrdao-drivers')
# TODO: Gah! Fix a cddb server spec matcher
declare -ga cddb_args
cddb_args=(
'--cddb-servers[specify list of CDDB servers to use]:CDDB servers:'
'--cddb-timeout[specify timeout in seconds for connections to CDDB servers]: :_guard "[[\:digit\:]]" timeout'
'--cddb-directory[directory where fetched CDDB records will be stored]:directory:_directories')
declare -g paranoiamode_arg=
paranoiamode_arg='--paranoia-mode[set correction mode for digital audio extraction]:mode:(("0\:no checking" "1\:perform overlapped reading to avoid jitter" "2\:like 1 but with checks of read audio data" "3\:like 2 but with scratch detection/repair (default)"))'
declare -g fasttoc_arg=
fasttoc_arg='--fast-toc[skip pre-gap-length and index-mark extraction]'
declare -g swap_arg=
swap_arg='--swap[swap the byte order of samples]'
declare -g reload_arg=
reload_arg='--reload[reload the disk if necessary]'
declare -g eject_arg=
eject_arg='--eject[eject CD after completed operation]'
declare -g speed_arg=
speed_arg='-speed[set writing speed]: :_guard "[[\:digit\:]]##" speed'
declare -ga common_args
common_args=(
'(*)'{-h,--help}'[display command/option summary]'
'-v[set verbosity level]: :_guard "[[\:digit\:]]##" verbosity')
declare -ga common_toc_args
common_toc_args=(
$common_args
':TOC file:_files -g "*.toc"')
declare -ga common_device_args
common_device_args=(
$common_args
$device_args)
declare -ga common_toc_device_args
common_toc_device_args=(
$common_toc_args
$common_device_args
$force_arg)
declare -ga common_read_args
common_read_args=(
'--rspeed[set reading speed]: :_guard "[[\:digit\:]]##" speed'
'--session[specify what session to process on multi-session CDs]: :_guard "[[\:digit\:]]##" "session number"'
'--read-subchan[set sub-channel reading-mode]:mode:(("rw\:de-interleaved and error corrected" "rw_raw\:not de-interleaved, not error-corrected, and L-EC data included"))'
'--tao-source[indicate that source CD was written in TAO mode]'
'--with-cddb[retrieve CD-TEXT data from a CDDB server]')
# Sub-command completion {{{1
_cdrdao-show-toc () {
__cdrdao-show-toc-or-toc-info-or-toc-size
}
_cdrdao-toc-info () {
__cdrdao-show-toc-or-toc-info-or-toc-size
}
_cdrdao-toc-size () {
__cdrdao-show-toc-or-toc-info-or-toc-size
}
__cdrdao-show-toc-or-toc-info-or-toc-size () {
_arguments \
$common_toc_args \
$tmpfile_args && ret=0
}
_cdrdao-read-toc () {
__cdrdao-read-toc-or-read-cd \
$fasttoc_arg
}
_cdrdao-read-cd () {
__cdrdao-read-toc-or-read-cd \
$paranoiamode_arg
}
__cdrdao-read-toc-or-read-cd () {
local -a dependent_args
__cdrdao-read-toc-or-read-cd-or-copy-dependent-args
_arguments \
$common_toc_device_args \
$common_read_args \
$dependent_args
'--datafile[set name of data file placed in TOC file]:file:_files' \
'--read-raw[read data in raw format from CD]' \
'--no-mode2-mixed[if MODE2_FORM1 or MODE2_FORM2, do not extract as MODE2_FORM_MIX]' \
$* && ret=0
}
_cdrdao-read-cddb () {
_arguments \
$common_toc_args \
$cddb_args && ret=0
}
_cdrdao-show-data () {
_arguments \
$common_toc_args \
$swap_arg && ret=0
}
_cdrdao-read-test () {
_arguments \
$common_toc_args && ret=0
}
_cdrdao-disk-info () {
__cdrdao-disk-info-or-drive-info
}
__cdrdao-disk-info-or-drive-info () {
_arguments \
$common_device_args && ret=0
}
_cdrdao-msinfo () {
_arguments \
$common_device_args \
$reload_arg && ret=0
}
_cdrdao-drive-info () {
__cdrdao-disk-info-or-drive-info
}
_cdrdao-unlock () {
_arguments \
$common_device_args \
$reload_arg \
$eject_arg && ret=0
}
_cdrdao-blank () {
_arguments \
$common_device_args \
$speed_arg \
'--blank-mode[set the blanking mode]:blanking mode:(("full\:completely erase data" "minimal\:only dereference data"))' \
$eject_arg && ret=0
}
_cdrdao-scanbus () {
_arguments \
$common_args && ret=0
}
_cdrdao-simulate () {
__cdrdao-simulate-or-write
}
__cdrdao-simulate-or-write () {
local capacity_arg=
if (( $words[(I)--full-burn] )); then
capacity_arg='--capacity[set disk capacity for --full-burn]: :_guard "[[\:digit\:]]" minutes'
fi
_arguments \
$common_toc_device_args \
$speed_arg \
'--multi[do not close the session after successful write]' \
'--overburn[allow overburing of medium]' \
'--full-burn[force burning to the outer disk edge]' \
$capacity_arg \
$eject_arg \
$swap_arg \
'--buffers[set fifo buffer size]: :_guard "[[\:digit\:]]" size' \
$reload_arg \
$tmpfile_args \
'-n[do not pause before writing]' \
$* && ret=0
}
_cdrdao-write () {
__cdrdao-simulate-or-write \
'--simulate[only perform a write simulation]' \
'--buffer-under-run-protection[whether to use buffer under-run protection]:buffer under-run protection setting:(("0\:disable buffer under-run protection" "1\:enable buffer under-run protection"))' \
'--write-speed-control[whether to use writing-speed control]:writing-speed control setting:(("0\:disable writing-speed control" "1\:enable writing-speed control"))' \
$*
}
__cdrdao-read-toc-or-read-cd-or-copy-dependent-args () {
if (( words[(I)--tao-source] )); then
dependent_args+='--tao-source-adjust[specify number of link blocks for tracks written in TAO mode]: :_guard "[[\:digit\:]]##" "link blocks"'
fi
if (( words[(I)--with-cddb] )); then
dependent_args+=$cddb_args
fi
}
_cdrdao-copy () {
local -ga dependent_args
__cdrdao-read-toc-or-read-cd-or-copy-dependent-args
_cdrdao-write \
$dependent_args
$common_read_args
'--source-device[set SCSI address of the CD reader]:device:__cdrdao-device' \
'--source-driver[use given driver for the CD reader]:driver:__cdrdao-drivers' \
'--on-the-fly[perform on-the-fly copy of CD (no image created)]' \
$fasttoc_arg \
'--keepimage[do not remove generated image when done]' \
$paranoiamode_arg && ret=0
}
# Type completion {{{1
__cdrdao-device () {
# Use cdrdao scanbus and also check what OS we’re running under and provide
# additional stuff, like devices (/dev/sg0)
local -a devices
devices=(${(f)"$(_call_program devices cdrdao scanbus -v 0 2>/dev/null)"})
if (( ${#pipestatus:#0} > 0 )); then
return 1
fi
_wanted devices expl 'device' compadd - $devices
}
__cdrdao-drivers () {
local -a drivers
drivers=(${(f)"$(_call_program drivers cut -d'|' -f4 /usr/share/cdrdao/drivers -s 2>/dev/null | sort -u)"})
if (( ${#pipestatus:#0} > 0 )); then
return 1
fi
_wanted drivers expl 'driver' compadd -qS: - $drivers
}
# }}}1
_cdrdao
|