System.DomainNameHelper.IsValid C# (CSharp) Method

IsValid() static private method

static private IsValid ( char name, ushort pos, int &returnedEnd, bool &notCanonical, bool notImplicitFile ) : bool
name char
pos ushort
returnedEnd int
notCanonical bool
notImplicitFile bool
return bool
        internal unsafe static bool IsValid(char* name, ushort pos, ref int returnedEnd, ref bool notCanonical, bool notImplicitFile) {

            char *curPos = name + pos;
            char *newPos = curPos;
            char *end    = name + returnedEnd;
            for (; newPos < end; ++newPos) {
                char ch = *newPos;
                if (ch == '/' || ch == '\\' || (notImplicitFile && (ch == ':' || ch == '?' || ch == '#'))) {
                    end = newPos;
                    break;
                }
            }

            if (end == curPos) {
                return false;
            }

            do {
                //  Determines whether a string is a valid domain name label. In keeping
                //  with RFC 1123, section 2.1, the requirement that the first character
                //  of a label be alphabetic is dropped. Therefore, Domain names are
                //  formed as:
                //
                //      <label> -> <alphanum> [<alphanum> | <hyphen> | <underscore>] * 62

                //find the dot or hit the end
                newPos = curPos;
                while (newPos < end) {
                    if (*newPos == '.') break;
                    ++newPos;
                }

                //check the label start/range
                if (curPos == newPos || newPos-curPos > 63 || !IsASCIILetterOrDigit(*curPos++, ref notCanonical)) {
                    return false;
                }
                //check the label content
                while(curPos < newPos) {
                    if (!IsValidDomainLabelCharacter(*curPos++, ref notCanonical)) {
                        return false;
                    }
                }
                ++curPos;

            } while (curPos < end);

            returnedEnd = (ushort)(end-name);
            return true;
        }
        //  Determines whether a character is a valid letter according to