Beispiel #1
0
const struct rfc822_header_desc *
__rfc822_header_lookup (register const char *str, register unsigned int len)
{
  static const struct rfc822_header_desc wordlist[] =
    {
      {"", 0}, {"", 0},
      {"Cc", RFC822_CC},
      {"Bcc", RFC822_BCC},
      {"", 0}, {"", 0}, {"", 0},
      {"Subject", RFC822_SUBJECT},
      {"", 0},
      {"Date", RFC822_DATE},
      {"Content-Id", RFC822_CONTENT_ID},
      {"Sender", RFC822_SENDER},
      {"To", RFC822_TO},
      {"Received", RFC822_RECEIVED},
      {"From", RFC822_FROM},
      {"References", RFC822_REFERENCES},
      {"Content-MD5", RFC822_CONTENT_MD5},
      {"Content-Type", RFC822_CONTENT_TYPE},
      {"", 0},
      {"Content-Disposition", RFC822_CONTENT_DISPOSITION},
      {"Message-ID", RFC822_MESSAGE_ID},
      {"In-Reply-To", RFC822_IN_REPLY_TO},
      {"", 0},
      {"Reply-To", RFC822_REPLY_TO},
      {"Content-Description", RFC822_CONTENT_DESCRIPTION},
      {"X-ME-Message-ID", RFC822_X_ME_MESSAGE_ID},
      {"Content-Location", RFC822_CONTENT_LOCATION},
      {"", 0}, {"", 0}, {"", 0},
      {"Content-Transfer-Encoding", RFC822_CONTENT_TRANSFER_ENCODING},
      {"Content-Language", RFC822_CONTENT_LANGUAGE},
      {"", 0},
      {"X-Deliveredinternaldate", RFC822_X_DELIVEREDINTERNALDATE}
    };

  if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
    {
      register int key = hash (str, len);

      if (key <= MAX_HASH_VALUE && key >= 0)
        {
          register const char *s = wordlist[key].name;

          if ((((unsigned char)*str ^ (unsigned char)*s) & ~32) == 0 && !gperf_case_strncmp (str, s, len) && s[len] == '\0')
            return &wordlist[key];
        }
    }
  return 0;
}
Beispiel #2
0
const char *
hoedown_find_html5_block_tag (register const char *str, register unsigned int len)
{
  enum
    {
      TOTAL_KEYWORDS = 35,
      MIN_WORD_LENGTH = 1,
      MAX_WORD_LENGTH = 10,
      MIN_HASH_VALUE = 1,
      MAX_HASH_VALUE = 37
    };

  if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
    {
      register int key = hash (str, len);

      if (key <= MAX_HASH_VALUE && key >= MIN_HASH_VALUE)
        {
          register const char *resword;

          switch (key - 1)
            {
              case 0:
                resword = "p";
                goto compare;
              case 2:
                resword = "ul";
                goto compare;
              case 3:
                resword = "pre";
                goto compare;
              case 5:
                resword = "form";
                goto compare;
              case 6:
                resword = "style";
                goto compare;
              case 7:
                resword = "footer";
                goto compare;
              case 8:
                resword = "figure";
                goto compare;
              case 9:
                resword = "section";
                goto compare;
              case 10:
                resword = "fieldset";
                goto compare;
              case 11:
                resword = "dl";
                goto compare;
              case 12:
                resword = "figcaption";
                goto compare;
              case 13:
                resword = "div";
                goto compare;
              case 14:
                resword = "del";
                goto compare;
              case 15:
                resword = "header";
                goto compare;
              case 16:
                resword = "script";
                goto compare;
              case 17:
                resword = "math";
                goto compare;
              case 18:
                resword = "video";
                goto compare;
              case 19:
                resword = "ol";
                goto compare;
              case 20:
                resword = "noscript";
                goto compare;
              case 21:
                resword = "hgroup";
                goto compare;
              case 22:
                resword = "table";
                goto compare;
              case 23:
                resword = "blockquote";
                goto compare;
              case 24:
                resword = "article";
                goto compare;
              case 25:
                resword = "aside";
                goto compare;
              case 26:
                resword = "ins";
                goto compare;
              case 27:
                resword = "iframe";
                goto compare;
              case 28:
                resword = "canvas";
                goto compare;
              case 29:
                resword = "nav";
                goto compare;
              case 30:
                resword = "h6";
                goto compare;
              case 31:
                resword = "h5";
                goto compare;
              case 32:
                resword = "h4";
                goto compare;
              case 33:
                resword = "h3";
                goto compare;
              case 34:
                resword = "h2";
                goto compare;
              case 35:
                resword = "h1";
                goto compare;
              case 36:
                resword = "output";
                goto compare;
            }
          return 0;
        compare:
          if ((((unsigned char)*str ^ (unsigned char)*resword) & ~32) == 0 && !gperf_case_strncmp (str, resword, len) && resword[len] == '\0')
            return resword;
        }
    }
  return 0;
}
Beispiel #3
0
const char *
hoedown_find_block_tag (register const char *str, register unsigned int len)
{
  enum
    {
      TOTAL_KEYWORDS = 24,
      MIN_WORD_LENGTH = 1,
      MAX_WORD_LENGTH = 10,
      MIN_HASH_VALUE = 1,
      MAX_HASH_VALUE = 24
    };

  if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
    {
      register int key = hash (str, len);

      if (key <= MAX_HASH_VALUE && key >= MIN_HASH_VALUE)
        {
          register const char *resword;

          switch (key - 1)
            {
              case 0:
                resword = "p";
                goto compare;
              case 1:
                resword = "h6";
                goto compare;
              case 2:
                resword = "div";
                goto compare;
              case 3:
                resword = "del";
                goto compare;
              case 4:
                resword = "form";
                goto compare;
              case 5:
                resword = "table";
                goto compare;
              case 6:
                resword = "figure";
                goto compare;
              case 7:
                resword = "pre";
                goto compare;
              case 8:
                resword = "fieldset";
                goto compare;
              case 9:
                resword = "noscript";
                goto compare;
              case 10:
                resword = "script";
                goto compare;
              case 11:
                resword = "style";
                goto compare;
              case 12:
                resword = "dl";
                goto compare;
              case 13:
                resword = "ol";
                goto compare;
              case 14:
                resword = "ul";
                goto compare;
              case 15:
                resword = "math";
                goto compare;
              case 16:
                resword = "ins";
                goto compare;
              case 17:
                resword = "h5";
                goto compare;
              case 18:
                resword = "iframe";
                goto compare;
              case 19:
                resword = "h4";
                goto compare;
              case 20:
                resword = "h3";
                goto compare;
              case 21:
                resword = "blockquote";
                goto compare;
              case 22:
                resword = "h2";
                goto compare;
              case 23:
                resword = "h1";
                goto compare;
            }
          return 0;
        compare:
          if ((((unsigned char)*str ^ (unsigned char)*resword) & ~32) == 0 && !gperf_case_strncmp (str, resword, len) && resword[len] == '\0')
            return resword;
        }
    }
  return 0;
}