MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / cli_fd_capture_end

Function cli_fd_capture_end

tests/test_cli.c:773–795  ·  view source on GitHub ↗

Returns the captured text (heap, "" when nothing was written) or NULL when * the capture never engaged. */

Source from the content-addressed store, hash-verified

771/* Returns the captured text (heap, "" when nothing was written) or NULL when
772 * the capture never engaged. */
773static char *cli_fd_capture_end(cli_fd_capture_t *capture) {
774 fflush(capture->stream);
775 if (capture->saved_fd >= 0) {
776 (void)dup2(capture->saved_fd, capture->target_fd);
777 close(capture->saved_fd);
778 capture->saved_fd = -1;
779 }
780 char *text = NULL;
781 if (capture->file) {
782 if (capture->redirected) {
783 rewind(capture->file);
784 size_t capacity = 65536U;
785 text = calloc(1U, capacity);
786 if (text) {
787 size_t count = fread(text, 1U, capacity - 1U, capture->file);
788 text[count] = '\0';
789 }
790 }
791 fclose(capture->file);
792 capture->file = NULL;
793 }
794 return text;
795}
796#endif /* !_WIN32 -- POSIX-only fd-capture helpers (#2110) */
797
798/* Mandatory-daemon activation guard fixture. The production path uses the

Callers 1

test_cli.cFile · 0.85

Calls 2

freadFunction · 0.85
closeFunction · 0.50

Tested by

no test coverage detected