2010-03-22 00:10:44 +01:00
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* Copyright (c) 2000-2003 Intel Corporation
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are met:
|
|
|
|
*
|
|
|
|
* - Redistributions of source code must retain the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer.
|
|
|
|
* - Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer in the documentation
|
|
|
|
* and/or other materials provided with the distribution.
|
|
|
|
* - Neither name of Intel Corporation nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
|
|
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
|
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
|
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
|
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
|
|
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
|
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
2007-05-24 12:32:40 +02:00
|
|
|
|
|
|
|
#include "sample_util.h"
|
2010-11-18 02:30:29 +01:00
|
|
|
#include "tv_device.h"
|
2007-05-25 17:20:19 +02:00
|
|
|
|
2010-11-18 16:59:08 +01:00
|
|
|
#include <stdarg.h>
|
2007-05-25 17:20:19 +02:00
|
|
|
#include <stdio.h>
|
2007-05-24 12:32:40 +02:00
|
|
|
|
2010-11-18 15:02:38 +01:00
|
|
|
int main(int argc, char *argv[])
|
2007-05-24 12:32:40 +02:00
|
|
|
{
|
2010-11-17 14:54:31 +01:00
|
|
|
int rc;
|
|
|
|
ithread_t cmdloop_thread;
|
2008-05-23 23:55:04 +02:00
|
|
|
#ifdef WIN32
|
|
|
|
#else
|
2010-11-17 14:54:31 +01:00
|
|
|
int sig;
|
|
|
|
sigset_t sigs_to_catch;
|
2008-03-22 18:10:29 +01:00
|
|
|
#endif
|
2010-11-17 14:54:31 +01:00
|
|
|
int code;
|
|
|
|
|
2012-03-04 05:38:13 +01:00
|
|
|
rc = device_main(argc, argv);
|
|
|
|
if (rc != UPNP_E_SUCCESS) {
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2010-11-17 14:54:31 +01:00
|
|
|
/* start a command loop thread */
|
2010-11-18 16:59:08 +01:00
|
|
|
code = ithread_create(&cmdloop_thread, NULL, TvDeviceCommandLoop, NULL);
|
2012-04-21 04:38:20 +02:00
|
|
|
if (code != 0) {
|
|
|
|
return UPNP_E_INTERNAL_ERROR;
|
|
|
|
}
|
2008-05-23 23:55:04 +02:00
|
|
|
#ifdef WIN32
|
2010-11-17 14:54:31 +01:00
|
|
|
ithread_join(cmdloop_thread, NULL);
|
2008-05-23 23:55:04 +02:00
|
|
|
#else
|
2010-11-17 14:54:31 +01:00
|
|
|
/* Catch Ctrl-C and properly shutdown */
|
|
|
|
sigemptyset(&sigs_to_catch);
|
|
|
|
sigaddset(&sigs_to_catch, SIGINT);
|
|
|
|
sigwait(&sigs_to_catch, &sig);
|
|
|
|
SampleUtil_Print("Shutting down on signal %d...\n", sig);
|
2008-03-22 18:10:29 +01:00
|
|
|
#endif
|
2010-11-18 16:59:08 +01:00
|
|
|
rc = TvDeviceStop();
|
2010-11-17 14:54:31 +01:00
|
|
|
|
|
|
|
return rc;
|
2007-05-24 12:32:40 +02:00
|
|
|
}
|
2010-11-17 14:54:31 +01:00
|
|
|
|