Sha256: 271511c0afdafe458449e417895a5f0bbc51266495bcb46b2b38ef35d7fcd970

Contents?: true

Size: 1.24 KB

Versions: 38

Compression:

Stored size: 1.24 KB

Contents

#include <stdio.h>

#define ALPHANUM(c) ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9'))
#define URL_SAFE(c) (ALPHANUM(c) || c == '-' || c == '_' || c == '.')

/* from uri/common.rb */
#define UNRESERVED(c) (ALPHANUM(c) || c == '-' || c == '_' || c == '.' || c == '!' || c == '~' || c == '*' || c == '\'' || c == '(' || c == ')')
#define RESERVED(c) (c == ';' || c == '/' || c == '?' || c == ':' || c == '@' || c== '&' || c == '=' || c == '+' || c == '$' || c == ',' || c == '[' || c == ']')
#define URI_SAFE(c) (URL_SAFE(c) || UNRESERVED(c) || RESERVED(c))

#define HREF_HTML_SAFE(c) (URL_SAFE(c) || strchr("-_.+!*(),%#@?=;:/,+$", c) != NULL)

int main(void)
{
	int i;

	printf("static const char HREF_SAFE[] = {\n\t");

	for (i = 0; i < 256; ++i) {
		printf("%d, ", HREF_HTML_SAFE(i));

		if (i % 16 == 15 && i < 255)
			printf("\n\t");
	}

	printf("};\n\n");

	printf("static const char URL_SAFE[] = {\n\t");

	for (i = 0; i < 256; ++i) {
		printf("%d, ", URL_SAFE(i));

		if (i % 16 == 15 && i < 255)
			printf("\n\t");
	}

	printf("};\n\n");

	printf("static const char URI_SAFE[] = {\n\t");

	for (i = 0; i < 256; ++i) {
		printf("%d, ", URI_SAFE(i));

		if (i % 16 == 15 && i < 255)
			printf("\n\t");
	}

	printf("};\n");

	return 0;
}

Version data entries

38 entries across 38 versions & 2 rubygems

Version Path
hamlit-2.2.4 ext/hamlit/houdini/tools/build_tables.c
hamlit-2.5.0 ext/hamlit/houdini/tools/build_tables.c
hamlit-2.4.2 ext/hamlit/houdini/tools/build_tables.c
hamlit-2.4.1 ext/hamlit/houdini/tools/build_tables.c
hamlit-2.4.0 ext/hamlit/houdini/tools/build_tables.c
hamlit-2.3.1 ext/hamlit/houdini/tools/build_tables.c
hamlit-2.3.0 ext/hamlit/houdini/tools/build_tables.c
hamlit-2.2.3 ext/hamlit/houdini/tools/build_tables.c
faml-0.8.1 vendor/houdini/tools/build_tables.c
hamlit-2.2.2 ext/hamlit/houdini/tools/build_tables.c
hamlit-2.2.1 ext/hamlit/houdini/tools/build_tables.c
faml-0.8.0 vendor/houdini/tools/build_tables.c
faml-0.7.3 vendor/houdini/tools/build_tables.c
hamlit-2.2.0 ext/hamlit/houdini/tools/build_tables.c
hamlit-2.1.2 ext/hamlit/houdini/tools/build_tables.c
hamlit-2.1.1 ext/hamlit/houdini/tools/build_tables.c
hamlit-2.1.0 ext/hamlit/houdini/tools/build_tables.c
faml-0.7.2 vendor/houdini/tools/build_tables.c
hamlit-2.0.2 ext/hamlit/houdini/tools/build_tables.c
faml-0.7.1 vendor/houdini/tools/build_tables.c