int main() { RTTEST hTest; int rc = RTTestInitAndCreate("tstRTNetIPv4", &hTest); if (rc) return rc; RTTestBanner(hTest); GOODADDR("1.2.3.4", 0x01020304); GOODADDR("0.0.0.0", 0x00000000); GOODADDR("255.255.255.255", 0xFFFFFFFF); /* leading and trailing whitespace is allowed */ GOODADDR(" 1.2.3.4 ", 0x01020304); GOODADDR("\t1.2.3.4\t", 0x01020304); BADADDR("1.2.3.4x"); BADADDR("1.2.3.4."); BADADDR("1.2.3"); BADADDR("0x1.2.3.4"); BADADDR("666.2.3.4"); BADADDR("1.666.3.4"); BADADDR("1.2.666.4"); BADADDR("1.2.3.666"); /* * Parsing itself is covered by the tests above, here we only * check trailers */ CHECKADDREX("1.2.3.4", "", VINF_SUCCESS, 0x01020304); CHECKADDREX("1.2.3.4", " ", VINF_SUCCESS, 0x01020304); CHECKADDREX("1.2.3.4", "x", VINF_SUCCESS, 0x01020304); CHECKADDREX("1.2.3.444", "", VERR_INVALID_PARAMETER, 0); IS_ANY("0.0.0.0"); IS_ANY("\t 0.0.0.0 \t"); NOT_ANY("1.1.1.1"); /* good address, but not INADDR_ANY */ NOT_ANY("0.0.0.0x"); /* bad address */ return RTTestSummaryAndDestroy(hTest); }
static void show_breadcrump_field (const char *str, /* {{{ */ const char *field_name) { if ((str == NULL) || (str[0] == 0)) printf ("<em>none</em>"); else if (IS_ANY (str)) printf ("<em>any</em>"); else if (IS_ALL (str)) printf ("<em>all</em>"); else { char *str_html = html_escape (str); if (field_name != NULL) printf ("<a href=\"%s?action=search;q=%s:%s\">%s</a>", script_name (), field_name, str_html, str_html); else printf ("<a href=\"%s?action=search;q=%s\">%s</a>", script_name (), str_html, str_html); free (str_html); } } /* }}} void show_breadcrump_field */