A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/rikvdh/matching below:

rikvdh/matching: String-based parser based on matching strings for interpreting and handling string-based interfaces

String-based parser based on matching strings for interpreting and handling string-based interfaces (like GSM-modem AT commands)

With clib:

clib install rikvdh/matching
#include "matching.h"
#include <assert.h>
#include <stdio.h>

static struct matching_ctx ctx;
static char ctx_linebuffer[256];

static void matching_cb_match_ko(struct matching_ctx *ctx)
{
	(void)ctx;
	printf("Matched on 'TEST'\n");
}

static const struct matching_item matching_items[] = {
	{ MATCHING_ITEM_STR("TEST"), 0, match_cb }
};

int main(int argc, char **argv)
{
	ctx.cfg.flags       = MATCHING_ITEM_FLAG_CB_ON_RESET;
	ctx.cfg.reset_chars = "\n";
	za_buffer_init(&ctx.linebuffer, ctx_linebuffer, sizeof(ctx_linebuffer));
	ctx.items.list      = matching_items;
	ctx.items.n         = sizeof(matching_items)/sizeof(matching_items[0]);
	ctx.items.state     = matching_items_state;
	matching_init(&ctx);

	matching_feed(&ctx, 'T', true);
	matching_feed(&ctx, 'E', true);
	matching_feed(&ctx, 'S', true);
	matching_feed(&ctx, 'T', true);
	matching_feed(&ctx, '\n', true);

	return 0;
}

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4