コード例 #1
0
ファイル: libsimspider.c プロジェクト: ifzz/simspider
int InitSimSpiderEnv( struct SimSpiderEnv **ppenv , char *log_file_format , ... )
{
	int		nret = 0 ;
	
	srand( (unsigned int)time( NULL ) );
	
	if( log_file_format )
	{
		va_list         valist ;
		va_start( valist , log_file_format );
		SetLogFileV( log_file_format , valist );
		va_end( valist );
	}
	else if( getenv("SIMSPIDER_LOGFILE") )
	{
		SetLogFile( "%s" , getenv("SIMSPIDER_LOGFILE") );
	}
	else if( getenv("SIMSPIDER_LOGDIR") )
	{
		SetLogFile( "%s/simspider.log" , getenv("SIMSPIDER_LOGDIR") );
	}
	
	if( getenv("SIMSPIDER_LOGLEVEL") )
	{
		if( STRCMP( getenv("SIMSPIDER_LOGLEVEL") , == , "DEBUG" ) )
			SetLogLevel( LOGLEVEL_DEBUG );
		else if( STRCMP( getenv("SIMSPIDER_LOGLEVEL") , == , "INFO" ) )
			SetLogLevel( LOGLEVEL_INFO );
		else if( STRCMP( getenv("SIMSPIDER_LOGLEVEL") , == , "WARN" ) )
コード例 #2
0
/*******************************************************************************
Description:
   VINETIC Report Set for all vinetic messages
Arguments:
   pDev         - pointer to the device interface
   driver_level - new DBG_LEVEL
Return:
    IFX_SUCCESS if no error, otherwise IFX_ERROR
*******************************************************************************/
IFX_int32_t VINETIC_Report_Set(IFX_uint32_t driver_level)
{
   if ((driver_level > DBG_LEVEL_HIGH) || (driver_level < DBG_LEVEL_LOW))
   {
      SetTraceLevel(VINETIC, DBG_LEVEL_OFF);
      SetLogLevel(VINETIC, DBG_LEVEL_OFF);
   }
   else
   {
      SetTraceLevel(VINETIC, driver_level);
      SetLogLevel(VINETIC, driver_level);
   }

   return IFX_SUCCESS;
}
コード例 #3
0
ファイル: log_frame.cpp プロジェクト: PZerua/rpcs3
void log_frame::LoadSettings()
{
	SetLogLevel(xgui_settings->GetLogLevel());
	SetTTYLogging(xgui_settings->GetValue(gui::l_tty).toBool());
	m_stack_log = xgui_settings->GetValue(gui::l_stack).toBool();
	m_stackAct->setChecked(m_stack_log);
}
コード例 #4
0
ファイル: weixin4c.c プロジェクト: wzzhan/weixin4c
static int cgiinit( struct Weixin4cEnv *penv )
{
	int		nret = 0 ;
	
	chdir( "/tmp" );
	
	SetLogFile( "%s/log/%s_weixin4c.log" , penv->pconf->home , penv->pconf->project_name );
	SetLogLevel( LOGLEVEL_DEBUG );
	
	if( penv->pconf->funcs.pfuncInitEnvProc )
	{
		nret = penv->pconf->funcs.pfuncInitEnvProc( penv->pconf->user_data ) ;
		if( nret )
		{
			ErrorLog( __FILE__ , __LINE__ , "pfuncInitEnvProc failed[%d]" , nret );
			return -2;
		}
		else
		{
			InfoLog( __FILE__ , __LINE__ , "pfuncInitEnvProc ok" );
		}
	}
	
	return 0;
}
コード例 #5
0
ファイル: test_outputfunc.c プロジェクト: BlueGuyuuu/iLOG3
int test_outputfunc()
{
	LOG		*g = NULL ;
	
	g = CreateLogHandle() ;
	if( g == NULL )
	{
		printf( "创建日志句柄失败errno[%d]\n" , errno );
		return -1;
	}
	else
	{
		printf( "创建日志句柄成功\n" );
	}
	
	SetLogOutput( g , LOG_OUTPUT_CALLBACK , "127.0.0.1:514" , & MyOpenLogFirst , NULL , & MyWriteLog , NULL , NULL , & MyCloseLogFinally );
	SetLogLevel( g , LOG_LEVEL_INFO );
	SetLogStyles( g , LOG_STYLES_LOG , LOG_NO_STYLEFUNC );
	
	DebugLog( g , __FILE__ , __LINE__ , "hello iLOG3\n" );
	InfoLog( g , __FILE__ , __LINE__ , "hello iLOG3\n" );
	WarnLog( g , __FILE__ , __LINE__ , "hello iLOG3\n" );
	ErrorLog( g , __FILE__ , __LINE__ , "hello iLOG3\n" );
	FatalLog( g , __FILE__ , __LINE__ , "hello iLOG3\n" );
	
	DestroyLogHandle( g );
	printf( "销毁日志句柄\n" );
	
	return 0;
}
コード例 #6
0
ファイル: TTLog.cpp プロジェクト: lwbjun/hodUART
void CTTLog::SetLogParam(const std::string path, const std::string filename, const LogLevel level, const unsigned int size/* =ALLOWSIZE */)
{
    CCriticalGuard guard(m_cs);
    SetLogPath(path);
    SetLogLevel(level);
    SetLogMaxSize(size);
    _filename = filename;
}
コード例 #7
0
ファイル: logger.cpp プロジェクト: harveyaot/ardb
 void ArdbLogger::InitDefaultLogger(const std::string& level, const std::string& logfile)
 {
     if (!logfile.empty() && (logfile != "stdout" && logfile != "stderr"))
     {
         kLogFilePath = logfile;
         reopen_default_logfile();
     }
     SetLogLevel(level);
 }
コード例 #8
0
ファイル: log.cpp プロジェクト: madnessw/thesnow
/* static */
void wxLog::SetComponentLevel(const wxString& component, wxLogLevel level)
{
    if ( component.empty() )
    {
        SetLogLevel(level);
    }
    else
    {
        wxCRIT_SECT_LOCKER(lock, GetLevelsCS());

        GetComponentLevels()[component] = level;
    }
}
コード例 #9
0
void AWDBusAdaptor::SetLogLevel(const QString &what, const int level)
{
    qCDebug(LOG_DBUS) << "Set log level" << level << "for" << what;

    if (level >= m_logLevels.count()) {
        qCDebug(LOG_DBUS) << "Invalid logging level" << level
                          << "should be less than" << m_logLevels.count();
        return;
    }

    for (auto &lev : m_logLevels)
        SetLogLevel(what, lev, m_logLevels.indexOf(lev) >= level);
}
コード例 #10
0
int main( int argc , char *argv[] )
{
	DC4CSetAppLogFile( "dc4c_test_worker_hello" );
	SetLogLevel( LOGLEVEL_INFO );
	
	if( argc == 1 + 1 )
	{
		DC4CFormatReplyInfo( "hello %s" , argv[1] );
		return 0;
	}
	else
	{
		return 1;
	}
}
コード例 #11
0
ファイル: accesstoken.c プロジェクト: RemixWorld/weixin4c
int main( int argc , char *argv[] )
{
	if( argc == 1 + 2 )
	{
		SetLogFile( "%s/log/%s_accesstoken.log" , getenv("HOME") , argv[1] );
		SetLogLevel( LOGLEVEL_DEBUG );
		
		return -AccessToken( argv[1] , atoi(argv[2]) );
	}
	else
	{
		usage();
		exit(9);
	}
}
コード例 #12
0
ファイル: Log4cplus.cpp プロジェクト: wang1986one/duipcmgr
Utils::CLogger::CLogger()
	: m_dwMainThreadID(0)
{
	log4cplus::initialize();
#ifdef _DEBUG
	m_DefaultLevel= TRACE_LOG_LEVEL;	// Debug模式输出所有信息
#else
	m_DefaultLevel= OFF_LOG_LEVEL;		// Release模式下默认关闭所有输出
#endif

	SetLogLevel(m_DefaultLevel);
	m_strPattern = _T("%D{%y-%m-%d %H:%M:%S:%Q}|%t|%-16c|%m%n");
	m_strDebugPattern = _T("%D{%H:%M:%S:%Q}|%t|%-16c|%m%n");;

	m_strLogPath.Format(_T("%s\\Log"),AppGetSystemInfo()->GetModuleDir());
}
コード例 #13
0
ファイル: test_press.c プロジェクト: BlueGuyuuu/iLOG3
int test_press( long count )
{
	LOG		*press = NULL ;
	
	LongToLong	llBegin , llEnd , llDiff ;
	double		dPerf ;
	long		l ;
	
	press = CreateLogHandle() ;
	if( press == NULL )
	{
		printf( "创建press日志句柄失败errno[%d]\n" , errno );
		return -1;
	}
	else
	{
		printf( "创建press日志句柄成功\n" );
	}
	
	/* SetLogOptions( press , LOG_OPTION_OPEN_ONCE ); */
	SetLogOutput( press , LOG_OUTPUT_FILE , "test_press.log" , LOG_NO_OUTPUTFUNC );
	SetLogLevel( press , LOG_LEVEL_INFO );
	SetLogStyles( press , LOG_STYLES_PRESS , LOG_NO_STYLEFUNC );
	SetLogRotateMode( press , LOG_ROTATEMODE_SIZE );
	SetLogRotateSize( press , 10*1024*1024 );
	
	llBegin = GetUnixSecondsExactly() ;
	for( l = 1 ; l <= count ; l++ )
	{
		InfoLog( press , __FILE__ , __LINE__ , "log" );
	}
	llEnd = GetUnixSecondsExactly() ;
	llDiff.high = llEnd.high - llBegin.high ;
	llDiff.low = llEnd.low - llBegin.low ;
	if( llDiff.low < 0 )
	{
		llDiff.low += 1000000 ;
		llDiff.high--;
	}
	dPerf = (double)(count) / ( (double)(llDiff.high) + (double)(llDiff.low) / 1000000 ) ;
	printf( "总耗时[%ld.%03ld] 平均每秒输出行日志[%.2lf]条\n" , llDiff.high , llDiff.low , dPerf );
	
	DestroyLogHandle( press );
	printf( "销毁press句柄环境\n" );
	
	return 0;
}
コード例 #14
0
ファイル: ProgramOptions.cpp プロジェクト: SubhamoyS/wxPlayer
ProgramOptions::ProgramOptions(int argc, char* argv[]) : m_loglevel() {
  try {
    TCLAP::CmdLine cmd(
        "wxPlayer is a simple audio player for Debian-like systems.",
        ' ',
        std::to_string(VERSION_MAJOR) + "." + std::to_string(VERSION_MINOR) + "." + std::to_string(VERSION_PATCHLEVEL));

    TCLAP::ValueArg<std::string> arg_loglevel(
        "l", "loglevel", "Sets the log level of the application. Case insensitive.", false, "INFO", "string", cmd);

    cmd.parse(argc, argv);

    SetLogLevel(arg_loglevel.getValue());

  } catch (const TCLAP::ArgException& e) {
    throw std::runtime_error(e.error() + " for " + e.argId());
  }
}
コード例 #15
0
/// @brief Constructor 
/// @param filename The filename to open
FFmpegSourceVideoProvider::FFmpegSourceVideoProvider(wxString filename)
: VideoSource(NULL)
, VideoInfo(NULL)
, Width(-1)
, Height(-1)
, FrameNumber(-1)
, COMInited(false)
{
#ifdef WIN32
	HRESULT res = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
	if (SUCCEEDED(res)) 
		COMInited = true;
	else if (res != RPC_E_CHANGED_MODE)
		throw VideoOpenError("COM initialization failure");
#endif
	// initialize ffmpegsource
	// FIXME: CPU detection?
#if FFMS_VERSION >= ((2 << 24) | (14 << 16) | (0 << 8) | 0)
	FFMS_Init(0, 1);
#else
	FFMS_Init(0);
#endif

	ErrInfo.Buffer		= FFMSErrMsg;
	ErrInfo.BufferSize	= sizeof(FFMSErrMsg);
	ErrInfo.ErrorType	= FFMS_ERROR_SUCCESS;
	ErrInfo.SubType		= FFMS_ERROR_SUCCESS;

	SetLogLevel();

	// and here we go
	try {
		LoadVideo(filename);
	}
	catch (wxString const& err) {
		Close();
		throw VideoOpenError(STD_STR(err));
	}
	catch (...) {
		Close();
		throw;
	}
}
コード例 #16
0
void CRelaxReminderDlg::LoadSettingFromDefault()
{
    // 设置时间参数
    m_tm.SetWD(DEFAULT_WORK_DURATION);
    m_tm.SetSRD(DEFAULT_SHORT_RELAX_DURATION);
    m_tm.SetEnableLongRelax(DEFAULT_ENABLE_LONG_RELAX);
    m_tm.SetLRF(DEFAULT_LONG_RELAX_FREQUENCY);
    m_tm.SetLRD(DEFAULT_LONG_RELAX_DURATION);

    // 设置提示参数
    m_bPreNotify = DEFAULT_ENABLE_PRENOTIFY;
    m_bLockInput = DEFAULT_ENABLE_LOCK_INPUT;
    m_iLockType  = DEFAULT_LOCK_TYPE;
    m_iGraceTimeBeforeLockInput = DEFAULT_GRACE_TIME_BEFORE_LOCK_INPUT;
    m_bDarkerScreen         = DEFAULT_ENABLE_DARKER_SCREEN;
    m_iDarkerScreenAlpha    = DEFAULT_DARKER_SCREEN_ALPHA;
    m_eDarkerScreenAnimateType  = DEFAULT_DARKER_SCREEN_ANIMATE;
    m_colorDarkerScreen     = DEFAULT_DARKER_SCREEN_COLOR;
    m_eNotifyWindowType     = DEFAULT_NOTIFY_WINDOW_TYPE;
    m_eDarkerScreenType     = DEFAULT_DARKER_SCREEN_TYPE;

    // 设置自动状态转换参数
    m_tm.SetEnableAutoPause(DEFAULT_ENABLE_AUTO_PAUSE);
    m_tm.SetAPT(DEFAULT_AUTO_PAUSE_THRESHOLD);
    m_tm.SetEnableFullScreenPause(DEFAULT_ENABLE_FULLSCREEN_PAUSE);
    m_tm.SetEnableAutoReset(DEFAULT_ENABLE_AUTO_RESET);
    m_tm.SetART(DEFAULT_AUTO_RESET_THRESHOLD);

    // 设置语言参数
    m_strLanguageId = DEFAULT_LANGUAGE;

    // 设置杂项参数
    m_bLockComputer = DEFAULT_ENABLE_LOCK_COMPUTER;
    m_bCloseMonitor = DEFAULT_ENABLE_CLOSE_MONITOR;
    m_bShowFloatingWindowAtStartup  = DEFAULT_SHOW_FLOATING_WINDOW;
    m_bShowTrayIconAtStartup        = DEFAULT_SHOW_TRAY_ICON;
    SetEnableLog(DEFAULT_ENABLE_LOG);
    SetLogLevel(DEFAULT_LOG_LEVEL);
    SetLogFileSize(DEFAULT_LOG_FILE_SIZE);
    SetAppAutoStartWithSystem(DEFAULT_AUTO_START, m_strAppFile);
}
コード例 #17
0
int main(int argc, char* argv[])
{
  std::vector<LEVEL> logLevels = {LEVEL::INFO, LEVEL::WARNING, LEVEL::ERROR,
                                  LEVEL::CRITICAL};
  for (auto level : logLevels)
  {
    SetLogLevel(level);

    LOG(LEVEL::INFO) << "It's getting warm" << std::endl;
    LOG(LEVEL::WARNING) << "It's getting dangerously hot" << std::endl;
    LOG(LEVEL::ERROR) << "I'm starting to singe a bit" << std::endl;
    LOG(LEVEL::CRITICAL) << "I am on fire!\n" << std::endl;
  }

  std::thread t1([]()
                 {
                   for (int i = 0; i < 50; ++i)
                   {
                     LOG(LEVEL::CRITICAL) << "Are we locked?" << std::endl;
                     std::this_thread::sleep_for(
                         std::chrono::milliseconds(100));
                   }
                 });

  std::thread t2([]()
                 {
                   for (int i = 0; i < 50; ++i)
                   {
                     LOG(LEVEL::CRITICAL) << "Are we really locked?"
                                          << std::endl;
                     std::this_thread::sleep_for(
                         std::chrono::milliseconds(200));
                   }
                 });

  t1.join();
  t2.join();

  return 0;
}
コード例 #18
0
ファイル: Settings.cpp プロジェクト: haskellove/MediaSoup
bool Settings::ReloadConfigurationFile() {
	MS_TRACE();

	if (Settings::arguments.configFile.empty()) {
		MS_ERROR("no configuration file was given in command line options");
		return false;
	}

	libconfig::Config* config;

	try {
		config = ParseConfigFile();
	}
	catch (const MediaSoupError &error) {
		MS_ERROR("%s", error.what());
		return false;
	}

	std::string str_value;

	// Just some configuration settings can be reloaded.

	try {
		/* First level settings. */

		if (config->lookupValue("logLevel", str_value))
			SetLogLevel(str_value);
		else
			Settings::configuration.logLevel = LOG_DEBUG;
	}
	catch (const MediaSoupError &error) {
		MS_ERROR("error in configuration file: %s", error.what());
		delete config;
		return false;
	}

	delete config;
	return true;
}
コード例 #19
0
ファイル: ConsoleAPI.cpp プロジェクト: Pouique/naali
ConsoleAPI::ConsoleAPI(Framework *fw) :
    QObject(fw),
    framework(fw),
    enabledLogChannels(LogLevelErrorWarnInfo),
    logFile(0),
    logFileText(0)
{
    if (!fw->IsHeadless())
        consoleWidget = new ConsoleWidget(framework);

    inputContext = framework->Input()->RegisterInputContext("Console", 100);
    inputContext->SetTakeKeyboardEventsOverQt(true);
    connect(inputContext.get(), SIGNAL(KeyEventReceived(KeyEvent *)), SLOT(HandleKeyEvent(KeyEvent *)));

    RegisterCommand("help", "Lists all registered commands.", this, SLOT(ListCommands()));
    RegisterCommand("clear", "Clears the console log.", this, SLOT(ClearLog()));
    RegisterCommand("setLogLevel", "Sets the current log level. Call with one of the parameters \"error\", \"warning\", \"info\", or \"debug\".",
        this, SLOT(SetLogLevel(const QString &)));
#ifdef WIN32
    RegisterCommand("createConsole", "Creates the native Windows console if Tundra was started without such.", this, SLOT(CreateNativeConsole()));
    RegisterCommand("removeConsole", "Removes the native Windows console if applicable.", this, SLOT(RemoveNativeConsole()));
#endif

    /// \todo Visual Leak Detector shows a memory leak originating from this allocation although the shellInputThread is released in the destructor. Perhaps a shared pointer is held elsewhere.
    shellInputThread = MAKE_SHARED(ShellInputThread);

    QStringList logLevel = fw->CommandLineParameters("--loglevel");
    if (logLevel.size() >= 1)
        SetLogLevel(logLevel[logLevel.size()-1]);
    if (logLevel.size() > 1)
        LogWarning("Ignoring multiple --loglevel command line parameters!");

    QStringList logFile = fw->CommandLineParameters("--logfile");
    if (logFile.size() >= 1)
        SetLogFile(logFile[logFile.size()-1]);
    if (logFile.size() > 1)
        LogWarning("Ignoring multiple --logfile command line parameters!");
}
コード例 #20
0
void
MarlinSecureServerApp::InitInstance()
{
  // First always call the main class 
  // Must init for the HTTPServer and other objects
  ServerApp::InitInstance();

  CString contract = "http://interface.marlin.org/testing/";

  // Can only be called once if correctly started
  if (!CorrectlyStarted() || m_running)
  {
    return;
  }
  // Instance is now running
  m_running = true;

  // Set our logging level
  SetLogLevel(HLL_TRACEDUMP);  // NOLOG / ERRORS / LOGGING / LOGBODY / TRACE / TRACEDUMP

  // Starting objects and sites
  TestSecureSite(m_httpServer);
}
コード例 #21
0
/// @brief Constructor
/// @param filename The filename to open
FFmpegSourceVideoProvider::FFmpegSourceVideoProvider(wxString filename) try
: VideoSource(NULL, FFMS_DestroyVideoSource)
, VideoInfo(NULL)
, Width(-1)
, Height(-1)
, FrameNumber(-1)
{
	ErrInfo.Buffer		= FFMSErrMsg;
	ErrInfo.BufferSize	= sizeof(FFMSErrMsg);
	ErrInfo.ErrorType	= FFMS_ERROR_SUCCESS;
	ErrInfo.SubType		= FFMS_ERROR_SUCCESS;

	SetLogLevel();

	// and here we go
	LoadVideo(filename);
}
catch (wxString const& err) {
	throw VideoOpenError(STD_STR(err));
}
catch (const char * err) {
	throw VideoOpenError(err);
}
コード例 #22
0
ファイル: main.cpp プロジェクト: ETRI-PEC/PPSP
int main(int argc, char* argv[])
{
	int idx = 1;
	std::string filename = "";
	std::string ipaddress = "";
	int port = 0;

	std::string trackerip = "";
	int trackerport = 0;

	std::string hash = "";

	int listenOpt = 0;

	if (argc < 2)
	{
		_usage();
		exit(0);
	}

	while (argc > idx)
	{

		char* arg = argv[idx];

		if (strlen(arg) == 2 && arg[0] == '-')
		{
			idx++;

			switch (arg[1])
			{
			case 'h':
				printf("h : %s\n", argv[idx]);
				hash = argv[idx];

				break;

			case 't':
			{
				printf("t : %s\n", argv[idx]);
				char* semi = strchr(argv[idx], ':');
				if (semi)
				{
					*semi = 0;
					trackerip = argv[idx];
					trackerport = atoi(semi + 1);
				}
				else
				{
					port = atoi(argv[idx]);
				}

				break;
			}

			case 'f':
				printf("f : %s\n", argv[idx]);
				filename = argv[idx];
				break;

			case 'l':
			{
				printf("l : %s\n", argv[idx]);
				char* semi = strchr(argv[idx], ':');
				if (semi)
				{
					*semi = 0;
					ipaddress = argv[idx];
					port = atoi(semi + 1);
				}
				else
				{
					port = atoi(argv[idx]);
				}
				break;
			}
			case 'd':
				SetLogLevel(LOG_LEVEL_DEBUG);
				idx--;
				break;
			case 'o':
				listenOpt = 1;
				idx--;
				break;
			}

			idx++;
		}		
	}

	if (trackerip.length() > 0)
	{
		if (hash.length() <= 0)
		{
			_usage();
			exit(0);
		}

		if (trackerport <= 0)
		{
			_usage();
			exit(0);
		}

		if (port <= 0)
		{
			_usage();
			exit(0);
		}
	}
	else
	{
		if (port <= 0)
		{
			_usage();
			exit(0);
		}

		if (filename.length() <= 0)
		{
			_usage();
			exit(0);
		}
	}

	MetaDataSt metaData;
	_readConfigFile(metaData);

	HTTP_Startup();
	
	PPServer ppserver;
	ppserver.SetPort(port);
	ppserver.SetIpAddress(ipaddress);
	ppserver.SetFileName(filename);
	ppserver.SetSwarmID(hash);
	ppserver.SetTrackerIpAddress(trackerip);
	ppserver.SetTrackerPort(trackerport);

	ppserver.SetVersion(metaData.version);
	ppserver.SetMinVersion(metaData.mkinVersion);
	ppserver.SetContentIntegrityProtectionMethod(metaData.contentIntegrityProtectionMethod);
	ppserver.SetMerkleHashTreeFunction(metaData.merkleHashTreeFunction);
	ppserver.SetLiveSignatureAlgorithm(metaData.liveSignatureAlgorithm);
	ppserver.SetChunkAddressingMethod(metaData.chunkAddressingMethod);
	ppserver.SetChunkSize(metaData.chunkSize);
	ppserver.SetRetryCount(metaData.retryCount);
	ppserver.SetKeepAliveInterval(metaData.keepAliveInterval);
	ppserver.SetPexReqInterval(metaData.pexReqInterval);
	ppserver.SetListenPortOption(listenOpt);
	
	if (!ppserver.Start())
	{
		exit(0);
	}
	
	ppserver.Join();

	HTTP_Cleanup();

	return 0;
}
コード例 #23
0
ファイル: Logger.cpp プロジェクト: eatskolnikov/Kuko
void Logger::Setup( int logLevel, const std::string& filter )
{
    Setup();
    SetLogLevel( logLevel );
    SetFilterWord( filter );
}
コード例 #24
0
ファイル: settings.c プロジェクト: ihbar/fpp
void initSettings(int argc, char **argv)
{
    char tmpDir[256];
    char mediaDir[256];

	settings.binDirectory = strdup(dirname(argv[0]));
	settings.fppMode = PLAYER_MODE;
    
    strcpy(tmpDir, settings.binDirectory);

    // trim off src/ or bin/
    char *offset = NULL;
    int size = strlen(tmpDir);

    if ((size > 4) && (!strcmp(&tmpDir[size - 4], "/src")))
        offset = &tmpDir[size - 4];
    else if ((size > 4) && (!strcmp(&tmpDir[size - 4], "/bin")))
        offset = &tmpDir[size - 4];
    else if ((size > 8) && (!strcmp(&tmpDir[size - 8], "/scripts")))
        offset = &tmpDir[size - 8];

    if (offset != NULL)
        *offset = 0;

    settings.fppDirectory = strdup(tmpDir);

	if (DirectoryExists("/home/fpp"))
		strcpy(mediaDir, "/home/fpp");
	else
		strcpy(mediaDir, "/home/pi");

	strcat(mediaDir, "/media");
	settings.mediaDirectory = strdup(mediaDir);

	strcpy(tmpDir, mediaDir);
	settings.musicDirectory = strdup(strcat(tmpDir, "/music"));
	strcpy(tmpDir, mediaDir);
	settings.sequenceDirectory = strdup(strcat(tmpDir, "/sequences"));
	strcpy(tmpDir, mediaDir);
	settings.playlistDirectory = strdup(strcat(tmpDir, "/playlists"));
	strcpy(tmpDir, mediaDir);
	settings.eventDirectory = strdup(strcat(tmpDir, "/events"));
	strcpy(tmpDir, mediaDir);
	settings.videoDirectory = strdup(strcat(tmpDir, "/videos"));
	strcpy(tmpDir, mediaDir);
	settings.effectDirectory = strdup(strcat(tmpDir, "/effects"));
	strcpy(tmpDir, mediaDir);
	settings.scriptDirectory = strdup(strcat(tmpDir, "/scripts"));
	strcpy(tmpDir, mediaDir);
	settings.pluginDirectory = strdup(strcat(tmpDir, "/plugins"));
	strcpy(tmpDir, mediaDir);
	settings.universeFile = strdup(strcat(tmpDir, "/universes"));
	strcpy(tmpDir, mediaDir);
	settings.pixelnetFile = strdup(strcat(tmpDir, "/config/Falcon.FPDV1"));
	strcpy(tmpDir, mediaDir);
	settings.scheduleFile = strdup(strcat(tmpDir, "/schedule"));
	strcpy(tmpDir, mediaDir);
	settings.logFile = strdup(strcat(tmpDir, "/logs/fppd.log"));
	strcpy(tmpDir, mediaDir);
	settings.silenceMusic = strdup(strcat(tmpDir, "/silence.ogg"));
	strcpy(tmpDir, mediaDir);
	settings.bytesFile = strdup(strcat(tmpDir, "/bytesReceived"));
	strcpy(tmpDir, mediaDir);
	settings.settingsFile = strdup(strcat(tmpDir, "/settings"));
	settings.daemonize = 1;
	settings.E131interface = strdup("eth0");
	settings.controlMajor = 0;
	settings.controlMinor = 0;

	SetLogLevel("info");
	SetLogMask("most");
}
コード例 #25
0
ファイル: settings.c プロジェクト: ihbar/fpp
int parseSetting(char *key, char *value)
{
    if (settings.keyVal[key]) {
        free(settings.keyVal[key]);
        settings.keyVal[key] = strdup(value);
    }

	if ( strcmp(key, "daemonize") == 0 )
	{
		settings.daemonize = atoi(value);
	}
	else if ( strcmp(key, "fppMode") == 0 )
	{
		if ( strcmp(value, "player") == 0 )
			settings.fppMode = PLAYER_MODE;
		else if ( strcmp(value, "bridge") == 0 )
			settings.fppMode = BRIDGE_MODE;
		else if ( strcmp(value, "master") == 0 )
			settings.fppMode = MASTER_MODE;
		else if ( strcmp(value, "remote") == 0 )
			settings.fppMode = REMOTE_MODE;
		else
		{
			fprintf(stderr, "Error parsing mode\n");
			exit(EXIT_FAILURE);
		}
	}
	else if ( strcmp(key, "alwaysTransmit") == 0 )
	{
		if ( strlen(value) )
			settings.alwaysTransmit = atoi(value);
		else
			fprintf(stderr, "Failed to apply alwaysTransmit setting\n");
	}
	else if ( strcmp(key, "mediaDirectory") == 0 )
	{
		if ( strlen(value) )
		{
			free(settings.mediaDirectory);
			settings.mediaDirectory = strdup(value);
		}
		else
			fprintf(stderr, "Failed to apply mediaDirectory\n");
	}
	else if ( strcmp(key, "musicDirectory") == 0 )
	{
		if ( strlen(value) )
		{
			free(settings.musicDirectory);
			settings.musicDirectory = strdup(value);
		}
		else
			fprintf(stderr, "Failed to apply musicDirectory\n");
	}
	else if ( strcmp(key, "sequenceDirectory") == 0 )
	{
		if ( strlen(value) )
		{
			free(settings.sequenceDirectory);
			settings.sequenceDirectory = strdup(value);
		}
		else
			fprintf(stderr, "Failed to apply sequenceDirectory\n");
	}
	else if ( strcmp(key, "eventDirectory") == 0 )
	{
		if ( strlen(value) )
		{
			free(settings.eventDirectory);
			settings.eventDirectory = strdup(value);
		}
		else
			fprintf(stderr, "Failed to apply eventDirectory\n");
	}
	else if ( strcmp(key, "videoDirectory") == 0 )
	{
		if ( strlen(value) )
		{
			free(settings.videoDirectory);
			settings.videoDirectory = strdup(value);
		}
		else
			fprintf(stderr, "Failed to apply videoDirectory\n");
	}
	else if ( strcmp(key, "effectDirectory") == 0 )
	{
		if ( strlen(value) )
		{
			free(settings.effectDirectory);
			settings.effectDirectory = strdup(value);
		}
		else
			fprintf(stderr, "Failed to apply effectDirectory\n");
	}
	else if ( strcmp(key, "scriptDirectory") == 0 )
	{
		if ( strlen(value) )
		{
			free(settings.scriptDirectory);
			settings.scriptDirectory = strdup(value);
		}
		else
			fprintf(stderr, "Failed to apply scriptDirectory\n");
	}
	else if ( strcmp(key, "pluginDirectory") == 0 )
	{
		if ( strlen(value) )
		{
			free(settings.pluginDirectory);
			settings.pluginDirectory = strdup(value);
		}
		else
			fprintf(stderr, "Failed to apply pluginDirectory\n");
	}
	else if ( strcmp(key, "playlistDirectory") == 0 )
	{
		if ( strlen(value) )
		{
			free(settings.playlistDirectory);
			settings.playlistDirectory = strdup(value);
		}
		else
			fprintf(stderr, "Failed to apply playlistDirectory\n");
	}
	else if ( strcmp(key, "universeFile") == 0 )
	{
		if ( strlen(value) )
		{
			free(settings.universeFile);
			settings.universeFile = strdup(value);
		}
		else
			fprintf(stderr, "Failed to apply universeFile\n");
	}
	else if ( strcmp(key, "pixelnetFile") == 0 )
	{
		if ( strlen(value) )
		{
			free(settings.pixelnetFile);
			settings.pixelnetFile = strdup(value);
		}
		else
			fprintf(stderr, "Failed to apply pixelnetFile\n");
	}
	else if ( strcmp(key, "scheduleFile") == 0 )
	{
		if ( strlen(value) )
		{
			free(settings.scheduleFile);
			settings.scheduleFile = strdup(value);
		}
		else
			fprintf(stderr, "Failed to apply scheduleFile\n");
	}
	else if ( strcmp(key, "LogLevel") == 0 )
	{
		if (strlen(value))
			SetLogLevel(value);
		else
			SetLogLevel("warn");
	}
	else if ( strcmp(key, "LogMask") == 0 )
	{
		if (strlen(value))
			SetLogMask(value);
		else
			SetLogMask("");
	}
	else if ( strcmp(key, "logFile") == 0 )
	{
		if ( strlen(value) )
		{
			free(settings.logFile);
			settings.logFile = strdup(value);
		}
		else
			fprintf(stderr, "Failed to apply logFile\n");
	}
	else if ( strcmp(key, "silenceMusic") == 0 )
	{
		if ( strlen(value) )
		{
			free(settings.silenceMusic);
			settings.silenceMusic = strdup(value);
		}
		else
			fprintf(stderr, "Failed to apply silenceMusic\n");
	}
	else if ( strcmp(key, "bytesFile") == 0 )
	{
		if ( strlen(value) )
		{
			free(settings.bytesFile);
			settings.bytesFile = strdup(value);
		}
		else
			fprintf(stderr, "Failed to apply bytesFile\n");
	}
	else if ( strcmp(key, "E131interface") == 0 )
	{
		if ( strlen(value) )
		{
			free(settings.E131interface);
			settings.E131interface = strdup(value);
		}
		else
			fprintf(stderr, "Failed to apply E131interface\n");
	}
	else if ( strcmp(key, "controlMajor") == 0 )
	{
		if ( strlen(value) )
		{
			int ivalue = atoi(value);
			if (ivalue >= 0)
				settings.controlMajor = (unsigned int)ivalue;
			else
				fprintf(stderr, "Error, controlMajor value negative\n");
		}
		else
			fprintf(stderr, "Failed to apply controlMajor setting\n");
	}
	else if ( strcmp(key, "controlMinor") == 0 )
	{
		if ( strlen(value) )
		{
			int ivalue = atoi(value);
			if (ivalue >= 0)
				settings.controlMinor = (unsigned int)ivalue;
			else
				fprintf(stderr, "Error, controlMinor value negative\n");
		}
		else
			fprintf(stderr, "Failed to apply controlMinor setting\n");
	}

	return 1;
}
コード例 #26
0
ファイル: Settings.cpp プロジェクト: haskellove/MediaSoup
void Settings::ReadConfigurationFile() {
	MS_TRACE();

	if (Settings::arguments.configFile.empty())
		return;

	libconfig::Config* config;

	try {
		config = ParseConfigFile();
	}
	catch (const MediaSoupError &error) {
		MS_EXIT_FAILURE("%s", error.what());
	}

	std::string str_value;
	std::string str_value2;
	int int_value;
	int int_value2;
	bool bool_value;
	std::string empty_string;

	try {
		/* First level settings. */

		if (config->lookupValue("logLevel", str_value))
			SetLogLevel(str_value);

		if (config->lookupValue("syslogFacility", str_value))
			SetSyslogFacility(str_value);

		if (config->lookupValue("numWorkers", int_value))
			SetNumWorkers(int_value);

		/* ControlProtocol section. */

		if (config->lookupValue("ControlProtocol.listenIP", str_value))
			SetControlProtocolListenIP(str_value);

		if (config->lookupValue("ControlProtocol.listenPort", int_value))
			SetControlProtocolListenPort(int_value);

		/* RTC section. */

		if (config->lookupValue("RTC.listenIPv4", str_value))
			SetRTClistenIPv4(str_value);
		else if ((config->lookupValue("RTC.listenIPv4", bool_value)) && bool_value == false)
			SetRTClistenIPv4(empty_string);

		if (config->lookupValue("RTC.listenIPv6", str_value))
			SetRTClistenIPv6(str_value);
		else if ((config->lookupValue("RTC.listenIPv6", bool_value)) && bool_value == false)
			SetRTClistenIPv6(empty_string);

		if (config->lookupValue("RTC.minPort", int_value) && config->lookupValue("RTC.maxPort", int_value2))
			SetRTCports(int_value, int_value2);

		if (config->lookupValue("RTC.dtlsCertificateFile", str_value) && config->lookupValue("RTC.dtlsPrivateKeyFile", str_value2))
			SetDtlsCertificateAndPrivateKeyFiles(str_value, str_value2);
	}
	catch (const MediaSoupError &error) {
		delete config;
		MS_EXIT_FAILURE("error in configuration file: %s", error.what());
	}

	delete config;
}
コード例 #27
0
ファイル: command.c プロジェクト: ihbar/fpp
char *ProcessCommand(char *command, char *response)
{
    char *s;
    char *s2;
    char *s3;
    char *s4;
    char *response2 = NULL;
    int i;
    char NextPlaylist[128] = "No playlist scheduled.";
    char NextScheduleStartText[64] = "";
    char CommandStr[64];
    LogExcess(VB_COMMAND, "CMD: %s\n", command);
    s = strtok(command,",");
    strcpy(CommandStr, s);
    if (!strcmp(CommandStr, "s")) {
        scheduler->GetNextScheduleStartText(NextScheduleStartText);
        scheduler->GetNextPlaylistText(NextPlaylist);
        if(FPPstatus==FPP_STATUS_IDLE) {
            if (getFPPmode() == REMOTE_MODE) {
                int secsElapsed = 0;
                int secsRemaining = 0;
                char seqFilename[1024];
                char mediaFilename[1024];

                if (sequence->IsSequenceRunning()) {
                    strcpy(seqFilename, sequence->m_seqFilename);
                    secsElapsed = sequence->m_seqSecondsElapsed;
                    secsRemaining = sequence->m_seqSecondsRemaining;
                } else {
                    strcpy(seqFilename, "");
                }

                if (mediaOutput) {
                    strcpy(mediaFilename, mediaOutput->m_mediaFilename.c_str());
                    secsElapsed = mediaOutputStatus.secondsElapsed;
                    secsRemaining = mediaOutputStatus.secondsRemaining;
                } else {
                    strcpy(mediaFilename, "");
                }

                sprintf(response,"%d,%d,%d,%s,%s,%d,%d\n",
                        getFPPmode(), 0, getVolume(), seqFilename,
                        mediaFilename, secsElapsed, secsRemaining);
            } else if (sequence->IsSequenceRunning()) {
                sprintf(response,"%d,%d,%d,,,%s,,0,0,%d,%d,%s,%s,0\n",
                        getFPPmode(),
                        1,
                        getVolume(),
                        sequence->m_seqFilename,
                        sequence->m_seqSecondsElapsed,
                        sequence->m_seqSecondsRemaining,
                        NextPlaylist,
                        NextScheduleStartText);
            } else {
                sprintf(response,"%d,%d,%d,%s,%s\n",getFPPmode(),0,getVolume(),NextPlaylist,NextScheduleStartText);
            }
        } else {
            Json::Value pl = playlist->GetInfo();
            if (pl["currentEntry"].isMember("dynamic"))
                pl["currentEntry"] = pl["currentEntry"]["dynamic"];

            if ((pl["currentEntry"]["type"] == "both") ||
                (pl["currentEntry"]["type"] == "media")) {
                //printf(" %s\n", pl.toStyledString().c_str());
                sprintf(response,"%d,%d,%d,%s,%s,%s,%s,%d,%d,%d,%d,%s,%s,%d\n",
                    getFPPmode(),
                    FPPstatus,
                    getVolume(),
                    pl["name"].asString().c_str(),
                    pl["currentEntry"]["type"].asString().c_str(),
                    pl["currentEntry"]["type"].asString() == "both" ? pl["currentEntry"]["sequence"]["sequenceName"].asString().c_str() : "",
                    pl["currentEntry"]["type"].asString() == "both"
                        ? pl["currentEntry"]["media"]["mediaFilename"].asString().c_str()
                        : pl["currentEntry"]["mediaFilename"].asString().c_str() ,
//							pl["currentEntry"]["entryID"].asInt() + 1,
                    playlist->GetPosition(),
                    pl["size"].asInt(),
                    pl["currentEntry"]["type"].asString() == "both"
                        ? pl["currentEntry"]["media"]["secondsElapsed"].asInt()
                        : pl["currentEntry"]["secondsElapsed"].asInt(),
                    pl["currentEntry"]["type"].asString() == "both"
                        ? pl["currentEntry"]["media"]["secondsRemaining"].asInt()
                        : pl["currentEntry"]["secondsRemaining"].asInt(),
                    NextPlaylist,
                    NextScheduleStartText,
                    pl["repeat"].asInt());
            } else if (pl["currentEntry"]["type"] == "sequence") {
                sprintf(response,"%d,%d,%d,%s,%s,%s,%s,%d,%d,%d,%d,%s,%s,%d\n",
                    getFPPmode(),
                    FPPstatus,
                    getVolume(),
                    pl["name"].asString().c_str(),
                    pl["currentEntry"]["type"].asString().c_str(),
                    pl["currentEntry"]["sequenceName"].asString().c_str(),
                    "",
//							pl["currentEntry"]["entryID"].asInt() + 1,
                    playlist->GetPosition(),
                    pl["size"].asInt(),
                    sequence->m_seqSecondsElapsed,
                    sequence->m_seqSecondsRemaining,
                    NextPlaylist,
                    NextScheduleStartText,
                    pl["repeat"].asInt());
            } else {
                sprintf(response,"%d,%d,%d,%s,%s,%s,%s,%d,%d,%d,%d,%s,%s,%d\n",
                    getFPPmode(),
                    FPPstatus,
                    getVolume(),
                    pl["name"].asString().c_str(),
                    pl["currentEntry"]["type"].asString().c_str(),
                    "",
                    "",
//							pl["currentEntry"]["entryID"].asInt() + 1,
                    playlist->GetPosition(),
                    pl["size"].asInt(),
                    pl["currentEntry"]["type"].asString() == "pause" ? pl["currentEntry"]["duration"].asInt() - pl["currentEntry"]["remaining"].asInt() : 0,
                    pl["currentEntry"]["type"].asString() == "pause" ? pl["currentEntry"]["remaining"].asInt() : 0,
                    NextPlaylist,
                    NextScheduleStartText,
                    pl["repeat"].asInt());
            }
        }
    } else if ((!strcmp(CommandStr, "P")) || (!strcmp(CommandStr, "p"))) {
        s = strtok(NULL,",");
        s2 = strtok(NULL,",");

        int entry = 0;
        if (s2 && s2[0])
            entry = atoi(s2);

        if (s)
        {
            int repeat = strcmp(CommandStr, "p") ? 0 : 1;
            int scheduledRepeat = 0;
            std::string playlistName = scheduler->GetPlaylistThatShouldBePlaying(scheduledRepeat);

            if ((playlistName == s) && (repeat == scheduledRepeat)) {
                // Use CheckIfShouldBePlayingNow() so the scheduler knows when
                // to stop the playlist
                scheduler->CheckIfShouldBePlayingNow(1);
                sprintf(response,"%d,%d,Playlist Started,,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS);
            } else if (playlist->Play(s, entry, repeat, 0)) {
                FPPstatus = FPP_STATUS_PLAYLIST_PLAYING;
                sprintf(response,"%d,%d,Playlist Started,,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS);
		    } else {
                sprintf(response,"%d,%d,Error Starting Playlist,,,,,,,,,,\n",getFPPmode(),COMMAND_FAILED);
            }
        } else {
            sprintf(response,"%d,%d,Unknown Playlist,,,,,,,,,,\n",getFPPmode(),COMMAND_FAILED);
        }
    } else if ((!strcmp(CommandStr, "S")) ||
               (!strcmp(CommandStr, "StopGracefully"))) {
        if (FPPstatus==FPP_STATUS_PLAYLIST_PLAYING) {
            playlist->StopGracefully(1);
            scheduler->ReLoadCurrentScheduleInfo();
            sprintf(response,"%d,%d,Playlist Stopping Gracefully,,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS);
        } else {
            sprintf(response,"%d,Not playing,,,,,,,,,,,\n",COMMAND_FAILED);
        }
    } else if ((!strcmp(CommandStr, "d")) ||
               (!strcmp(CommandStr, "StopNow"))) {
        if (FPPstatus==FPP_STATUS_PLAYLIST_PLAYING || FPPstatus==FPP_STATUS_STOPPING_GRACEFULLY) {
            playlist->StopNow(1);
            scheduler->ReLoadCurrentScheduleInfo();
            sprintf(response,"%d,%d,Playlist Stopping Now,,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS);
        } else if ((FPPstatus == FPP_STATUS_IDLE) &&
                   (sequence->IsSequenceRunning())) {
            sequence->CloseSequenceFile();
            sprintf(response,"%d,%d,Sequence Stopping Now,,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS);
        } else {
            sprintf(response,"%d,%d,Not playing,,,,,,,,,,\n",getFPPmode(),COMMAND_FAILED);
        }
    } else if (!strcmp(CommandStr, "R")) {
        scheduler->ReLoadNextScheduleInfo();
        if (FPPstatus==FPP_STATUS_IDLE) {
            scheduler->ReLoadCurrentScheduleInfo();
            scheduler->CheckIfShouldBePlayingNow();
        }
        sprintf(response,"%d,%d,Reloading Schedule,,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS);
    } else if (!strcmp(CommandStr, "v")) {
        s = strtok(NULL,",");
        if (s) {
            setVolume(atoi(s));
            sprintf(response,"%d,%d,Setting Volume,,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS);
        } else {
            sprintf(response,"%d,%d,Invalid Volume,,,,,,,,,,\n",getFPPmode(),COMMAND_FAILED);
        }
    } else if (!strcmp(CommandStr, "q")) {
        // Quit/Shutdown fppd
        if ((FPPstatus == FPP_STATUS_PLAYLIST_PLAYING) ||
            (FPPstatus == FPP_STATUS_STOPPING_GRACEFULLY)) {
            playlist->StopNow(1);
            sleep(2);
        }

        ShutdownFPPD();

        sleep(1);
    } else if (!strcmp(CommandStr, "e")) {
        // Start an Effect
        s = strtok(NULL,",");
        s2 = strtok(NULL,",");
        s3 = strtok(NULL,",");
        if (s && s2) {
            i = StartEffect(s, atoi(s2), atoi(s3));
            if (i >= 0)
                sprintf(response,"%d,%d,Starting Effect,%d,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS,i);
            else
                sprintf(response,"%d,%d,Invalid Effect,,,,,,,,,,\n",getFPPmode(),COMMAND_FAILED);
        } else
            sprintf(response,"%d,%d,Invalid Effect,,,,,,,,,,\n",getFPPmode(),COMMAND_FAILED);
    } else if (!strcmp(CommandStr, "t")) {
        // Trigger an event
        s = strtok(NULL,",");
        pluginCallbackManager.eventCallback(s, "command");
        i = TriggerEventByID(s);
        if (i >= 0)
            sprintf(response,"%d,%d,Event Triggered,%d,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS,i);
        else
            sprintf(response,"%d,%d,Event Failed,,,,,,,,,,\n",getFPPmode(),COMMAND_FAILED);
    } else if (!strcmp(CommandStr, "GetTestMode")) {
        strcpy(response, channelTester->GetConfig().c_str());
        strcat(response, "\n");
    } else if (!strcmp(CommandStr, "SetTestMode")) {
        if (channelTester->SetupTest(std::string(s + strlen(s) + 1)))
        {
            sprintf(response, "0,%d,Test Mode Activated,,,,,,,,,\n",
                COMMAND_SUCCESS);
        } else {
            sprintf(response, "0,%d,Test Mode Deactivated,,,,,,,,,\n",
                COMMAND_SUCCESS);
        }
    } else if (!strcmp(CommandStr, "LogLevel")) {
        s = strtok(NULL,",");

        if (SetLogLevel(s)) {
            sprintf(response,"%d,%d,Log Level Updated,%d,%d,,,,,,,,,\n",
                getFPPmode(),COMMAND_SUCCESS,logLevel,logMask);
        } else {
            sprintf(response,"%d,%d,Error Updating Log Level,%d,%d,,,,,,,,,\n",
                getFPPmode(),COMMAND_FAILED,logLevel,logMask);
        }
    } else if (!strcmp(CommandStr, "LogMask")) {
        s = strtok(NULL,",");

        if ((s && SetLogMask(s)) || SetLogMask("")) {
            sprintf(response,"%d,%d,Log Mask Updated,%d,%d,,,,,,,,,\n",
                getFPPmode(),COMMAND_SUCCESS,logLevel,logMask);
        } else {
            sprintf(response,"%d,%d,Error Updating Log Mask,%d,%d,,,,,,,,,\n",
                getFPPmode(),COMMAND_FAILED,logLevel,logMask);
        }
    } else if (!strcmp(CommandStr, "SetSetting")) {
        char name[128];

        s = strtok(NULL,",");
        if (s) {
            strcpy(name, s);
            s = strtok(NULL,",");
            if (s)
                parseSetting(name, s);
        }
    } else if (!strcmp(CommandStr, "StopAllEffects")) {
        StopAllEffects();
        sprintf(response,"%d,%d,All Effects Stopped,,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS);
    } else if (!strcmp(CommandStr, "StopEffectByName")) {
        s = strtok(NULL,",");
        if (strlen(s)) {
            if (StopEffect(s))
                sprintf(response,"%d,%d,Stopping Effect,%s,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS,s);
            else
                sprintf(response,"%d,%d,Stop Effect Failed,,,,,,,,,,\n",getFPPmode(),COMMAND_FAILED);
        }
    } else if (!strcmp(CommandStr, "StopEffect")) {
        s = strtok(NULL,",");
        i = atoi(s);
        if (StopEffect(i))
            sprintf(response,"%d,%d,Stopping Effect,%d,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS,i);
        else
            sprintf(response,"%d,%d,Stop Effect Failed,,,,,,,,,,\n",getFPPmode(),COMMAND_FAILED);
    } else if (!strcmp(CommandStr, "GetRunningEffects")) {
        sprintf(response,"%d,%d,Running Effects",getFPPmode(),COMMAND_SUCCESS);
        GetRunningEffects(response, &response2);
    } else if (!strcmp(CommandStr, "GetFPPDUptime")) {
        sprintf(response,"%d,%d,FPPD Uptime,%ld,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS, time(NULL) - fppdStartTime);
    } else if (!strcmp(CommandStr, "StartSequence")) {
        if ((FPPstatus == FPP_STATUS_IDLE) &&
            (!sequence->IsSequenceRunning())) {
            s = strtok(NULL,",");
            s2 = strtok(NULL,",");
            if (s && s2) {
                i = atoi(s2);
                sequence->OpenSequenceFile(s, 0, i);
            } else {
                LogDebug(VB_COMMAND, "Invalid command: %s\n", command);
            }
        } else {
            LogErr(VB_COMMAND, "Tried to start a sequence when a playlist or "
                    "sequence is already running\n");
        }
    } else if (!strcmp(CommandStr, "StopSequence")) {
        if ((FPPstatus == FPP_STATUS_IDLE) &&
            (sequence->IsSequenceRunning())) {
            sequence->CloseSequenceFile();
        } else {
            LogDebug(VB_COMMAND,
                "Tried to stop a sequence when no sequence is running\n");
        }
    } else if (!strcmp(CommandStr, "ToggleSequencePause")) {
        if ((sequence->IsSequenceRunning()) &&
            ((FPPstatus == FPP_STATUS_IDLE) ||
             ((FPPstatus != FPP_STATUS_IDLE) &&
              (playlist->GetInfo()["currentEntry"]["type"] == "sequence")))) {
            sequence->ToggleSequencePause();
        }
    } else if (!strcmp(CommandStr, "SingleStepSequence")) {
        if ((sequence->IsSequenceRunning()) &&
            (sequence->SequenceIsPaused()) &&
            ((FPPstatus == FPP_STATUS_IDLE) ||
             ((FPPstatus != FPP_STATUS_IDLE) &&
              (playlist->GetInfo()["currentEntry"]["type"] == "sequence")))) {
            sequence->SingleStepSequence();
        }
    } else if (!strcmp(CommandStr, "SingleStepSequenceBack")) {
        if ((sequence->IsSequenceRunning()) &&
            (sequence->SequenceIsPaused()) &&
            ((FPPstatus == FPP_STATUS_IDLE) ||
             ((FPPstatus != FPP_STATUS_IDLE) &&
              (playlist->GetInfo()["currentEntry"]["type"] == "sequence")))) {
            sequence->SingleStepSequenceBack();
        }
    } else if (!strcmp(CommandStr, "NextPlaylistItem")) {
        switch (FPPstatus)
        {
            case FPP_STATUS_IDLE:
                sprintf(response,"%d,%d,No playlist running\n",getFPPmode(),COMMAND_FAILED);
                break;
            case FPP_STATUS_PLAYLIST_PLAYING:
                sprintf(response,"%d,%d,Skipping to next playlist item\n",getFPPmode(),COMMAND_SUCCESS);
                playlist->NextItem();
                break;
            case FPP_STATUS_STOPPING_GRACEFULLY:
                sprintf(response,"%d,%d,Playlist is stopping gracefully\n",getFPPmode(),COMMAND_FAILED);
                break;
        }
    } else if (!strcmp(CommandStr, "PrevPlaylistItem")) {
        switch (FPPstatus) {
            case FPP_STATUS_IDLE:
                sprintf(response,"%d,%d,No playlist running\n",getFPPmode(),COMMAND_FAILED);
                break;
            case FPP_STATUS_PLAYLIST_PLAYING:
                sprintf(response,"%d,%d,Skipping to previous playlist item\n",getFPPmode(),COMMAND_SUCCESS);
                playlist->PrevItem();
                break;
            case FPP_STATUS_STOPPING_GRACEFULLY:
                sprintf(response,"%d,%d,Playlist is stopping gracefully\n",getFPPmode(),COMMAND_FAILED);
                break;
        }
    } else if (!strcmp(CommandStr, "SetupExtGPIO")) {
        // Configure the given GPIO to the given mode
        s = strtok(NULL,",");
        s2 = strtok(NULL,",");
        if (s && s2)
        {
            
            if (!SetupExtGPIO(atoi(s), s2))
            {
                sprintf(response, "%d,%d,Configuring GPIO,%d,%s,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS,atoi(s),s2);
            } else {
                sprintf(response, "%d,%d,Configuring GPIO,%d,%s,,,,,,,,,\n",getFPPmode(),COMMAND_FAILED,atoi(s),s2);
            }
        }
    } else if (!strcmp(CommandStr, "ExtGPIO")) {
        s = strtok(NULL,",");
        s2 = strtok(NULL,",");
        s3 = strtok(NULL,",");
        if (s && s2 && s3)
        {
            i = ExtGPIO(atoi(s), s2, atoi(s3));
            if (i >= 0)
            {
                sprintf(response, "%d,%d,Setting GPIO,%d,%s,%d,%d,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS,atoi(s),s2,atoi(s3),i);
            } else {
                sprintf(response, "%d,%d,Setting GPIO,%d,%s,%d,,,,,,,,\n",getFPPmode(),COMMAND_FAILED,atoi(s),s2,atoi(s3));
            }
        }
    } else {
        sprintf(response,"Invalid command: '%s'\n", CommandStr);
    }

    return response2;
}
コード例 #28
0
ファイル: fsequtil.c プロジェクト: dkulp/fpp
int main (int argc, char *argv[])
{
	char *inFilename = 0;
	char *outFilename = 0;
	int info = 0;

	SetLogLevel("debug");
	SetLogMask("sequence");

	if(argc>1)
	{
		for (int c = 1; c < argc; c++)
		{
			if(!strncmp(argv[c],"-h",2))
			{
				Usage(argv[0]);
			}
			// Info - example "fpp -i <FILENAME>"
			else if(!strncmp(argv[c],"-i",2))
			{
				info = 1;
			}
			else if(!strncmp(argv[c],"-o",2) && ((c+1) < argc))
			{
				outFilename = argv[c+1];
				c++;
			}
			else if(!strncmp(argv[c],"-b",2) && ((c+1) < argc))
			{
				brightness = atoi(argv[c+1]);
				c++;
			}
			else if (c == (argc - 1))
			{
				inFilename = argv[c];
			}
			else
			{
				// Unknown option, print usage
				printf( "Unknown option: '%s'\n\n", argv[c]);

				Usage(argv[0]);
			}
		}
	}
	else
	{
		Usage(argv[0]);
	}

	if (!inFilename)
	{
		Usage(argv[0]);
	}

	if (info)
	{
		fseqInfo(inFilename);
	}
	else if (outFilename)
	{
		fseqCopy(inFilename, outFilename);
	}
	else
	{
		// No other valid args so display info on the file by default
		fseqInfo(inFilename);
	}

	return 0;
}
コード例 #29
0
BOOL CRelaxReminderDlg::LoadSettingFromIniFile()
{
    // 进入临界区保护
    EnterCriticalSection(&m_csSettingFile); 

    // 打开配置文件
    CIni Ini(m_strConfigFile);

    // 先判断版本信息是否存在。若不存在,直接返回FALSE,加载默认参数。
    BOOL bVersionExist = Ini.CheckExist("Version", "CurrentVersion");
    if (bVersionExist == FALSE)
    {
        AppLog2Buf(L_WARN, "config file[%s] does NOT have version info.", m_strConfigFile);
        LeaveCriticalSection(&m_csSettingFile);
        return FALSE;
    }

    // 读取版本信息
    CString strIniFileVersion = Ini.ReadText("Version", "CurrentVersion");
    UINT dwIniFileVersion = VersionString2Num(strIniFileVersion);

    if (dwIniFileVersion == m_dwVersion)
    {
        AppLog2Buf(L_MSG, "config file version is %s, compatible with main app.",
                   strIniFileVersion);
    }
    else
    {
        AppLog2Buf(L_WARN, "config file version is %s, file converting.",
                   strIniFileVersion);
    }

    switch (dwIniFileVersion)
    {
    case VERSION_0_8_4:
        m_eDarkerScreenType = (EMultiMonitorType)Ini.ReadInt("Notify", "DarkerScreenType");
        m_eNotifyWindowType = (EMultiMonitorType)Ini.ReadInt("Notify", "NotifyWindowType");
        m_iGraceTimeBeforeLockInput = Ini.ReadInt("Notify", "GraceTimeBeforeLockInput");
    case VERSION_0_8_3:
    case VERSION_0_8_2:
    case VERSION_0_8_1:
    case VERSION_0_8:
    case VERSION_0_7_14:
        m_strLanguageId = Ini.ReadText("Language", "LanguageId");
    case VERSION_0_7_13:
        m_bShowFloatingWindowAtStartup = Ini.ReadInt("Misc", "ShowFloatingWindow");
        m_bShowTrayIconAtStartup = Ini.ReadInt("Misc", "ShowTrayIcon");
    case VERSION_0_7_12:
        m_tm.SetEnableFullScreenPause(Ini.ReadInt("AutoAway", "FullscreenPause"));
    case VERSION_0_7_11:
    case VERSION_0_7_10:
        m_eDarkerScreenAnimateType = (EAnimateType)Ini.ReadInt("Notify", "DarkerScreenAnimate");
        m_colorDarkerScreen = Ini.ReadInt("Notify", "DarkerScreenColor");
    case VERSION_0_7_9:
    case VERSION_0_7_8:
    case VERSION_0_7_7:
        SetEnableLog(Ini.ReadInt("Misc", "EnableLog"));
        SetLogLevel((ELogLevel)Ini.ReadInt("Misc", "LogLevel"));
        SetLogFileSize((ELogFileSize)Ini.ReadInt("Misc", "LogFileSize"));
        SetAppAutoStartWithSystem(Ini.ReadInt("Misc", "AutoStartWithSystem"),
                                  m_strAppFile);
    case VERSION_0_7_6:
    case VERSION_0_7_5:
    case VERSION_0_7_4:
        // 设置时间参数
        m_tm.SetWD(Ini.ReadInt("Time", "WorkDuration"));
        m_tm.SetSRD(Ini.ReadInt("Time", "ShortRelaxDuration"));
        m_tm.SetEnableLongRelax(Ini.ReadInt("Time", "EnableLongRelax"));
        m_tm.SetLRF(Ini.ReadInt("Time", "LongRelaxFrequency"));
        m_tm.SetLRD(Ini.ReadInt("Time", "LongRelaxDuration"));

        // 设置提示参数
        m_bPreNotify = Ini.ReadInt("Notify", "PreNotify");
        m_bLockInput = Ini.ReadInt("Notify", "LockInput");
        m_iLockType  = Ini.ReadInt("Notify", "LockType");
        m_bDarkerScreen         = Ini.ReadInt("Notify", "DarkerScreen");
        m_iDarkerScreenAlpha    = Ini.ReadInt("Notify", "DarkerScreenAlpha");
    
        // 设置自动状态转换参数
        m_tm.SetEnableAutoPause(Ini.ReadInt("AutoAway", "EnableAutoPause"));
        m_tm.SetAPT(Ini.ReadInt("AutoAway", "AutoPauseThreshold"));
        m_tm.SetEnableAutoReset(Ini.ReadInt("AutoAway", "EnableAutoReset"));
        m_tm.SetART(Ini.ReadInt("AutoAway", "AutoResetThreshold"));

        // 设置杂项参数
        m_bLockComputer = Ini.ReadInt("Misc", "LockComputer");
        m_bCloseMonitor = Ini.ReadInt("Misc", "CloseMonitor");
        break;
    default:
        AppLog2Buf(L_WARN, "invalid config file version[%s].", strIniFileVersion);
        break;
    }
    
    // 离开临界区保护
    LeaveCriticalSection(&m_csSettingFile); 

    return (dwIniFileVersion == m_dwVersion);
}
コード例 #30
0
ファイル: command.c プロジェクト: dkulp/fpp
  void ProcessCommand(char *command)
  {
    char *s;
    char *s2;
    char *s3;
    char *s4;
    char *response2 = NULL;
    int i;
		char NextPlaylist[128] = "No playlist scheduled.";
		char NextScheduleStartText[64] = "";
		char CommandStr[64];
		LogExcess(VB_COMMAND, "CMD: %s\n", command);
		s = strtok(command,",");
		strcpy(CommandStr, s);
		if (!strcmp(CommandStr, "s"))
		{
				Json::Value info = player->GetCurrentPlaylistInfo();
				char currentEntryType = 'u'; // Unknown
				const char *currentSequenceName = NULL;
				const char *currentMediaName = NULL;

				if (info["currentEntry"].isMember("sequenceName"))
					currentSequenceName = info["currentEntry"]["sequenceName"].asString().c_str();

				if (info["currentEntry"].isMember("mediaFilename"))
					currentMediaName = info["currentEntry"]["mediaFilename"].asString().c_str();

				if (info["currentEntry"].isMember("type"))
				{
					std::string type = info["currentEntry"]["type"].asString();
					if (type == "both")
						currentEntryType = 'b';
					else if (type == "event")
						currentEntryType = 'e';
					else if (type == "media")
						currentEntryType = 'm';
					else if (type == "pause")
						currentEntryType = 'p';
					else if (type == "plugin")
						currentEntryType = 'P';
					else if (type == "sequence")
						currentEntryType = 's';
				}

				player->GetNextScheduleStartText(NextScheduleStartText);
				player->GetNextPlaylistText(NextPlaylist);
				if(FPPstatus==FPP_STATUS_IDLE)
				{
					if (getFPPmode() == REMOTE_MODE)
					{
						sprintf(response,"%d,%d,%d,%s,%s,%d,%d\n",
							getFPPmode(), 0, getVolume(),
							currentSequenceName,
							currentMediaName,
							player->GetPlaybackSecondsElapsed(),
							player->GetPlaybackSecondsRemaining());
					}
					else
					{
						sprintf(response,"%d,%d,%d,%s,%s\n",
							getFPPmode(),0,getVolume(),
							NextPlaylist,NextScheduleStartText);
					}
				}
				else
				{
					sprintf(response,"%d,%d,%d,%s,%c,%s,%s,%d,%d,%d,%d,%s,%s,%d\n",
							getFPPmode(),FPPstatus,getVolume(),
							info["name"].asString().c_str(),
							currentEntryType,
							currentSequenceName,
							currentMediaName,
							info["currentPosition"].asInt() + 1,
							info["size"].asInt(),
							info["currentEntry"]["secondsElapsed"].asInt(),
							info["currentEntry"]["secondsRemaining"].asInt(),
							NextPlaylist,NextScheduleStartText,
							info["repeat"].asInt());
				}
		}
		else if ((!strcmp(CommandStr, "p")) ||
				 (!strcmp(CommandStr, "P")))
		{
				if(FPPstatus==FPP_STATUS_PLAYLIST_PLAYING || FPPstatus==FPP_STATUS_STOPPING_GRACEFULLY)
				{
					player->PlaylistStopNow();
					sleep(1);
				}
	
				s = strtok(NULL,",");
				if (s)
				{
					std::string playlistName(s);
					int repeat = !strcmp(CommandStr, "p") ? 1 : 0;
					int position = 0;

					s = strtok(NULL,",");
					if (s)
						position = atoi(s);

					if (player->PlaylistStart(playlistName, position, repeat))
					{
						sprintf(response,"%d,%d,Playlist Started,,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS);
					}
					else
					{
						sprintf(response,"%d,%d,Playlist Start Failed,,,,,,,,,,\n",getFPPmode(),COMMAND_FAILED);
					}
				}
				else
				{
					sprintf(response,"%d,%d,Unknown Playlist,,,,,,,,,,\n",getFPPmode(),COMMAND_FAILED);
				}
		}
		else if (!strcmp(CommandStr, "S"))
		{
				if(FPPstatus==FPP_STATUS_PLAYLIST_PLAYING)
				{
					player->PlaylistStopGracefully();
					player->ReLoadCurrentScheduleInfo();
					sprintf(response,"%d,%d,Playlist Stopping Gracefully,,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS);
				}
				else
				{
					sprintf(response,"%d,Not playing,,,,,,,,,,,\n",COMMAND_FAILED);
				}
		}
		else if (!strcmp(CommandStr, "d"))
		{
				if(FPPstatus==FPP_STATUS_PLAYLIST_PLAYING || FPPstatus==FPP_STATUS_STOPPING_GRACEFULLY)
				{
					player->PlaylistStopNow();
					player->ReLoadCurrentScheduleInfo();
					sprintf(response,"%d,%d,Playlist Stopping Now,,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS);
				}
				else
				{
					sprintf(response,"%d,%d,Not playing,,,,,,,,,,\n",getFPPmode(),COMMAND_FAILED);
				}
		}
		else if (!strcmp(CommandStr, "R"))
		{
				if(FPPstatus==FPP_STATUS_IDLE)
				{
					player->ReLoadCurrentScheduleInfo();
				}
				player->ReLoadNextScheduleInfo();
				
				
				sprintf(response,"%d,%d,Reloading Schedule,,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS);
		}
		else if (!strcmp(CommandStr, "v"))
		{
				s = strtok(NULL,",");
				if (s)
				{
					setVolume(atoi(s));
					sprintf(response,"%d,%d,Setting Volume,,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS);
				}
				else
				{
					sprintf(response,"%d,%d,Invalid Volume,,,,,,,,,,\n",getFPPmode(),COMMAND_FAILED);
				}
		}
		else if (!strcmp(CommandStr, "w"))
		{
				LogInfo(VB_SETTING, "Sending Falcon hardware config\n");
				if (!DetectFalconHardware(1))
					SendFPDConfig();
		}
		else if (!strcmp(CommandStr, "r"))
		{
				WriteBytesReceivedFile();
				sprintf(response,"true\n");
		}
		else if (!strcmp(CommandStr, "q"))
		{
			// Quit/Shutdown fppd
			ShutdownFPPD();
		}
		else if (!strcmp(CommandStr, "e"))
		{
			// Start an Effect
			s = strtok(NULL,",");
			s2 = strtok(NULL,",");
			s3 = strtok(NULL,",");
			if (s && s2)
			{
				i = StartEffect(s, atoi(s2), atoi(s3));
				if (i >= 0)
					sprintf(response,"%d,%d,Starting Effect,%d,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS,i);
				else
					sprintf(response,"%d,%d,Invalid Effect,,,,,,,,,,\n",getFPPmode(),COMMAND_FAILED);
			}
			else
				sprintf(response,"%d,%d,Invalid Effect,,,,,,,,,,\n",getFPPmode(),COMMAND_FAILED);
		}
		else if (!strcmp(CommandStr, "t"))
		{
			// Trigger an event
			s = strtok(NULL,",");
			pluginCallbackManager.eventCallback(s, "command");
			i = TriggerEventByID(s);
			if (i >= 0)
				sprintf(response,"%d,%d,Event Triggered,%d,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS,i);
			else
				sprintf(response,"%d,%d,Event Failed,,,,,,,,,,\n",getFPPmode(),COMMAND_FAILED);
		}
		else if (!strcmp(CommandStr, "GetTestMode"))
		{
			strcpy(response, channelTester->GetConfig().c_str());
			strcat(response, "\n");
		}
		else if (!strcmp(CommandStr, "SetTestMode"))
		{
			if (channelTester->SetupTest(std::string(s + strlen(s) + 1)))
			{
				sprintf(response, "0,%d,Test Mode Activated,,,,,,,,,\n",
					COMMAND_SUCCESS);
			}
			else
			{
				sprintf(response, "0,%d,Test Mode Deactivated,,,,,,,,,\n",
					COMMAND_SUCCESS);
			}
		}
		else if (!strcmp(CommandStr, "LogLevel"))
		{
			s = strtok(NULL,",");

			if (SetLogLevel(s)) {
				sprintf(response,"%d,%d,Log Level Updated,%d,%d,,,,,,,,,\n",
					getFPPmode(),COMMAND_SUCCESS,logLevel,logMask);
			} else {
				sprintf(response,"%d,%d,Error Updating Log Level,%d,%d,,,,,,,,,\n",
					getFPPmode(),COMMAND_FAILED,logLevel,logMask);
			}
		}
		else if (!strcmp(CommandStr, "LogMask"))
		{
			s = strtok(NULL,",");

			if ((s && SetLogMask(s)) || SetLogMask("")) {
				sprintf(response,"%d,%d,Log Mask Updated,%d,%d,,,,,,,,,\n",
					getFPPmode(),COMMAND_SUCCESS,logLevel,logMask);
			} else {
				sprintf(response,"%d,%d,Error Updating Log Mask,%d,%d,,,,,,,,,\n",
					getFPPmode(),COMMAND_FAILED,logLevel,logMask);
			}
		}
		else if (!strcmp(CommandStr, "SetSetting"))
		{
			char name[128];

			s = strtok(NULL,",");
			if (s)
			{
				strcpy(name, s);
				s = strtok(NULL,",");
				if (s)
					parseSetting(name, s);
			}
		}
		else if (!strcmp(CommandStr, "StopAllEffects"))
		{
			StopAllEffects();
			sprintf(response,"%d,%d,All Effects Stopped,,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS);
		}
		else if (!strcmp(CommandStr, "StopEffectByName"))
		{
			s = strtok(NULL,",");
			if (strlen(s))
			{
				if (StopEffect(s))
						sprintf(response,"%d,%d,Stopping Effect,%s,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS,s);
				else
						sprintf(response,"%d,%d,Stop Effect Failed,,,,,,,,,,\n",getFPPmode(),COMMAND_FAILED);
			}
		}
		else if (!strcmp(CommandStr, "StopEffect"))
		{
			s = strtok(NULL,",");
			i = atoi(s);
			if (StopEffect(i))
					sprintf(response,"%d,%d,Stopping Effect,%d,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS,i);
			else
					sprintf(response,"%d,%d,Stop Effect Failed,,,,,,,,,,\n",getFPPmode(),COMMAND_FAILED);
		}
		else if (!strcmp(CommandStr, "GetRunningEffects"))
		{
			sprintf(response,"%d,%d,Running Effects",getFPPmode(),COMMAND_SUCCESS);
			GetRunningEffects(response, &response2);
		}
		else if (!strcmp(CommandStr, "ReloadChannelRemapData"))
		{
			if ((FPPstatus==FPP_STATUS_IDLE) &&
				(LoadChannelRemapData())) {
				sprintf(response,"%d,%d,Channel Remap Data Reloaded,,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS);
			} else {
				sprintf(response,"%d,%d,Failed to reload Channel Remap Data,,,,,,,,,,\n",getFPPmode(),COMMAND_FAILED);
			}
		}
		else if (!strcmp(CommandStr, "GetFPPDUptime"))
		{
			sprintf(response,"%d,%d,FPPD Uptime,%d,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS, time(NULL) - fppdStartTime);
		}
		else if (!strcmp(CommandStr, "StartSequence"))
		{
			s = strtok(NULL,",");
			s2 = strtok(NULL,",");
			if (s && s2)
			{
				i = atoi(s2);
				player->StartSequence(s, 0, i);
				sprintf(response,"%d,%d,Sequence Started,,,,,,,,,,,,\n",
					getFPPmode(), COMMAND_SUCCESS);
			}
			else
			{
				LogErr(VB_COMMAND, "Tried to start a sequence when a playlist or "
						"sequence is already running\n");
				sprintf(response,"%d,%d,Sequence Failed,,,,,,,,,,,,\n",
					getFPPmode(), COMMAND_FAILED);
			}
		}
		else if (!strcmp(CommandStr, "StopSequence"))
		{
			s = strtok(NULL,",");
			if (s)
			{
				player->StopSequence(s);
				sprintf(response,"%d,%d,Sequence Stopped,,,,,,,,,,,,\n",
					getFPPmode(), COMMAND_SUCCESS);
			}
			else
			{
				LogDebug(VB_COMMAND, "Invalid command: %s\n", command);
				sprintf(response,"%d,%d,Sequence Name Missing,,,,,,,,,,,,\n",
					getFPPmode(), COMMAND_FAILED);
			}
		}
		else if (!strcmp(CommandStr, "ToggleSequencePause"))
		{
			if ((player->SequencesRunning()) &&
				((FPPstatus == FPP_STATUS_IDLE) ||
				 (FPPstatus != FPP_STATUS_IDLE)))
			{
				player->ToggleSequencePause();
			}
		}
		else if (!strcmp(CommandStr, "SingleStepSequence"))
		{
			if ((player->SequencesRunning()) &&
				(player->SequencesArePaused()) &&
				((FPPstatus == FPP_STATUS_IDLE) ||
				 ((FPPstatus != FPP_STATUS_IDLE))))
			{
				player->SingleStepSequences();
			}
		}
		else if (!strcmp(CommandStr, "SingleStepSequenceBack"))
		{
			if ((player->SequencesRunning()) &&
				(player->SequencesArePaused()) &&
				((FPPstatus == FPP_STATUS_IDLE) ||
				 ((FPPstatus != FPP_STATUS_IDLE))))
			{
				player->SingleStepSequencesBack();
			}
		}
		else if (!strcmp(CommandStr, "NextPlaylistItem"))
		{
			switch (FPPstatus)
			{
				case FPP_STATUS_IDLE:
					sprintf(response,"%d,%d,No playlist running\n",getFPPmode(),COMMAND_FAILED);
					break;
				case FPP_STATUS_PLAYLIST_PLAYING:
					sprintf(response,"%d,%d,Skipping to next playlist item\n",getFPPmode(),COMMAND_SUCCESS);
					player->NextPlaylistItem();
					break;
				case FPP_STATUS_STOPPING_GRACEFULLY:
					sprintf(response,"%d,%d,Playlist is stopping gracefully\n",getFPPmode(),COMMAND_FAILED);
					break;
			}
		}
		else if (!strcmp(CommandStr, "PrevPlaylistItem"))
		{
			switch (FPPstatus)
			{
				case FPP_STATUS_IDLE:
					sprintf(response,"%d,%d,No playlist running\n",getFPPmode(),COMMAND_FAILED);
					break;
				case FPP_STATUS_PLAYLIST_PLAYING:
					sprintf(response,"%d,%d,Skipping to previous playlist item\n",getFPPmode(),COMMAND_SUCCESS);
					player->PrevPlaylistItem();
					break;
				case FPP_STATUS_STOPPING_GRACEFULLY:
					sprintf(response,"%d,%d,Playlist is stopping gracefully\n",getFPPmode(),COMMAND_FAILED);
					break;
			}
		}
		else if (!strcmp(CommandStr, "SetupExtGPIO"))
		{
			// Configure the given GPIO to the given mode
			s = strtok(NULL,",");
			s2 = strtok(NULL,",");
			if (s && s2)
			{
				
				if (!SetupExtGPIO(atoi(s), s2))
				{
					sprintf(response, "%d,%d,Configuring GPIO,%d,%s,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS,atoi(s),s2);
				}
				else
				{
					sprintf(response, "%d,%d,Configuring GPIO,%d,%s,,,,,,,,,\n",getFPPmode(),COMMAND_FAILED,atoi(s),s2);
				}
			}
		}
		else if (!strcmp(CommandStr, "ExtGPIO"))
		{
			s = strtok(NULL,",");
			s2 = strtok(NULL,",");
			s3 = strtok(NULL,",");
			if (s && s2 && s3)
			{
				i = ExtGPIO(atoi(s), s2, atoi(s3));
				if (i >= 0) 
				{
					sprintf(response, "%d,%d,Setting GPIO,%d,%s,%d,%d,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS,atoi(s),s2,atoi(s3),i);
				}
				else
				{
					sprintf(response, "%d,%d,Setting GPIO,%d,%s,%d,,,,,,,,\n",getFPPmode(),COMMAND_FAILED,atoi(s),s2,atoi(s3));
				}
			}
		}
		else
		{
			sprintf(response,"Invalid command: '%s'\n", CommandStr);
		}

		if (response2)
		{
			bytes_sent = sendto(socket_fd, response2, strlen(response2), 0,
                          (struct sockaddr *) &(client_address), sizeof(struct sockaddr_un));
			LogDebug(VB_COMMAND, "%s %s", CommandStr, response2);
			free(response2);
			response2 = NULL;
		}
		else
		{
			bytes_sent = sendto(socket_fd, response, strlen(response), 0,
                          (struct sockaddr *) &(client_address), sizeof(struct sockaddr_un));
			LogDebug(VB_COMMAND, "%s %s", CommandStr, response);
		}
  }