util-string.o \
util-queue.o \
util-tod.o \
- tree.o \
+ util-tree.o \
$(MONBIN)
-eximon.bin: $(EXIMON_EDITME) eximon $(OBJ_MONBIN) \
- ../exim_monitor/em_version.c
+eximon.bin: $(EXIMON_EDITME) eximon $(OBJ_MONBIN) ../exim_monitor/em_version.c \
+ mytypes.h store.h macros.h
@echo "$(CC) exim_monitor/em_version.c"
$(FE)$(CC) -o em_version.o -c \
$(CFLAGS) $(XINCLUDE) -I. ../exim_monitor/em_version.c
@echo "$(CC) -DCOMPILE_UTILITY tod.c"
$(FE)$(CC) -c $(CFLAGS) $(INCLUDE) -DCOMPILE_UTILITY -o util-tod.o tod.c
+util-tree.o: $(HDRS) tree.c
+ @echo "$(CC) -DCOMPILE_UTILITY tree.c"
+ $(FE)$(CC) -c $(CFLAGS) $(INCLUDE) -DCOMPILE_UTILITY -o util-tree.o tree.c
+
util-os.o: $(HDRS) os.c
@echo "$(CC) -DCOMPILE_UTILITY os.c"
$(FE)$(CC) -c $(CFLAGS) $(INCLUDE) \
local_scan.o: config local_scan.h ../$(LOCAL_SCAN_SOURCE)
@echo "$(CC) local_scan.c"
- $(FE)$(CC) -c $(CFLAGS) -I. $(INCLUDE) -o local_scan.o ../$(LOCAL_SCAN_SOURCE)
+ $(FE)$(CC) -DLOCAL_SCAN -c $(CFLAGS) -I. $(INCLUDE) -o local_scan.o ../$(LOCAL_SCAN_SOURCE)
# Dependencies for the "ordinary" exim modules
#endif
typedef void hctx;
-#include "config.h"
-#include "mytypes.h"
-#include "macros.h"
-
#include "local_scan.h"
+#include "macros.h"
#include "structs.h"
#include "blob.h"
#include "globals.h"
#include "dbstuff.h"
#include "functions.h"
#include "osfunctions.h"
-#include "store.h"
/* The sys/resource.h header on SunOS 4 causes trouble with the gcc
compiler. Just stuff the bit we want in here; pragmatic easy way out. */
/* See the file NOTICE for conditions of use and distribution. */
#include "mytypes.h"
+#include "store.h"
#include "macros.h"
#include <string.h>
#include <stdlib.h>
g = string_vformat(g, TRUE, format, ap);
va_end(ap);
-gstring_reset_unused(g);
+gstring_release_unused(g);
*log_msgptr = string_from_gstring(g);
return ERROR;
}
if (!g) return US"no b= value";
al->b.data = string_from_gstring(g);
al->b.len = g->ptr;
- gstring_reset_unused(g);
+ gstring_release_unused(g);
bend = s;
break;
case 'h': /* bh= AMS body hash */
if (!g) return US"no bh= value";
al->bh.data = string_from_gstring(g);
al->bh.len = g->ptr;
- gstring_reset_unused(g);
+ gstring_release_unused(g);
break;
default:
return US"b? tag";
g = string_catn(g, US"\r\n\t ", 5);
}
g = string_catn(g, US";\r\n", 3);
-gstring_reset_unused(g);
+gstring_release_unused(g);
string_from_gstring(g);
return g;
}
if (sigheaders) g = string_catn(g, sigheaders->s, sigheaders->ptr);
(void) string_from_gstring(g);
-gstring_reset_unused(g);
+gstring_release_unused(g);
return g;
}
/* check if this looks like a DKIM record */
if (Ustrncmp(g->s, "v=", 2) != 0 || strncasecmp(CS g->s, "v=dkim", 6) == 0)
{
- gstring_reset_unused(g);
+ gstring_release_unused(g);
return string_from_gstring(g);
}
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);
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
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_ */
extern int smtp_fflush(void);
extern void smtp_printf(const char *, BOOL, ...) PRINTF_FUNCTION(1,3);
extern void smtp_vprintf(const char *, BOOL, va_list);
-extern uschar *string_copy(const uschar *);
-extern uschar *string_copyn(const uschar *, int);
extern uschar *string_sprintf(const char *, ...) ALMOST_PRINTF(1,2);
+#ifdef LOCAL_SCAN
+/* When compiling a local_scan() file we want to rename a published API, so that
+we can use an inlined implementation in the compiles of the main Exim files,
+with the original name. */
+
+# define string_copy(s) string_copy_function(s)
+# define string_copyn(s, n) string_copyn_function(s, n)
+
+extern uschar * string_copy_function(const uschar *);
+extern uschar * string_copyn_function(const uschar *);
+#endif
+
/* End of local_scan.h */
if (!data) data = string_get(1);
(void) string_from_gstring(data);
-gstring_reset_unused(data);
+gstring_release_unused(data);
/* Copy the last dn into eldap_dn */
#define Ustrtol(s,t,b) strtol(CCS(s),CSS(t),b)
#define Ustrtoul(s,t,b) strtoul(CCS(s),CSS(t),b)
#define Uunlink(s) unlink(CCS(s))
+
#endif
/* End of mytypes.h */
+#ifdef HAVE_LOCAL_SCAN
/*************************************************
* Copy and save string *
*************************************************/
*/
uschar *
-string_copy(const uschar *s)
+string_copy_function(const uschar *s)
{
int len = Ustrlen(s) + 1;
uschar *ss = store_get(len);
}
-
-/*************************************************
-* Copy and save string in malloc'd store *
-*************************************************/
-
-/* This function assumes that memcpy() is faster than strcpy().
-
-Argument: string to copy
-Returns: copy of string in new store
-*/
-
-uschar *
-string_copy_malloc(const uschar *s)
-{
-int len = Ustrlen(s) + 1;
-uschar *ss = store_malloc(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
-*/
-
-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 *
*************************************************/
*/
uschar *
-string_copyn(const uschar *s, int n)
+string_copyn_function(const uschar *s, int n)
{
uschar *ss = store_get(n + 1);
Ustrncpy(ss, s, n);
ss[n] = 0;
return ss;
}
+#endif
/*************************************************
-* Copy, lowercase, and save string, given length *
+* Copy and save string in malloc'd store *
*************************************************/
-/* It is assumed the data contains no zeros. A zero is added
-onto the end.
-
-Arguments:
- s string to copy
- n number of characters
+/* This function assumes that memcpy() is faster than strcpy().
-Returns: copy of string in new store, with letters lowercased
+Argument: string to copy
+Returns: copy of string in new store
*/
uschar *
-string_copynlc(uschar *s, int n)
+string_copy_malloc(const uschar *s)
{
-uschar *ss = store_get(n + 1);
-uschar *p = ss;
-while (n-- > 0) *p++ = tolower(*s++);
-*p = 0;
+int len = Ustrlen(s) + 1;
+uschar *ss = store_malloc(len);
+memcpy(ss, s, len);
return ss;
}
#ifdef COMPILE_UTILITY
return string_copy(gp->s);
#else
-gstring_reset_unused(gp);
+gstring_release_unused(gp);
return gp->s;
#endif
}
}
while (g->ptr > 0 && isspace(g->s[g->ptr-1])) g->ptr--;
buffer = string_from_gstring(g);
- gstring_reset_unused(g);
+ gstring_release_unused(g);
}
/* Update the current pointer and return the new string */
/************************************************/
-/* Create a growable-string with some preassigned space */
-
-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. */
-
-uschar *
-string_from_gstring(gstring * g)
-{
-if (!g) return NULL;
-g->s[g->ptr] = '\0';
-return g->s;
-}
-
-void
-gstring_reset_unused(gstring * g)
-{
-store_reset(g->s + (g->size = g->ptr + 1));
-}
-
-
/* Add more space to a growable-string.
Arguments:
va_start(ap, format);
(void) string_vformat(g, FALSE, format, ap);
string_from_gstring(g);
-gstring_reset_unused(g);
+gstring_release_unused(g);
va_end(ap);
return eno == EACCES