URI parsing/formatting example
#include <network/gru_uri.h> // amqp://localhost:61613/queue amq localhost 61613 /queue int main(int argc, char **argv) { gru_uri_t uri = {0}; gru_status_t status = gru_status_new(); if (argc < 3) { fprintf(stderr, "Missing arguments\n"); return EXIT_FAILURE; } uri = gru_uri_parse(argv[1], &status); if (gru_status_error(&status)) { fprintf(stderr, "%s", status.message); goto err_exit; } if (strcmp(uri.scheme, argv[2]) != 0) { fprintf(stderr, "Expected scheme '%s' does not match returned one '%s'\n", argv[2], uri.scheme); goto err_exit; } if (strcmp(uri.host, argv[3]) != 0) { fprintf( stderr, "Expected host '%s' does not match returned one '%s'\n", argv[3], uri.host); goto err_exit; } if (uri.port != atoi(argv[4])) { fprintf( stderr, "Expected port '%s' does not match returned one '%d'\n", argv[2], uri.port); goto err_exit; } if (strcmp(uri.path, argv[5]) != 0) { fprintf( stderr, "Expected path '%s' does not match returned one '%s'\n", argv[5], uri.path); goto err_exit; } gru_uri_cleanup(&uri); return EXIT_SUCCESS; err_exit: gru_uri_cleanup(&uri); return EXIT_FAILURE; }