Sha256: 590b17c25792af7ef159d3c0ce9aae863ed91ee66835873dc230481b83061f9f

Contents?: true

Size: 1.7 KB

Versions: 33

Compression:

Stored size: 1.7 KB

Contents

#ifndef ws_framing_utils_h
#define ws_framing_utils_h


#include <stdint.h>


/* Extracted from http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ */

#define UTF8_ACCEPT 0
#define UTF8_REJECT 1
#define UTF8D_SIZE 400

static const uint8_t utf8d[] = {
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 00..1f */
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 20..3f */
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 40..5f */
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 60..7f */
  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, /* 80..9f */
  7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, /* a0..bf */
  8,8,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, /* c0..df */
  0xa,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x4,0x3,0x3, /* e0..ef */
  0xb,0x6,0x6,0x6,0x5,0x8,0x8,0x8,0x8,0x8,0x8,0x8,0x8,0x8,0x8,0x8, /* f0..ff */
  0x0,0x1,0x2,0x3,0x5,0x8,0x7,0x1,0x1,0x1,0x4,0x6,0x1,0x1,0x1,0x1, /* s0..s0 */
  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,0,1,0,1,1,1,1,1,1, /* s1..s2 */
  1,2,1,1,1,1,1,2,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1, /* s3..s4 */
  1,2,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,3,1,3,1,1,1,1,1,1, /* s5..s6 */
  1,3,1,1,1,1,1,3,1,3,1,1,1,1,1,1,1,3,1,1,1,1,1,1,1,1,1,1,1,1,1,1  /* s7..s8 */
};

uint32_t inline utf8_decode(uint32_t* state, uint32_t* codep, uint32_t byte) {
  uint32_t type = utf8d[byte];

  *codep = (*state != UTF8_ACCEPT) ? (byte & 0x3fu) | (*codep << 6) : (0xff >> type) & (byte);
  *state = utf8d[256 + *state*16 + type];
  return *state;
}


typedef struct utf8_validator {
  uint32_t codepoint;
  uint32_t state;
} utf8_validator;


#endif

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
oversip-1.4.1 ext/websocket_framing_utils/ws_framing_utils.h
oversip-1.4.0 ext/websocket_framing_utils/ws_framing_utils.h
oversip-1.3.8 ext/websocket_framing_utils/ws_framing_utils.h
oversip-1.3.7 ext/websocket_framing_utils/ws_framing_utils.h
oversip-1.3.6 ext/websocket_framing_utils/ws_framing_utils.h
oversip-1.3.5 ext/websocket_framing_utils/ws_framing_utils.h
oversip-1.3.3 ext/websocket_framing_utils/ws_framing_utils.h
oversip-1.3.2 ext/websocket_framing_utils/ws_framing_utils.h
oversip-1.3.1 ext/websocket_framing_utils/ws_framing_utils.h
oversip-1.3.0 ext/websocket_framing_utils/ws_framing_utils.h
oversip-1.3.0.dev1 ext/websocket_framing_utils/ws_framing_utils.h
oversip-1.2.1 ext/websocket_framing_utils/ws_framing_utils.h
oversip-1.2.0 ext/websocket_framing_utils/ws_framing_utils.h
oversip-1.1.2 ext/websocket_framing_utils/ws_framing_utils.h
oversip-1.1.1 ext/websocket_framing_utils/ws_framing_utils.h
oversip-1.1.0 ext/websocket_framing_utils/ws_framing_utils.h
oversip-1.1.0.beta5 ext/websocket_framing_utils/ws_framing_utils.h
oversip-1.1.0.beta4 ext/websocket_framing_utils/ws_framing_utils.h
oversip-1.1.0.beta3 ext/websocket_framing_utils/ws_framing_utils.h
oversip-1.1.0.beta2 ext/websocket_framing_utils/ws_framing_utils.h