/* * 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. * * $Id: hdrmod.h,v 1.8 2005/11/19 01:52:54 ca Exp $ */ #ifndef SM_HDRMOD_H #define SM_HDRMOD_H 1 #include "sm/generic.h" #include "sm/hdrmoddef.h" #include "sm/types.h" #include "sm/cstr.h" #include "sm/queue.h" #include "sm/rcb.h" enum sm_hm_type_E { SM_HM_TYPE_PREPEND = SM_HDRMOD_T_PREPEND ,SM_HM_TYPE_INSERT = SM_HDRMOD_T_INSERT ,SM_HM_TYPE_REPLACE = SM_HDRMOD_T_REPLACE ,SM_HM_TYPE_REMOVE = SM_HDRMOD_T_REMOVE ,SM_HM_TYPE_APPEND = SM_HDRMOD_T_APPEND }; typedef enum sm_hm_type_E sm_hm_type_T; #define SM_HM_USE_POS(sm_hm_type) \ (SM_HM_TYPE_INSERT == (sm_hm_type) || \ SM_HM_TYPE_REPLACE == (sm_hm_type) || \ SM_HM_TYPE_REMOVE == (sm_hm_type)) /* header modification entry (in a list/simple queue) */ typedef struct sm_hdrmod_S sm_hdrmod_T, *sm_hdrmod_P; /* head for header modification list */ TAILQ_HEAD(sm_hdrmodhd_S, sm_hdrmod_S); typedef struct sm_hdrmodhd_S sm_hdrmodhd_T, *sm_hdrmodhd_P; struct sm_hdrmod_S { sm_hm_type_T sm_hm_type; uint sm_hm_pos; sm_cstr_P sm_hm_hdr; TAILQ_ENTRY(sm_hdrmod_S) sm_hm_next; }; /* need to use tailq to allow removal of last element?? */ #define HDRMODL_INIT(sm_hdrmodhd) TAILQ_INIT(sm_hdrmodhd) #define HDRMODL_FIRST(sm_hdrmodhd) \ (((sm_hdrmodhd) != NULL) ? TAILQ_FIRST(sm_hdrmodhd) : NULL) #define HDRMODL_LAST(sm_hdrmodhd) TAILQ_LAST(sm_hdrmodhd, sm_hdrmodhd_S) #define HDRMODL_END(sm_hdrmodhd) TAILQ_END(sm_hdrmodhd) #define HDRMODL_EMPTY(sm_hdrmodhd) \ ((NULL == (sm_hdrmodhd)) || TAILQ_EMPTY(sm_hdrmodhd)) #define HDRMODL_NEXT(sm_hdrmod) TAILQ_NEXT(sm_hdrmod, sm_hm_next) #define HDRMODL_APP(sm_hdrmodhd, sm_hdrmod) TAILQ_INSERT_TAIL(sm_hdrmodhd, sm_hdrmod, sm_hm_next) #define HDRMODL_PRE(sm_hdrmodhd, sm_hdrmod) TAILQ_INSERT_HEAD(sm_hdrmodhd, sm_hdrmod, sm_hm_next) #define HDRMODL_INS_BEFORE(sm_hdrmodhd, sm_hdrmod_new, sm_hdrmod_old) \ TAILQ_INSERT_BEFORE(sm_hdrmod_old, sm_hdrmod_new, sm_hm_next) #define HDRMODL_RM_FIRST(sm_hdrmodhd) TAILQ_REMOVE((sm_hdrmodhd), HDRMODL_FIRST(sm_hdrmodhd), sm_hm_next) #define HDRMODL_RM_LAST(sm_hdrmodhd) TAILQ_REMOVE((sm_hdrmodhd), HDRMODL_LAST(sm_hdrmodhd), sm_hm_next) #define HDRMODL_REMOVE(sm_hdrmodhd) TAILQ_REMOVE((sm_hdrmodhd), HDRMODL_FIRST(sm_hdrmodhd), sm_hm_next) #define HDRMODL_RM_ELEM(sm_hdrmodhd, sm_hdrmod) TAILQ_REMOVE((sm_hdrmodhd), (sm_hdrmod), sm_hm_next) sm_ret_T sm_hdrmod_new(sm_hdrmodhd_P *_psm_hdrmodhd, bool _append, sm_hdrmod_P *_psm_hdrmod); sm_ret_T sm_hdrmod_rm(sm_hdrmodhd_P *_sm_hdrmodhd); sm_ret_T sm_hdrmod_rm_last(sm_hdrmodhd_P *_psm_hdrmodhd); sm_ret_T sm_hdrmod_rm_elem(sm_hdrmodhd_P *_psm_hdrmodhd, sm_hdrmod_P _sm_hdrmod); sm_ret_T sm_hdrmodl_free(sm_hdrmodhd_P *_psm_hdrmodhd); sm_ret_T sm_hdrmod_insert(sm_hdrmodhd_P _sm_hdrmodhd, sm_hdrmod_P _sm_hdrmod); sm_ret_T sm_hdrmodl_wr(sm_hdrmodhd_P _sm_hdrmodhd, sm_rcb_P _rcb, uint32_t _rttp, uint32_t _rthdr); sm_ret_T sm_hdrmodl_rd(sm_hdrmodhd_P _sm_hdrmodhd, sm_rcb_P _rcb, uint32_t _rttp, uint32_t _rthdr); #endif /* SM_HDRMOD_H */