forked from facebookarchive/fb-adb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfdrecorder.h
39 lines (33 loc) · 1.47 KB
/
fdrecorder.h
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
/*
* Copyright (c) 2014, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in
* the LICENSE file in the root directory of this source tree. An
* additional grant of patent rights can be found in the PATENTS file
* in the same directory.
*
*/
#pragma once
#include "util.h"
// An fdrecorder, through dark magic unix and firelit sacrifices to
// SIGIO (the ancient and terrible God of level-triggered event
// handling), records all writes to its associate write fd from this
// program or, more importantly, _any_ _other_ _program_, even after
// we close our own copy of the fdrecorder's write fd. We only stop
// recordng when all copies of the write FD and closed or when an
// fdrecorder it scraped off its parent reslist.
struct fdrecorder;
// Make a new fdrecorder; it begins recording immediately.
struct fdrecorder* fdrecorder_new(void);
// Retrieve the write end of the fdrecorder. Writes to this FD or any
// duplicate of it from any program get sucked into the fdrecorder's
// internal buffer.
int fdrecorder_write_fd(struct fdrecorder* fdr);
// Close our copy of the write descriptor. Other copies can live as
// long as you'd like.
void fdrecorder_close_write_fd(struct fdrecorder* fdr);
// Retrieve the currently-recorded bytes, ownership of which is
// transferred to the caller's reslist. Empties the fdrecorder buffer
// by side effect.
struct growable_buffer fdrecorder_get_clean(struct fdrecorder* fdr);