Commit 10cdcfea authored by Cyril Deguet's avatar Cyril Deguet

- some fixes to prepare the win32 port (with mingw32)

  It shouldn't have broken anything under linux ;)
parent 656bdba2
......@@ -2,7 +2,7 @@
* application.cpp: Application class
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: application.cpp,v 1.5 2002/03/24 15:56:08 asmax Exp $
* $Id: application.cpp,v 1.6 2002/03/24 18:54:10 asmax Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
*
......@@ -341,6 +341,7 @@ void C_Application::SignalHandler(int iSignal)
ASSERT(pApp);
handle hLog = pApp->m_hLog;
#ifdef HAVE_SIGACTION
switch(iSignal)
{
case SIGHUP:
......@@ -395,5 +396,6 @@ void C_Application::SignalHandler(int iSignal)
break;
}
}
#endif
}
......@@ -2,7 +2,7 @@
* socket.cpp: socket management
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: socket.cpp,v 1.4 2002/03/06 00:05:08 bozo Exp $
* $Id: socket.cpp,v 1.5 2002/03/24 18:54:10 asmax Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
* Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
......@@ -281,6 +281,7 @@ void C_Inet4Addr::Build(const C_String& strHost, const C_String& strPort)
//------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------
#ifndef _WIN32
void C_Inet6Addr::Build(const C_String& strHost, const C_String& strPort,
int iType)
{
......@@ -310,6 +311,7 @@ void C_Inet6Addr::Build(const C_String& strHost, const C_String& strPort,
throw E_InetAddr(C_String("Inet6 address error: ") + gai_strerror(iRc));
}
}
#endif
//******************************************************************************
......@@ -422,6 +424,7 @@ void C_Socket::Bind(const C_String& strIntf, const C_String& strPort)
pAddr = (struct sockaddr*)cIntfAddr.GetInetAddr();
iAddrLen = sizeof(*cIntfAddr.GetInetAddr());
}
#ifndef _WIN32
else if(m_iDomain == AF_INET6)
{
C_Inet6Addr cIntfAddr;
......@@ -438,6 +441,7 @@ void C_Socket::Bind(const C_String& strIntf, const C_String& strPort)
pAddr = (struct sockaddr*)cIntfAddr.GetInetAddr();
iAddrLen = sizeof(*cIntfAddr.GetInetAddr());
}
#endif
else
{
ASSERT(false);
......@@ -479,6 +483,7 @@ void C_Socket::Connect(const C_String& strPeer, const C_String& strPort)
pAddr = (struct sockaddr*)cPeerAddr.GetInetAddr();
iAddrLen = sizeof(*cPeerAddr.GetInetAddr());
}
#ifndef _WIN32
else if(m_iDomain == AF_INET6)
{
C_Inet6Addr cPeerAddr;
......@@ -496,6 +501,7 @@ void C_Socket::Connect(const C_String& strPeer, const C_String& strPort)
pAddr = (struct sockaddr*)cPeerAddr.GetInetAddr();
iAddrLen = sizeof(*cPeerAddr.GetInetAddr());
}
#endif
else
{
ASSERT(false);
......@@ -540,6 +546,7 @@ C_Socket* C_Socket::Accept()
iRc = accept(m_hSocket, (struct sockaddr*)&sPeer, &iAddrLen);
}
#ifndef _WIN32
else if(m_iDomain == AF_INET6)
{
struct sockaddr_in6 sPeer;
......@@ -547,6 +554,7 @@ C_Socket* C_Socket::Accept()
iRc = accept(m_hSocket, (struct sockaddr*)&sPeer, &iAddrLen);
}
#endif
else
{
ASSERT(false);
......@@ -730,6 +738,7 @@ int C_Socket::WriteTo(C_Inet4Addr& cPeerAddr,
//------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------
#ifndef _WIN32
int C_Socket::WriteTo(C_Inet6Addr& cPeerAddr,
const byte* pBuff, int iBuffLen, int iFlags)
{
......@@ -747,6 +756,7 @@ int C_Socket::WriteTo(C_Inet6Addr& cPeerAddr,
return iRc;
}
#endif
//------------------------------------------------------------------------------
......
......@@ -2,7 +2,7 @@
* socket.h: Socket class definition
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: socket.h,v 1.3 2002/03/06 00:05:08 bozo Exp $
* $Id: socket.h,v 1.4 2002/03/24 18:54:10 asmax Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
* Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
......@@ -127,6 +127,7 @@ class C_Inet4Addr
//------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------
#ifndef _WIN32
class C_Inet6Addr
{
public:
......@@ -141,6 +142,7 @@ class C_Inet6Addr
private:
struct sockaddr_in6 m_sInetAddr;
};
#endif
//------------------------------------------------------------------------------
......@@ -176,8 +178,10 @@ class C_Socket
int Write(const byte* pBuff, int iBuffLen, int iFlags = 0);
int WriteTo(C_Inet4Addr& cPeerAddr,
const byte* pBuff, int iBuffLen, int iFlags = 0);
#ifndef _WIN32
int WriteTo(C_Inet6Addr& cPeerAddr,
const byte* pBuff, int iBuffLen, int iFlags = 0);
#endif
int Read(byte* pBuff, int iBuffLen, int iFlags = 0);
// Receive with timeout
......
......@@ -2,7 +2,7 @@
* string.h: String class definition
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: string.h,v 1.1 2001/10/06 21:23:36 bozo Exp $
* $Id: string.h,v 1.2 2002/03/24 18:54:10 asmax Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
*
......@@ -25,8 +25,8 @@
*******************************************************************************/
#ifndef _STRING_H_
#define _STRING_H_
#ifndef __STRING_H_
#define __STRING_H_
//------------------------------------------------------------------------------
......
......@@ -2,7 +2,7 @@
* thread.cpp: thread management
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: thread.cpp,v 1.2 2001/10/07 12:26:45 bozo Exp $
* $Id: thread.cpp,v 1.3 2002/03/24 18:54:10 asmax Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
*
......@@ -39,8 +39,10 @@
#endif
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "common.h"
#include "string.h"
......@@ -327,12 +329,17 @@ void C_Thread::Stop()
{
// As all our threads are created joinable, we must ensure that the calling
// thread is a different thread to avoid a deadlock. So if a thread try to stop
// itself, we ask another thread (the killer) to do the job.
// itself, we ask another thread (the killer) to do the job.
#ifdef PTHREAD_COND_T_IN_PTHREAD_H
if(pthread_self() == tId)
#else
if (1)
#endif
{
ASSERT(false);
//s_cThreadKiller.Kill(this);
}
// Don't join if not started
// It avoids exception's generation because pthread_join returns an error
// when the thread was not started.
......@@ -407,7 +414,12 @@ void C_Thread::DelayedInterruption()
for(unsigned int ui = 0; (ui < INT_TEST_COUNT) &&
(m_iStatus == THREAD_STATUS_STARTED); ui++)
{
#ifdef WIN32
Sleep(INT_TEST_DELAY / 1000000);
#else
usleep(INT_TEST_DELAY);
#endif
}
}
......
......@@ -2,7 +2,7 @@
* netchannel.cpp: network channel
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: netchannel.cpp,v 1.4 2002/03/04 01:55:50 bozo Exp $
* $Id: netchannel.cpp,v 1.5 2002/03/24 18:54:10 asmax Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
* Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
......@@ -81,8 +81,10 @@ C_NetChannel::C_NetChannel(C_Module* pModule,
if(strDomain == "inet4")
m_pOutput = new C_Net4Output(m_strName);
#ifndef _WIN32
else if(strDomain == "inet6")
m_pOutput = new C_Net6Output(m_strName);
#endif
else
throw E_Exception(GEN_ERR, "Unknown domain \"" + strDomain +
"\" for network channel \"" + m_strName + "\"");
......
......@@ -2,7 +2,7 @@
* netoutput.cpp: network output
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: netoutput.cpp,v 1.5 2002/03/06 14:58:39 bozo Exp $
* $Id: netoutput.cpp,v 1.6 2002/03/24 18:54:10 asmax Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
* Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
......@@ -135,11 +135,13 @@ void C_NetOutput::OnInit()
// Set the Time To Live value if != 0
if(m_iTTL)
{
#ifndef _WIN32
if((m_strType == "unicast") || (m_strType == "broadcast"))
m_cSocket.SetOption(IPPROTO_IP, IP_TTL, &m_iTTL, sizeof(m_iTTL));
else if(m_strType == "multicast")
m_cSocket.SetOption(IPPROTO_IP, IP_MULTICAST_TTL,
&m_iTTL, sizeof(m_iTTL));
#endif
}
// Bind it to the local address if specified
......@@ -268,6 +270,7 @@ void C_Net4Output::OnInit()
C_NetOutput::OnInit();
#ifndef _WIN32
if(m_strType == "multicast")
{
struct ip_mreq imr;
......@@ -278,6 +281,7 @@ void C_Net4Output::OnInit()
imr.imr_multiaddr.s_addr = cAddr.GetInetAddr()->sin_addr.s_addr;
m_cSocket.SetOption(IPPROTO_IP, IP_ADD_MEMBERSHIP, &imr, sizeof(imr));
}
#endif
}
catch(E_Exception e)
{
......@@ -293,6 +297,7 @@ void C_Net4Output::OnClose()
{
try
{
#ifndef _WIN32
if(m_strType == "multicast")
{
struct ip_mreq imr;
......@@ -303,6 +308,7 @@ void C_Net4Output::OnClose()
imr.imr_multiaddr.s_addr = cAddr.GetInetAddr()->sin_addr.s_addr;
m_cSocket.SetOption(IPPROTO_IP, IP_DROP_MEMBERSHIP, &imr, sizeof(imr));
}
#endif
C_NetOutput::OnClose();
}
......@@ -333,6 +339,7 @@ int C_Net4Output::PrivateWriteTo(int iBuffLen)
//------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------
#ifndef _WIN32
C_Net6Output::C_Net6Output(const C_String& strChannelName) :
C_NetOutput(strChannelName)
{
......@@ -419,3 +426,4 @@ int C_Net6Output::PrivateWriteTo(int iBuffLen)
}
#endif
#endif
......@@ -2,7 +2,7 @@
* netoutput.h: network output
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: netoutput.h,v 1.4 2002/03/06 14:58:39 bozo Exp $
* $Id: netoutput.h,v 1.5 2002/03/24 18:54:10 asmax Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
* Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
......@@ -98,6 +98,7 @@ class C_Net4Output : public C_NetOutput
//------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------
#ifndef _WIN32
class C_Net6Output : public C_NetOutput
{
public:
......@@ -114,7 +115,7 @@ class C_Net6Output : public C_NetOutput
C_Inet6Addr m_cOutputInetAddr;
#endif
};
#endif
#else
#error "Multiple inclusions of netoutput.h"
......
......@@ -2,7 +2,7 @@
* admin.cpp:
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: admin.cpp,v 1.4 2002/03/21 22:27:35 asmax Exp $
* $Id: admin.cpp,v 1.5 2002/03/24 18:54:10 asmax Exp $
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
*
......@@ -30,7 +30,9 @@
//------------------------------------------------------------------------------
#include "../core/defs.h"
#ifndef _WIN32
#include <crypt.h>
#endif
#include "config.h"
#include "../core/core.h"
......@@ -464,8 +466,12 @@ int C_Admin::Authentificate(C_AdminSession *pSession,
return GEN_ERR;
}
#ifdef _WIN32
C_String strCrypt(strPasswd);
#else
C_String strCrypt(crypt(strPasswd.GetString(),
pUser->m_strEncPasswd.GetString()));
#endif
if(strCrypt == pUser->m_strEncPasswd.GetString())
{
Log(m_hLog, LOG_NOTE,
......
......@@ -2,7 +2,7 @@
* tsstreamer.cpp:
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: tsstreamer.cpp,v 1.2 2002/03/21 14:09:19 bozo Exp $
* $Id: tsstreamer.cpp,v 1.3 2002/03/24 18:54:10 asmax Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
* Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
......@@ -321,18 +321,22 @@ inline void C_TsStreamer::WaitSendDate()
{
s64 iSendDate = m_iLastTime + m_iDeltaClock + (s64)m_dSlope*m_uiByteRead;
s64 iWait = iSendDate - GetDate();
// Wait only if the delay becomes > 0.5 ms, for the select will make we late
// (it usually takes more than 1 ms)
if(iWait > 500)
{
// Sleep during the given time
#ifdef WIN32
Sleep((int)(iWait / 1000));
#else
struct timespec tsDelay;
tsDelay.tv_sec = iWait / 1000000;
tsDelay.tv_nsec = 1000 * (iWait % 1000000);
// Wait for the given delay
nanosleep(&tsDelay, NULL);
#endif
}
}
......@@ -342,8 +346,21 @@ inline void C_TsStreamer::WaitSendDate()
//------------------------------------------------------------------------------
inline s64 C_TsStreamer::GetDate()
{
#ifdef _WIN32
s64 freq, usec_time;
if( QueryPerformanceFrequency( (LARGE_INTEGER *)&freq ) )
{
// Microsecond resolution
QueryPerformanceCounter( (LARGE_INTEGER *)&usec_time );
return ( usec_time * 1000000 ) / freq;
}
// Milisecond resolution
return 1000 * GetTickCount();
#else
struct timeval tv;
gettimeofday(&tv, NULL);
return( (s64)tv.tv_sec * 1000000 + (s64)tv.tv_usec );
#endif
}
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