C interoperability module for streaming curl output via popen.
This module provides POSIX popen() bindings to stream curl output directly to memory, eliminating the need for temporary files.
Note
This module requires POSIX-compliant systems (Linux, macOS, Unix).
Warning
Not portable to Windows.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
integer, | private, | parameter | :: | CHUNK_SIZE | = | 8192 |
Maximum chunk size for reading from pipe (8KB) |
Open a pipe to a command and return file pointer.
@param command The command to execute @param mode Open mode ("r" for read, "w" for write) @return C pointer to FILE stream, or NULL on failure
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(kind=c_char, len=1), | intent(in), | dimension(*) | :: | command | ||
character(kind=c_char, len=1), | intent(in), | dimension(*) | :: | mode |
Close a pipe opened with popen.
@param stream The FILE pointer to close @return Exit status of command, or -1 on error
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(c_ptr), | intent(in), | value | :: | stream |
Read data from a stream.
@param ptr Pointer to buffer to read into @param size Size of each element @param nmemb Number of elements to read @param stream FILE pointer to read from @return Number of elements successfully read
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(c_ptr), | intent(in), | value | :: | ptr | ||
integer(kind=c_size_t), | intent(in), | value | :: | size | ||
integer(kind=c_size_t), | intent(in), | value | :: | nmemb | ||
type(c_ptr), | intent(in), | value | :: | stream |
Stream command output directly to memory.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | command | |||
character(len=:), | intent(out), | allocatable | :: | output | ||
integer, | intent(out) | :: | exit_status |