Get back to the previous code.
authorjaesick.shin <jaesick.shin@samsung.com>
Sun, 4 Sep 2016 22:00:10 +0000 (07:00 +0900)
committerUze Choi <uzchoi@samsung.com>
Tue, 6 Sep 2016 10:15:41 +0000 (10:15 +0000)
change input logic for example.

second patch included,
change fgets to input function.

Change-Id: Id763ae718db2daaeaeac9cc55149f6eb58183361
Signed-off-by: jaesick.shin <jaesick.shin@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/11363
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Hun-je Yeon <hunje.yeon@samsung.com>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
service/notification/examples/linux/notificationprovider.c

index c643fcf..b3ba5b0 100644 (file)
@@ -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);