Applications that need to include ocstack.h for access to OC* APIs currently need to bring in
multiple unrelated (and platform-specific) headers. This is because octypes.h, a public type
definition header used by ocstack.h, is including more headers than it needs to. It is more
desirable for applications to bring in only requird headers.
This change reduces the number of required headers from the public surface, specifically ocstack.h,
by taking advantange of IoTivity's requirement that all supported compilers are at least
C++11-compliant. See https://wiki.iotivity.org/compiler_support?s[]=compiler for details.
Before this change, users of ocstack.h must also bring in (this example is from Windows):
Ocstack.h
Octypes.h
Iotivity_config.h
Ocpresence.h
Ocstackconfig.h
Platform_features.h
Windows\include\memmem.h
Windows\include\pthread_create.h
Windows\include\vs12_snprintf.h
Windows\include\win_sleep.h
After this change, the list becomes:
Ocstack.h
Octypes.h
Ocpresence.h
Ocstackconfig.h
Arguably ocpresence.h and ocstackconfig.h could be combined into octypes.h since they are just
simple type definitions, just like octypes.h. That work is lower priority as both ocpresence.h
and ocstackconfig.h are already platform independent.
Change-Id: I9943589603453730446b2d616b497fbb235774a5
Signed-off-by: Way Vadhanasin <wayvad@microsoft.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/18487
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Dan Mihai <Daniel.Mihai@microsoft.com>
// except for resource-specific IoTivity APIs (ie. OCCreateResource(),
// OCDeleteResource(), EntityHandler()..etc.)
+#include "iotivity_config.h"
#include "IotivityandZigbeeClient.h"
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <condition_variable>
+#include "iotivity_config.h"
#include "ipca.h"
#include "OCFDevice.h"
*
******************************************************************/
+#include "iotivity_config.h"
#include "oic_malloc.h"
#include "ipca.h"
#include "ipcainternal.h"
#include <condition_variable>
#include "gtest/gtest.h"
+#include "iotivity_config.h"
#include "ocrandom.h"
#include "octypes.h"
#include "ipca.h"
#define PLATFORM_FEATURES_H_
-#if (__cplusplus >=201103L) || defined(__GXX_EXPERIMENTAL_CXX0X__)
-# define SUPPORTS_DEFAULT_CTOR
-#endif
-
#if (__STDC_VERSION__ >= 201112L)
# include <assert.h>
# define OC_STATIC_ASSERT(condition, msg) static_assert(condition, msg)
# define ssize_t SSIZE_T
# define SHUT_RDWR SD_BOTH
# define sleep(SECS) Sleep(1000*(SECS))
-# ifdef __cplusplus
-# define SUPPORTS_DEFAULT_CTOR
-# endif
# include "windows/include/memmem.h"
# include "windows/include/win_sleep.h"
# include "windows/include/pthread_create.h"
#ifndef OCTYPES_H_
#define OCTYPES_H_
-#include "iotivity_config.h"
#include "ocstackconfig.h"
#include <stdbool.h>
#include <stdint.h>
/** pointer to its data.*/
uint8_t optionData[MAX_HEADER_OPTION_DATA_LENGTH];
-#ifdef SUPPORTS_DEFAULT_CTOR
+#ifdef __cplusplus
OCHeaderOption() = default;
OCHeaderOption(OCTransportProtocolID pid,
uint16_t optId,
memcpy(optionData, optData, optionLength);
optionData[optionLength - 1] = '\0';
}
-#endif
+#endif // __cplusplus
} OCHeaderOption;
/**
/** A pointer to a function to delete the context when this callback is removed.*/
OCClientContextDeleter cd;
-#ifdef SUPPORTS_DEFAULT_CTOR
+#ifdef __cplusplus
OCCallbackData() = default;
OCCallbackData(void* ctx, OCClientResponseHandler callback, OCClientContextDeleter deleter)
:context(ctx), cb(callback), cd(deleter){}
-#endif
+#endif // __cplusplus
} OCCallbackData;
/**
// limitations under the License.
//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+#include "iotivity_config.h"
#include <iostream>
#include <sstream>
#include <limits>
// limitations under the License.
//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+#include "iotivity_config.h"
#include <iostream>
#include "octypes.h"
#include "ocstack.h"
extern "C"
{
+ #include "iotivity_config.h"
#include "rd_client.h"
#include "rd_server.h"
#include "ocpayload.h"
VERIFY_NOT_NULL(TAG, motCtx->ctxResultArray, ERROR);
//Send POST request
- OCCallbackData cbData = {.context=NULL, .cb=NULL, .cd=NULL};
+ OCCallbackData cbData;
+ memset(&cbData, 0, sizeof(cbData));
cbData.cb = &MOTUpdateSecurityResourceCB;
cbData.context = (void *)motCtx;
OIC_LOG(DEBUG, TAG, "Sending POST 'doxm' request to resource server");
VERIFY_NOT_NULL(TAG, motCtx->ctxResultArray, ERROR);
//Send POST request
- OCCallbackData cbData = {.context=NULL, .cb=NULL, .cd=NULL};
+ OCCallbackData cbData;
+ memset(&cbData, 0, sizeof(cbData));
cbData.cb = &MOTUpdateSecurityResourceCB;
cbData.context = (void *)motCtx;
OIC_LOG(DEBUG, TAG, "Sending POST Preconfiged PIN credenatial request to resource server");
}
OIC_LOG_V(DEBUG, TAG, "Query=%s", query);
- OCCallbackData cbData = {.context=NULL, .cb=NULL, .cd=NULL};
+ OCCallbackData cbData;
+ memset(&cbData, 0, sizeof(cbData));
cbData.cb = &ProvisioningStatusHandler;
cbData.context = (void*)otmCtx;
cbData.cd = NULL;
}
OIC_LOG_V(DEBUG, TAG, "Query=%s", query);
- OCCallbackData cbData = {.context=NULL, .cb=NULL, .cd=NULL};
+ OCCallbackData cbData;
+ memset(&cbData, 0, sizeof(cbData));
cbData.cb = &ReadyForNomalStatusHandler;
cbData.context = (void*)otmCtx;
cbData.cd = NULL;
}
OIC_LOG_V(DEBUG, TAG, "Query=%s", query);
- OCCallbackData cbData = { .context = NULL, .cb = NULL, .cd = NULL };
+ OCCallbackData cbData;
+ memset(&cbData, 0, sizeof(cbData));
cbData.cb = responseHandler;
cbData.context = (void *)credData;
cbData.cd = NULL;
//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+#include "iotivity_config.h"
#include <stdlib.h>
#include <string.h>
#include "oic_malloc.h"
dpairData->resultCallback = resultCallback;
dpairData->userCtx = ctx;
- OCCallbackData cbData = {.context=NULL, .cb=NULL, .cd=NULL};
+ OCCallbackData cbData;
+ memset(&cbData, 0, sizeof(cbData));
cbData.cb = DirectPairingFinalizeHandler;
cbData.context = (void*)dpairData;
cbData.cd = NULL;
dpairData->resultCallback = resultCallback;
dpairData->userCtx = ctx;
- OCCallbackData cbData = {.context=NULL, .cb=NULL, .cd=NULL};
+ OCCallbackData cbData;
+ memset(&cbData, 0, sizeof(cbData));
cbData.cb = DirectPairingHandler;
cbData.context = (void*)dpairData;
cbData.cd = NULL;
//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+#include "iotivity_config.h"
+
#include <stdlib.h>
#include <string.h>
#include "ocstack.h"
#include <stdlib.h>
#include "cbor.h"
+#include "platform_features.h"
#define STRINGIZE2(x) #x
#define STRINGIZE(x) STRINGIZE2(x)
//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-#include <ocstack.h>
+#include "iotivity_config.h"
+#include "ocstack.h"
#include <stdio.h>
#include <stdlib.h>
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-#include <ocstack.h>
+#include "iotivity_config.h"
+#include "ocstack.h"
#include <stdio.h>
#include <string.h>
//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+#include "iotivity_config.h"
#include <stdio.h>
#include <glib.h>
#include <stdlib.h>
#include <functional>
#endif
+#include "iotivity_config.h"
#include "iotivity_debug.h"
#include "octypes.h"
#include "OCApi.h"
#include "OCPlatform_impl.h"
#include "oxmverifycommon.h"
+#include "securevirtualresourcetypes.h"
namespace OC
{
#include <boost/lexical_cast.hpp>
#include <algorithm>
#include <iomanip>
+#include "iotivity_config.h"
#include "ocpayload.h"
#include "ocrandom.h"
#include "oic_malloc.h"