From 10f9e11ee61b8d4f3669c7b931fb2b5accdf26d4 Mon Sep 17 00:00:00 2001
From: David Anderson <davea@ssl.berkeley.edu>
Date: Tue, 16 Jun 2009 20:54:44 +0000
Subject: [PATCH] - lib: created a new file for declaring "replacements"    
 for functions like strlcpy() etc.     config.h is included here rather than
 in str_util.h

svn path=/trunk/boinc/; revision=18437
---
 api/boinc_api.cpp           |  1 +
 api/gutil_text.cpp          |  1 +
 checkin_notes               |  9 +++++++++
 client/acct_mgr.cpp         |  1 +
 client/app_start.cpp        |  1 +
 client/boinc_cmd.cpp        |  1 +
 client/check_security.cpp   |  1 +
 client/client_msgs.cpp      |  1 +
 client/client_state.cpp     |  1 +
 client/client_types.cpp     |  1 +
 client/cs_account.cpp       |  1 +
 client/cs_cmdline.cpp       |  1 +
 client/cs_platforms.cpp     |  1 +
 client/cs_prefs.cpp         |  1 +
 client/cs_scheduler.cpp     |  1 +
 client/file_names.cpp       |  1 +
 client/hostinfo_network.cpp |  1 +
 client/hostinfo_unix.cpp    |  4 +---
 client/http_curl.cpp        |  1 +
 client/main.cpp             |  1 +
 client/sandbox.cpp          |  1 +
 client/scheduler_op.cpp     |  1 +
 client/sim_util.cpp         |  1 +
 db/boinc_db.cpp             |  1 +
 db/db_base.cpp              |  1 +
 lib/app_ipc.cpp             |  1 +
 lib/filesys.cpp             |  1 +
 lib/parse.cpp               |  1 +
 lib/procinfo_unix.cpp       |  1 +
 lib/str_replace.h           | 37 +++++++++++++++++++++++++++++++++++++
 lib/str_util.cpp            |  2 +-
 lib/str_util.h              | 12 ------------
 sched/db_dump.cpp           |  1 +
 sched/file_deleter.cpp      |  1 +
 sched/handle_request.cpp    |  1 +
 sched/sched_config.cpp      |  2 +-
 sched/sched_result.cpp      |  1 +
 tools/backend_lib.cpp       |  1 +
 38 files changed, 81 insertions(+), 17 deletions(-)
 create mode 100644 lib/str_replace.h

diff --git a/api/boinc_api.cpp b/api/boinc_api.cpp
index 2ecd541761..a97079d617 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 8b63a8995f..c065cfa720 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 f7f3d3d168..6181d15e29 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 efb204fafb..7ddc742a1c 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 93176ee657..898f93d13d 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 09f4c4aa7e..ff69518c90 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 42ecc53517..0d526c2e33 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 6977fdecc9..0df3d715cb 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 6c5f7f1870..b394d251dc 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 73b357657e..c3394b7be0 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 42988a20aa..c60b700026 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 81f7674e29..8e923e35e5 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 02d803943d..7fc7f2d0ed 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 f8a4e84124..da1cdacd42 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 3583b238fe..f27669f560 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 8b9c030e86..ceb4c5e842 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 866da2e0b8..f1c74edfd1 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 78ea399256..10bd60c24d 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 83b949b7a4..f88e1ec16a 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 17c074ffa0..f85d20523c 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 88f51221a6..94e0af7c1c 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 0ecac72e93..757de421e9 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 8b0ea07b3e..615a24285b 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 b41afadee7..aa6c79ad84 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 fa1cd0ae4f..9d7e93c115 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 b4eadbbdde..49a96a308e 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 2e180ccf47..1dccbfa84c 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 a302b9b713..ef9cd99f8a 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 18a4028404..077b151748 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 0000000000..e2dd09d41d
--- /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 7a2afb0bf4..44dac9a872 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 2e4ceb0f96..9d43317bd3 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 edeb204fae..e76cd4d541 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 c7f5c3f51d..658d39e9f4 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 b62f01976b..9f38448cee 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 8cb57e21fc..4317070302 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 f5ef7d94dc..924cdab0c9 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 15630c5a8b..7c0a6cdb79 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"
-- 
GitLab