Created
May 10, 2011 16:45
-
-
Save rfc1459/964866 to your computer and use it in GitHub Desktop.
Sample tldgen output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Azzurra IRC Services (C) 2001-2011 Azzurra IRC Network | |
* | |
* This program is free but copyrighted software; see COPYING for details. | |
* | |
* tld_tab.h - DFA state matrix for TLD check | |
* THIS FILE IS AUTOGENERATED - DO NOT EDIT! | |
*/ | |
#ifndef I_HAVE_A_VERY_GOOD_REASON_TO_INCLUDE_TLD_TAB_H | |
#error "*NEVER* *EVER* include this file unless you know what you're doing" | |
#endif /* I_HAVE_A_VERY_GOOD_REASON_TO_INCLUDE_TLD_TAB_H */ | |
/* Token map */ | |
static uint8_t dfa_token_map[] = { | |
0, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, | |
27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, | |
27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, | |
27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, | |
27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, | |
27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, | |
27, 1, 25, 2, 6, 3, 8, 7, 21, 9, 26, 22, 11, 10, 12, 5, | |
15, 13, 4, 14, 17, 16, 23, 18, 19, 24, 20, 27, 27, 27, 27, 27, | |
27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, | |
27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, | |
27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, | |
27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, | |
27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, | |
27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, | |
27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, | |
27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27 | |
}; | |
#define DFA_TOKEN_EPSILON (dfa_token_map['\0']) | |
#define DFA_STATE_COUNT 62 | |
#define DFA_START_STATE 0 | |
#define DFA_ACCEPT_STATE 1 | |
#define DFA_ILLEGAL_STATE 62 | |
#define DFA_TRANSITIONS 27 | |
/* DFA state matrix */ | |
static uint8_t tld_dfa_matrix[DFA_STATE_COUNT][DFA_TRANSITIONS] = { | |
{ 62, 2,11,16,47,42,15,19,18,22,30,29,38,46,48,44,55,49,57,58,61,21,28,56,60, 9,25 }, | |
{ 62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62 }, | |
{ 62,62, 1, 3, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 7,62, 1, 1, 1, 1, 1,62,62,62,62,62,62 }, | |
{ 1,62,62,62, 4,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62 }, | |
{ 62,62,62,62,62, 1,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62 }, | |
{ 1,62,62,62,62,62,62,62,62,62,62,62,62,62,62, 6,62,62,62,62,62,62,62,62,62,62,62 }, | |
{ 62, 1,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62 }, | |
{ 1,62,62,62,62,62,62,62,62, 8,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62 }, | |
{ 62, 1,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62 }, | |
{ 62, 1,62, 1, 1, 1, 1, 1, 1,10, 1,62, 1,62, 1,62,62, 1, 1,62, 1, 1,62, 1, 1, 1, 1 }, | |
{ 1,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62, 1,62,62,62,62,62,62 }, | |
{ 62,12, 1,62, 1,13, 1, 1, 1, 1, 1, 1, 1,62,62,62, 1,62,62, 1, 1, 1, 1, 1, 1,62,62 }, | |
{ 1,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62, 1,62,62,62,62,62,62,62,62,62 }, | |
{ 1,62,62,62,62,14,62,62,62,62, 1,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62 }, | |
{ 62,62,62,62,62,62,62,62,62,62,62,62,62,62,62, 1,62,62,62,62,62,62,62,62,62,62,62 }, | |
{ 62,62,62, 1,62, 1,62,62,62,62, 1,62,62,62,62,62,62,62,62,62, 1,62, 1,62,62,62, 1 }, | |
{ 62,62, 1, 1, 1,62,17, 1,62,62,62,62,62,62, 1,62, 1, 1,62,62,62,62,62,62,62,62,62 }, | |
{ 62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62, 1,62,62,62,62,62,62,62,62,62,62 }, | |
{ 62,62,62,62, 1, 1,62,62,62, 1, 1,62,62,62,62,62,62,62,62,62,62,62, 1,62,62,62, 1 }, | |
{ 62, 1,62, 1, 1,20, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,62,62, 1,62,62, 1, 1,62 }, | |
{ 62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62, 1,62,62,62 }, | |
{ 62,62,62,62, 1,62,62,62,62,62, 1,62, 1,62,62,62, 1, 1,62,62,62,62, 1,62,62,62,62 }, | |
{ 62,62,62, 1, 1, 1, 1,62,62,62, 1, 1,23, 1, 1,62,62, 1,62,62,62,62,62,62,62,62,62 }, | |
{ 1,62,62,62,62,62,62,62,24,62,62,62,62,62,62,62,62, 1,62,62,62,62,62,62,62,62,62 }, | |
{ 62,62,62,62,62, 1,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62 }, | |
{ 62,62,62, 1,62,26,62,62,62,62, 1,62,62,62,62, 1,62,62,62,62,62,62,62,62,62,62,62 }, | |
{ 1,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,27,62 }, | |
{ 62,62,62,62,62,62,62,62,62,62,62,62,62,62, 1,62,62,62,62,62,62,62,62,62,62,62,62 }, | |
{ 62,62,62, 1, 1,62,62, 1,62, 1, 1,62, 1,62,62, 1,62,62, 1,62, 1, 1,62,62, 1,62,62 }, | |
{ 62, 1, 1,62, 1,62,62,62,62, 1,62,62,62,62, 1,62, 1, 1,62,62,62,62, 1, 1, 1, 1,62 }, | |
{ 62, 1, 1, 1, 1,32, 1, 1,62,31, 1, 1, 1, 1, 1, 1,34, 1, 1, 1, 1, 1, 1, 1, 1,62,62 }, | |
{ 62,62,62,62,62,62,62,62,62,62,62, 1,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62 }, | |
{ 1,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,33,62 }, | |
{ 62,62,62,62,62,62,62,62,62, 1,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62 }, | |
{ 1,62,62,62,62,62,62,62,62,62,62,62,62,62,35,62,62,62,62,62,62,62,62,62,62,62,62 }, | |
{ 62,62,62,36,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62 }, | |
{ 62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,37,62,62,62,62,62,62,62,62,62,62 }, | |
{ 62,62,62,62,62,62,62,62,62,62, 1,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62 }, | |
{ 62,39, 1,41, 1, 1,62, 1, 1, 1,62, 1,62,62,62, 1, 1,62,62,62, 1,62,62,62,62,62,62 }, | |
{ 1,62,62,62,62,62,62,62,62,62,40,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62 }, | |
{ 62,62,62, 1,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62 }, | |
{ 1,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62, 1,62,62,62,62,62,62,62,62,62 }, | |
{ 62,62,62,62,43,62,62,62,62,62, 1,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62 }, | |
{ 62,62,62,62,62,62,62, 1,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62 }, | |
{ 62, 1,62, 1,45,62,62, 1, 1,62, 1, 1, 1,62, 1,62,62, 1, 1,62,62, 1, 1,62, 1,62,62 }, | |
{ 1,62,62,62,62, 1,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62 }, | |
{ 62, 1,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62 }, | |
{ 62,62,62, 1,62, 1,62,62,62,62,62,62,62,62, 1,62, 1,62, 1,62,62,62,62,62,62,62,62 }, | |
{ 62, 1, 1, 1, 1, 1, 1, 1,62, 1, 1, 1, 1,62,62,62, 1, 1,62,62, 1, 1, 1, 1, 1, 1, 1 }, | |
{ 62,62, 1,50,51, 1, 1, 1, 1,62, 1, 1, 1,62,62, 1,62, 1, 1,62, 1, 1, 1, 1,62,62, 1 }, | |
{ 62,62,62,62,62,62,62,62,62,62,62, 1,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62 }, | |
{ 1,52,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62 }, | |
{ 62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,53,62,62,62 }, | |
{ 62,62,62,54,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62 }, | |
{ 62,62,62,62,62,62,62,62,62,62,62, 1,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62 }, | |
{ 62, 1,62,62,62,62,62, 1,62,62,62,62,62,62, 1,62,62,62,62,62, 1,62, 1,62, 1,62,62 }, | |
{ 62, 1, 1, 1,62,62,62, 1,62, 1,62,62, 1,62,62,62, 1,62,62,62,62,62,62,62,62,62,62 }, | |
{ 62,62,62,62,62,62,62,62, 1,62,62,62,62,62, 1,62,62,62,62,62,62,62,62,62,62,62,62 }, | |
{ 62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,59,62,62,62,62,62,62,62 }, | |
{ 62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62, 1,62,62,62,62,62,62,62 }, | |
{ 62,62,62, 1,62,62,62,62,62,62,62,62,62,62,62,62,62, 1,62,62,62,62,62,62,62,62,62 }, | |
{ 62, 1,62,62,62,62,62,62,62,62, 1,62,62,62,62,62,62,62, 1,62,62,62,62,62,62,62,62 } | |
}; | |
/* Verify if given string is accepted by this DFA */ | |
static char check_tld(const unsigned char *s) | |
{ | |
uint8_t token; | |
uint8_t state = DFA_START_STATE; | |
if (s == NULL) | |
return 0; | |
while (*s) | |
{ | |
token = dfa_token_map[*s]; | |
if (token >= DFA_TRANSITIONS) | |
return 0; | |
/* Get next state */ | |
state = tld_dfa_matrix[state][token]; | |
if (state == DFA_ILLEGAL_STATE || state >= DFA_STATE_COUNT) | |
return 0; | |
s++; | |
} | |
return *s == '\0' && (state == DFA_ACCEPT_STATE | |
|| tld_dfa_matrix[state][DFA_TOKEN_EPSILON] == DFA_ACCEPT_STATE); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment