1 /* 2 * Generic text normalizer. 3 * 4 * Copyright (C) 2013-2022 Cisco Systems, Inc. and/or its affiliates. All rights reserved. 5 * Copyright (C) 2008-2013 Sourcefire, Inc. 6 * 7 * Authors: Török Edvin 8 * 9 * This program is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License version 2 as 11 * published by the Free Software Foundation. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 21 * MA 02110-1301, USA. 22 */ 23 24 #ifndef __TEXTNORM_H 25 #define __TEXTNORM_H 26 27 #include "fmap.h" 28 29 struct text_norm_state { 30 unsigned char *out; 31 size_t out_len; 32 size_t out_pos; 33 int space_written; 34 }; 35 36 #define ASCII_FILE_BUFF_LENGTH 131072 37 #define MAX_ASCII_FILE_SIZE 20000000 38 39 #define MIN_3(x, y, z) ((x) < (y) ? ((x) < (z) ? (x) : (z)) : ((y) < (z) ? (y) : (z))) 40 41 int text_normalize_init(struct text_norm_state *state, unsigned char *out, size_t out_len); 42 void text_normalize_reset(struct text_norm_state *state); 43 size_t text_normalize_buffer(struct text_norm_state *state, const unsigned char *buf, const size_t buf_len); 44 size_t text_normalize_map(struct text_norm_state *state, fmap_t *map, size_t offset); 45 46 #endif 47