1 /* spmfilter - mail filtering framework 2 * Copyright (C) 2009-2012 Axel Steiner and SpaceNet AG 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Lesser General Public 6 * License as published by the Free Software Foundation; either 7 * version 3 of the License, or (at your option) 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 GNU 12 * Lesser General Public License for more details. 13 * 14 * You should have received a copy of the GNU Lesser General Public 15 * License along with this program. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 /*! 19 * @file smf_internal.h 20 * @brief Internal helper functions 21 */ 22 23 #ifndef _SMF_INTERNAL_H 24 #define _SMF_INTERNAL_H 25 26 #ifdef __cplusplus 27 extern "C" { 28 #endif 29 30 #include <unistd.h> 31 #include <sys/times.h> 32 33 #include "smf_settings.h" 34 #include "smf_session.h" 35 36 #define MAXLINE 512 37 #define BUFSIZE 512 38 39 #define CRLF "\r\n" 40 #define LF "\n" 41 #define CR "\r" 42 43 typedef struct { 44 int count; 45 char *current; 46 char buf[BUFSIZE]; 47 } readline_t; 48 49 void smf_internal_string_list_destroy(void *data); 50 void smf_internal_dict_list_destroy(void *data); 51 void smf_internal_user_data_list_destroy(void *data); 52 char *smf_internal_build_module_path(const char *libdir, const char *modname); 53 54 /* removes leading < and trailing > 55 * returns a newlly allocated pointer */ 56 char *smf_internal_strip_email_addr(char *addr); 57 58 ssize_t smf_internal_readn(int fd, void *buf, size_t nbyte); 59 ssize_t smf_internal_writen(int fd, const void *buf, size_t nbyte); 60 ssize_t smf_internal_readline(int fd, void *buf, size_t nbyte, void **help); 61 ssize_t smf_internal_readcbuf(int fd, char *buf, readline_t *rl); 62 63 struct tms smf_internal_init_runtime_stats(void); 64 void smf_internal_print_runtime_stats(struct tms start_acct, const char *sid); 65 char *smf_internal_determine_linebreak(const char *s); 66 int smf_internal_fetch_user_data(SMFSettings_T *settings, SMFSession_T *session); 67 char *smf_internal_generate_sid(void); 68 69 #ifdef __cplusplus 70 } 71 #endif 72 73 #endif /* _SMF_INTERNAL_H */ 74 75