1/* This file is part of Mailfromd. -*- c -*- 2 Copyright (C) 2008-2021 Sergey Poznyakoff 3 4 This program is free software; you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation; either version 3, or (at your option) 7 any later version. 8 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 14 You should have received a copy of the GNU General Public License 15 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 17MF_BUILTIN_MODULE 18 19MF_DEFUN(header_add, VOID, STRING name, STRING value, OPTIONAL, NUMBER idx) 20{ 21 struct mu_locus_range locus; 22 23 env_get_locus(env, &locus); 24 25 if (MF_DEFINED(idx)) { 26 trace("%s%s:%u: %s %ld \"%s: %s\"", 27 mailfromd_msgid(env_get_context(env)), 28 locus.beg.mu_file, locus.beg.mu_line, 29 msgmod_opcode_str(header_insert), 30 idx, 31 name, value); 32 env_msgmod_append(env, header_insert, name, value, idx); 33 } else { 34 trace("%s%s:%u: %s \"%s: %s\"", 35 mailfromd_msgid(env_get_context(env)), 36 locus.beg.mu_file, locus.beg.mu_line, 37 msgmod_opcode_str(header_add), 38 name, value); 39 env_msgmod_append(env, header_add, name, value, 1); 40 } 41} 42END 43 44MF_DEFUN(header_insert, VOID, STRING name, STRING value, NUMBER idx) 45{ 46 struct mu_locus_range locus; 47 48 env_get_locus(env, &locus); 49 50 trace("%s%s:%u: %s %ld \"%s: %s\"", 51 mailfromd_msgid(env_get_context(env)), 52 locus.beg.mu_file, locus.beg.mu_line, 53 msgmod_opcode_str(header_insert), 54 idx, 55 name, value); 56 env_msgmod_append(env, header_insert, name, value, idx); 57} 58END 59 60MF_DEFUN(header_delete, VOID, STRING name, OPTIONAL, NUMBER idx) 61{ 62 struct mu_locus_range locus; 63 64 env_get_locus(env, &locus); 65 66 trace("%s%s:%u: %s \"%s\" (%lu)", 67 mailfromd_msgid(env_get_context(env)), 68 locus.beg.mu_file, locus.beg.mu_line, 69 msgmod_opcode_str(header_delete), 70 name, MF_OPTVAL(idx, 1)); 71 env_msgmod_append(env, header_delete, name, NULL, MF_OPTVAL(idx, 1)); 72} 73END 74 75MF_DEFUN(header_replace, VOID, STRING name, STRING value, OPTIONAL, NUMBER idx) 76{ 77 struct mu_locus_range locus; 78 79 env_get_locus(env, &locus); 80 81 trace("%s%s:%u: %s \"%s: %s\" (%lu)", 82 mailfromd_msgid(env_get_context(env)), 83 locus.beg.mu_file, locus.beg.mu_line, 84 msgmod_opcode_str(header_replace), 85 name, value, MF_OPTVAL(idx, 1)); 86 env_msgmod_append(env, header_replace, name, value, MF_OPTVAL(idx, 1)); 87} 88END 89 90