Lines Matching defs:file
3 * you may not use this file except in compliance with the License.
72 file_rec *file;
101 "file",
104 " --file, -f <name>\t\t\tFile to read the firehose from.\n\t\t\t\t\tDefaults to stdin." },
129 "writes each connection to a file, or to a socket as appropriate.\n" \
131 "When writing to files, each connection is placed into a dedicated file\n" \
184 apr_hash_set(rec->file->response_uuids, rec->uuid, APR_HASH_KEY_STRING,
188 apr_hash_set(rec->file->request_uuids, rec->uuid, APR_HASH_KEY_STRING,
198 static apr_status_t make_uuid_rec(file_rec *file, header_rec *header,
203 apr_pool_create(&pool, file->pool);
207 rec->file = file;
214 apr_hash_set(file->response_uuids, rec->uuid, APR_HASH_KEY_STRING, rec);
217 apr_hash_set(file->request_uuids, rec->uuid, APR_HASH_KEY_STRING, rec);
231 static apr_status_t finalise_body(file_rec *file, header_rec *header)
237 apr_pool_create(&pool, file->pool);
243 status = apr_filepath_merge(&nfrom, file->directory, from,
246 status = apr_filepath_merge(&nto, file->directory, to,
249 if (APR_SUCCESS == (status = apr_file_mtime_set(nfrom, file->end, pool))) {
252 file->file_err,
253 "Could not rename file '%s' to '%s' for fragment write: %pm\n",
259 file->file_err,
260 "Could not set mtime on file '%s' to '%" APR_TIME_T_FMT "' for fragment write: %pm\n",
261 nfrom, file->end, &status);
265 apr_file_printf(file->file_err,
266 "Could not merge directory '%s' with file '%s': %pm\n",
267 file->directory, to, &status);
271 apr_file_printf(file->file_err,
272 "Could not merge directory '%s' with file '%s': %pm\n",
273 file->directory, from, &status);
284 static int check_prefix(file_rec *file, header_rec *header, const char *str,
292 apr_pool_create(&pool, file->pool);
294 for (hi = apr_hash_first(pool, file->filters); hi; hi = apr_hash_next(hi)) {
314 * Currently, we append it to a file named after the UUID of the connection.
316 * The file is opened on demand and closed when done, so that we are
317 * guaranteed never to hit a file handle limit (within reason).
319 static apr_status_t process_body(file_rec *file, header_rec *header,
327 if (!file->start) {
328 file->start = header->timestamp;
330 file->end = header->timestamp;
332 apr_pool_create(&pool, file->pool);
339 status = apr_filepath_merge(&native, file->directory, name,
346 apr_file_printf(file->file_err,
347 "Could not write fragment body to file '%s': %pm\n",
352 apr_file_printf(file->file_err,
353 "Could not open file '%s' for fragment write: %pm\n",
358 apr_file_printf(file->file_err,
359 "Could not merge directory '%s' with file '%s': %pm\n",
360 file->directory, name, &status);
427 static apr_status_t process_header(file_rec *file, header_rec *header,
496 * Suck on the file/pipe, and demux any fragments on the incoming stream.
500 static apr_status_t demux(file_rec *file)
509 bb = apr_brigade_create(file->pool, file->alloc);
510 obb = apr_brigade_create(file->pool, file->alloc);
511 b = apr_bucket_pipe_create(file->file_in, file->alloc);
534 file->skipped_bytes += len;
542 file->skipped_bytes += len;
546 status = process_header(file, &header, str, len);
548 file->skipped_bytes += len;
556 header.rec = apr_hash_get(file->response_uuids,
560 header.rec = apr_hash_get(file->request_uuids,
566 file->dropped_fragments++;
572 if (file->limit) {
578 file->skipped_bytes += len;
584 make_uuid_rec(file, &header, &header.rec);
592 file->file_err,
593 "Could not read fragment body from input file: %pm\n", &status);
598 if (!ignore && !header.count && !check_prefix(file,
603 status = process_body(file, &header, buf, len);
608 file->skipped_bytes += len;
624 status = process_body(file, &header, "", 0);
626 status = finalise_body(file, &header);
637 apr_file_printf(file->file_err,
638 "Could not read fragment header from input file: %pm\n", &status);
658 file_rec *file;
674 file = apr_pcalloc(pool, sizeof(file_rec));
675 apr_file_open_stderr(&file->file_err, pool);
676 apr_file_open_stdin(&file->file_in, pool);
677 apr_file_open_stdout(&file->file_out, pool);
679 file->pool = pool;
680 file->alloc = apr_bucket_alloc_create(pool);
681 file->bb = apr_brigade_create(pool, file->alloc);
682 file->request_uuids = apr_hash_make(pool);
683 file->response_uuids = apr_hash_make(pool);
684 file->filters = apr_hash_make(pool);
692 status = apr_file_open(&file->file_in, optarg, APR_FOPEN_READ,
695 apr_file_printf(file->file_err,
696 "Could not open file '%s' for read: %pm\n", optarg, &status);
705 apr_file_printf(file->file_err,
710 apr_file_printf(file->file_err,
714 file->directory = optarg;
724 apr_hash_set(file->request_uuids, optarg, APR_HASH_KEY_STRING, rec);
725 apr_hash_set(file->response_uuids, optarg, APR_HASH_KEY_STRING, rec);
726 file->limit++;
754 apr_hash_set(file->filters, opt->argv[opt->ind], APR_HASH_KEY_STRING,
759 status = demux(file);
762 if (file->skipped_bytes || file->dropped_fragments) {
764 file->file_err,
766 file->skipped_bytes, file->dropped_fragments);