diff --git a/src/project.c b/src/project.c index fd4cb8d..1e99817 100644 --- a/src/project.c +++ b/src/project.c @@ -11,13 +11,9 @@ ****************************************************************************** */ +#include #include #include -#ifndef __APPLE__ -#include -#else -#include -#endif //*** For the Windows SDK _tempnam function ***// #ifdef _WIN32 @@ -174,7 +170,7 @@ int openoutfile(Project *pr) // Close output file if already opened closeoutfile(pr); - + // If output file name was supplied, then attempt to // open it. Otherwise open a temporary output file. pr->outfile.OutFile = fopen(pr->outfile.OutFname, "w+b"); @@ -284,7 +280,7 @@ void initpointers(Project *pr) pr->hydraul.smatrix.XLNZ = NULL; pr->hydraul.smatrix.NZSUB = NULL; pr->hydraul.smatrix.LNZ = NULL; - + initrules(pr); } @@ -1027,7 +1023,7 @@ char *xstrcpy(char **s1, const char *s2, const size_t n) { size_t n1 = 0, n2; - // Source string is empty -- free destination string + // Source string is empty -- free destination string if (s2 == NULL || strlen(s2) == 0) { free(*s1); diff --git a/src/util/filemanager.c b/src/util/filemanager.c index 7a4469f..eb9c4cd 100644 --- a/src/util/filemanager.c +++ b/src/util/filemanager.c @@ -58,12 +58,12 @@ void delete_file_manager(file_handle_t *file_handle) { } -void get_filename(file_handle_t *file_handle, char **filename, size_t *size) +int get_filename(file_handle_t *file_handle, char **filename) // // BE AWARE: The memory allocated here must be freed by the caller // { - copy_cstr(file_handle->filename, filename); + return copy_cstr(file_handle->filename, filename); } @@ -86,7 +86,7 @@ int open_file(file_handle_t *file_handle, const char *filename, const char *file int seek_file(file_handle_t *file_handle, F_OFF offset, int whence) { -#ifdef _WIN32 // Windows (32-bit and 64-bit) +#ifdef _MSC_VER // Windows (32-bit and 64-bit) #define FSEEK64 _fseeki64 #else // Other platforms #define FSEEK64 fseeko @@ -97,7 +97,7 @@ int seek_file(file_handle_t *file_handle, F_OFF offset, int whence) F_OFF tell_file(file_handle_t *file_handle) { -#ifdef _WIN32 // Windows (32-bit and 64-bit) +#ifdef _MSC_VER // Windows (32-bit and 64-bit) #define FTELL64 _ftelli64 #else // Other platforms #define FTELL64 ftello @@ -171,7 +171,7 @@ int _fopen(FILE **f, const char *name, const char *mode) { int ret = 0; -#ifdef _WIN32 +#ifdef _MSC_VER ret = (int)fopen_s(f, name, mode); #else *f = fopen(name, mode); @@ -185,7 +185,7 @@ int _get_temp_filename(char **tempname) { int error = 0; -#ifdef _WIN32 +#ifdef _MSC_VER char *name = NULL; // --- use Windows _tempnam function to get a pointer to an diff --git a/src/util/filemanager.h b/src/util/filemanager.h index 93ee8d9..a3866c3 100644 --- a/src/util/filemanager.h +++ b/src/util/filemanager.h @@ -22,7 +22,7 @@ // F_OFF Must be a 8 byte / 64 bit integer for large file support -#ifdef _WIN32 // Windows (32-bit and 64-bit) +#ifdef _MSC_VER // Windows (32-bit and 64-bit) #define F_OFF __int64 #else // Other platforms #define F_OFF off_t @@ -44,7 +44,7 @@ file_handle_t *create_file_manager(); void delete_file_manager(file_handle_t *file_handle); -void get_filename(file_handle_t *file_handle, char **filename, size_t *size); +int get_filename(file_handle_t *file_handle, char **filename); int open_file(file_handle_t *file_handle, const char *filename, const char *file_mode); diff --git a/tests/test_link.cpp b/tests/test_link.cpp index 15f451e..aa20d23 100644 --- a/tests/test_link.cpp +++ b/tests/test_link.cpp @@ -11,6 +11,8 @@ ****************************************************************************** */ +#include + #include #include "test_toolkit.hpp" diff --git a/tests/util/test_errormanager.cpp b/tests/util/test_errormanager.cpp index f9a88b6..43f59e2 100644 --- a/tests/util/test_errormanager.cpp +++ b/tests/util/test_errormanager.cpp @@ -15,10 +15,10 @@ void mock_lookup(int errcode, char *errmsg, int len) char *msg = NULL; if (errcode == 100) { - msg = MESSAGE_STRING; + msg = (char *)MESSAGE_STRING; } else { - msg = ""; + msg = (char *)""; } strncpy(errmsg, msg, len); } diff --git a/tests/util/test_filemanager.cpp b/tests/util/test_filemanager.cpp index 70ff6c6..7e17577 100644 --- a/tests/util/test_filemanager.cpp +++ b/tests/util/test_filemanager.cpp @@ -82,12 +82,12 @@ struct Fixture{ BOOST_FIXTURE_TEST_CASE(test_temp_file, Fixture) { char *filename; - size_t size; printf_file(file_handle, "%s", "This is a test."); - get_filename(file_handle, &filename, &size); - BOOST_CHECK(is_valid(file_handle) == true); + error = get_filename(file_handle, &filename); + BOOST_REQUIRE(error == 0); + BOOST_CHECK(is_valid(file_handle) == true); BOOST_CHECK(boost::filesystem::exists(filename) == true);