コード例 #1
0
ファイル: chat.c プロジェクト: yonathanPodolak/c_chatServer
static int InitListeningSocket(ChatDetails* _chat, char* _ip)
{
	int optval = 1;
	struct ip_mreq mreq;

	mreq.imr_multiaddr.s_addr = inet_addr(_ip);
	mreq.imr_interface.s_addr = htonl(INADDR_ANY);

	if ((_chat->m_listeningSocket = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
	{
		perror("socket failed1\n");
		free(_chat);
		return -1;
	}
	if (setsockopt(_chat->m_listeningSocket, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval)) < 0)
	{
		perror("setsockopt failed1\n");
		CloseAll(_chat);
		return -1;
	}
	if (bind(_chat->m_listeningSocket, (struct sockaddr*)&_chat->m_recvAddr, sizeof(_chat->m_recvAddr)) < 0)
	{
		perror("bind failed\n");
		CloseAll(_chat);
		return -1;
	}
	if (setsockopt(_chat->m_listeningSocket, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char*)&mreq, sizeof(mreq)) < 0)
	{
		perror("setsockopt failed2\n");
		CloseAll(_chat);
		return -1;
	}
	return 0;
}
コード例 #2
0
void InitSelectGroup (struct MCMap *SelectGroup, gint start)
{
    gulong i,j;

    errormsg(MAPDEBUG1,"InitSelectGroup: Entered");

    SelectGroup->mm_MapSize.x = SELXSIZE;
    SelectGroup->mm_MapSize.y = SELYSIZE;
    SelectGroup->mm_MapSize.l = 2;
    SelectGroup->mm_Copy = FALSE;
    SelectGroup->mm_Size = sizeof(struct MCMap);
    SelectGroup->mm_NextLayer = NULL;
    SelectGroup->mm_Columns = g_malloc0(sizeof(gulong)*SELYSIZE);
    if (!SelectGroup->mm_Columns)
    {
      printf("Could not allocate memory for SelectGroup\n");
      CloseAll();
      exit(20);
    }
#if DEBUGLEV > 2
    errormsg(MAPDEBUG3,"InitSelectGroup: SelectGroup->mm_Columns=%x, ",
	     SelectGroup->mm_Columns);
#endif

    for(i=0;i<SELYSIZE;i++)
    {
        SelectGroup->mm_Rows = g_malloc0(sizeof(struct MapPiece)*SELXSIZE);
#if DEBUGLEV > 5
	errormsg(MAPDEBUG3,"InitSelectGroup: i=%d, SelectGroup->mm_Rows=%x",i,
		 SelectGroup->mm_Rows);
#endif
        if (!SelectGroup->mm_Rows)
        {
            printf("Could not allocate memory for SelectGroup\n");
            CloseAll();
            exit(20);
        }
        SelectGroup->mm_Columns[i] = (gulong)SelectGroup->mm_Rows;

        for(j=0;j<SELXSIZE;j++)
        {
#if DEBUGLEV > 5
	    errormsg(MAPDEBUG6,"InitSelectGroup: j=%d",j);
#endif
            SelectGroup->mm_Rows[j].mp_Coordinates.x = j * 37;
            SelectGroup->mm_Rows[j].mp_Coordinates.y = i * 13;
            SelectGroup->mm_Rows[j].mp_Coordinates.l = 1;
            SelectGroup->mm_Rows[j].mp_PixbufNumber = start+i*SELYSIZE+j;
            SelectGroup->mm_Rows[j].mp_Size = sizeof(struct MapPiece);
        }
    }

    errormsg(MAPDEBUG1,"InitSelectGroup: Finished succesfully");
}
コード例 #3
0
int Device_Helios::Init()
{
	CloseAll();

	heliosDevice = new HeliosDacClass;
	
	ready = true;
	int result = heliosDevice->OpenDevices();

	if (result <= 0)
		CloseAll();

	return result;
}
コード例 #4
0
int main( int argc, char **argv )
{
#ifdef DELLOG
    {
        FILE *fh;

        fh=fopen(getLogfile(),"w");
	fclose(fh);
    }
#endif
    gtk_init(&argc, &argv);

#if DEBUGLEV > 4
    errormsg(MAPMSG,"\nmain: Trying to load MapPieces Pixbuf...");
#endif
    if (!MapPicLoad())
    {
        printf("Could not load MapPieces Bitmap.\n");
        CloseAll();
        exit(20);
    }
#if DEBUGLEV > 4
    errormsg(MAPMSG,".Done\nmain: Trying to initialize window..");
#endif

    if (!(WO_Window=InitTestMEdWindow()))
    {
        printf("Did not get a Window pointer. Continuing anyway..\n");
        //CloseAll();
        //exit(20);
    }
#if DEBUGLEV > 4
    errormsg(MAPMSG,".Done\nMain Loop\n");
#endif

    /* Main Loop */

    gtk_main();

#if DEBUGLEV > 4
    errormsg(MAPMSG,"Exiting..");
#endif
    CloseAll();
#if DEBUGLEV > 4
    errormsg(MAPMSG,".Done\n");
#endif
    exit(0);
}
コード例 #5
0
void
MessagePortService::CloseAll(const nsID& aUUID)
{
  MessagePortServiceData* data;
  if (!mPorts.Get(aUUID, &data)) {
    MaybeShutdown();
    return;
  }

  if (data->mParent) {
    data->mParent->Close();
  }

  for (const MessagePortServiceData::NextParent& parent : data->mNextParents) {
    parent.mParent->CloseAndDelete();
  }

  nsID destinationUUID = data->mDestinationUUID;
  mPorts.Remove(aUUID);

  CloseAll(destinationUUID);

  // CloseAll calls itself recursively and it can happen that it deletes
  // itself. Before continuing we must check if we are still alive.
  if (!gInstance) {
    return;
  }

#ifdef DEBUG
  mPorts.EnumerateRead(CloseAllDebugCheck, const_cast<nsID*>(&aUUID));
#endif

  MaybeShutdown();
}
コード例 #6
0
bool
MessagePortService::ClosePort(MessagePortParent* aParent)
{
  MessagePortServiceData* data;
  if (!mPorts.Get(aParent->ID(), &data)) {
    MOZ_ASSERT(false, "Unknown MessagePortParent should not happend.");
    return false;
  }

  if (data->mParent != aParent) {
    MOZ_ASSERT(false, "ClosePort() should be called just from the correct parent.");
    return false;
  }

  if (!data->mNextParents.IsEmpty()) {
    MOZ_ASSERT(false, "ClosePort() should be called when there are not next parents.");
    return false;
  }

  // We don't want to send a message to this parent.
  data->mParent = nullptr;

  CloseAll(aParent->ID());
  return true;
}
コード例 #7
0
ファイル: hhctrl.cpp プロジェクト: jimmccurdy/ArchiveGit
// Destructor
CHtmlHelpControl::~CHtmlHelpControl()
{
	// Shut down the help control
	CloseAll();
	// Unload the control if we have it loaded.
	Unload();
}
コード例 #8
0
ファイル: mdig.cpp プロジェクト: czxxjtu/wxPython-1
void wxGenericMDIParentFrame::OnClose(wxCloseEvent& event)
{
    if ( !CloseAll() )
        event.Veto();
    else
        event.Skip();
}
コード例 #9
0
ファイル: mainbook.cpp プロジェクト: fmestrone/codelite
void MainBook::RestoreSession(SessionEntry& session)
{
    if(session.GetTabInfoArr().empty()) return; // nothing to restore

    CloseAll(false);
    size_t sel = session.GetSelectedTab();
    const std::vector<TabInfo>& vTabInfoArr = session.GetTabInfoArr();
    for(size_t i = 0; i < vTabInfoArr.size(); i++) {
        const TabInfo& ti = vTabInfoArr[i];
        m_reloadingDoRaise = (i == vTabInfoArr.size() - 1); // Raise() when opening only the last editor
        LEditor* editor = OpenFile(ti.GetFileName());
        if(!editor) {
            if(i < sel) {
                // have to adjust selected tab number because couldn't open tab
                sel--;
            }
            continue;
        }

        editor->SetFirstVisibleLine(ti.GetFirstVisibleLine());
        editor->SetEnsureCaretIsVisible(editor->PositionFromLine(ti.GetCurrentLine()));
        editor->LoadMarkersFromArray(ti.GetBookmarks());
        editor->LoadCollapsedFoldsFromArray(ti.GetCollapsedFolds());
    }
    m_book->SetSelection(sel);
}
コード例 #10
0
ファイル: BattleScene.cpp プロジェクト: Lin20/projectpmr
void BattleScene::CleanupBattle()
{
	stage = 0;
	scroll_timer = 0;

	for (int i = 0; i < 6; i++)
	{
		if (opponent[i] != 0)
		{
			delete opponent[i];
			opponent[i] = 0;
		}
	}

	if (opponent_image)
	{
		//delete opponent_image;
		//opponent_image = 0;
	}
	if (party_status)
	{
		delete party_status;
		party_status = 0;
	}

	CloseAll(); //close all textboxes
}
コード例 #11
0
/**
	@return true if a wininet session was initialized successfully, false if failed
*/
bool InternetRequest::OpenSession()
{
	// Close existing session
	CloseAll();

	try
	{
		// Start the session
		m_hSession = ::InternetOpen(_T("CogniView CCInfo/0.1"), INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
		if (m_hSession == NULL)
		{
			// Error
			m_sError = _T("Cannot connect to the internet");
			return false;
		}

		// Set status callback
		if (::InternetSetStatusCallback(m_hSession, InternetCallback) == INTERNET_INVALID_STATUS_CALLBACK)
		{
			// Error
			m_sError = _T("Cannot set connection callback");
			return false;
		}
	}
	catch (...)
	{
		return false;
	}

	// All is well
	return true;
}
コード例 #12
0
bool MediaSourceV4L2::CloseGrabDevice()
{
    bool tResult = false;

    LOG(LOG_VERBOSE, "Going to close");

    if (mMediaType == MEDIA_AUDIO)
    {
        LOG(LOG_ERROR, "Wrong media type");
        return false;
    }

    if (mMediaSourceOpened)
    {
        CloseAll();

        // Free the frames
        av_free(mRGBFrame);
        av_free(mSourceFrame);

        tResult = true;
    }else
        LOG(LOG_INFO, "...wasn't open");

    mGrabbingStopped = false;
    mSupportsMultipleInputChannels = false;
    mMediaType = MEDIA_UNKNOWN;

    ResetPacketStatistic();

    return tResult;
}
コード例 #13
0
ファイル: mdig.cpp プロジェクト: czxxjtu/wxPython-1
void wxGenericMDIParentFrame::OnWindowMenu(wxCommandEvent &event)
{
    switch ( event.GetId() )
    {
        case wxWINDOWCLOSE:
            if ( m_currentChild )
                m_currentChild->Close();
            break;

        case wxWINDOWCLOSEALL:
            CloseAll();
            break;

        case wxWINDOWNEXT:
            ActivateNext();
            break;

        case wxWINDOWPREV:
            ActivatePrevious();
            break;

        default:
            event.Skip();
    }
}
コード例 #14
0
int Device_OLSC::Init()
{
	CloseAll();

	OLSCLibrary = LoadLibrary(L"OLSC.dll");
	if (OLSCLibrary == NULL) return -2;

	OLSC_Initialize = (OLSCFuncPtr1)GetProcAddress(OLSCLibrary, "OLSC_Initialize");
	if (!OLSC_Initialize)
	{
		FreeLibrary(OLSCLibrary);
		return -1;
	}

	OLSC_Shutdown = (OLSCFuncPtr1)GetProcAddress(OLSCLibrary, "OLSC_Shutdown");
	if (!OLSC_Shutdown)
	{
		FreeLibrary(OLSCLibrary);
		return -1;
	}

	OLSC_GetStatus = (OLSCFuncPtr4)GetProcAddress(OLSCLibrary, "OLSC_GetStatus");
	if (!OLSC_GetStatus)
	{
		FreeLibrary(OLSCLibrary);
		return -1;
	}

	OLSC_GetInterfaceName = (OLSCFuncPtr0)GetProcAddress(OLSCLibrary, "OLSC_GetInterfaceName");
	if (!OLSC_GetInterfaceName)
	{
		FreeLibrary(OLSCLibrary);
		return -1;
	}

	OLSC_Pause = (OLSCFuncPtr2)GetProcAddress(OLSCLibrary, "OLSC_Pause");
	if (!OLSC_Pause)
	{
		FreeLibrary(OLSCLibrary);
		return -1;
	}

	OLSC_WriteFrameEx = (OLSCFuncPtr3)GetProcAddress(OLSCLibrary, "OLSC_WriteFrameEx");
	if (!OLSC_WriteFrameEx)
	{
		FreeLibrary(OLSCLibrary);
		return -1;
	}

	int openResult = OLSC_Initialize();
	if (openResult <= 0)
	{
		OLSC_Shutdown();
		FreeLibrary(OLSCLibrary);
		return openResult;
	}

	ready = true;
	return openResult;
}
コード例 #15
0
bool CTaiKlineHistorySelect::OpenAll()
{
	ASSERT(FALSE);
	return false;

	CloseAll();

	CTime tm = CTime::GetCurrentTime ();
	CString sTm = tm.Format ("%Y%m%d");

	bool bToday = false;

	for(int i=0;i<m_fileNameArray.GetSize ();i++)
	{
		CString sPathSh;
		CString sPathSz;
		CString filename ;
		CString sTitle = m_fileNameArray[i];
		CString title = sTitle+".hst";
		sPathSh = "data\\historysh\\";
		sPathSz = "data\\historysz\\";
		CTaiKlineFileHS* pFile;
		if(m_fileNameArray[i]>=sTm)
		{
			if(bToday == false)
			{
				sPathSh = "data\\historysh\\";
				sPathSz = "data\\historysz\\";
				title = "buysell.dat";
				sTitle = "buysell";
				bToday = true;
			}
			else
				continue;
		}
		pFile = new CTaiKlineFileHS(true);


		filename =sPathSh + title;
		if(!pFile->Open (filename,0))
		{
			delete pFile;
			continue;
		}
		m_fileHsShArray[sTitle] = (pFile);

		pFile = new CTaiKlineFileHS(false);
		filename =sPathSz + title;
		if(!pFile->Open (filename,0))
		{
			delete pFile;
			continue;
		}
		m_fileHsSzArray[sTitle] = (pFile);

	}
	return true;
}
コード例 #16
0
void MainBook::OnWorkspaceClosed(wxCommandEvent& e)
{
    e.Skip();
    CloseAll(false); // make sure no unsaved files
    clStatusBar* sb = clGetManager()->GetStatusBar();
    if(sb) {
        sb->SetSourceControlBitmap(wxNullBitmap, "", "");
    }
}
コード例 #17
0
///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
//Tests macros and functions.
//If (!aValue) then the test will be panicked, the test data files will be deleted.
static void Check(TInt aValue, TInt aLine)
	{
	if(!aValue)
		{
		CloseAll();
		DeleteFile(TheDatabaseFileName);
		TheTest(EFalse, aLine);
		}
	}
コード例 #18
0
ファイル: main.c プロジェクト: abashkirtsev/Shell
void CloseAll (int in, int out, struct pipefdlist ** list)
{
	if (*list == NULL)
		return;
	if (((*list)->fd)[0] != in)
		close (((*list)->fd)[0]);
	if (((*list)->fd)[1] != out)
		close (((*list)->fd)[1]);
	CloseAll (in, out, &((*list)->next));
}
コード例 #19
0
ファイル: v4lhelper.cpp プロジェクト: Kr0nZ/boxee
bool V4LHelper::Stop()
{
  CSingleLock lock(m_lock);

  CloseAll();
  m_lastFreq = "";
  m_tuningState = DvbTuner::TUNING_STATE_IDLE;

  return true;
}
コード例 #20
0
//If (aValue != aExpected) then the test will be panicked, the test data files will be deleted.
static void Check(TInt aValue, TInt aExpected, TInt aLine)
	{
	if(aValue != aExpected)
		{
		TheTest.Printf(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue);
		CloseAll();
		DeleteFile(TheDatabaseFileName);
		TheTest(EFalse, aLine);
		}
	}
コード例 #21
0
ファイル: output.cpp プロジェクト: v-zaburdaev/Gsplayer2
void COutput::Close()
{
	CAutoLock lock(&m_csecDevice);

	if (!m_fDoubleBuf) {
		CloseAll();
		return;
	}

	Reset();
}
コード例 #22
0
void DirectoryFileSystem::DoState(PointerWrap &p) {
	auto s = p.Section("DirectoryFileSystem", 0, 2);
	if (!s)
		return;

	// Savestate layout:
	// u32: number of entries
	// per-entry:
	//     u32:              handle number
	//     std::string       filename (in guest's terms, untranslated)
	//     enum FileAccess   file access mode
	//     u32               seek position
	//     s64               current truncate position (v2+ only)

	u32 num = (u32) entries.size();
	p.Do(num);

	if (p.mode == p.MODE_READ) {
		CloseAll();
		u32 key;
		OpenFileEntry entry;
		for (u32 i = 0; i < num; i++) {
			p.Do(key);
			p.Do(entry.guestFilename);
			p.Do(entry.access);
			u32 err;
			if (!entry.hFile.Open(basePath,entry.guestFilename,entry.access, err)) {
				ERROR_LOG(FILESYS, "Failed to reopen file while loading state: %s", entry.guestFilename.c_str());
				continue;
			}
			u32 position;
			p.Do(position);
			if (position != entry.hFile.Seek(position, FILEMOVE_BEGIN)) {
				ERROR_LOG(FILESYS, "Failed to restore seek position while loading state: %s", entry.guestFilename.c_str());
				continue;
			}
			if (s >= 2) {
				p.Do(entry.hFile.needsTrunc_);
			}
			entries[key] = entry;
		}
	} else {
		for (auto iter = entries.begin(); iter != entries.end(); ++iter) {
			u32 key = iter->first;
			p.Do(key);
			p.Do(iter->second.guestFilename);
			p.Do(iter->second.access);
			u32 position = (u32)iter->second.hFile.Seek(0, FILEMOVE_CURRENT);
			p.Do(position);
			p.Do(iter->second.hFile.needsTrunc_);
		}
	}
}
コード例 #23
0
ファイル: XMMTCtl.cpp プロジェクト: ja7ude/XMMT
void CXMMTCtrl::OnResetState()
{
	COleControl::OnResetState();  // DoPropExchange を呼び出してデフォルト値にリセット

	CloseAll();
	m_bFftConversion = FALSE;
	m_PortTCP = 10301;
	m_ConnectionCount = 0;
	memset(m_pConnection, 0, sizeof(m_pConnection));
	memset(m_bBusy, TRUE, sizeof(m_bBusy));
	memset(m_bNotify, 0, sizeof(m_bNotify));
}
コード例 #24
0
ファイル: XMMTCtl.cpp プロジェクト: ja7ude/XMMT
BOOL CXMMTCtrl::Listen() 
{
	CloseAll();
	if( !m_pSocket ){
		m_pSocket = new CLSocket(this);
		if( !m_pSocket->Create(m_PortTCP) || !m_pSocket->Listen() ){
			delete m_pSocket;
			m_pSocket = NULL;
		}
	}
	return m_pSocket != NULL;
}
コード例 #25
0
void
JXDockManager::ReadSetup
	(
	istream& input
	)
{
	CloseAll();

	itsIsReadingSetupFlag = kJTrue;

	JFileVersion vers;
	input >> vers;
	assert( vers <= kCurrentSetupVersion );

	JSize count;
	input >> count;

	(JXGetApplication())->SetCurrentDisplay(itsDisplay);

	JString title;
	for (JIndex i=1; i<=count; i++)
		{
		title = GetNewDockTitle();

		JXDockDirector* dock = new JXDockDirector(input, vers, title);
		assert( dock != NULL );
		itsDockList->Append(dock);
		dock->Activate();
		}

	itsWindowTypeMap->RemoveAll();
	if (vers >= 1)
		{
		JString windowType;
		while (1)
			{
			JBoolean keepGoing;
			input >> keepGoing;
			if (input.fail() || !keepGoing)
				{
				break;
				}

			JIndex id;
			input >> windowType >> id;

			JXDockWidget* dock;
			if (FindDock(id, &dock))
				{
				itsWindowTypeMap->SetElement(windowType, id);
				}
			}
		}
コード例 #26
0
ファイル: COMM32.CPP プロジェクト: crespo2014/cpp-lib
// Habilitacion y programacion del puerto serie
int CComm32::OpenComm()
{
	if (m_OnOpen) return ERROR_ALREADY_INITIALIZED;
	
	m_HPort=CreateFile(m_Name,GENERIC_READ+GENERIC_WRITE,
		0,NULL,OPEN_EXISTING,FILE_FLAG_OVERLAPPED,0);

	if (m_HPort==INVALID_HANDLE_VALUE)
		return GetLastError();
	
	m_OnOpen=true;

	if (GetFileType(m_HPort)!=FILE_TYPE_CHAR)
	{
		CloseHandle(m_HPort);
		return ERROR_OPEN_FAILED;
	}

	m_Read_Overlapped.hEvent=CreateEvent(NULL,true,true,NULL);
	if (m_Read_Overlapped.hEvent==0)
	{
		CloseAll();
		return GetLastError();
	}

	m_Write_Overlapped.hEvent=CreateEvent(NULL,true,true,NULL);
	if (m_Write_Overlapped.hEvent==0)
	{
		CloseAll();
		return GetLastError();
	}
	GetCommProperties(m_HPort,&m_CommProp);
	SetCommMask(m_HPort,m_EvtMask);
	SetCommTimeouts(m_HPort,&m_CommTimeOuts);
	GetCommModemStatus(m_HPort,&m_ModemStat);
	DWORD size=sizeof(COMMCONFIG);
	GetCommConfig(m_HPort,&m_CommConfig,&size);
	return 0;

}
コード例 #27
0
ファイル: CPPF.cpp プロジェクト: BackupTheBerlios/ppftool
CPPF::~CPPF()
{
	CloseAll();
	if(m_pDataP!=NULL)
	{
    free(m_pDataP);
  }
  
	if(m_pDataO!=NULL)
	{
    free(m_pDataO);
  }
}
コード例 #28
0
ファイル: XMMTCtl.cpp プロジェクト: ja7ude/XMMT
void CXMMTCtrl::SetBActive(BOOL bNewValue) 
{
	if( GetBActive() != bNewValue ){
		if( bNewValue ){
			Listen();
			SetModifiedFlag();
		}
		else {
			CloseAll();
			SetModifiedFlag();
		}
	}
}
コード例 #29
0
ファイル: AutoHideBar.cpp プロジェクト: kolyden/mirror
void AutoHideBar::Detach(DockableCtrl& ctrl)
{
    DockWindow& c = reinterpret_cast<DockWindow&>(ctrl);
    active = TabInterface::Find(ctrl);
    if(tabs.GetCount() == 1)
    {
        CloseAll();
        HideBar();
    }
    else Close(active);
    childcount--;
    c.SetOwnerBar(NULL);
    HideWindow();
}
コード例 #30
0
ファイル: MainFrm.cpp プロジェクト: killbug2004/WSProf
bool CMainFrame::Close(bool promptToSave)
{
	if( GetApp()->ComparisonRunning() )
		return false;

	CChildFrame* const pFrame = DYNAMIC_DOWNCAST( CChildFrame, MDIGetActive() );

	if (CloseAll(promptToSave ? 0 : 1))
	{
		CMDIFrameWndEx::OnClose();
		return true;
	}
	return false;
}