diff --git a/api/boinc_api.cpp b/api/boinc_api.cpp
index 2ecd54176153402e062f65b26d6bd131ecf485e4..a97079d617ad35e3fe0113f02ce53c4449eff783 100644
--- a/api/boinc_api.cpp
+++ b/api/boinc_api.cpp
@@ -43,6 +43,7 @@
 #include "shmem.h"
 #include "util.h"
 #include "str_util.h"
+#include "str_replace.h"
 #include "filesys.h"
 #include "mem_usage.h"
 #include "error_numbers.h"
diff --git a/api/gutil_text.cpp b/api/gutil_text.cpp
index 8b63a8995ff823c4e841a6c9ce9a27ba1b1f8f3a..c065cfa7206b4108a41b9fecac092718a493245e 100644
--- a/api/gutil_text.cpp
+++ b/api/gutil_text.cpp
@@ -55,6 +55,7 @@ extern "C"{
 
 #include "filesys.h"
 #include "str_util.h"
+#include "str_replace.h"
 
 #include "gutil.h"
 
diff --git a/checkin_notes b/checkin_notes
index f7f3d3d168a5fbdd1de8d89d4bbaf7359d52e4ed..6181d15e29c785b0d8589b90fa4b3f68766b6649 100644
--- a/checkin_notes
+++ b/checkin_notes
@@ -5746,3 +5746,12 @@ Charlie 16 June 2009
 
     clientgui/
         BOINCClientManager.cpp
+
+David  16 June 2009
+    - lib: created a new file for declaring "replacements"
+        for functions like strlcpy() etc.
+        config.h is included here rather than in str_util.h
+
+    lib/
+        str_replace.h (new)
+    ... and a lot of .cpp's
diff --git a/client/acct_mgr.cpp b/client/acct_mgr.cpp
index efb204fafb54060bc6ee84bbf16f7534672f0047..7ddc742a1cbb751dd1845c145902eac352398ce8 100644
--- a/client/acct_mgr.cpp
+++ b/client/acct_mgr.cpp
@@ -26,6 +26,7 @@
 #include "error_numbers.h"
 #include "client_msgs.h"
 #include "str_util.h"
+#include "str_replace.h"
 #include "file_names.h"
 #include "filesys.h"
 #include "client_state.h"
diff --git a/client/app_start.cpp b/client/app_start.cpp
index 93176ee6571140cb9232b2ea11b0b9865b76e570..898f93d13d337f7d8d5d91c7040de095c2458efa 100644
--- a/client/app_start.cpp
+++ b/client/app_start.cpp
@@ -66,6 +66,7 @@ using std::string;
 #include "error_numbers.h"
 #include "util.h"
 #include "str_util.h"
+#include "str_replace.h"
 #include "shmem.h"
 #include "client_msgs.h"
 #include "client_state.h"
diff --git a/client/boinc_cmd.cpp b/client/boinc_cmd.cpp
index 09f4c4aa7ed53f37379840b3d0d8c54184fedf51..ff69518c90982ca9395fdc810df2c4ffd7066d71 100644
--- a/client/boinc_cmd.cpp
+++ b/client/boinc_cmd.cpp
@@ -42,6 +42,7 @@ using std::string;
 #include "error_numbers.h"
 #include "util.h"
 #include "str_util.h"
+#include "str_replace.h"
 #include "version.h"
 #include "common_defs.h"
 
diff --git a/client/check_security.cpp b/client/check_security.cpp
index 42ecc535172630c4d356ab57816ad5d9b8595716..0d526c2e33b35945f8cf3b32014dc7be45f23412 100644
--- a/client/check_security.cpp
+++ b/client/check_security.cpp
@@ -32,6 +32,7 @@
 #endif
 
 #include "util.h"
+#include "str_replace.h"
 #include "error_numbers.h"
 #include "file_names.h"
 
diff --git a/client/client_msgs.cpp b/client/client_msgs.cpp
index 6977fdecc9d7664ea20d87453d3d48bc52ece16d..0df3d715cb52eab1b8f06c509c6c77cdfe2e9fb0 100644
--- a/client/client_msgs.cpp
+++ b/client/client_msgs.cpp
@@ -28,6 +28,7 @@
 using std::deque;
 
 #include "log_flags.h"
+#include "str_replace.h"
 #include "client_types.h"
 #include "client_msgs.h"
 
diff --git a/client/client_state.cpp b/client/client_state.cpp
index 6c5f7f1870dc0a58730e8d76431e4d47377abaf3..b394d251dcad326d335416582d04737dfb807055 100644
--- a/client/client_state.cpp
+++ b/client/client_state.cpp
@@ -35,6 +35,7 @@
 
 #include "parse.h"
 #include "str_util.h"
+#include "str_replace.h"
 #include "util.h"
 #include "error_numbers.h"
 #include "filesys.h"
diff --git a/client/client_types.cpp b/client/client_types.cpp
index 73b357657ea34bd6b71068c6118b58447f1a8956..c3394b7be0b07e334538e149ee16fddf1b99695f 100644
--- a/client/client_types.cpp
+++ b/client/client_types.cpp
@@ -45,6 +45,7 @@
 #include "parse.h"
 #include "util.h"
 #include "str_util.h"
+#include "str_replace.h"
 #include "client_state.h"
 #include "pers_file_xfer.h"
 #include "sandbox.h"
diff --git a/client/cs_account.cpp b/client/cs_account.cpp
index 42988a20aa32b9f235c6e097d7073d1e3484fdd8..c60b700026dc2cd42bb899ecaf64263ffcc41aad 100644
--- a/client/cs_account.cpp
+++ b/client/cs_account.cpp
@@ -35,6 +35,7 @@
 #include "filesys.h"
 #include "parse.h"
 #include "str_util.h"
+#include "str_replace.h"
 #include "client_state.h"
 #include "client_msgs.h"
 #include "log_flags.h"
diff --git a/client/cs_cmdline.cpp b/client/cs_cmdline.cpp
index 81f7674e29eff0ea58a4ba5c919dbf96530238a7..8e923e35e53044f4f2cd0bfe9ed212416a5fc065 100644
--- a/client/cs_cmdline.cpp
+++ b/client/cs_cmdline.cpp
@@ -27,6 +27,7 @@
 
 #include "main.h"
 #include "str_util.h"
+#include "str_replace.h"
 #include "util.h"
 #include "client_msgs.h"
 #include "client_state.h"
diff --git a/client/cs_platforms.cpp b/client/cs_platforms.cpp
index 02d803943d01ed0d13fc07543cae28fc0d5067ed..7fc7f2d0ed9d458496a1c8efed157b3a9459d39b 100644
--- a/client/cs_platforms.cpp
+++ b/client/cs_platforms.cpp
@@ -48,6 +48,7 @@ LPFN_ISWOW64PROCESS fnIsWow64Process;
 #include "log_flags.h"
 #include "filesys.h"
 #include "str_util.h"
+#include "str_replace.h"
 #include "util.h"
 
 // return the primary platform id.
diff --git a/client/cs_prefs.cpp b/client/cs_prefs.cpp
index f8a4e84124bd0ead4e00e6ee1f12bd217f0d8ffd..da1cdacd42413af87a533f36728ee92feed87434 100644
--- a/client/cs_prefs.cpp
+++ b/client/cs_prefs.cpp
@@ -34,6 +34,7 @@
 #endif
 
 #include "str_util.h"
+#include "str_replace.h"
 #include "util.h"
 #include "filesys.h"
 #include "parse.h"
diff --git a/client/cs_scheduler.cpp b/client/cs_scheduler.cpp
index 3583b238fe3b5d74898c94e5c173a3892ad7458b..f27669f5606ee3f7f287aeef72ee26e22bc7dd7c 100644
--- a/client/cs_scheduler.cpp
+++ b/client/cs_scheduler.cpp
@@ -42,6 +42,7 @@
 #include "filesys.h"
 #include "parse.h"
 #include "str_util.h"
+#include "str_replace.h"
 #include "util.h"
 
 #include "client_msgs.h"
diff --git a/client/file_names.cpp b/client/file_names.cpp
index 8b9c030e860287125b794134f331baa994768314..ceb4c5e84263874896bde13bdb82096e0b3dd6dd 100644
--- a/client/file_names.cpp
+++ b/client/file_names.cpp
@@ -35,6 +35,7 @@
 #include "filesys.h"
 #include "error_numbers.h"
 #include "str_util.h"
+#include "str_replace.h"
 #include "util.h"
 #include "client_msgs.h"
 #include "sandbox.h"
diff --git a/client/hostinfo_network.cpp b/client/hostinfo_network.cpp
index 866da2e0b8b31e8684fa6a79a86a98d1accdd5ac..f1c74edfd14bc1341132a1d86d16a1f879016dcd 100644
--- a/client/hostinfo_network.cpp
+++ b/client/hostinfo_network.cpp
@@ -46,6 +46,7 @@
 #endif
 
 #include "str_util.h"
+#include "str_replace.h"
 #include "parse.h"
 #include "util.h"
 #include "file_names.h"
diff --git a/client/hostinfo_unix.cpp b/client/hostinfo_unix.cpp
index 78ea399256c6d26f078f7017b679b8dd4a4e9711..10bd60c24d7a08d8d6f4461c25e47fe174487600 100644
--- a/client/hostinfo_unix.cpp
+++ b/client/hostinfo_unix.cpp
@@ -51,9 +51,6 @@
 #include <cstring>
 #endif
 
-
-
-
 #include <cstdio>
 #include <cstdlib>
 #include <cstring>
@@ -107,6 +104,7 @@
 #include "filesys.h"
 #include "error_numbers.h"
 #include "str_util.h"
+#include "str_replace.h"
 #include "client_state.h"
 #include "hostinfo_network.h"
 #include "client_msgs.h"
diff --git a/client/http_curl.cpp b/client/http_curl.cpp
index 83b949b7a4eff7644fd3080149913019ebede105..f88e1ec16a40da2c1fa56a50ad65a806ddef2017 100644
--- a/client/http_curl.cpp
+++ b/client/http_curl.cpp
@@ -37,6 +37,7 @@
 #include "client_msgs.h"
 #include "log_flags.h"
 #include "str_util.h"
+#include "str_replace.h"
 #include "util.h"
 
 #include "network.h"
diff --git a/client/main.cpp b/client/main.cpp
index 17c074ffa087bb6ede33e7776e5df4069a9f8426..f85d20523c7f4c2302c9e2f5a54f1de0918be430 100644
--- a/client/main.cpp
+++ b/client/main.cpp
@@ -65,6 +65,7 @@ typedef void (CALLBACK* ClientLibraryShutdown)();
 #include "diagnostics.h"
 #include "error_numbers.h"
 #include "str_util.h"
+#include "str_replace.h"
 #include "util.h"
 #include "unix_util.h"
 #include "prefs.h"
diff --git a/client/sandbox.cpp b/client/sandbox.cpp
index 88f51221a6253613b3be20ad463561f14490a659..94e0af7c1c86abe677542a466a6dc073199d2989 100644
--- a/client/sandbox.cpp
+++ b/client/sandbox.cpp
@@ -27,6 +27,7 @@
 #include "file_names.h"
 #include "util.h"
 #include "str_util.h"
+#include "str_replace.h"
 #include "filesys.h"
 #include "parse.h"
 #include "client_msgs.h"
diff --git a/client/scheduler_op.cpp b/client/scheduler_op.cpp
index 0ecac72e932efcb5338874ffa3e411469eaad5ce..757de421e9f4a84163aad0010570baa3eb1559e6 100644
--- a/client/scheduler_op.cpp
+++ b/client/scheduler_op.cpp
@@ -28,6 +28,7 @@
 #endif
 
 #include "str_util.h"
+#include "str_replace.h"
 #include "util.h"
 #include "parse.h"
 #include "error_numbers.h"
diff --git a/client/sim_util.cpp b/client/sim_util.cpp
index 8b0ea07b3eb842fdd7cff2d2324706319c11f6c7..615a24285b63a5e344248d51a335cdd4685e2784 100644
--- a/client/sim_util.cpp
+++ b/client/sim_util.cpp
@@ -33,6 +33,7 @@
 
 #include "error_numbers.h"
 #include "str_util.h"
+#include "str_replace.h"
 #include "log_flags.h"
 #include "filesys.h"
 #include "network.h"
diff --git a/db/boinc_db.cpp b/db/boinc_db.cpp
index b41afadee705104e78fd3e2d2b99af02bdc01cc0..aa6c79ad84de23279ec9fcd1097c6ab16ba9bdea 100644
--- a/db/boinc_db.cpp
+++ b/db/boinc_db.cpp
@@ -29,6 +29,7 @@
 #endif
 
 #include "str_util.h"
+#include "str_replace.h"
 #include "util.h"
 #include "error_numbers.h"
 #include "boinc_db.h"
diff --git a/db/db_base.cpp b/db/db_base.cpp
index fa1cd0ae4f5da07fd9c955463228d13469f27c1b..9d7e93c11534bf37599de3b8371417ca3e9d4a0c 100644
--- a/db/db_base.cpp
+++ b/db/db_base.cpp
@@ -23,6 +23,7 @@
 
 #include "error_numbers.h"
 #include "str_util.h"
+#include "str_replace.h"
 #include "db_base.h"
 
 #ifdef _USING_FCGI_
diff --git a/lib/app_ipc.cpp b/lib/app_ipc.cpp
index b4eadbbddef60d9b8d32d099b676cc28e1a81939..49a96a308ee13a1cc27cd8712122f33b16272e3b 100644
--- a/lib/app_ipc.cpp
+++ b/lib/app_ipc.cpp
@@ -28,6 +28,7 @@
 #include "parse.h"
 #include "error_numbers.h"
 #include "str_util.h"
+#include "str_replace.h"
 #include "filesys.h"
 #include "miofile.h"
 #include "app_ipc.h"
diff --git a/lib/filesys.cpp b/lib/filesys.cpp
index 2e180ccf477c38074d70d63e7f07a46af29e8b09..1dccbfa84cf63f523bfa13fe1e757c3a53dc58fa 100644
--- a/lib/filesys.cpp
+++ b/lib/filesys.cpp
@@ -64,6 +64,7 @@ typedef BOOL (CALLBACK* FreeFn)(LPCSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARG
 
 #include "util.h"
 #include "str_util.h"
+#include "str_replace.h"
 #include "error_numbers.h"
 #include "filesys.h"
 
diff --git a/lib/parse.cpp b/lib/parse.cpp
index a302b9b713c94e7d01546f68c2a7c2048544bbb3..ef9cd99f8a53ba8cd256a338182c1018117fdabc 100644
--- a/lib/parse.cpp
+++ b/lib/parse.cpp
@@ -40,6 +40,7 @@
 
 #include "error_numbers.h"
 #include "str_util.h"
+#include "str_replace.h"
 #include "parse.h"
 
 #ifdef _USING_FCGI_
diff --git a/lib/procinfo_unix.cpp b/lib/procinfo_unix.cpp
index 18a4028404f418020ed57e08181e8e64caac27b1..077b1517482c38dd0c24e439c60196d4368948a4 100644
--- a/lib/procinfo_unix.cpp
+++ b/lib/procinfo_unix.cpp
@@ -44,6 +44,7 @@
 
 #include "procinfo.h"
 #include "str_util.h"
+#include "str_replace.h"
 #include "client_msgs.h"
 
 using std::vector;
diff --git a/lib/str_replace.h b/lib/str_replace.h
new file mode 100644
index 0000000000000000000000000000000000000000..e2dd09d41d15793ef26407f681a2e46bb4f37df0
--- /dev/null
+++ b/lib/str_replace.h
@@ -0,0 +1,37 @@
+// This file is part of BOINC.
+// http://boinc.berkeley.edu
+// Copyright (C) 2008 University of California
+//
+// BOINC is free software; you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License
+// as published by the Free Software Foundation,
+// either version 3 of the License, or (at your option) any later version.
+//
+// BOINC is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with BOINC.  If not, see <http://www.gnu.org/licenses/>.
+
+// declare replacement string functions for platforms that lack themn
+
+#ifndef STR_REPLACE_H
+#define STR_REPLACE_H
+
+#include "config.h"
+
+#if !defined(HAVE_STRLCPY)
+extern size_t strlcpy(char*, const char*, size_t);
+#endif
+
+#if !defined(HAVE_STRLCAT)
+extern size_t strlcat(char *dst, const char *src, size_t size);
+#endif
+
+#if !defined(HAVE_STRCASESTR)
+extern char *strcasestr(const char *s1, const char *s2);
+#endif
+
+#endif
diff --git a/lib/str_util.cpp b/lib/str_util.cpp
index 7a2afb0bf40c2464f8f45fe95ca78de7a88d6157..44dac9a872a3cbb8b77c198c5c4242686a6ab2d3 100644
--- a/lib/str_util.cpp
+++ b/lib/str_util.cpp
@@ -34,10 +34,10 @@
 #endif
 #endif
 
-
 #include "error_numbers.h"
 #include "common_defs.h"
 #include "filesys.h"
+#include "str_replace.h"
 #include "str_util.h"
 
 #ifdef _USING_FCGI_
diff --git a/lib/str_util.h b/lib/str_util.h
index 2e4ceb0f961e8b0c21321d633854d3b2a6574470..9d43317bd3c9c0ba46cc18df0bfa3bad1c1c0b3e 100644
--- a/lib/str_util.h
+++ b/lib/str_util.h
@@ -29,18 +29,6 @@
 #define MEGA (1048576.0)
 #define GIGA (1024.*1048576.0)
 
-#if !defined(HAVE_STRLCPY)
-extern size_t strlcpy(char*, const char*, size_t);
-#endif
-
-#if !defined(HAVE_STRLCAT)
-extern size_t strlcat(char *dst, const char *src, size_t size);
-#endif
-
-#if !defined(HAVE_STRCASESTR)
-extern char *strcasestr(const char *s1, const char *s2);
-#endif
-
 extern int ndays_to_string(double x, int smallest_timescale, char *buf);
 extern void nbytes_to_string(double nbytes, double total_bytes, char* str, int len);
 extern int parse_command_line(char*, char**);
diff --git a/sched/db_dump.cpp b/sched/db_dump.cpp
index edeb204fae754d48b81962390c1ef82bbbe9d81d..e76cd4d5414ccfb2b238ef516e8f9c8ef4cc5540 100644
--- a/sched/db_dump.cpp
+++ b/sched/db_dump.cpp
@@ -36,6 +36,7 @@
 #include "filesys.h"
 #include "util.h"
 #include "str_util.h"
+#include "str_replace.h"
 #include "error_numbers.h"
 #include "md5_file.h"
 #include "parse.h"
diff --git a/sched/file_deleter.cpp b/sched/file_deleter.cpp
index c7f5c3f51daffb0b6bc00324ce70a337bd34a270..658d39e9f4d1fa28116f6a084dbb876c01131c40 100644
--- a/sched/file_deleter.cpp
+++ b/sched/file_deleter.cpp
@@ -54,6 +54,7 @@
 #include "error_numbers.h"
 #include "util.h"
 #include "str_util.h"
+#include "str_replace.h"
 #include "filesys.h"
 #include "strings.h"
 
diff --git a/sched/handle_request.cpp b/sched/handle_request.cpp
index b62f01976bedbdb32c291bfc296f48d65fe48116..9f38448cee4665159fbbade6db3510f0da60d32a 100644
--- a/sched/handle_request.cpp
+++ b/sched/handle_request.cpp
@@ -43,6 +43,7 @@
 #include "error_numbers.h"
 #include "parse.h"
 #include "str_util.h"
+#include "str_replace.h"
 #include "util.h"
 #include "filesys.h"
 
diff --git a/sched/sched_config.cpp b/sched/sched_config.cpp
index 8cb57e21fc681ba3981689d23a8168724380aafe..431707030260d36ad2f99030e10043464082d873 100644
--- a/sched/sched_config.cpp
+++ b/sched/sched_config.cpp
@@ -29,12 +29,12 @@
 #include "error_numbers.h"
 #include "filesys.h"
 #include "str_util.h"
+#include "str_replace.h"
 
 #include "sched_msgs.h"
 #include "sched_util.h"
 #include "sched_config.h"
 
-
 const char* CONFIG_FILE = "config.xml";
 
 SCHED_CONFIG config;
diff --git a/sched/sched_result.cpp b/sched/sched_result.cpp
index f5ef7d94dc34159528124785a08b0c77953ec750..924cdab0c90dca8db28ab47bcaf568a0cef779c9 100644
--- a/sched/sched_result.cpp
+++ b/sched/sched_result.cpp
@@ -17,6 +17,7 @@
 
 #include "boinc_db.h"
 #include "str_util.h"
+#include "str_replace.h"
 #include "parse.h"
 
 #include "server_types.h"
diff --git a/tools/backend_lib.cpp b/tools/backend_lib.cpp
index 15630c5a8b748330244e5439d6bceab2feb5e161..7c0a6cdb79cfd921b48788e8a6eca261248d3998 100644
--- a/tools/backend_lib.cpp
+++ b/tools/backend_lib.cpp
@@ -38,6 +38,7 @@
 #include "md5_file.h"
 #include "parse.h"
 #include "str_util.h"
+#include "str_replace.h"
 #include "common_defs.h"
 #include "filesys.h"
 #include "sched_util.h"