comparison RenderingPlugin/Resources/Orthanc/Plugins/OrthancPluginCppWrapper.cpp @ 1936:224d7763eede

sync
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 06 May 2022 15:30:26 +0200
parents 6a65b7cb77ab
children c0aa4b03f219
comparison
equal deleted inserted replaced
1935:49c615745708 1936:224d7763eede
1544 boost::lexical_cast<std::string>(minor) + "." + 1544 boost::lexical_cast<std::string>(minor) + "." +
1545 boost::lexical_cast<std::string>(revision) + 1545 boost::lexical_cast<std::string>(revision) +
1546 " is required)"); 1546 " is required)");
1547 } 1547 }
1548 1548
1549 1549 bool CheckMinimalVersion(const char* version,
1550 bool CheckMinimalOrthancVersion(unsigned int major, 1550 unsigned int major,
1551 unsigned int minor, 1551 unsigned int minor,
1552 unsigned int revision) 1552 unsigned int revision)
1553 { 1553 {
1554 if (!HasGlobalContext()) 1554 if (!strcmp(version, "mainline"))
1555 {
1556 LogError("Bad Orthanc context in the plugin");
1557 return false;
1558 }
1559
1560 if (!strcmp(GetGlobalContext()->orthancVersion, "mainline"))
1561 { 1555 {
1562 // Assume compatibility with the mainline 1556 // Assume compatibility with the mainline
1563 return true; 1557 return true;
1564 } 1558 }
1565 1559
1566 // Parse the version of the Orthanc core 1560 // Parse the version
1567 int aa, bb, cc; 1561 int aa, bb, cc;
1568 if ( 1562 if (
1569 #ifdef _MSC_VER 1563 #ifdef _MSC_VER
1570 sscanf_s 1564 sscanf_s
1571 #else 1565 #else
1572 sscanf 1566 sscanf
1573 #endif 1567 #endif
1574 (GetGlobalContext()->orthancVersion, "%4d.%4d.%4d", &aa, &bb, &cc) != 3 || 1568 (version, "%4d.%4d.%4d", &aa, &bb, &cc) != 3 ||
1575 aa < 0 || 1569 aa < 0 ||
1576 bb < 0 || 1570 bb < 0 ||
1577 cc < 0) 1571 cc < 0)
1578 { 1572 {
1579 return false; 1573 return false;
1593 if (a < major) 1587 if (a < major)
1594 { 1588 {
1595 return false; 1589 return false;
1596 } 1590 }
1597 1591
1598
1599 // Check the minor version number 1592 // Check the minor version number
1600 assert(a == major); 1593 assert(a == major);
1601 1594
1602 if (b > minor) 1595 if (b > minor)
1603 { 1596 {
1618 } 1611 }
1619 else 1612 else
1620 { 1613 {
1621 return false; 1614 return false;
1622 } 1615 }
1616 }
1617
1618
1619 bool CheckMinimalOrthancVersion(unsigned int major,
1620 unsigned int minor,
1621 unsigned int revision)
1622 {
1623 if (!HasGlobalContext())
1624 {
1625 LogError("Bad Orthanc context in the plugin");
1626 return false;
1627 }
1628
1629 return CheckMinimalVersion(GetGlobalContext()->orthancVersion,
1630 major, minor, revision);
1623 } 1631 }
1624 1632
1625 1633
1626 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 5, 0) 1634 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 5, 0)
1627 const char* AutodetectMimeType(const std::string& path) 1635 const char* AutodetectMimeType(const std::string& path)
3701 { 3709 {
3702 IWebDavCollection& that = *reinterpret_cast<IWebDavCollection*>(payload); 3710 IWebDavCollection& that = *reinterpret_cast<IWebDavCollection*>(payload);
3703 3711
3704 try 3712 try
3705 { 3713 {
3706 *isReadOnly = (that.StoreFile(WebDavConvertPath(pathSize, pathItems), data, size) ? 1 : 0); 3714 if (static_cast<uint64_t>(static_cast<size_t>(size)) != size)
3715 {
3716 ORTHANC_PLUGINS_THROW_EXCEPTION(NotEnoughMemory);
3717 }
3718
3719 *isReadOnly = (that.StoreFile(WebDavConvertPath(pathSize, pathItems), data,
3720 static_cast<size_t>(size)) ? 1 : 0);
3707 return OrthancPluginErrorCode_Success; 3721 return OrthancPluginErrorCode_Success;
3708 } 3722 }
3709 catch (ORTHANC_PLUGINS_EXCEPTION_CLASS& e) 3723 catch (ORTHANC_PLUGINS_EXCEPTION_CLASS& e)
3710 { 3724 {
3711 return static_cast<OrthancPluginErrorCode>(e.GetErrorCode()); 3725 return static_cast<OrthancPluginErrorCode>(e.GetErrorCode());