]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS-Labs/Source/FreeRTOS-IoT-Libraries/c_sdk/aws/common/src/aws_iot_validate.c
Add the Labs projects provided in the V10.2.1_191129 zip file.
[freertos] / FreeRTOS-Labs / Source / FreeRTOS-IoT-Libraries / c_sdk / aws / common / src / aws_iot_validate.c
diff --git a/FreeRTOS-Labs/Source/FreeRTOS-IoT-Libraries/c_sdk/aws/common/src/aws_iot_validate.c b/FreeRTOS-Labs/Source/FreeRTOS-IoT-Libraries/c_sdk/aws/common/src/aws_iot_validate.c
new file mode 100644 (file)
index 0000000..3073146
--- /dev/null
@@ -0,0 +1,62 @@
+/*\r
+ * AWS IoT Common V1.0.0\r
+ * Copyright (C) 2019 Amazon.com, Inc. or its affiliates.  All Rights Reserved.\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of\r
+ * this software and associated documentation files (the "Software"), to deal in\r
+ * the Software without restriction, including without limitation the rights to\r
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\r
+ * the Software, and to permit persons to whom the Software is furnished to do so,\r
+ * subject to the following conditions:\r
+ *\r
+ * The above copyright notice and this permission notice shall be included in all\r
+ * copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+ */\r
+\r
+/**\r
+ * @file aws_iot_validate.c\r
+ * @brief Validates Thing Names and other parameters to AWS IoT.\r
+ */\r
+\r
+/* The config header is always included first. */\r
+#include "iot_config.h"\r
+\r
+/* AWS IoT include. */\r
+#include "aws_iot.h"\r
+\r
+/* Error handling include. */\r
+#include "iot_error.h"\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+bool AwsIot_ValidateThingName( const char * pThingName,\r
+                               size_t thingNameLength )\r
+{\r
+    IOT_FUNCTION_ENTRY( bool, true );\r
+\r
+    if( pThingName == NULL )\r
+    {\r
+        IOT_SET_AND_GOTO_CLEANUP( false );\r
+    }\r
+\r
+    if( thingNameLength == 0 )\r
+    {\r
+        IOT_SET_AND_GOTO_CLEANUP( false );\r
+    }\r
+\r
+    if( thingNameLength > AWS_IOT_MAX_THING_NAME_LENGTH )\r
+    {\r
+        IOT_SET_AND_GOTO_CLEANUP( false );\r
+    }\r
+\r
+    IOT_FUNCTION_EXIT_NO_CLEANUP();\r
+}\r
+\r
+/*-----------------------------------------------------------*/\r