2023-11-15 09:35:59 +01:00
|
|
|
#ifndef LANDERCTL
|
|
|
|
#define LANDERCTL
|
|
|
|
|
2023-11-15 14:50:02 +01:00
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
#include <curl/curl.h>
|
|
|
|
|
2023-11-15 09:35:59 +01:00
|
|
|
typedef struct landerctl_cfg {
|
|
|
|
const char *api_key;
|
2023-11-15 14:50:02 +01:00
|
|
|
const char *server_url;
|
2023-11-17 10:29:24 +01:00
|
|
|
const char *ca_certs_bundle;
|
2023-11-15 09:35:59 +01:00
|
|
|
} landerctl_cfg;
|
|
|
|
|
|
|
|
typedef enum landerctl_cfg_err {
|
|
|
|
landerctl_cfg_err_ok = 0,
|
|
|
|
landerctl_cfg_err_not_found,
|
|
|
|
landerctl_cfg_err_invalid,
|
|
|
|
landerctl_cfg_err_incomplete,
|
|
|
|
} landerctl_cfg_err;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Try to parse the required config arguments from the config file
|
|
|
|
*
|
|
|
|
* @param out config to write values to. Existing values are overwritten
|
|
|
|
* @param path path to config file
|
|
|
|
*/
|
|
|
|
landerctl_cfg_err landerctl_cfg_parse(landerctl_cfg *out, const char *path);
|
|
|
|
|
2023-11-15 14:50:02 +01:00
|
|
|
typedef enum landerctl_mode {
|
|
|
|
landerctl_mode_none = 0,
|
|
|
|
landerctl_mode_short,
|
|
|
|
landerctl_mode_paste,
|
|
|
|
landerctl_mode_file,
|
|
|
|
} landerctl_mode;
|
|
|
|
|
2023-11-16 11:30:02 +01:00
|
|
|
typedef enum landerctl_err {
|
|
|
|
landerctl_err_ok = 0,
|
|
|
|
landerctl_err_not_found
|
|
|
|
} landerctl_err;
|
|
|
|
|
|
|
|
typedef struct landerctl_ctx {
|
|
|
|
landerctl_cfg cfg;
|
|
|
|
landerctl_mode mode;
|
|
|
|
bool secure;
|
|
|
|
bool verbose;
|
|
|
|
const char *arg;
|
|
|
|
const char *key;
|
|
|
|
CURL *curl;
|
|
|
|
struct curl_slist *headers;
|
|
|
|
FILE *data_file;
|
|
|
|
} landerctl_ctx;
|
|
|
|
|
|
|
|
const char *landerctl_err_msg(landerctl_err err);
|
|
|
|
|
|
|
|
void landerctl_set_common(landerctl_ctx *ctx);
|
|
|
|
landerctl_err landerctl_post_short(landerctl_ctx *ctx);
|
|
|
|
landerctl_err landerctl_post_paste(landerctl_ctx *ctx);
|
|
|
|
landerctl_err landerctl_post_file(landerctl_ctx *ctx);
|
2023-11-15 14:50:02 +01:00
|
|
|
|
2023-11-15 09:35:59 +01:00
|
|
|
#endif
|