Skip to content

Instantly share code, notes, and snippets.

@shanna
Created December 3, 2012 05:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shanna/4192996 to your computer and use it in GitHub Desktop.
Save shanna/4192996 to your computer and use it in GitHub Desktop.
libmosquitto mosquitto_topic_matches_sub
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <mosquitto.h>
int main (int argc, char *argv[])
{
bool matches = false;
mosquitto_topic_matches_sub(argv[1], argv[2], &matches);
printf("matches: %d\n", matches);
return 0;
}
/*
gcc tms.c -o tms -lmosquitto
tms "foo/bar" "foo/bar"
matches: 1
tms "foo/+" "foo/bar"
matches: 0
tms "foo/+/baz "foo/bar/baz"
matches: 1
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment