static void handle_auth_plain_response(str* line, ssize_t offset) { int start; int end; saw_auth_plain = 0; if (base64decode(line->s + offset, line->len - offset, &tmpstr)) { /* tmpstr should now contain "AUTHORIZATION\0AUTHENTICATION\0PASSWORD" */ if ((start = str_findfirst(&tmpstr, NUL)) >= 0 && (end = str_findnext(&tmpstr, NUL, ++start)) > start) { make_username(tmpstr.s + start, end - start, "AUTH PLAIN "); str_splice(&tmpstr, start, end - start, &username); line->len = offset; base64encode(tmpstr.s, tmpstr.len, line); str_catb(line, CRLF, 2); } } }
static void handle_login(int offset) { const char* start; const char* end; start = linebuf.s + offset; while (isspace(*start)) ++start; if (*start == '"') { end = ++start; while (*end != '"') ++end; } else { end = start; while (!isspace(*end)) ++end; } make_username(start, end - start, "LOGIN "); str_splice(&linebuf, start-linebuf.s, end-start, &username); str_copy(&saved_label, &label); str_truncate(&label, 0); }