avoid passing time_t between different compilers

This commit is contained in:
David Rose 2010-06-17 00:46:05 +00:00
parent 39e74cea5c
commit c2e54f12db
7 changed files with 51 additions and 9 deletions

View File

@ -220,7 +220,11 @@ P3DInstance(P3D_request_ready_func *func,
_panda_script_object->set_string_property("coreapiHostUrl", inst_mgr->get_coreapi_host_url());
time_t timestamp = inst_mgr->get_coreapi_timestamp();
_panda_script_object->set_int_property("coreapiTimestamp", (int)timestamp);
_panda_script_object->set_string_property("coreapiTimestampString", ctime(&timestamp));
const char *timestamp_string = ctime(&timestamp);
if (timestamp_string == NULL) {
timestamp_string = "";
}
_panda_script_object->set_string_property("coreapiTimestampString", timestamp_string);
_panda_script_object->set_string_property("coreapiVersionString", inst_mgr->get_coreapi_set_ver());

View File

@ -333,7 +333,12 @@ set_plugin_version(int major, int minor, int sequence,
nout << "Plugin distributor: " << _plugin_distributor << "\n";
nout << "Core API host URL: " << _coreapi_host_url << "\n";
nout << "Core API version: " << _coreapi_set_ver << "\n";
nout << "Core API date: " << ctime(&_coreapi_timestamp) << "\n";
const char *timestamp_string = ctime(&_coreapi_timestamp);
if (timestamp_string == NULL) {
timestamp_string = "";
}
nout << "Core API date: " << timestamp_string << "\n";
}
////////////////////////////////////////////////////////////////////
@ -1379,6 +1384,7 @@ create_runtime_environment() {
<< ", host_url = " << _host_url
<< ", verify_contents = " << _verify_contents
<< "\n";
nout << "api_version = " << _api_version << "\n";
// Make the certificate directory.
_certs_dir = _root_dir + "/certs";

View File

@ -104,7 +104,7 @@ void
P3D_set_plugin_version(int major, int minor, int sequence,
bool official, const char *distributor,
const char *coreapi_host_url,
time_t coreapi_timestamp,
const char *coreapi_timestamp_str,
const char *coreapi_set_ver) {
assert(P3DInstanceManager::get_global_ptr()->is_initialized());
if (distributor == NULL) {
@ -116,7 +116,19 @@ P3D_set_plugin_version(int major, int minor, int sequence,
ACQUIRE_LOCK(_api_lock);
P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr();
time_t coreapi_timestamp = 0;
if (inst_mgr->get_api_version() < 15) {
// Before version 15, this was passed as a time_t.
coreapi_timestamp = (time_t)coreapi_timestamp_str;
} else {
// Passing a time_t causes problems with disagreements about word
// size, so since version 15 we pass it as a string.
coreapi_timestamp = strtoul(coreapi_timestamp_str, NULL, 10);
}
if (inst_mgr->get_api_version() < 14 || coreapi_set_ver == NULL) {
// Prior to version 14 this parameter was absent.
coreapi_set_ver = "";
}

View File

@ -79,7 +79,7 @@ extern "C" {
(below). This number will be incremented whenever there are changes
to any of the interface specifications defined in this header
file. */
#define P3D_API_VERSION 14
#define P3D_API_VERSION 15
/************************ GLOBAL FUNCTIONS **************************/
@ -168,7 +168,7 @@ typedef void
P3D_set_plugin_version_func(int major, int minor, int sequence,
bool official, const char *distributor,
const char *coreapi_host_url,
time_t coreapi_timestamp,
const char *coreapi_timestamp,
const char *coreapi_set_ver);
/* This function defines a "super mirror" URL: a special URL that is

View File

@ -529,6 +529,13 @@ int PPInstance::LoadPlugin( const std::string& dllFilename )
nout << "Unable to launch core API in " << pathname << "\n";
error = 1;
} else {
// Format the coreapi_timestamp as a string, for passing as a
// parameter.
ostringstream stream;
stream << _coreapi_dll.get_timestamp();
string coreapi_timestamp = stream.str();
#ifdef PANDA_OFFICIAL_VERSION
static const bool official = true;
#else
@ -537,7 +544,7 @@ int PPInstance::LoadPlugin( const std::string& dllFilename )
P3D_set_plugin_version_ptr(P3D_PLUGIN_MAJOR_VERSION, P3D_PLUGIN_MINOR_VERSION,
P3D_PLUGIN_SEQUENCE_VERSION, official,
PANDA_DISTRIBUTOR,
PANDA_PACKAGE_HOST_URL, _coreapi_dll.get_timestamp(),
PANDA_PACKAGE_HOST_URL, coreapi_timestamp.c_str(),
_coreapi_set_ver.c_str());
}
@ -831,7 +838,7 @@ lookup_token(const string &keyword) const {
}
if (lower_keyword == keyword) {
return m_parentCtrl.m_parameters[i].second;
return (const char *)m_parentCtrl.m_parameters[i].second;
}
}

View File

@ -1592,6 +1592,12 @@ do_load_plugin() {
return;
}
// Format the coreapi_timestamp as a string, for passing as a
// parameter.
ostringstream stream;
stream << _coreapi_dll.get_timestamp();
string coreapi_timestamp = stream.str();
#ifdef PANDA_OFFICIAL_VERSION
static const bool official = true;
#else
@ -1600,7 +1606,7 @@ do_load_plugin() {
P3D_set_plugin_version_ptr(P3D_PLUGIN_MAJOR_VERSION, P3D_PLUGIN_MINOR_VERSION,
P3D_PLUGIN_SEQUENCE_VERSION, official,
PANDA_DISTRIBUTOR,
PANDA_PACKAGE_HOST_URL, _coreapi_dll.get_timestamp(),
PANDA_PACKAGE_HOST_URL, coreapi_timestamp.c_str(),
_coreapi_set_ver.c_str());
create_instance();

View File

@ -813,10 +813,17 @@ get_core_api() {
#else
static const bool official = false;
#endif
// Format the coreapi_timestamp as a string, for passing as a
// parameter.
ostringstream stream;
stream << _coreapi_dll.get_timestamp();
string coreapi_timestamp = stream.str();
P3D_set_plugin_version_ptr(P3D_PLUGIN_MAJOR_VERSION, P3D_PLUGIN_MINOR_VERSION,
P3D_PLUGIN_SEQUENCE_VERSION, official,
PANDA_DISTRIBUTOR,
_host_url.c_str(), _coreapi_dll.get_timestamp(),
_host_url.c_str(), coreapi_timestamp.c_str(),
_coreapi_set_ver.c_str());
return true;