From e03ff7b09dd5e75961efe39e0f6f84eb2ee9b6d6 Mon Sep 17 00:00:00 2001 From: "jaesick.shin" Date: Mon, 5 Sep 2016 07:00:10 +0900 Subject: [PATCH] Get back to the previous code. change input logic for example. second patch included, change fgets to input function. Change-Id: Id763ae718db2daaeaeac9cc55149f6eb58183361 Signed-off-by: jaesick.shin Reviewed-on: https://gerrit.iotivity.org/gerrit/11363 Tested-by: jenkins-iotivity Reviewed-by: Hun-je Yeon Reviewed-by: Uze Choi --- .../examples/linux/notificationprovider.c | 23 ++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/service/notification/examples/linux/notificationprovider.c b/service/notification/examples/linux/notificationprovider.c index c643fcf..b3ba5b0 100644 --- a/service/notification/examples/linux/notificationprovider.c +++ b/service/notification/examples/linux/notificationprovider.c @@ -135,6 +135,17 @@ void removeTopics(NSTopicLL * topics) } } +void input(char * buffer) +{ + char ch; + int i = 0; + + while( (ch = getchar()) != '\n' && i < 100) + buffer[i++] = ch; + + buffer[i] = '\0'; +} + int main() { int num; @@ -216,19 +227,19 @@ int main() case 3: { printf("NSSendNotification()"); - char title[100]; - char body[100]; - char topic[100]; + char title[100] = {'\0',}; + char body[100] = {'\0',}; + char topic[100] = {'\0',}; printf("id : %d\n", ++id); printf("title : "); - gets(title); + input(title); printf("body : "); - gets(body); + input(body); printf("topic : "); - gets(topic); + input(topic); printf("app - mTitle : %s \n", title); printf("app - mContentText : %s \n", body); -- 2.7.4