nostrdb

an unfairly fast embedded nostr database backed by lmdb
git clone git://jb55.com/nostrdb
Log | Files | Refs | Submodules | README | LICENSE

_info (1047B)


      1 #include "config.h"
      2 #include <stdio.h>
      3 #include <string.h>
      4 
      5 /**
      6  * utf8 - Simple routines to encode/decode valid UTF-8.
      7  *
      8  * This code contains routines to encode and decode UTF-8 characters.
      9  * Table and test code stolen entirely from:
     10  *    Copyright (c) 2017 Christian Hansen <chansen@cpan.org>
     11  *    <https://github.com/chansen/c-utf8-valid>
     12  * 
     13  * Example:
     14  *	int main(int argc, char *argv[])
     15  *	{
     16  *		size_t i;
     17  *		struct utf8_state utf8_state = UTF8_STATE_INIT;
     18  *		bool decoded = true;
     19  *
     20  *		for (i = 0; i < strlen(argv[1]); i++) {
     21  *			decoded = utf8_decode(&utf8_state, argv[1][i]);
     22  *			if (decoded) {
     23  *				if (errno != 0)
     24  *					err(1, "Invalid UTF8 char %zu-%zu",
     25  *					    i - utf8_state.used_len, i);
     26  *				printf("Character %u\n", utf8_state.c);
     27  *			}
     28  *		}
     29  *
     30  *		if (!decoded)
     31  *			errx(1, "Incomplete UTF8");
     32  *		return 0;
     33  *	}
     34  *
     35  * License: BSD-MIT
     36  */
     37 int main(int argc, char *argv[])
     38 {
     39 	/* Expect exactly one argument */
     40 	if (argc != 2)
     41 		return 1;
     42 
     43 	if (strcmp(argv[1], "depends") == 0) {
     44 		return 0;
     45 	}
     46 
     47 	return 1;
     48 }