/* * Copyright (c) 2006 Claus Assmann * * By using this file, you agree to the terms and conditions set * forth in the license/LICENSE.3C file which can be found at the * top level of this source code distribution. */ #include "sm/generic.h" SM_RCSID("@(#)$Id: pm_add_domain.c,v 1.4 2006/11/22 03:44:15 ca Exp $") #include "sm/assert.h" #include "sm/error.h" #include "sm/str-int.h" #include "sm/str.h" #include "sm/misc.h" /* ** SM_POSTMASTER_ADD_DOMAIN -- check for and convert it ** ** Parameters: ** str -- printable address ** domain -- domain to append ** offset -- where in str does the address begin? ** ** Returns: ** usual return code */ sm_ret_T sm_postmaster_add_domain(sm_str_P str, sm_str_P domain, size_t offset) { sm_ret_T ret; #define POSTMASTER "" #define POSTMASTER_LEN (sizeof(POSTMASTER) - 1) SM_IS_BUF(str); SM_IS_BUF(domain); SM_REQUIRE(offset < sm_str_getlen(str)); if (strncasecmp((const char *)sm_str_data(str) + offset, (const char *)POSTMASTER, POSTMASTER_LEN) != 0) return SM_NOTDONE; if (sm_is_success(ret = sm_str_shorten(str, (int) offset)) && sm_is_success(ret = sm_str_scat(str, "'))) return SM_SUCCESS; return ret; }