X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=resource%2Fcsdk%2Fsecurity%2Fprovisioning%2Fsample%2Fcloud%2FcloudWrapper.c;h=7702c3d1588197bba3b360dc8cf4ee045a710ad8;hb=refs%2Ftags%2Faccepted%2Ftizen%2Funified%2F20171010.063815;hp=4c1b565eb59341b674fed6d4b8037f36962b3da4;hpb=1a2e71f9c470c7cc17157f83deb4488ee83050a4;p=platform%2Fupstream%2Fiotivity.git diff --git a/resource/csdk/security/provisioning/sample/cloud/cloudWrapper.c b/resource/csdk/security/provisioning/sample/cloud/cloudWrapper.c index 4c1b565..7702c3d 100644 --- a/resource/csdk/security/provisioning/sample/cloud/cloudWrapper.c +++ b/resource/csdk/security/provisioning/sample/cloud/cloudWrapper.c @@ -1,3 +1,22 @@ +/* ***************************************************************** + * + * Copyright 2016 Samsung Electronics All Rights Reserved. + * + * + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * *****************************************************************/ #include "logger.h" #include "occloudprovisioning.h" #include "oic_malloc.h" @@ -48,12 +67,16 @@ static bool readOptional(const char* description) } printf("Do you want to Enter %s (y/n):\n", description); - char choice = 0; + char temp, choice = 0; while(1) { - scanf("%c", &choice); - skipSpecialCharacters(); + for(int ret = 0; 1 != ret; ) + { + ret = scanf("%c", &temp); + skipSpecialCharacters(); + } + choice = temp; switch (choice) { @@ -67,11 +90,24 @@ static bool readOptional(const char* description) void readString(char* item, int length, const char* description, const char* example) { + char *temp = (char*)OICCalloc(length, sizeof(char)); + if (NULL == temp) + { + OIC_LOG(INFO, TAG, "temp is NULL"); + return; + } + printf("Enter %s (f.e. %s):\n", description, example); char template[8] = { 0 }; snprintf(template, sizeof(template), "%%%ds", length - 1); - scanf(template, item); - skipSpecialCharacters(); + + for(int ret = 0; 1 != ret; ) + { + ret = scanf(template, temp); + skipSpecialCharacters(); + } + strncpy(item, temp, length); + OICFree(temp); } /** @@ -92,9 +128,16 @@ static void readOptionalString(char* item, int length, const char* description, void readInteger(int* item, const char* description, const char* example) { + int temp; + printf("Enter %s (f.e. %s):\n", description, example); - scanf("%d", item); - skipSpecialCharacters(); + + for(int ret = 0; 1 != ret; ) + { + ret = scanf("%d", &temp); + skipSpecialCharacters(); + } + *item = temp; } /**