projects
/
platform
/
upstream
/
iotivity.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
replace : iotivity -> iotivity-sec
[platform/upstream/iotivity.git]
/
service
/
resource-container
/
examples
/
ContainerSample.cpp
diff --git
a/service/resource-container/examples/ContainerSample.cpp
b/service/resource-container/examples/ContainerSample.cpp
index
2240510
..
32397b7
100644
(file)
--- a/
service/resource-container/examples/ContainerSample.cpp
+++ b/
service/resource-container/examples/ContainerSample.cpp
@@
-46,7
+46,9
@@
namespace
EXIT = 11
} APPMenu;
EXIT = 11
} APPMenu;
- struct CloseApp {};
+ struct CloseApp
+ {
+ };
const int MAX_PATH = 2048;
const int MAX_PATH = 2048;
@@
-66,10
+68,12
@@
RCSResourceContainer *g_pResourceContainer = nullptr;
void getCurrentPath(std::string *pPath)
{
void getCurrentPath(std::string *pPath)
{
- char buffer[MAX_PATH];
+ char buffer[MAX_PATH]
= {0,}
;
if (!pPath->empty())
if (!pPath->empty())
+ {
pPath->clear();
pPath->clear();
+ }
#if defined(__linux__)
char *strPath = NULL;
#if defined(__linux__)
char *strPath = NULL;
@@
-81,7
+85,9
@@
void getCurrentPath(std::string *pPath)
strPath = strrchr(buffer, '/');
if (strPath != NULL)
strPath = strrchr(buffer, '/');
if (strPath != NULL)
+ {
*strPath = '\0';
*strPath = '\0';
+ }
}
#endif
pPath->append(buffer);
}
#endif
pPath->append(buffer);
@@
-89,12
+95,14
@@
void getCurrentPath(std::string *pPath)
int processUserInput(int min, int max)
{
int processUserInput(int min, int max)
{
- int input;
+ int input
= 0
;
std::cin >> input;
if (!std::cin.fail() && min <= input && input <= max)
std::cin >> input;
if (!std::cin.fail() && min <= input && input <= max)
+ {
return input;
return input;
+ }
std::cin.clear();
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
std::cin.clear();
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
@@
-141,7
+149,9
@@
bool checkBundleRegistered(std::string bundleId)
for (auto &bundle : bundleList)
{
if (bundle->getID().compare(bundleId) == 0)
for (auto &bundle : bundleList)
{
if (bundle->getID().compare(bundleId) == 0)
+ {
return true;
return true;
+ }
}
}
}
}
@@
-160,7
+170,9
@@
bool checkResourceRegistered(std::string bundleId, std::string resourceUri)
for (auto &resource : resourceList)
{
if (resource.compare(resourceUri) == 0)
for (auto &resource : resourceList)
{
if (resource.compare(resourceUri) == 0)
+ {
return true;
return true;
+ }
}
}
}
}
@@
-174,6
+186,7
@@
void StartContainer(std::string configPath)
{
g_pResourceContainer->startContainer(configPath);
g_bContainerStarted = true;
{
g_pResourceContainer->startContainer(configPath);
g_bContainerStarted = true;
+ std::cout << "Container started." << std::endl;
}
else
{
}
else
{
@@
-236,7
+249,9
@@
void StopSampleBundle()
g_bSampleBundleStarted = false;
}
else
g_bSampleBundleStarted = false;
}
else
+ {
std::cout << "Sample Bundle is not started." << std::endl;
std::cout << "Sample Bundle is not started." << std::endl;
+ }
}
else
{
}
else
{
@@
-249,7
+264,9
@@
void RemoveSampleBundle()
if (g_pResourceContainer && g_bContainerStarted)
{
if (checkBundleRegistered(EXAMPLE_BUNDLE_ID))
if (g_pResourceContainer && g_bContainerStarted)
{
if (checkBundleRegistered(EXAMPLE_BUNDLE_ID))
+ {
g_pResourceContainer->removeBundle(EXAMPLE_BUNDLE_ID);
g_pResourceContainer->removeBundle(EXAMPLE_BUNDLE_ID);
+ }
}
else
{
}
else
{
@@
-272,7
+289,9
@@
void AddSampleBundleResource()
resourceParams);
}
else
resourceParams);
}
else
+ {
std::cout << "Sample Bundle is not started." << std::endl;
std::cout << "Sample Bundle is not started." << std::endl;
+ }
}
else
{
}
else
{
@@
-286,9
+305,13
@@
void RemoveSampleBundleResource()
{
if (checkResourceRegistered(EXAMPLE_BUNDLE_ID, EXAMPLE_RESOURCE_URI)
&& g_bSampleBundleStarted)
{
if (checkResourceRegistered(EXAMPLE_BUNDLE_ID, EXAMPLE_RESOURCE_URI)
&& g_bSampleBundleStarted)
+ {
g_pResourceContainer->removeResourceConfig(EXAMPLE_BUNDLE_ID, EXAMPLE_RESOURCE_URI);
g_pResourceContainer->removeResourceConfig(EXAMPLE_BUNDLE_ID, EXAMPLE_RESOURCE_URI);
+ }
else
else
+ {
std::cout << "Sample Bundle is not started." << std::endl;
std::cout << "Sample Bundle is not started." << std::endl;
+ }
}
else
{
}
else
{
@@
-433,9
+456,11
@@
int main()
}
if (g_bContainerStarted)
}
if (g_bContainerStarted)
+ {
g_pResourceContainer->stopContainer();
g_pResourceContainer->stopContainer();
+ }
g_pResourceContainer = nullptr;
return 0;
g_pResourceContainer = nullptr;
return 0;
-}
\ No newline at end of file
+}