/* * Copyright (c) 2005 Sendmail, Inc. and its suppliers. * All rights reserved. * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of * the sendmail distribution. */ #include "sm/generic.h" SM_RCSID("@(#)$Id: pmilter_setreply.c,v 1.4 2006/10/05 04:27:38 ca Exp $") #include "sm/error.h" #include "sm/assert.h" #include "sm/ctype.h" #include "pmilter.h" #include "sm/pmfdef.h" #include "sm/pmfapi.h" #if MTA_USE_PMILTER /* ** SM_PMFI_SETREPLY -- Set reply for next command ** ** Parameters: ** pmse_ctx -- pmilter/SMTP server session context ** reply -- reply text including error codes ** ** Returns: ** usual sm_error code */ sm_ret_T sm_pmfi_setreply(pmse_ctx_P pmse_ctx, const char *reply_text) { sm_ret_T ret; SM_IS_PMSE_CTX(pmse_ctx); if (reply_text != NULL && *reply_text != '\0') { size_t len; char c; len = strlen(reply_text); if (len < 5) return sm_err_perm(EINVAL); c = reply_text[0]; if (c != '2' && c != '3' && c != '4' && c != '5') return sm_err_perm(EINVAL); if (!ISDIGIT(reply_text[1]) || !ISDIGIT(reply_text[2])) return sm_err_perm(EINVAL); if (reply_text[len - 2] != '\r' || reply_text[len - 1] != '\n') return sm_err_perm(EINVAL); ret = sm_str_scopy(pmse_ctx->pmse_reply_text, reply_text); } else { sm_str_clr(pmse_ctx->pmse_reply_text); ret = SM_SUCCESS; } return ret; } #endif /* MTA_USE_PMILTER */