Created
January 10, 2015 16:44
-
-
Save klondi/7b5aa6a6f47ed2c9a36b to your computer and use it in GitHub Desktop.
This is code I wrote for an I2PD http parser which will never see the light, consider it public domain
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
inline bool isValidHeaderChar(uint8_t c) { return (c > 0x20 && c != 0x7f); } | |
inline bool isValidHeaderNameChar(uint8_t c) { | |
//This is a bool vector containing the valid characters | |
//!#$%&'*+-.^_`|~0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ | |
static const uint8_t *valid = {0, 0, 0, 0, 250, 108, 255, 3, 254, 255, 255, 199, | |
255, 255, 255, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; | |
return valid[(x / 8) & 31] & (1 << (x & 7)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Keep in mind that you can use compres the vector if you remove values below 0x20 and over 0x7f