Re: CODE: Regexp/email check.

From: Daniel A. Koepke (dkoepke@circlemud.org)
Date: 06/16/01


Mmm, an old thread, but I just had an idea.

  #define EMAIL_SET     "a-zA-Z0-9!#$%&'*+=/?^_`{|}~.-"
  #define EMAIL_EXPR    "%[" EMAIL_SET "]@%[" EMAIL_SET "]"

  bool valid_email(const char *em)
  {
    char mbox[MAX_INPUT_LENGTH];
    char domain[MAX_INPUT_LENGTH];

    if (sscanf(em, EMAIL_EXPR, mbox, domain) != 2)
      return (FALSE);
    else if (!str_cmp(mbox, "root") || !str_cmp(mbox, "abuse") ||
             !str_cmp(mbox, "postoffice") ||
             !str_cmp(mbox, "postmaster") ||
             !str_cmp(mbox, "webmaster"))
      return (FALSE);
    else if (!str_cmp(domain, "127.0.0.1") ||
             !str_cmp(domain, "localhost"))
      return (FALSE);

    return (TRUE);
  }

That's much more compact than what I had previously written, but it works
just as well.


--
Daniel A. Koepke (dak), dkoepke@circlemud.org
Caveat emptor: I say what I mean and mean what I say.  Listen well.
Caveat venditor: Say what you mean, mean what you say.  Say it well.

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/05/01 PST