int receive(int* arg) {
  char buffer[BUFFER_SIZE];
  int i;
  int bytes_received;
  network_address_t my_address;
  minisocket_t socket;
  minisocket_error error;

  /* 
   * It is crucial that this minithread_yield() works properly
   * (i.e. it really gives the processor to another thread)
   * othrevise the client starts before the server and it will
   * fail (there is nobody to connect to).
   */
  minithread_yield();
  network_get_my_address(my_address);
  int x;

  /* create a network connection to the local machine */

  socket = minisocket_client_create(my_address, port,&error);
  if (socket==NULL){
    printf("3ERROR: %s. Exiting. \n",GetErrorDescription(error));
    return -1;
  }
//semaphore_P(done_sending);
  /* receive the message */
  bytes_received=0;
  while (bytes_received!=BUFFER_SIZE/20){
    int received_bytes;
    if ((received_bytes=minisocket_receive(socket,buffer, 2, &error))==-1){
      printf("inside, socket status = %d [%p]\n", socket->status, socket);
      printf("4ERROR: %s. Exiting. \n",GetErrorDescription(error));
      /* close the connection */
      minisocket_close(socket);
      return -1;
    }   
    /* test the information received */
    for (i=0; i<received_bytes; i++){
      if (buffer[i]!=(char)( (bytes_received+i)%256 )){
	printf("The %d'th byte received is wrong ('%d'-'%d'-'%d'-'%d' vs '%d'-'%d'-'%d'-'%d') [%d].\n",
	       bytes_received+i, buffer[i-3], buffer[i-2], buffer[i-1], buffer[i], 
         (bytes_received+i-3)%256, (bytes_received+i-2)%256, (bytes_received+i-1)%256, (bytes_received+i)%256,
         received_bytes);
	/* close the connection */
	minisocket_close(socket);
	return -1;
      }
    }
	      
    bytes_received+=received_bytes;
  }

  printf("All bytes received correctly (received %d bytes).\n", bytes_received);
  
  minisocket_close(socket);

  return 0;
}
Esempio n. 2
0
int receive(int* arg) {
  char buffer[BUFFER_SIZE];
  int i;
  int bytes_received;
  network_address_t my_address;
  minisocket_t socket;
  minisocket_error error;

  /* 
   * It is crucial that this minithread_yield() works properly
   * (i.e. it really gives the processor to another thread)
   * othrevise the client starts before the server and it will
   * fail (there is nobody to connect to).
   */
  minithread_yield();
  
  network_get_my_address(my_address);
  
  /* create a network connection to the local machine */
  printf("creating client\n");
  socket = minisocket_client_create(my_address, port,&error);
  printf("client unblocked\n");
  if (socket==NULL){
    printf("ERROR: %s. Exiting. \n",GetErrorDescription(error));
    return -1;
  }

  /* receive the message */
  bytes_received=0;
  while (bytes_received!=BUFFER_SIZE){
    int received_bytes;
    if ((received_bytes=minisocket_receive(socket,buffer, BUFFER_SIZE-bytes_received, &error))==-1){
      printf("ERROR: %s. Exiting. \n",GetErrorDescription(error));
      /* close the connection */
      minisocket_close(socket);
      return -1;
    }   
    printf("checking bytes\n");
    /* test the information received */
    for (i=0; i<received_bytes; i++){
      if (buffer[i]!=(char)( (bytes_received+i)%256 )){
	printf("The %d'th byte received is wrong.\n",
	       bytes_received+i);
	/* close the connection */
	minisocket_close(socket);
	return -1;
      }
    }
	      
    bytes_received+=received_bytes;
  }

  printf("All bytes received correctly.\n");
  
  minisocket_close(socket);

  return 0;
}
Esempio n. 3
0
//++ ------------------------------------------------------------------------------------
// Details: Initialize resources for *this debugger object.
// Type:    Method.
// Args:    None.
// Return:  MIstatus::success - Functionality succeeded.
//          MIstatus::failure - Functionality failed.
// Throws:  None.
//--
bool
CMICmnLLDBDebugger::Initialize()
{
    m_clientUsageRefCnt++;

    if (m_bInitialized)
        return MIstatus::success;

    bool bOk = MIstatus::success;
    CMIUtilString errMsg;
    ClrErrorDescription();

    if (m_pClientDriver == nullptr)
    {
        bOk = false;
        errMsg = MIRSRC(IDS_LLDBDEBUGGER_ERR_CLIENTDRIVER);
    }

    // Note initialization order is important here as some resources depend on previous
    MI::ModuleInit<CMICmnLog>(IDS_MI_INIT_ERR_LOG, bOk, errMsg);
    MI::ModuleInit<CMICmnResources>(IDS_MI_INIT_ERR_RESOURCES, bOk, errMsg);
    MI::ModuleInit<CMICmnThreadMgrStd>(IDS_MI_INIT_ERR_THREADMGR, bOk, errMsg);
    MI::ModuleInit<CMICmnLLDBDebuggerHandleEvents>(IDS_MI_INIT_ERR_OUTOFBANDHANDLER, bOk, errMsg);
    MI::ModuleInit<CMICmnLLDBDebugSessionInfo>(IDS_MI_INIT_ERR_DEBUGSESSIONINFO, bOk, errMsg);

    // Note order is important here!
    if (bOk)
        lldb::SBDebugger::Initialize();
    if (bOk && !InitSBDebugger())
    {
        bOk = false;
        if (!errMsg.empty())
            errMsg += ", ";
        errMsg += GetErrorDescription().c_str();
    }
    if (bOk && !InitSBListener())
    {
        bOk = false;
        if (!errMsg.empty())
            errMsg += ", ";
        errMsg += GetErrorDescription().c_str();
    }
    bOk = bOk && InitStdStreams();
    bOk = bOk && RegisterMISummaryProviders();
    m_bInitialized = bOk;

    if (!bOk && !HaveErrorDescription())
    {
        CMIUtilString strInitError(CMIUtilString::Format(MIRSRC(IDS_MI_INIT_ERR_LLDBDEBUGGER), errMsg.c_str()));
        SetErrorDescription(strInitError);
    }

    return bOk;
}
Esempio n. 4
0
HRESULT FMPlayerDShow::BuildTheGraph()
{
	CComQIPtr<IGraphBuilder> pGraphBuilder = m_FilterGraph; 
	HRESULT hr = E_FAIL; 
	if (pGraphBuilder)
	{
		CComPtr<IPin> Pin1 = GetOutPin(m_AviSplitter, 0); 
		CComPtr<IPin> Pin2 = GetOutPin(m_AviSplitter, 1); 
		CComPtr<IPin> PinXV = GetInPin(m_xVid, 0); 
		if (Pin1 && Pin2 && PinXV)
		{
			hr = m_FilterGraph->ConnectDirect(Pin1, PinXV, NULL); 
			if (FAILED(hr))
			{
				hr = m_FilterGraph->ConnectDirect(Pin2, PinXV, NULL); 
			}
			if (SUCCEEDED(hr))
			{
				CComPtr<IPin> PinOutXV = GetOutPin(m_xVid, 0); 
				CComPtr<IPin> PinInRenderer = GetInPin(m_VideoRenderer, 0); 
				if (PinOutXV && PinInRenderer)
				{
					CComPtr<IPin> PinConnected; 
					if (PinOutXV->ConnectedTo(&PinConnected) & VFW_E_NOT_CONNECTED)
					{
						//Disconnect renderer from any filters;
						PinInRenderer->Disconnect(); 
						hr = m_FilterGraph->ConnectDirect(PinOutXV, PinInRenderer, NULL); 
					}
					if (SUCCEEDED(hr))
					{
						hr = RenderOutputPins(pGraphBuilder, m_AviSplitter); 
						if (FAILED(hr))
							_DBGAlertM("FMediaMgr: **RenderOutputPins: %s\n", GetErrorDescription(hr)); 
						m_GraphBuilt = TRUE; 
					}
					else
						_DBGAlertM("FMediaMgr: **Connect PinOutXV to PinInRenderer: %s\n", GetErrorDescription(hr)); 
				}
				else
					_DBGAlertM("FMediaMgr: **PinOutXV or PinInRenderer is NULL\n"); 
			}
			else
				_DBGAlertM("FMediaMgr: **Connect Splitter to xvid: %s\n", GetErrorDescription(hr)); 
		}
		else
			_DBGAlertM("FMediaMgr: **Pin1 or Pin2 or PinXV is NULL.\n"); 
	}

	return hr; 
}
Esempio n. 5
0
int transmit(int* arg) {
  char buffer[BUFFER_SIZE];
  int i;
  int bytes_sent;
  minisocket_t socket;
  minisocket_error error;

  minithread_fork(receive, NULL);
  // receiver = minithread_fork(receive, NULL);
  
  printf("in transmit\n");
  socket = minisocket_server_create(port,&error);
  printf("created a server\n");
  if (socket==NULL){
    printf("ERROR: %s. Exiting. \n",GetErrorDescription(error));
    return -1;
  }

  /* Fill in the buffer with numbers from 0 to BUFFER_SIZE-1 */
  for (i=0; i<BUFFER_SIZE; i++){
    buffer[i]=(char)(i%256);
  }

  /* send the message */
  bytes_sent=0;
  while (bytes_sent!=BUFFER_SIZE){
    int trans_bytes=
      minisocket_send(socket,buffer+bytes_sent,
		      BUFFER_SIZE-bytes_sent, &error);
  
    printf("Sent %d bytes.\n",trans_bytes);

    if (error!=SOCKET_NOERROR){
      printf("ERROR: %s. Exiting. \n",GetErrorDescription(error));
      /* close the connection */
      minisocket_close(socket);
    
      return -1;
    }   

    bytes_sent+=trans_bytes;
  }

  /* close the connection */
  minisocket_close(socket);

  return 0;
}
	ERMsg CBioSIMProject::Save(const string& filePath)
	{
		ERMsg msg;

		try
		{
			zen::XmlDoc doc(XML_FLAG);
			writeStruc(doc.root());
			doc.root().setAttribute("version", "11");
			doc.setEncoding("Windows-1252");

			std::string filePathU8 = ANSI_UTF8(filePath);
			zen::save(doc, filePathU8); //throw XmlFileError, XmlParsingError
		}
		catch (const zen::XmlFileError& e)
		{
			// handle error
			msg.ajoute(GetErrorDescription(e.lastError));
		}
		catch (const ERMsg& e)
		{
			// handle error
			msg = e;
		}

		//msg = zen::SaveXML(filePath, XML_FLAG, "11", *this);

		if (msg)
			m_filePath = filePath;

		return msg;
	}
Esempio n. 7
0
bool CalcRequiredClipRect(HWND hwnd, RECT& rect)
{
	std::string description;

	if (!GetClientRect(hwnd, &rect))
	{
		DWORD lastError = GetLastError();
		GetErrorDescription(lastError, description);
		throw std::runtime_error(description);
	}

	POINT pt1 = { rect.left, rect.top };
	POINT pt2 = { rect.right, rect.bottom };

	if (!ClientToScreen(hwnd, &pt1))
		return false;
	
	if (!ClientToScreen(hwnd, &pt2))
		return false;

	if (!SetRect(&rect, pt1.x, pt1.y, pt2.x, pt2.y))
		return false;

	return true;
}
Esempio n. 8
0
void _DBGLogResult(HRESULT hr, const tchar* szFilterName)
{
	if (FAILED(hr))
		_DBGAlertM("FMPlayerDShow: **%s not loaded: %s\n", szFilterName, GetErrorDescription(hr));
	else
		_DBGAlertM("FMPlayerDShow: %s loaded\n", szFilterName); 
}
Esempio n. 9
0
BOOL CZipException::GetErrorMessage(LPTSTR lpszError, UINT nMaxError,
	UINT* )

{
	if (!lpszError || !nMaxError)
		return FALSE;
	CZipString sz = GetErrorDescription();
	if (sz.IsEmpty())
		return FALSE;
	UINT iLen = sz.GetLength();
	if (nMaxError - 1 < iLen)
		iLen = nMaxError - 1;
	LPTSTR lpsz = sz.GetBuffer(iLen);
#if _MSC_VER >= 1400
	#ifdef _UNICODE	
		wcsncpy_s(lpszError, nMaxError, lpsz, iLen);
	#else
		strncpy_s(lpszError, nMaxError, lpsz, iLen);
	#endif
#else
	#ifdef _UNICODE	
		wcsncpy(lpszError, lpsz, iLen);
	#else
		strncpy(lpszError, lpsz, iLen);
	#endif
#endif

	lpszError[iLen] = _T('\0');
	return TRUE;
}
Esempio n. 10
0
File: handshake.c Progetto: obsc/os
int receive(int* arg) {
  network_address_t my_address;
  minisocket_t socket;
  minisocket_error error;

  printf("starting receive\n");

  minithread_yield();

  printf("continuing receive\n");

  network_get_my_address(my_address);

  /* create a network connection to the local machine */
  socket = minisocket_client_create(my_address, port,&error);
  if (socket==NULL){
    printf("ERROR: %s. Exiting. \n",GetErrorDescription(error));
    return -1;
  }

  printf("client connected\n");

  minisocket_close(socket);

  return 0;
}
int client(int* arg) {
  char buffer[BUFFER_SIZE];
  int i;
  int bytes_received;
  network_address_t address;
  minisocket_t socket;
  minisocket_error error;
  
  network_translate_hostname(hostname, address);
  
  /* create a network connection to the local machine */
  socket = minisocket_client_create(address, port,&error);
  if (socket==NULL){
    printf("ERROR: %s. Exiting. \n",GetErrorDescription(error));
    return -1;
  }

  /* receive the message */
  bytes_received=0;
  while (bytes_received!=BUFFER_SIZE){
    int received_bytes;
    if ( (received_bytes=minisocket_receive(socket,buffer,BUFFER_SIZE-bytes_received, &error))==-1){
      printf("ERROR: %s. Exiting. \n",GetErrorDescription(error));
      /* close the connection */
      minisocket_close(socket);
      return -1;
    }   
    /* test the information received */
    for (i=0; i<received_bytes; i++){
      if (buffer[i]!=(char)( (bytes_received+i)%256 )){
	printf("The %d'th byte received is wrong.\n",
	       bytes_received+i);
	/* close the connection */
	minisocket_close(socket);
	return -1;
      }
    }
	      
    bytes_received+=received_bytes;
  }

  printf("All bytes received correctly.\n");
  
  minisocket_close(socket);

  return 0;
}
Esempio n. 12
0
void RaiseError(const char* msgPrefix)
{
	std::string description;
	GetErrorDescription(::GetLastError(), description);
	
	std::string msg(msgPrefix);
	msg.append(description);
	
	throw std::runtime_error(msg);
}
Esempio n. 13
0
wxString wxFileSystemWatcherEvent::ToString() const
{
    if (IsError())
    {
        return wxString::Format("FSW_EVT type=%d (%s) message='%s'", m_changeType,
            GetFSWEventChangeTypeName(m_changeType), GetErrorDescription());
    }
    return wxString::Format("FSW_EVT type=%d (%s) path='%s'", m_changeType,
            GetFSWEventChangeTypeName(m_changeType), GetPath().GetFullPath());
}
Esempio n. 14
0
// void GetErrorDescription(int *ErrNo, char strErrDescription[]);
static PyObject*
ParODE_GetErrorDescription(PyObject *self, PyObject *args){
	// input : nErr
	int nErr;
	if(!PyArg_ParseTuple(args, "i", &nErr))
		return NULL;
	char strErr[256];
	GetErrorDescription(&nErr, strErr);
	return Py_BuildValue("s", strErr);
}
Esempio n. 15
0
string CZipCompression::FormatErrorMessage(string where,
        unsigned long pos) const
{
    string str = "[" + where + "]  " + GetErrorDescription();
    if ( !pos ) {
        pos = STREAM->total_in;
    }
    str += ";  error code = " + NStr::IntToString(GetErrorCode()) +
           ", number of processed bytes = " + NStr::ULongToString(pos);
    return str + ".";
}
Esempio n. 16
0
int server(int* arg) {
    (void)arg; //unused

    char buffer[BUFFER_SIZE];

    minisocket_error error;
    minisocket_t *socket = minisocket_server_create(port,&error);
    if (socket==NULL){
        printf("ERROR: %s. Exiting. \n",GetErrorDescription(error));
        return -1;
    }

    // Fill in the buffer with numbers from 0 to BUFFER_SIZE-1
    for (int i=0; i<BUFFER_SIZE; i++){
        buffer[i]=(char)(i%256);
    }

    // send the message
    int bytes_sent=0;
    while (bytes_sent!=BUFFER_SIZE){
        int trans_bytes=
                minisocket_send(socket,buffer+bytes_sent,
                                BUFFER_SIZE-bytes_sent, &error);

        printf("Sent %d bytes.\n",trans_bytes);

        if (error!=SOCKET_NOERROR){
            printf("ERROR: %s. Exiting. \n",GetErrorDescription(error));
            /* close the connection */
            minisocket_close(socket);

            return -1;
        }

        bytes_sent+=trans_bytes;
    }

    minisocket_close(socket);
    return 0;
}
	ERMsg CUISolutionMesonetDaily::LoadStationList(CCallback& callback)
	{
		ERMsg msg;

		m_stations.clear();
		string filePath = GetStationListFilePath();

		
		ifStream file;
		file.imbue(std::locale(std::locale::classic(), new std::codecvt_utf8<char>()));
		msg = file.open(filePath);
		if (msg)
		{
			try
			{
				string str = file.GetText();
				std::replace(str.begin(), str.end(), '\'', 'Ã');

				zen::XmlDoc doc = zen::parse(str);

				zen::XmlIn in(doc.root());
				for (zen::XmlIn child = in["station"]; child; child.next())
				{
					CLocation tmp;
					child.attribute("fullname", tmp.m_name);
					std::replace(tmp.m_name.begin(), tmp.m_name.end(), 'Ã', '\'');
					child.attribute("name", tmp.m_ID);
					child.attribute("lat", tmp.m_lat);
					child.attribute("lon", tmp.m_lon);
					child.attribute("elev", tmp.m_elev);
					m_stations[tmp.m_ID] = tmp;
				}

			}
			catch (const zen::XmlFileError& e)
			{
				// handle error
				msg.ajoute(GetErrorDescription(e.lastError));
			}
			catch (const zen::XmlParsingError& e)
			{
				// handle error
				msg.ajoute("Error parsing XML file: col=" + ToString(e.col) + ", row=" + ToString(e.row));
			}
		}

		return msg;
	}
Esempio n. 18
0
std::wstring GraphicsException::GetFullMessage() const
{
	const std::wstring empty = L"";
	const std::wstring errorName = GetErrorName();
	const std::wstring errorDesc = GetErrorDescription();
	const std::wstring& note = GetNote();
	const std::wstring location = GetLocation();
	return    ( !errorName.empty() ? std::wstring( L"Error: " ) + errorName + L"\n"
		: empty )
		+ ( !errorDesc.empty() ? std::wstring( L"Description: " ) + errorDesc + L"\n"
		: empty )
		+ ( !note.empty() ? std::wstring( L"Note: " ) + note + L"\n"
		: empty )
		+ ( !location.empty() ? std::wstring( L"Location: " ) + location
		: empty );
}
Esempio n. 19
0
int server(int* arg) {
  minisocket_error error;
  minisocket_t socket;
  char* msg;
  int data_len;

  msg = "hello\n";
  data_len = strlen(msg) + 1;
  socket = minisocket_server_create(port,&error);
  printf("made a server\n");
  if (socket==NULL){
    printf("ERROR: %s. Exiting. \n",GetErrorDescription(error));
    return -1;
  }
  minisocket_send(socket, msg, data_len, &error);
  printf("sent my thang!\n");
  return 0;
}
Esempio n. 20
0
int server(int* arg) {
  int port;
  minisocket_t socket;
  minisocket_error error;

  port = *arg;
  
  socket = minisocket_server_create(port,&error);
  if (socket==NULL){
    printf("ERROR: %s. Exiting. \n",GetErrorDescription(error));
    return -1;
  }

  printf("Server connected on port %i\n", port);

  /* close the connection */
  minisocket_close(socket);

  return 0;
}
Esempio n. 21
0
int client(int* arg) {
  int port;
  network_address_t address;
  minisocket_t socket;
  minisocket_error error;
  
  port = *arg;
  network_translate_hostname(hostname, address);
  
  socket = minisocket_client_create(address, port, &error);
  if (socket==NULL){
    printf("ERROR: %s. Exiting. \n",GetErrorDescription(error));
    return -1;
  }

  printf("Client connected on port %i\n", port);
  
  minisocket_close(socket);

  return 0;
}
Esempio n. 22
0
File: handshake.c Progetto: obsc/os
int transmit(int* arg) {
  minisocket_t socket;
  minisocket_error error;

  printf("starting transmit\n");

  minithread_fork(receive, NULL);

  printf("continuing transmit\n");

  socket = minisocket_server_create(port,&error);
  if (socket==NULL){
    printf("ERROR: %s. Exiting. \n",GetErrorDescription(error));
    return -1;
  }

  printf("server connected\n");

  /* close the connection */
  minisocket_close(socket);

  return 0;
}
Esempio n. 23
0
    void ProcessNativeEvent(const inotify_event& inevt)
    {
        wxLogTrace(wxTRACE_FSWATCHER, InotifyEventToString(inevt));

        // after removing inotify watch we get IN_IGNORED for it, but the watch
        // will be already removed from our list at that time
        if (inevt.mask & IN_IGNORED)
        {
            // It is now safe to remove it from the stale descriptors too, we
            // won't get any more events for it.
            // However if we're here because a dir that we're still watching
            // has just been deleted, its wd won't be on this list
            const int pos = m_staleDescriptors.Index(inevt.wd);
            if ( pos != wxNOT_FOUND )
            {
                m_staleDescriptors.RemoveAt(static_cast<size_t>(pos));
                wxLogTrace(wxTRACE_FSWATCHER,
                       "Removed wd %i from the stale-wd cache", inevt.wd);
            }
            return;
        }

        // get watch entry for this event
        wxFSWatchEntryDescriptors::iterator it = m_watchMap.find(inevt.wd);
        if (it == m_watchMap.end())
        {
            // It's not in the map; check if was recently removed from it.
            if (m_staleDescriptors.Index(inevt.wd) != wxNOT_FOUND)
            {
                wxLogTrace(wxTRACE_FSWATCHER,
                           "Got an event for stale wd %i", inevt.wd);
            }
            else
            {
                wxFAIL_MSG("Event for unknown watch descriptor.");
            }

            // In any case, don't process this event: it's either for an
            // already removed entry, or for a completely unknown one.
            return;
        }

        wxFSWatchEntry& watch = *(it->second);
        int nativeFlags = inevt.mask;
        int flags = Native2WatcherFlags(nativeFlags);

        // check out for error/warning condition
        if (flags & wxFSW_EVENT_WARNING || flags & wxFSW_EVENT_ERROR)
        {
            wxString errMsg = GetErrorDescription(Watcher2NativeFlags(flags));
            wxFileSystemWatcherEvent event(flags, errMsg);
            SendEvent(event);
        }
        // filter out ignored events and those not asked for.
        // we never filter out warnings or exceptions
        else if ((flags == 0) || !(flags & watch.GetFlags()))
        {
            return;
        }

        // Creation
        // We need do something here only if the original watch was recursive;
        // we don't watch a child dir itself inside a non-tree watch.
        // We watch only dirs explicitly, so we don't want file IN_CREATEs.
        // Distinguish by whether nativeFlags contain IN_ISDIR
        else if ((nativeFlags & IN_CREATE) &&
                 (watch.GetType() == wxFSWPath_Tree) && (inevt.mask & IN_ISDIR))
        {
            wxFileName fn = GetEventPath(watch, inevt);
            // Though it's a dir, fn treats it as a file. So:
            fn.AssignDir(fn.GetFullPath());

            if (m_watcher->AddAny(fn, wxFSW_EVENT_ALL,
                                   wxFSWPath_Tree, watch.GetFilespec()))
            {
                // Tell the owner, in case it's interested
                // If there's a filespec, assume he's not
                if (watch.GetFilespec().empty())
                {
                    wxFileSystemWatcherEvent event(flags, fn, fn);
                    SendEvent(event);
                }
            }
        }

        // Deletion
        // We watch only dirs explicitly, so we don't want file IN_DELETEs.
        // We obviously can't check using DirExists() as the object has been
        // deleted; and nativeFlags here doesn't contain IN_ISDIR, even for
        // a dir. Fortunately IN_DELETE_SELF doesn't happen for files. We need
        // to do something here only inside a tree watch, or if it's the parent
        // dir that's deleted. Otherwise let the parent dir cope
        else if ((nativeFlags & IN_DELETE_SELF) &&
                    ((watch.GetType() == wxFSWPath_Dir) ||
                     (watch.GetType() == wxFSWPath_Tree)))
        {
            // We must remove the deleted directory from the map, so that
            // DoRemoveInotify() isn't called on it in the future. Don't assert
            // if the wd isn't found: repeated IN_DELETE_SELFs can occur
            wxFileName fn = GetEventPath(watch, inevt);
            wxString path(fn.GetPathWithSep());

            if (m_watchMap.erase(inevt.wd) == 1)
            {
                // Delete from wxFileSystemWatcher
                wxDynamicCast(m_watcher, wxInotifyFileSystemWatcher)->
                                            OnDirDeleted(path);

                // Now remove from our local list of watched items
                wxFSWatchEntries::iterator wit =
                                        m_watches.find(path);
                if (wit != m_watches.end())
                {
                    m_watches.erase(wit);
                }

                // Cache the wd in case any events arrive late
                m_staleDescriptors.Add(inevt.wd);
            }

            // Tell the owner, in case it's interested
            // If there's a filespec, assume he's not
            if (watch.GetFilespec().empty())
            {
                wxFileSystemWatcherEvent event(flags, fn, fn);
                SendEvent(event);
            }
        }

        // renames
        else if (nativeFlags & IN_MOVE)
        {
            wxInotifyCookies::iterator it2 = m_cookies.find(inevt.cookie);
            if ( it2 == m_cookies.end() )
            {
                int size = sizeof(inevt) + inevt.len;
                inotify_event* e = (inotify_event*) operator new (size);
                memcpy(e, &inevt, size);

                wxInotifyCookies::value_type val(e->cookie, e);
                m_cookies.insert(val);
            }
            else
            {
                inotify_event& oldinevt = *(it2->second);

                // Tell the owner, in case it's interested
                // If there's a filespec, assume he's not
                if ( watch.GetFilespec().empty() )
                {
                    wxFileSystemWatcherEvent event(flags);
                    if ( inevt.mask & IN_MOVED_FROM )
                    {
                        event.SetPath(GetEventPath(watch, inevt));
                        event.SetNewPath(GetEventPath(watch, oldinevt));
                    }
                    else
                    {
                        event.SetPath(GetEventPath(watch, oldinevt));
                        event.SetNewPath(GetEventPath(watch, inevt));
                    }
                    SendEvent(event);
                }

                m_cookies.erase(it2);
                delete &oldinevt;
            }
        }
        // every other kind of event
        else
        {
            wxFileName path = GetEventPath(watch, inevt);
            // For files, check that it matches any filespec
            if ( MatchesFilespec(path, watch.GetFilespec()) )
            {
                wxFileSystemWatcherEvent event(flags, path, path);
                SendEvent(event);
            }
        }
    }
Esempio n. 24
0
int main(int argc, char* argv[])
{
	ISmsProtocolGsm     *pGsm		= NULL;
	ISmsMessage			*pMessage   = NULL;
	ISmsDeliveryStatus	*pDeliveryStatus	= NULL;
	LPSTR				lpszMessage	= NULL;
	LPSTR				lpszPincode	= NULL;
	BSTR				bstrMessageReference = NULL;
	VARIANT				vtVar;
	HRESULT				hr;
	LONG				lLastError;
	char				*cp;
	BOOL				bRequestDeliveryReport	= FALSE;
	LONG				lDeliveryStatus = 0L, lDeliveryStatusCode = 0L;
	BSTR				bstrDeliveryStatusTime	= NULL, bstrStatusDescription = NULL;
	BOOL				bDeliveryCompleted = FALSE;

	
	CoInitialize(NULL);

	VariantInit( &vtVar );

	
	hr = CoCreateInstance(CLSID_SmsProtocolGsm, NULL, CLSCTX_INPROC_SERVER, IID_ISmsProtocolGsm, (void**) &pGsm);
	if( SUCCEEDED( hr ) )
		hr = CoCreateInstance(CLSID_SmsMessage, NULL, CLSCTX_INPROC_SERVER, IID_ISmsMessage, (void**) &pMessage );
	if( ! SUCCEEDED( hr ) )
	{
		printf( "无法创建对象\n" );
		goto _EndMain;
	}

	// 选择设备
	pGsm->put_Device( _bstr_t( "COM1" ) );

	pMessage->Clear();

	// 接收者号码
	pMessage->put_Recipient( _bstr_t( ReadInput( "输入接收者号码,号码必须以+86开头" ) ) );

	//定义短信编码方式
	pMessage->put_Format( asMESSAGEFORMAT_UNICODE_MULTIPART );


	// 短信内容
	lpszMessage = ReadInput( "输入短信内容" );
	pMessage->put_Data( _bstr_t( lpszMessage ) );

	printf( "正在发送信息...\n" );
    pGsm->Send( &_variant_t ( ( IDispatch*) pMessage ), &bstrMessageReference );
	pGsm->get_LastError( &lLastError );
	printf( "发送结果: %ld (%s)\n\n", lLastError, GetErrorDescription( lLastError, pGsm ) );

	goto _EndMain;

_EndMain:

	if( pGsm != NULL ) 
		pGsm->Release();

	if( pMessage != NULL ) 
		pMessage->Release();

	if( bstrMessageReference != NULL )
		SysFreeString( bstrMessageReference );

	CoUninitialize();

	printf("结束...\n");

	return 0;
}
Esempio n. 25
0
//++ ------------------------------------------------------------------------------------
// Details: Retrieve *this driver's last error condition.
// Type:    Overridden.
// Args:    None.
// Return:  CMIUtilString - Text description.
// Throws:  None.
//--
CMIUtilString
CMIDriver::GetError(void) const
{
    return GetErrorDescription();
}
Esempio n. 26
0
HRESULT FMPlayerDShow::InitFilters(const tchar* pFileName)
{
	USES_CONVERSION; 
	HRESULT hr = S_OK; 
	m_FrameRate = 25.0;

	if (m_VideoType == VIDEO_TYPE_MPG)
	{
		hr = m_xVid.CoCreateInstance(CLSID_CMpegVideoCodec, NULL, CLSCTX_INPROC);
		_DBGLogResult(hr, "mpg codec"); 
		m_FourCC = "mpeg1";
		//we use IMediaDet for MPEG and we determine the AVI frame rate from the AVI header.
		CComPtr<IMediaDet> iMediaDet;
		if (SUCCEEDED(iMediaDet.CoCreateInstance(CLSID_MediaDet, NULL, CLSCTX_INPROC)))
			if (SUCCEEDED(iMediaDet->put_Filename(T2OLE(pFileName))))
				iMediaDet->get_FrameRate(&m_FrameRate);
	}
	else
	{
		FString sFourCC; 
		if (GetAVIInfo(pFileName))
		{
			_DBGAlert("%s: 4CC = %s\n", pFileName, sFourCC); 
			if (m_FourCC == "x264" || m_FourCC == "h264")
			{
				hr = DSHelpCreateInstance(T2OLE(g_AppSettings.AppDir("x264.ax")), IID_ICoreAVC, NULL, IID_IBaseFilter, (void**)&m_xVid); 
				_DBGLogResult(hr, "x264.ax"); 
			}
			else
			{
				if (m_FourCC == "divx" && m_StreamFormat == "divx")
				{
					hr = DSHelpCreateInstance(T2OLE(g_AppSettings.AppDir("divxdec.ax")), IID_IDivX4, NULL, IID_IBaseFilter, (void**)&m_xVid);
					_DBGLogResult(hr, "divxdec.ax"); 	
				}
				else
				{
					hr = DSHelpCreateInstance(T2OLE(g_AppSettings.AppDir("xvid.ax")), IID_IXvidDecoder, NULL, IID_IBaseFilter, (void**)&m_xVid); 
					_DBGLogResult(hr, "xvid.ax"); 
				}
			}
		}
	}

	hr = DSHelpCreateInstance(T2OLE(g_AppSettings.AppDir("ac3filter.ax")), IID_IAC3Decoder, NULL, IID_IBaseFilter, (void**)&m_AC3Filter);
	_DBGLogResult(hr, "ac3filter.ax"); 	


	//	hr = DSHelpCreateInstance(T2OLE(g_AppSettings.AppDir("msadds32.ax")), IID_IMSAudio, NULL, IID_IBaseFilter, (void**)&m_MSAud);
	//	_DBGLogResult(hr, "msadds32.ax"); 

	hr = m_DSoundFilter.CoCreateInstance(CLSID_DSoundRender, NULL, CLSCTX_INPROC); 
	_DBGLogResult(hr, "dsoundrender"); 

	if (m_VideoType == VIDEO_TYPE_MPG)
	{
		hr = m_AviSplitter.CoCreateInstance(CLSID_MPEG1Splitter, NULL, CLSCTX_INPROC); 
		_DBGLogResult(hr, "mpg splitter"); 
	}
	else
	{
		hr = m_AviSplitter.CoCreateInstance(CLSID_AviSplitter, NULL, CLSCTX_INPROC); 
		_DBGLogResult(hr, "avisplitter"); 
	}




	//Create video renderer
	if (m_VideoRenderer == NULL)
	{
		///hr = DSHelpCreateInstance(L"quartz.dll", CLSID_VideoRendererDefault, NULL, IID_IBaseFilter, (void**)&m_VideoRenderer);
		hr = m_VideoRenderer.CoCreateInstance(CLSID_VideoRendererDefault, NULL, CLSCTX_INPROC); 
		_DBGLogResult(hr, "video renderer"); 
	}
	else
	{
		DisconnectPins(m_VideoRenderer); 
	}

	if (SUCCEEDED(hr))
	{
		CComQIPtr<IGraphBuilder> pGraphBuilder = m_FilterGraph; 

		hr |= pGraphBuilder->AddFilter(m_xVid, L"Video Decoder");
		hr |= pGraphBuilder->AddFilter(m_DSoundFilter, L"DSound Output");
		hr |= pGraphBuilder->AddFilter(m_AC3Filter, L"AC3 Audio Decoder"); 
		hr |= pGraphBuilder->AddFilter(m_AviSplitter, L"Avi Splitter");
		hr |= pGraphBuilder->AddFilter(m_VideoRenderer, L"Video Renderer"); 

		if (FAILED(hr))
		{
			_DBGAlertM("**Warning prebuilding graph: %s\n", GetErrorDescription(hr));
		}
	}
	return hr; 
}
Esempio n. 27
0
LTRESULT CLTRealConsoleMgr::GetLastErrorDescription(char* szBuffer, uint32* pSizeOfBuffer)
{
	// Let our main function do the real work...

	return(GetErrorDescription(m_hrLastError, szBuffer, pSizeOfBuffer));
}
Esempio n. 28
0
HRESULT FMPlayerDShow::LoadMedia(const tchar* pFileName, IMediaOptions* pOptions)
{
	USES_CONVERSION;

	HRESULT hr = E_FAIL; 

	if (m_FourCC == "divx" && m_StreamFormat == "divx")
	{
		Init(m_hWndParent, m_pNotify); 
	}

	if (m_FilterGraph == NULL)
		return E_FAIL;

	m_MediaControl->Stop(); 


	if (m_FileSource)
	{
		m_FilterGraph->RemoveFilter(m_FileSource);
		m_FileSource.Release();
	}
	else
	{
	/*	CComQIPtr<IGraphBuilder> pGraphBuilder = m_FilterGraph; 

		if (SUCCEEDED(pGraphBuilder->RenderFile(T2OLE(pFileName), NULL)))
		{
			hr = Start();
			return hr; 
		}
	*/
		if (SUCCEEDED(DetermineVideoType(pFileName)))
		{
			InitFilters(pFileName); 
		}
		else
		{
			_DBGAlertM("FMPlayerDShow: PlayVideo: **Unable to determine file format.\n");
			return E_FAIL;
		}
	}

	_DBGAlertM("FMPlayerDShow: Starting playback: %s; offset = %I64d\n", pFileName, pOptions->rtOffset); 

	CComQIPtr<IGraphBuilder> pGraphBuilder = m_FilterGraph; 

	hr = pGraphBuilder->AddSourceFilter(T2OLE(pFileName), T2OLE(pFileName), &m_FileSource); 

	if (SUCCEEDED(hr))
	{
		CComPtr<IPin> PinSourceOut = GetOutPin(m_FileSource, 0); 
		CComPtr<IPin> PinSplitterIn = GetInPin(m_AviSplitter, 0); 

		if (PinSourceOut && PinSplitterIn)
		{
			PinSplitterIn->Disconnect(); 
			hr = m_FilterGraph->ConnectDirect(PinSourceOut, PinSplitterIn, NULL); 
			if (FAILED(hr))
				_DBGAlertM("FMediaMgr: **Connect SourceOut to SplitterIn: %s\n", GetErrorDescription(hr)); 
		}
		else
			_DBGAlertM("FMediaMgr: **PinSourceOut or PinSourceIn is NULL\n"); 

		hr = BuildTheGraph(); 

		if (SUCCEEDED(hr))
		{
			m_FileName = pFileName; 
			m_Offset = pOptions->rtOffset;

			hr = Start(); 
			if (FAILED(hr))
				_DBGAlertM("FMPlayerDShow: **Start() failed: %s\n", GetErrorDescription(hr));
			else
			{
				SetVideoRect(m_VideoRect); 
			}
		}
		else
			_DBGAlertM("FMPlayerDShow: **Cannot Start(): %s\n", GetErrorDescription(hr)); 
	}
	else
		_DBGAlertM("FMPlayerDShow: **AddSourceFilter() failed: %s\n", GetErrorDescription(hr));

	_DBGAlertM("FMPlayerDShow: StartPlayback() exiting: %s\n", GetErrorDescription(hr)); 
	return hr; 
}
Esempio n. 29
0
    void ProcessNativeEvent(const inotify_event& inevt)
    {
        wxLogTrace(wxTRACE_FSWATCHER, InotifyEventToString(inevt));

        // after removing inotify watch we get IN_IGNORED for it, but the watch
        // will be already removed from our list at that time
        if (inevt.mask & IN_IGNORED)
        {
            return;
        }

        // get watch entry for this event
        wxFSWatchEntryDescriptors::iterator it = m_watchMap.find(inevt.wd);
        wxCHECK_RET(it != m_watchMap.end(),
                             "Watch descriptor not present in the watch map!");

        wxFSWatchEntry& watch = *(it->second);
        int nativeFlags = inevt.mask;
        int flags = Native2WatcherFlags(nativeFlags);

        // check out for error/warning condition
        if (flags & wxFSW_EVENT_WARNING || flags & wxFSW_EVENT_ERROR)
        {
            wxString errMsg = GetErrorDescription(Watcher2NativeFlags(flags));
            wxFileSystemWatcherEvent event(flags, errMsg);
            SendEvent(event);
        }
        // filter out ignored events and those not asked for.
        // we never filter out warnings or exceptions
        else if ((flags == 0) || !(flags & watch.GetFlags()))
        {
            return;
        }
        // renames
        else if (nativeFlags & IN_MOVE)
        {
            wxInotifyCookies::iterator it = m_cookies.find(inevt.cookie);
            if ( it == m_cookies.end() )
            {
                int size = sizeof(inevt) + inevt.len;
                inotify_event* e = (inotify_event*) operator new (size);
                memcpy(e, &inevt, size);

                wxInotifyCookies::value_type val(e->cookie, e);
                m_cookies.insert(val);
            }
            else
            {
                inotify_event& oldinevt = *(it->second);

                wxFileSystemWatcherEvent event(flags);
                if ( inevt.mask & IN_MOVED_FROM )
                {
                    event.SetPath(GetEventPath(watch, inevt));
                    event.SetNewPath(GetEventPath(watch, oldinevt));
                }
                else
                {
                    event.SetPath(GetEventPath(watch, oldinevt));
                    event.SetNewPath(GetEventPath(watch, inevt));
                }
                SendEvent(event);

                m_cookies.erase(it);
                delete &oldinevt;
            }
        }
        // every other kind of event
        else
        {
            wxFileName path = GetEventPath(watch, inevt);
            wxFileSystemWatcherEvent event(flags, path, path);
            SendEvent(event);
        }
    }
Esempio n. 30
0
int main(int argc, char* argv[])
{
	IMmsProtocolMm1     *pMm1Protocol		= NULL;
	IMmsSlide			*pSlide	    = NULL;
	IMmsMessage			*pMessage   = NULL;
	LPSTR				lpszPincode	= NULL;
	HRESULT				hr;
	LONG				lLastError;

	 
	CoInitialize(NULL);
	
	hr = CoCreateInstance(CLSID_MmsProtocolMm1, NULL, CLSCTX_INPROC_SERVER, IID_IMmsProtocolMm1, (void**) &pMm1Protocol);
	if( SUCCEEDED( hr ) )
		hr = CoCreateInstance(CLSID_MmsSlide, NULL, CLSCTX_INPROC_SERVER, IID_IMmsSlide, (void**) &pSlide );
	if( SUCCEEDED( hr ) )
		hr = CoCreateInstance(CLSID_MmsMessage, NULL, CLSCTX_INPROC_SERVER, IID_IMmsMessage, (void**) &pMessage );
	if( ! SUCCEEDED( hr ) )
	{
		printf( "无法创建对象.\n" );
		goto _EndMain;
	}

	pSlide->Clear();

	// 增加幻灯片中的图片和文本
	pSlide->AddAttachment( _bstr_t( "test.jpg" ) );
	pSlide->AddText( _bstr_t( "这里可以输入文本信息" ) );

	pMessage->Clear();

	// 接收者号码
	pMessage->AddRecipient( _bstr_t( ReadInput( "输入接收者号码(号码必须以'+86'开头)" ) ), asMMS_RECIPIENT_TO  );
	
	// 彩信主题
	pMessage->put_Subject( _bstr_t("此处为彩信主题")  );

	// 增加幻灯片
	pMessage->AddSlide( &_variant_t ( ( IDispatch*) pSlide ) );

	pMm1Protocol->Clear();

	// 选择发送设备
	pMm1Protocol->put_Device( _bstr_t( "标准 33600 bps 调制解调器" ) );

	// 中国移动彩信发送配置
	pMm1Protocol->put_ProviderMMSC( _bstr_t("http://mmsc.monternet.com") );
	pMm1Protocol->put_ProviderAPN( _bstr_t( "cmwap" ) );
    pMm1Protocol->put_ProviderAPNAccount( _bstr_t( "") );
	pMm1Protocol->put_ProviderAPNPassword( _bstr_t( "") );
	pMm1Protocol->put_ProviderWAPGateway( _bstr_t( "10.0.0.172" ) );

    /* 中国移动彩信发送配置
	pMm1Protocol->put_ProviderMMSC( _bstr_t( "http://mmsc.myuni.com.cn" ) );
	pMm1Protocol->put_ProviderAPN( _bstr_t( "UNIWAP" ) );
    pMm1Protocol->put_ProviderAPNAccount( _bstr_t( "") );
	pMm1Protocol->put_ProviderAPNPassword( _bstr_t( "") );
	pMm1Protocol->put_ProviderWAPGateway( _bstr_t( "10.0.0.172" ) );
	*/


	// 连接gprs网络
	printf( "正在拨号gprs网络...\n" );
	pMm1Protocol->Connect();
	pMm1Protocol->get_LastError( &lLastError );
	printf( "结果: %ld (%s)\n\n", lLastError, GetErrorDescription( lLastError, pMm1Protocol ) );
	if( lLastError != 0L )
		goto _EndMain;

	// 发送彩信
	printf( "正在发送...\n" );
	pMm1Protocol->Send( &_variant_t ( ( IDispatch*) pMessage ) );
	pMm1Protocol->get_LastError( &lLastError );
	printf( "结果: %ld (%s)\n\n", lLastError, GetErrorDescription( lLastError, pMm1Protocol ) );


_EndMain:

	if( pMm1Protocol != NULL ) 
	{
		pMm1Protocol->Disconnect();
		pMm1Protocol->Release();
	}

	if( pMessage != NULL ) 
		pMessage->Release();

	if( pSlide != NULL ) 
		pSlide->Release();

	CoUninitialize();

	printf("结束.......\n");

	return 0;
}