+ int prefixlen = strlen(name) + 2, column = prefixlen, groupflag, errflag;
+ int eightbitchars;
+ char *mp, *output = NULL;
+ struct mailname *mn;
+
+ /*
+ * Because these are addresses, we need to handle them individually.
+ *
+ * Break them down and process them one by one. This means we have to
+ * rewrite the whole header, but that's unavoidable.
+ */
+
+ /*
+ * The output headers always have to start with a space first.
+ */
+
+ output = add(" ", output);
+
+ for (groupflag = 0; mp = getname(*value); ) {
+ if ((mn = getm(mp, NULL, 0, AD_HOST, NULL)) == NULL) {
+ errflag++;
+ continue;
+ }
+
+ /*
+ * We only care if the phrase (m_pers) or any trailing comment
+ * (m_note) have 8-bit characters. If doing q-p, we also need
+ * to encode anything marked as qspecial().
+ */
+ }
+}
+
+/*
+ * Scan a string, check for characters that need to be encoded
+ */
+
+static int
+scanstring(const char *string, int *asciilen, int *eightbitchars,
+ int *specialchars)
+{
+ *asciilen = 0;
+ *eightbitchars = 0;
+ *specialchars = 0;
+
+ for (; *string != '\0'; string++) {
+ if ((isascii((unsigned char) *string))) {
+ (*asciilen++);
+ if (!qphrasevalid((unsigned char) *string))
+ (*specialchars)++;
+ } else {
+ (*eightbitchars)++;
+ }
+ }
+
+ return eightbitchars > 0;