X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fsrc%2Ffunctions.h;h=1273e8138a2170d068756271d5bda087869f3c84;hb=436bda2ac0c4a245815db3fc1ef2aedee05eab8d;hp=c5af51652030ac8e8f08487faadbe2aa285edf69;hpb=b66fecb428871a3eb274d9370671f1eaf8c5ccec;p=user%2Fhenk%2Fcode%2Fexim.git diff --git a/src/src/functions.h b/src/src/functions.h index c5af51652..1273e8138 100644 --- a/src/src/functions.h +++ b/src/src/functions.h @@ -22,7 +22,7 @@ extern uschar *init_perl(uschar *); #endif -#ifdef SUPPORT_TLS +#ifndef DISABLE_TLS extern const char * std_dh_prime_default(void); extern const char * @@ -51,6 +51,7 @@ extern BOOL tls_client_start(client_conn_ctx *, smtp_connect_args *, extern void tls_close(void *, int); extern BOOL tls_could_read(void); +extern void tls_daemon_init(void); extern int tls_export_cert(uschar *, size_t, void *); extern int tls_feof(void); extern int tls_ferror(void); @@ -66,7 +67,7 @@ extern int tls_ungetc(int); extern int tls_write(void *, const uschar *, size_t, BOOL); extern uschar *tls_validate_require_cipher(void); extern void tls_version_report(FILE *); -# ifndef USE_GNUTLS +# ifdef USE_OPENSSL extern BOOL tls_openssl_options_parse(uschar *, long *); # endif extern uschar * tls_field_from_dn(uschar *, const uschar *); @@ -76,7 +77,7 @@ extern BOOL tls_is_name_for_cert(const uschar *, void *); extern int tlsa_lookup(const host_item *, dns_answer *, BOOL); # endif -#endif /*SUPPORT_TLS*/ +#endif /*DISABLE_TLS*/ /* Everything else... */ @@ -213,8 +214,6 @@ extern void msg_event_raise(const uschar *, const address_item *); #endif extern int exim_chown_failure(int, const uschar*, uid_t, gid_t); -inline int exim_chown(const uschar*, uid_t, gid_t); -inline int exim_fchown(int, uid_t, gid_t, const uschar*); extern const uschar * exim_errstr(int); extern void exim_exit(int, const uschar *); extern void exim_nullstd(void); @@ -232,7 +231,7 @@ extern uschar *expand_string_copy(const uschar *); extern int_eximarith_t expand_string_integer(uschar *, BOOL); extern void modify_variable(uschar *, void *); -extern BOOL fd_ready(int, int); +extern BOOL fd_ready(int, time_t); extern int filter_interpret(uschar *, int, address_item **, uschar **); extern BOOL filter_personal(string_item *, BOOL); @@ -241,8 +240,6 @@ extern BOOL filter_system_interpret(address_item **, uschar **); extern uschar * fn_hdrs_added(void); -extern void gstring_reset_unused(gstring *); - extern void header_add(int, const char *, ...); extern header_line *header_add_at_position_internal(BOOL, uschar *, BOOL, int, const char *, ...); extern int header_checkname(header_line *, BOOL); @@ -279,7 +276,7 @@ extern int ip_connectedsocket(int, const uschar *, int, int, int, host_item *, uschar **, const blob *); extern int ip_get_address_family(int); extern void ip_keepalive(int, const uschar *, BOOL); -extern int ip_recv(client_conn_ctx *, uschar *, int, int); +extern int ip_recv(client_conn_ctx *, uschar *, int, time_t); extern int ip_socket(int, int); extern int ip_tcpsocket(const uschar *, uschar **, int); @@ -351,7 +348,7 @@ extern uschar *parse_message_id(uschar *, uschar **, uschar **); extern const uschar *parse_quote_2047(const uschar *, int, uschar *, uschar *, int, BOOL); extern uschar *parse_date_time(uschar *str, time_t *t); extern int vaguely_random_number(int); -#ifdef SUPPORT_TLS +#ifndef DISABLE_TLS extern int vaguely_random_number_fallback(int); #endif @@ -498,14 +495,10 @@ extern gstring *string_catn(gstring *, const uschar *, int) WARN_UNUSED_RESULT; extern int string_compare_by_pointer(const void *, const void *); extern uschar *string_copy_dnsdomain(uschar *); extern uschar *string_copy_malloc(const uschar *); -extern uschar *string_copylc(const uschar *); -extern uschar *string_copynlc(uschar *, int); extern uschar *string_dequote(const uschar **); extern gstring *string_fmt_append(gstring *, const char *, ...) ALMOST_PRINTF(2,3); extern BOOL string_format(uschar *, int, const char *, ...) ALMOST_PRINTF(3,4); extern uschar *string_format_size(int, uschar *); -extern uschar *string_from_gstring(gstring *); -extern gstring *string_get(unsigned); extern int string_interpret_escape(const uschar **); extern int string_is_ip_address(const uschar *, int *); #ifdef SUPPORT_I18N @@ -591,38 +584,167 @@ extern void version_init(void); extern BOOL write_chunk(transport_ctx *, uschar *, int); extern ssize_t write_to_fd_buf(int, const uschar *, size_t); + +#if !defined(MACRO_PREDEF) && !defined(COMPILE_UTILITY) /* exim_chown - in some NFSv4 setups *seemes* to be an issue with - chown(, ). +chown(, ). - Probably because the idmapping is broken, misconfigured or set up in - an unusal way. (see Bug 2931). As I'm not sure, if this was a single - case of misconfiguration, or if there are more such broken systems - out, I try to impose as least impact as possible and for now just write - a panic log entry pointing to the bug report. You're encouraged to - contact the developers, if you experience this issue. +Probably because the idmapping is broken, misconfigured or set up in +an unusal way. (see Bug 2931). As I'm not sure, if this was a single +case of misconfiguration, or if there are more such broken systems +out, I try to impose as least impact as possible and for now just write +a panic log entry pointing to the bug report. You're encouraged to +contact the developers, if you experience this issue. - fd the file descriptor (or -1 if not valid) - name the file name for error messages or for file operations, - if fd is < 0 - owner the owner - group the group +fd the file descriptor (or -1 if not valid) +name the file name for error messages or for file operations, + if fd is < 0 +owner the owner +group the group - returns 0 on success, -1 on failure */ +returns 0 on success, -1 on failure */ -inline int +static inline int exim_fchown(int fd, uid_t owner, gid_t group, const uschar *name) { -return (0 == fchown(fd, owner, group)) - ? 0 : exim_chown_failure(fd, name, owner, group); +return fchown(fd, owner, group) + ? exim_chown_failure(fd, name, owner, group) : 0; } -inline int +static inline int exim_chown(const uschar *name, uid_t owner, gid_t group) { -return (0 == chown(name, owner, group)) - ? 0 : exim_chown_failure(-1, name, owner, group); +return chown(CCS name, owner, group) + ? exim_chown_failure(-1, name, owner, group) : 0; } +#endif /* !MACRO_PREDEF && !COMPILE_UTILITY */ +/******************************************************************************/ +/* String functions */ + +/************************************************* +* Copy and save string * +*************************************************/ + +/* This function assumes that memcpy() is faster than strcpy(). +*/ + +#if !defined(MACRO_PREDEF) +static inline uschar * +string_copy(const uschar *s) +{ +int len = Ustrlen(s) + 1; +uschar *ss = store_get(len); +memcpy(ss, s, len); +return ss; +} + + +/************************************************* +* Copy, lowercase and save string * +*************************************************/ + +/* +Argument: string to copy +Returns: copy of string in new store, with letters lowercased +*/ + +static inline uschar * +string_copylc(const uschar *s) +{ +uschar *ss = store_get(Ustrlen(s) + 1); +uschar *p = ss; +while (*s != 0) *p++ = tolower(*s++); +*p = 0; +return ss; +} + + + +/************************************************* +* Copy and save string, given length * +*************************************************/ + +/* It is assumed the data contains no zeros. A zero is added +onto the end. + +Arguments: + s string to copy + n number of characters + +Returns: copy of string in new store + +This is an API for local_scan hence not static. +*/ + +static inline uschar * +string_copyn(const uschar *s, int n) +{ +uschar *ss = store_get(n + 1); +Ustrncpy(ss, s, n); +ss[n] = 0; +return ss; +} + +/************************************************* +* Copy, lowercase, and save string, given length * +*************************************************/ + +/* It is assumed the data contains no zeros. A zero is added +onto the end. + +Arguments: + s string to copy + n number of characters + +Returns: copy of string in new store, with letters lowercased +*/ + +static inline uschar * +string_copynlc(uschar *s, int n) +{ +uschar *ss = store_get(n + 1); +uschar *p = ss; +while (n-- > 0) *p++ = tolower(*s++); +*p = 0; +return ss; +} + + +/******************************************************************************/ +/* Growable-string functions */ + +/* Create a growable-string with some preassigned space, in untainted memory */ + +static inline gstring * +string_get(unsigned size) +{ +gstring * g = store_get(sizeof(gstring) + size); +g->size = size; +g->ptr = 0; +g->s = US(g + 1); +return g; +} + +/* NUL-terminate the C string in the growable-string, and return it. */ + +static inline uschar * +string_from_gstring(gstring * g) +{ +if (!g) return NULL; +g->s[g->ptr] = '\0'; +return g->s; +} + +static inline void +gstring_release_unused(gstring * g) +{ +if (g) store_reset(g->s + (g->size = g->ptr + 1)); +} + +/******************************************************************************/ +#endif /* !MACRO_PREDEF */ + #endif /* _FUNCTIONS_H_ */ /* vi: aw