/* -*- buffer-read-only: t -*- vi: set ro: THIS FILE IS GENERATED AUTOMATICALLY. PLEASE DO NOT EDIT. */ #line 1 "callout.mf4" /* Callout functions -*- mfl -*- Copyright (C) 2010-2020 Sergey Poznyakoff This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ module 'callout'. require status #pragma regex push +extended dclex e_callout_proto #line 29 string last_poll_host string last_poll_greeting string last_poll_helo string last_poll_sent string last_poll_recv number cache_used static func setvar(number fd, string name, string value) do write(fd, "SET %name=%value\r\n") set reply getline(fd) if not reply matches 'OK.*' throw e_callout_proto reply fi done func callout_open(string url) returns number do number fd open("@ %url") fd_set_delimiter(fd,"\r\n") string reply getline(fd) if not reply matches 'OK.*' throw e_callout_proto reply fi string sid "" if milter_client_address == "" set sid "local:" else set sid "%milter_client_address:" fi if macro_defined("i") set sid sid . getmacro("i") fi write(fd, "SID %sid\r\n") set reply getline(fd) if not reply matches 'OK.*' throw e_callout_proto reply fi #line 79 return fd done func callout_close(number fd) do write(fd, "QUIT\r\n") set reply getline(fd) close(fd) done func callout_do(number fd, string email; string rest) returns number do string reply "" if dequote(email) == "" return 0 fi write(fd, 'VRFY "'.escape(email).'"') if $#>@rest write(fd, ' '.rest) fi write(fd, "\r\n") set reply getline(fd) if not reply matches 'OK.*' throw e_callout_proto reply fi write(fd, "RUN\r\n") set cache_used 1 loop for set reply getline(fd), while index(reply, "*") == 0, set reply getline(fd) do if reply matches '\* ([0-9]+) ([A-Z]+) (.*)' set cache_used 0 switch \2 do case "INIT": set last_poll_host \3 case "GRTNG": set last_poll_greeting \3 case "HELO": set last_poll_helo \3 case "SENT": set last_poll_sent \3 case "RECV": set last_poll_recv \3 done fi done if reply matches "OK ([0-9]+)=(.*)" switch \2 do case "success": pass case "not_found": return e_not_found case "failure": return e_failure case "temp_failure" or "timeout": return e_temp_failure done else return e_not_found fi return 0 done #pragma provide-callout precious string callout_server_url precious number __callout_fd -1 begin do if callout_server_url == "" set callout_server_url default_callout_server_url() fi done func __callout_open_default() returns number do if __callout_fd == -1 set __callout_fd callout_open(callout_server_url) fi return __callout_fd done func callout(string email) returns number do return callout_do(__callout_open_default(), email) done