Commit 7bd37d9d authored by Tristan Leteurtre's avatar Tristan Leteurtre

. Fixed a compilation warning

  . Added the "Launch on start up" functionnality :
   some commands (telnet style) can be automatically launched when vls is
   starting.

   For example, in vls.cfg :

   BEGIN "LaunchOnStartUp"
     command1 = "start film localhost local1 --loop"
     command2 = "start 28009 client1 dvb"
   END
parent 2cb74b5f
......@@ -2,7 +2,7 @@
* application.h: Application class definition
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: application.h,v 1.4 2002/09/04 10:56:34 jpsaman Exp $
* $Id: application.h,v 1.5 2002/09/10 11:56:28 tooney Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
*
......@@ -142,7 +142,7 @@ class C_Application
// Debugging logs (works only in DEBUG mode)
#ifdef DEBUG
#define LogDbg(handle, message) \
C_Application::GetApp()->LogMsg(handle, LOG_DEBUG, C_String("In ")+__FILE__+ \
C_Application::GetApp()->LogMsg(handle, LOG_DBG, C_String("In ")+__FILE__+ \
" line "+__LINE__+" -> "+message)
#else
......
......@@ -2,7 +2,7 @@
* log.cpp: Logging method
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: log.cpp,v 1.5 2002/08/14 11:13:27 tooney Exp $
* $Id: log.cpp,v 1.6 2002/09/10 11:56:28 tooney Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
*
......@@ -270,7 +270,7 @@ void C_Log::Append(handle hModule, u8 iLevel, const C_String& strMsg)
case LOG_ERROR:
strBuff += "[ERROR/";
break;
case LOG_DEBUG:
case LOG_DBG:
strBuff += "[DEBUG/";
break;
default:
......
......@@ -2,7 +2,7 @@
* log.h: Log class definition
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: log.h,v 1.2 2002/08/14 11:13:27 tooney Exp $
* $Id: log.h,v 1.3 2002/09/10 11:56:28 tooney Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
*
......@@ -39,7 +39,7 @@
#define LOG_MSGSIZE 128
// Log severity levels
#define LOG_DEBUG 1
#define LOG_DBG 1
#define LOG_NOTE 2
#define LOG_WARN 4
#define LOG_ERROR 8
......
......@@ -2,7 +2,7 @@
* admin.cpp:
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: admin.cpp,v 1.12 2002/09/04 10:56:35 jpsaman Exp $
* $Id: admin.cpp,v 1.13 2002/09/10 11:56:28 tooney Exp $
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
*
......@@ -187,7 +187,7 @@ int C_AdminSession::Authenticate(const C_String& strLogin,
*
*******************************************************************************/
//------------------------------------------------------------------------------
// Constructor
//------------------------------------------------------------------------------
......@@ -503,6 +503,33 @@ int C_Admin::Init()
if(!iRc)
iRc = m_pTelnet->Init();
// Automatic launch of commands
C_Vector<C_Setting> vLaunch = pApp->GetSettings("LaunchOnStartUp");
for(unsigned int i = 0; i < vLaunch.Size(); i++)
{
C_String strCmd = vLaunch[i].GetValue();
Log(m_hLog, LOG_NOTE,"Executing " +vLaunch[i].GetName()+ " : '"
+ strCmd +"'");
C_Request cRequest("");
// Get input name and type
C_Answer cAnswer = ParseCmdLine(NULL,vLaunch[i].GetValue(),cRequest);
if (cAnswer.GetStatus() == ADMIN_WELLFORMED_COMMAND)
cAnswer = HandleRequest(cRequest);
C_List<C_String> cMessageList = cAnswer.GetMessages();
unsigned int iSize = cMessageList.Size();
for(unsigned int i = 0; i < iSize; i++)
{
Log(m_hLog, LOG_WARN,cMessageList[i]);
}
}
return iRc;
}
......@@ -597,7 +624,7 @@ C_Answer C_Admin::ParseCmdLine(C_AdminSession* pSession,
const C_String& strCmdLine,
C_Request& cRequest)
{
ASSERT(pSession);
// ASSERT(pSession);
C_Answer cAnswer("Admin");
......@@ -615,11 +642,13 @@ C_Answer C_Admin::ParseCmdLine(C_AdminSession* pSession,
if(vArgs.Size() == 0)
{
cAnswer.SetStatus(ADMIN_EMPTY_COMMAND);
cAnswer.AddMessage(" empty command.");
return cAnswer;
}
// Unknown command ?
C_String strCmd = vArgs[0];
C_CommandDesc* pCmdDesc = m_cCmdDescriptions.Get(strCmd);
if(!pCmdDesc)
{
......@@ -629,12 +658,13 @@ C_Answer C_Admin::ParseCmdLine(C_AdminSession* pSession,
}
// The user is not allowed to run this command ?
if(pSession->m_vCommands.Find(strCmd) < 0)
{
cAnswer.SetStatus(ADMIN_COMMAND_DENIED);
cAnswer.AddMessage(strCmd + ": permission denied.");
return cAnswer;
}
if (pSession != NULL)
if(pSession->m_vCommands.Find(strCmd) < 0)
{
cAnswer.SetStatus(ADMIN_COMMAND_DENIED);
cAnswer.AddMessage(strCmd + ": permission denied.");
return cAnswer;
}
// Command is OK, now parse the arguments
C_Request cRq(strCmd);
......@@ -731,7 +761,7 @@ C_Answer C_Admin::ParseCmdLine(C_AdminSession* pSession,
}
}
}
// Check if there are enough arguments
if(uiMandatory < pCmdDesc->m_vMandatoryArgs.Size())
{
......
......@@ -2,7 +2,7 @@
* admin.h: Admin class definition
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: admin.h,v 1.3 2002/07/16 22:12:36 sam Exp $
* $Id: admin.h,v 1.4 2002/09/10 11:56:28 tooney Exp $
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
*
......@@ -125,8 +125,8 @@ public:
void Close();
protected:
virtual void OnInit() = 0;
virtual void OnClose() = 0;
virtual void OnInit() {};
virtual void OnClose() {};
int Authenticate(const C_String& strLogin, const C_String& strPasswd);
......
......@@ -2,7 +2,7 @@
* manager.cpp: Vls manager
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: manager.cpp,v 1.15 2002/09/09 15:29:35 jpsaman Exp $
* $Id: manager.cpp,v 1.16 2002/09/10 11:56:28 tooney Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
* Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
......@@ -1009,7 +1009,7 @@ C_Answer C_Manager::Channel(const C_Request& cRequest)
// First stop streaming to the channel before removing it
C_Request* pStopRequest = new C_Request("stop");
pStopRequest->SetArg("channel",strChannelName);
Log(m_hLog, LOG_DEBUG, "Trying to stop channel " + strChannelName);
Log(m_hLog, LOG_DBG, "Trying to stop channel " + strChannelName);
m_cChannelList.UnLock(); //Unlocking, because stop() need the Lock
Stop(*pStopRequest);
......
......@@ -91,7 +91,7 @@ END
# Channels configuration
BEGIN "localhost" # The client is on the same host as the server
DstHost = "localhost"
DstHost = "127.0.0.1"
DstPort = "1234"
END
......@@ -118,3 +118,9 @@ END
# Append = "no" # rewrite the file if it exists
#END
# Commands automatically lanched on Startup
# Commands shall be like they would be typed in a telnet console.
BEGIN "LaunchOnStartUp"
# command1 = "start film localhost local1 --loop"
# command2 = "start 28009 client1 dvb"
END
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment