1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- #pragma once
- #include <stdlib.h>
- #include <stdbool.h>
- #include "curl.h"
- #define MAX_BUF_SZ 2048
- enum environment_variable_key {
- OS_AUTH_TYPE,
- OS_AUTH_URL,
- OS_IDENTITY_API_VERSION,
- OS_INTERFACE,
- OS_PASSWORD,
- OS_PROJECT_DOMAIN_NAME,
- OS_PROJECT_ID,
- OS_PROJECT_NAME,
- OS_REGION_NAME,
- OS_USER_DOMAIN_NAME,
- OS_USERNAME,
- n_vars
- };
- struct environment_variable {
- char *name;
- char *val;
- bool req;
- };
- extern struct environment_variable env[n_vars];
- struct command {
- char *name;
- int (*fn)(int argc, char **argv);
- };
- // https://stackoverflow.com/a/40706869/10210798
- #define CMD_DEF(f) { #f, f }
- // Keep track of where we are in the subcommand stack, eg for adding to help/usage messages.
- extern int subcommand_depth;
- extern char *subcommand_breadcrumbs;
- void usage();
- #define WHEREAMI() { printf("In %s:%d, function '%s'\n", __FILE__, __LINE__, __func__); }
- void get_environment_variables();
- void print_credentials();
- void api_url_build(char *url, const char *endpoint, const char *path);
- void get_interface_endpoint(char *url, const char *endpoint);
- void print_response(const struct string *s, const char *item);
- void common_main(int argc, char **argv, struct command *subcommands);
|