On Mon, 10 Nov 2003, Corey Wallis wrote: > I'm currently developing a program, in C#, to compile the list and > remove any duplicate domain names etc. The last piece of the puzzle is > the sub domain check. Could you please tell me how you implemented this > in the Squid code.
A is a subdomain of B if the following criterias is fulfilled B starts with a dot and end of A matches B or A matches B without the leading dot. if (B[0] == '.') { if (strlen(B) <= strlen(A) && strcasecmp(A+strlen(A)-strlen(B), B)==0) return 1; /* end of A matches B */ else if (strcasecmp(A, B+1) == 0) return 1; /* A matches B without the dot */ } else if (strcasecmp(A, B) == 0) { return 1; /* A identical to B */ } return 0; /* no match. A is not a subdomain of B */ Regards Henrik