uiot_internal.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Copyright (C) 2012-2019 UCloud. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License").
  5. * You may not use this file except in compliance with the License.
  6. * A copy of the License is located at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * or in the "license" file accompanying this file. This file is distributed
  11. * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  12. * express or implied. See the License for the specific language governing
  13. * permissions and limitations under the License.
  14. */
  15. #ifndef C_SDK_UIOT_INTERNAL_H_
  16. #define C_SDK_UIOT_INTERNAL_H_
  17. #if defined(__cplusplus)
  18. extern "C" {
  19. #endif
  20. #include "uiot_export.h"
  21. #include "uiot_import.h"
  22. #define NUMERIC_VALID_CHECK(num, err) \
  23. do { \
  24. if (0 == (num)) { \
  25. return (err); \
  26. } \
  27. } while(0)
  28. #define POINTER_VALID_CHECK(ptr, err) \
  29. do { \
  30. if (NULL == (ptr)) { \
  31. return (err); \
  32. } \
  33. } while(0)
  34. #define POINTER_VALID_CHECK_RTN(ptr) \
  35. do { \
  36. if (NULL == (ptr)) { \
  37. return; \
  38. } \
  39. } while(0)
  40. #define STRING_PTR_VALID_CHECK(ptr, err) \
  41. do { \
  42. if (NULL == (ptr)) { \
  43. return (err); \
  44. } \
  45. if (0 == strlen((ptr))) { \
  46. return (err); \
  47. } \
  48. } while(0)
  49. #if defined(__cplusplus)
  50. }
  51. #endif
  52. #endif /* C_SDK_UIOT_INTERNAL_H_ */