- printf("chunk_table: ");
- for (i = 0; i <= afhi->chunks_total; i++)
- printf("%u ", afhi->chunk_table[i]);
- printf("\n");
-}
-
-static int cat_file(void *audio_file_data, struct afh_info *afhi)
-{
- int ret;
- struct timeval stream_start;
- long unsigned i, first_chunk, last_chunk;
- const char *buf;
- size_t size;
-
-
- if (conf.begin_chunk_arg < 0) {
- if (-conf.begin_chunk_arg > afhi->chunks_total)
- return -ERRNO_TO_PARA_ERROR(EINVAL);
- first_chunk = afhi->chunks_total + conf.begin_chunk_arg;
- } else
- first_chunk = conf.begin_chunk_arg;
- if (conf.end_chunk_given) {
- if (conf.end_chunk_arg < 0) {
- if (-conf.end_chunk_arg > afhi->chunks_total)
- return -ERRNO_TO_PARA_ERROR(EINVAL);
- last_chunk = afhi->chunks_total + conf.end_chunk_arg;
- } else {
- if (conf.end_chunk_arg >= afhi->chunks_total)
- return -ERRNO_TO_PARA_ERROR(EINVAL);
- last_chunk = conf.end_chunk_arg;
- }
- } else
- last_chunk = afhi->chunks_total - 1;
- if (first_chunk >= last_chunk)
- return -ERRNO_TO_PARA_ERROR(EINVAL);
- if (!afhi->chunks_total)
- return 1;
- afh_get_header(afhi, audio_file_data, &buf, &size);
- if (size && first_chunk && !conf.no_header_given) {
- PARA_INFO_LOG("writing audio file header (%zu bytes)\n", size);
- ret = write(STDOUT_FILENO, buf, size);
- if (ret < 0)
- return ret;
- if (ret != size)
- return -E_AFH_SHORT_WRITE;