remote_app_onboarding.c File
An app on the primary hub's PC grants one app on another PC: the invitation joins that PC's hub as a member and admits the app there with no prompt, under a peer id the primary remembers. More...
Functions Index
| static int | issue (QarRuntime *runtime) |
|
|
|
| static int | join (QarRuntime *runtime) |
|
|
|
| int | main (int argc, char **argv) |
|
|
|
| static void | on_progress (QarActionSeverity severity, float percent, const char *message, void *state) |
|
|
|
| static QarResult | onboard_local (QarRuntime *runtime, const char *tag, const QarMemberHubInvitation *grant, QarSession **out_session) |
|
|
|
| static bool | read_invitation (uint8_t *buffer, size_t buffer_size, size_t *out_size) |
|
|
|
| static void | report (const char *label, QarResult result) |
|
|
|
| static bool | set_binary (FILE *stream) |
|
|
|
| static int | start (QarRuntime *runtime) |
|
|
|
Macro Definitions Index
Description
An app on the primary hub's PC grants one app on another PC: the invitation joins that PC's hub as a member and admits the app there with no prompt, under a peer id the primary remembers.
Functions
issue()
join()
main()
| int main (int argc, char ** argv) |
|
on_progress()
| void on_progress (QarActionSeverity severity, float percent, const char * message, void * state) |
|
static
|
onboard_local()
read_invitation()
| bool read_invitation (uint8_t * buffer, size_t buffer_size, size_t * out_size) |
|
static
|
report()
| void report (const char * label, QarResult result) |
|
static
|
set_binary()
| bool set_binary (FILE * stream) |
|
static
|
start()
Macro Definitions
example_fileno
| #define example_fileno fileno |
|
example_isatty
| #define example_isatty isatty |
|
GRANT_TAG
| #define GRANT_TAG "client.remote-app-onboarding.examples.quaternar" |
|
ISSUER_TAG
| #define ISSUER_TAG "server.remote-app-onboarding.examples.quaternar" |
|
MAX_INVITATION_BYTES
| #define MAX_INVITATION_BYTES (16 * 1024) |
|
File Listing
The file content with the documentation metadata removed is:
117#ifndef QAR_ENABLE_DYNAMIC_LOADING
118#define QAR_ENABLE_DYNAMIC_LOADING
125#define example_isatty _isatty
126#define example_fileno _fileno
129#define example_isatty isatty
130#define example_fileno fileno
137#define ISSUER_TAG "server.remote-app-onboarding.examples.quaternar"
138#define GRANT_TAG "client.remote-app-onboarding.examples.quaternar"
140#define MAX_INVITATION_BYTES (16 * 1024)
147 if(_setmode(_fileno(stream), _O_BINARY) == -1)
149 fprintf(stderr, "Could not switch a standard stream to binary mode.\n");
162 char message[512] = { 0 };
165 fprintf(stderr, "%s: ok\n", label);
169 fprintf(stderr, "%s: error %d: %s\n", label, (int)result.code, message);
178 if(message != NULL && message[0] != '\0')
180 fprintf(stderr, "%s\n", message);
221 "Refusing to print the invitation on a console: pipe stdout into your channel.\n"
229 report("qar_runtime_onboard (issuer)", joined);
238 init.label = "Remote app example";
246 report("qar_runtime_create_member_hub_invitation", created);
249 fprintf(stderr, "Ask the operator to allow this app to bring in member hubs.\n");
253 uint8_t* bytes = NULL;
259 bytes = (uint8_t*)calloc(1, size);
263 report("qar_member_hub_invitation_serialized_size", sized);
271 report("qar_member_hub_invitation_serialize", serialized);
274 && fwrite(bytes, 1, written, stdout) == written && fflush(stdout) == 0)
280 fprintf(stderr, "The invitation was not handed over.\n");
282 memset(bytes, 0, size);
300 *out_size = fread(buffer, 1, buffer_size, stdin);
301 if(ferror(stdin) || *out_size == 0 || *out_size == buffer_size)
322 report("qar_member_hub_invitation_deserialize", parsed);
326 fprintf(stderr, "No invitation on stdin.\n");
343 report("qar_runtime_join_hub_as_member", joined_hub);
346 fprintf(stderr, "The join is committed; run join again once the hub is back.\n");
355 report("qar_runtime_onboard (remote app)", joined);
358 fprintf(stderr, "The grant already admitted another app, or it was revoked.\n");
380 report("qar_runtime_onboard (remote app)", joined);
392main(int argc, char** argv)
394 const char* role = argc >= 2 ? argv[1] : "";
395 if(strcmp(role, "issue") != 0 && strcmp(role, "join") != 0 && strcmp(role, "start") != 0)
398 stderr, "Usage: %s issue|join|start\n", argc >= 1 ? argv[0] : "remote_app_onboarding"
405 fprintf(stderr, "QAROS is not installed on this PC.\n");
413 report("qar_library_init", initialized);
422 report("qar_runtime_create", created);
425 if(strcmp(role, "issue") == 0)
427 exit_code = issue(runtime);
429 else if(strcmp(role, "join") == 0)
431 exit_code = join(runtime);
435 exit_code = start(runtime);
Generated via doxygen2docusaurus 2.2.1 by Doxygen 1.9.8.