1 //******************************************************************
3 // Copyright 2015 Samsung Electronics All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
11 // http://www.apache.org/licenses/LICENSE-2.0
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20 #include "rd_server.h"
27 void handleSigInt(int signum);
30 * This method is an entry point of Resource Directory.
31 * This function should be run only on the device that it could be host device.
36 printf("OCResourceDirectory is starting...\n");
37 OCStackResult result = OCInit(NULL, 0, OC_CLIENT_SERVER);
38 if (result != OC_STACK_OK)
40 printf("Failed starting RD server ...\n");
43 if (OCRDStart() != OC_STACK_OK)
45 printf("OCRDStart failed...\n");
49 printf("OCRDStart successfully...\n");
51 signal(SIGINT, handleSigInt);
54 if (OCProcess() != OC_STACK_OK)
57 printf("OCStack process error\n");
62 if (OCRDStop() != OC_STACK_OK)
64 printf("OCRDStop failed...\n");
68 printf("OCRDStop success...\n");
71 printf("Exiting OCResourceDirectory main loop...\n");
77 * This is a signal handling function for SIGINT(CTRL+C).
78 * A Resource Directory handle the SIGINT signal for safe exit.
81 * signal number of caught signal.
83 void handleSigInt(int signum)