char *find_str (const char [], size_t, const char *);
char *rfind_str (const char [], size_t, const char *);
char *nmh_strcasestr (const char *, const char *);
+
+/*
+ * See if a string contains 8 bit characters (use isascii() for the test).
+ * Arguments include:
+ *
+ * start - Pointer to start of string to test.
+ * end - End of string to test (test will stop before reaching
+ * this point). If NULL, continue until reaching '\0'.
+ *
+ * This function always stops at '\0' regardless of the value of 'end'.
+ * Returns 1 if the string contains an 8-bit character, 0 if it does not.
+ */
+int contains8bit(const char *start, const char *end);
static int domain (char *);
static int route (char *);
static int my_lex (char *);
-static int contains8bit (const char *);
int
* Reject the address if key fields contain 8bit characters
*/
- if (contains8bit(mbox) || contains8bit(host) || contains8bit(path) ||
- contains8bit(grp)) {
+ if (contains8bit(mbox, NULL) || contains8bit(host, NULL) ||
+ contains8bit(path, NULL) || contains8bit(grp, NULL)) {
strcpy(err, "Address contains 8-bit characters");
}
}
-/*
- * Return true if the string contains an 8-bit character
- */
-
-static int
-contains8bit(const char *p)
-{
- if (! p)
- return 0;
-
- for (; *p; p++) {
- if (! isascii((unsigned char) *p))
- return 1;
- }
-
- return 0;
-}
-
-
char *
legal_person (const char *p)
{
return status;
}
}
+
+/*
+ * Scan for any 8-bit characters. Return 1 if they exist.
+ *
+ * Scan up until the given endpoint (but not the actual endpoint itself).
+ * If the endpoint is NULL, scan until a '\0' is reached.
+ */
+
+int
+contains8bit(const char *start, const char *end)
+{
+ while (*start != '\0' && (!end || (start < end)))
+ if (! isascii((unsigned char) *start++))
+ return 1;
+
+ return 0;
+}