aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-10-16 04:49:14 +0200
committerdec05eba <dec05eba@protonmail.com>2020-10-16 04:49:14 +0200
commit221522cf995cbcd39c956f66423a26bbccae8f72 (patch)
treeb09dd14964465e4d69082725d4ad950141692d8f /include
parent66a97007eb36a112f31e923c20e434ba8b39c4ba (diff)
Matrix: stream download to rapidjson parser
Diffstat (limited to 'include')
-rw-r--r--include/DownloadUtils.hpp2
-rw-r--r--include/Program.h15
2 files changed, 9 insertions, 8 deletions
diff --git a/include/DownloadUtils.hpp b/include/DownloadUtils.hpp
index 7ce4b15..2d2b813 100644
--- a/include/DownloadUtils.hpp
+++ b/include/DownloadUtils.hpp
@@ -2,6 +2,7 @@
#include <string>
#include <vector>
+#include <rapidjson/document.h>
namespace QuickMedia {
enum class DownloadResult {
@@ -17,4 +18,5 @@ namespace QuickMedia {
DownloadResult download_to_string(const std::string &url, std::string &result, const std::vector<CommandArg> &additional_args, bool use_tor, bool use_browser_useragent = false, bool fail_on_error = true);
DownloadResult download_to_string_cache(const std::string &url, std::string &result, const std::vector<CommandArg> &additional_args, bool use_tor, bool use_browser_useragent = false);
+ DownloadResult download_to_json(const std::string &url, rapidjson::Document &result, const std::vector<CommandArg> &additional_args, bool use_tor, bool use_browser_useragent = false, bool fail_on_error = true);
} \ No newline at end of file
diff --git a/include/Program.h b/include/Program.h
index 3cbf09e..cab8d26 100644
--- a/include/Program.h
+++ b/include/Program.h
@@ -10,8 +10,7 @@ extern "C" {
typedef struct {
pid_t pid;
int read_fd;
- int write_fd;
-} ProgramPipe;
+} ReadProgram;
/* Return 0 if you want to continue reading. @data is null-terminated */
typedef int (*ProgramOutputCallback)(char *data, int size, void *userdata);
@@ -20,6 +19,12 @@ typedef int (*ProgramOutputCallback)(char *data, int size, void *userdata);
@args need to have at least 2 arguments. The first which is the program name
and the last which is NULL, which indicates end of args
*/
+int exec_program_pipe(const char **args, ReadProgram *read_program);
+
+/*
+ @args need to have at least 2 arguments. The first which is the program name
+ and the last which is NULL, which indicates end of args
+*/
int exec_program(const char **args, ProgramOutputCallback output_callback, void *userdata);
// Return the exit status, or a negative value if waiting failed
@@ -35,12 +40,6 @@ int wait_program_non_blocking(pid_t process_id, int *status);
and you want the child process to be cleaned up automatically when it dies.
*/
int exec_program_async(const char **args, pid_t *result_process_id);
-#if 0
-
-int program_pipe_write(ProgramPipe *self, const char *data, size_t size);
-int program_pipe_read(ProgramPipe *self, ProgramOutputCallback output_callback, void *userdata);
-void program_pipe_close(ProgramPipe *self);
-#endif
#ifdef __cplusplus
}