Exemplo n.º 1
0
bool CreateListenSocket()
{
	int retval;
	
	g_listenSock = socket(AF_INET, SOCK_STREAM, 0);
	if(g_listenSock == INVALID_SOCKET)
	{
		DisplayMessage();	return false;
	}
	
	SOCKADDR_IN serveraddr;
	ZeroMemory(&serveraddr, sizeof(serveraddr));
	serveraddr.sin_family = AF_INET;
	serveraddr.sin_port = htons(40100);
	serveraddr.sin_addr.s_addr = htonl(INADDR_ANY);
	retval = bind(g_listenSock, (SOCKADDR*)&serveraddr, sizeof(serveraddr));
	if(retval == SOCKET_ERROR)
	{
		DisplayMessage();
		return false;
	}
	retval = listen(g_listenSock,SOMAXCONN);
	if(retval == SOCKET_ERROR)
	{
		DisplayMessage();
		return false;
	}
	return true;
}
Exemplo n.º 2
0
Arquivo: iff.cpp Projeto: Scraft/avpmp
				~AllocList()
				{
					#ifdef _CPPRTTI // this works in MSVC 5.0 - ie. the macro is defined if RTTI is turned on
						// but there appears to be no preprocessor way of determining if RTTI is turned on under Watcom
						// No, I think it works in Watcom too, actually...
						#pragma message("Run-Time Type Identification (RTTI) is enabled")
						for (Iterator itLeak(*this) ; !itLeak.Done() ; itLeak.Next())
						{
							TCHAR buf[256];
							::wsprintf(buf,TEXT("Object not deallocated:\nType: %s\nRefCnt: %u"),typeid(*itLeak.Get()).name(),itLeak.Get()->m_nRefCnt);
							DisplayMessage(TEXT("Memory Leak!"),buf);
						}
					#else // ! _CPPRTTI
						unsigned nRefs(0);
						for (Iterator itLeak(*this) ; !itLeak.Done() ; itLeak.Next())
						{
							nRefs += itLeak.Get()->m_nRefCnt;
						}
						if (Size())
						{
							char buf[256];
							::sprintf(buf,"Objects not deallocated:\nNumber of Objects: %u\nNumber of References: %u",Size(),nRefs);
							DisplayMessage("Memory Leaks!",buf);
						}
					#endif // ! _CPPRTTI
					g_bAllocListActive = false;
				}
Exemplo n.º 3
0
bool CreateListenSocket()
{
	int retval;
	
	g_ServerSocket = socket(AF_INET, SOCK_STREAM, 0);
	if(g_ServerSocket == INVALID_SOCKET)
	{
		DisplayMessage();	return false;
	}
	SOCKADDR_IN serveraddr;
	ZeroMemory(&serveraddr, sizeof(serveraddr));
	serveraddr.sin_family = AF_INET;
	serveraddr.sin_port = htons(40100);
	serveraddr.sin_addr.s_addr = htonl(INADDR_ANY);
	retval = bind(g_ServerSocket, (SOCKADDR*)&serveraddr, sizeof(serveraddr));
	if(retval == SOCKET_ERROR)
	{
		DisplayMessage();
		return false;
	}
	retval = listen(g_ServerSocket,SOMAXCONN);
	if(retval == SOCKET_ERROR)
	{
		DisplayMessage();
		return false;
	}
	HANDLE hEvent = WSACreateEvent();
	WSAEventSelect( g_ServerSocket, hEvent, FD_ACCEPT | FD_CLOSE);
	EventList[0] = hEvent;
	g_SockCnt++;
	return true;
}
Exemplo n.º 4
0
bool gameInstance::ResourceLoader()
{
    std::ifstream resources[3]; //Otwieramy wszystkie pliki cfg zawierajace dane o obiektach gry
    resources[0].open("game/sounds.cfg");
    resources[1].open("game/units.cfg");
    resources[2].open("game/objs.cfg");

    if(!resources[0].good()) { DisplayMessage("Blad!","Nie mozna otworzyc pliku sounds.cfg!"); return false; } //Sprawdzamy czy
    if(!resources[1].good()) { DisplayMessage("Blad!","Nie mozna otworzyc pliku units.cfg!"); return false; } //listy sa dostepne
    if(!resources[2].good()) { DisplayMessage("Blad!","Nie mozna otworzyc pliku objs.cfg!"); return false; } // do wczytania

    std::string line;

    for(int i=0;i<3;i++)
    {
        while(!resources[i].eof()) //Wczytujemy po kolei ka¿dy z plików do odpowiedniej listy
        {
            getline(resources[i],line);
            if(line=="[UNIT]")
            {
                std::string name,file,sound_movement,sound_attack,sound_death;
                int HP,attack,defence;
                resources[i]>>line; //Sprawdzamy czy dany wpis w pliku cfg istnieje i czy jest na odpowiedniej pozycji
                if(line=="[NAME]") resources[i] >> name; else  continue;  //wczytujemy dane, albo przerywamy je¿eli s¹ niepoprawne
                resources[i] >> line;
                if(line=="[BITMAP]") resources[i] >> file; else continue;
                resources[i] >> line;
                if(line=="[HP]") resources[i] >> HP;  else continue;
Exemplo n.º 5
0
/*
 * GroupPrint:  Display the members of the group with the given name.
 */
void GroupPrint(char *group_name)
{
   UserGroup g;
   int i, index;
   COLORREF color;
   BYTE style;
   ID id;
   char buf[MAX_CHARNAME + 10];

   index = FindGroupByName(group_name);
   switch (index)
   {
   case GROUP_NOMATCH:
      GameMessage(GetString(hInst, IDS_BADGROUPNAME));
      break;
      
   case GROUP_AMBIGUOUS:
      GameMessage(GetString(hInst, IDS_DUPLICATEGROUPNAME));
      break;

   default:
      group_name = groups[index];
      GroupLoad(group_name, &g);

      GameMessagePrintf(GetString(hInst, IDS_GROUPMEMBERS), MAX_GROUPNAME, group_name);

      color = RGB(0, 0, 0);
      style = STYLE_NORMAL;
      EditBoxStartAdd();
      for (i=0; i < g.num_users; i++)
      {
	 if (i != 0)
	    DisplayMessage(", ", color, style);
	 id = FindPlayerByNameExact(g.names[i]);
	 
	 // Show player in red if logged on
	 if (id == 0 || id == INVALID_ID)
	    DisplayMessage(g.names[i], color, style);
	 else
	 {
	    sprintf(buf, "~r%s~n", g.names[i]);
	    DisplayMessage(buf, color, style);
	 }
      }
      EditBoxEndAdd();
      break;
   }
}
/* #FN#
   Reads a keyboard template from a given file */
BOOL
/* #AS#
   TRUE if succeeded, otherwise FALSE */
CKeyboardDlg::
PrepareTemplate(
	LPSTR pszTemplateFile,
	LPSTR pszTemplateDesc,
	BOOL  bCheckIfExists /*=TRUE*/
)
{
	BOOL bResult = FALSE;

	if( _IsPathAvailable( pszTemplateFile ) )
	{
		CFileStatus fsStatus;

		if( !bCheckIfExists || CFile::GetStatus( pszTemplateFile, fsStatus ) )
		{
			if( !CKeyTemplateDlg::ReadKeyTemplate( pszTemplateFile, pszTemplateDesc, s_anKBTable, GetSafeHwnd() ) )
			{
				DisplayMessage( GetSafeHwnd(), IDS_ERROR_A8K_LOAD, 0, MB_ICONEXCLAMATION | MB_OK );
				strcpy( pszTemplateFile, FILE_NONE );
			}
			else
				bResult = TRUE;
		}
	}
	/* Clear the template description */
	if( !bResult )
		*pszTemplateDesc = '\0';

	return bResult;

} /* #OF# CKeyboardDlg::PrepareTemplate */
Exemplo n.º 7
0
void MovieToggleReadOnly(void) {

	if(Movie.Status == Playback) {

		if(Movie.ReadOnly == 1) 
		{
			Movie.ReadOnly=0;
			DisplayMessage("Movie is now read+write.");
		}
		else 
		{
			Movie.ReadOnly=1;
			DisplayMessage("Movie is now read only.");
		}
	}
}
Exemplo n.º 8
0
logical cClassCode :: ExecuteFunction (char *fname, logical chk_opt )
{
  char     actname[ID_SIZE];
  cfte    *cfteptr;
  logical  term      = NO;
BEGINSEQ
  static cfte acttbl[] = { 
                           cfte("InsertCheckError",ALINK(this,cClassCode,InsertCheckError)),
                           cfte("InsertError",ALINK(this,cClassCode,InsertError)),
                           cfte("InsertErrorNum",ALINK(this,cClassCode,InsertErrorNum)),
                           cfte("InsertLeaveseq",ALINK(this,cClassCode,InsertLeaveseq)),
                           cfte("InsertProjError",ALINK(this,cClassCode,InsertProjError)),
                         };
  static srt  cftesrt(sizeof(acttbl)/CFTE,CFTE,UNDEF,UNDEF,UNDEF,(char *)acttbl,NO);

  if ( !cftesrt.srtkln() )
    cftesrt.srtsor(CFTE_KPS,CFTE_KLN,CFTE_KTP);

  if ( cfteptr = (cfte *)cftesrt.srtigt(cftesrt.srtssr(gvtxstb(actname,fname,ID_SIZE))) )
  {
    if ( chk_opt )                                   LEAVESEQ
    term = cfteptr->ActionCall(this);
  }
  else
    term = cClassCodeBase::ExecuteFunction(fname,chk_opt);
  
  if ( term && !chk_opt )
    DisplayMessage();
ENDSEQ
  return(term);
}
Exemplo n.º 9
0
Win32FileContents ReadEntireFile(const char * Filename){
	HANDLE File = CreateFileA(Filename, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0);

	if (File == INVALID_HANDLE_VALUE) {
		return{ 0, 0 };
	}

	LARGE_INTEGER Size;
	GetFileSizeEx(File, &Size);

	Win32FileContents FileContents = {};

	FileContents.Size = Size.QuadPart;
	FileContents.Data = (unsigned char *)VirtualAlloc(0, Size.LowPart, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);

	DWORD BytesRead;
	ReadFile(File, FileContents.Data, Size.LowPart, &BytesRead, 0);


	if (BytesRead != Size.LowPart) {
		DisplayMessage(GetLastError());
		//TODO: Logging, errors etc
	}

	return FileContents;
};
Exemplo n.º 10
0
bool AddClient(int index)
{
	SOCKET ClientSocket;
	SOCKADDR_IN sockaddr;
	int addrlen = sizeof(sockaddr);
	ClientSocket = accept(SockList[index], (SOCKADDR*)&sockaddr, &addrlen);
	if(ClientSocket == SOCKET_ERROR)
	{
		DisplayMessage();	return false;
	}
	
	// 이벤트 등록
	WSAEVENT hClientEvent = WSACreateEvent();
	WSAEventSelect(ClientSocket, hClientEvent, FD_WRITE | FD_READ | FD_CLOSE);
	// 전역변수에 저장
	SockList[g_SockCnt] = ClientSocket;
	EventList[g_SockCnt] = hClientEvent;
	g_SockCnt++;
	// 접속메세지 전송
	char buf[BUFFERSIZE];
	int retByte = sprintf(buf, "\n[TCP 서버] 클라이언트 접속: IP주소=%s, 포트 번호=%d\n",
		inet_ntoa(sockaddr.sin_addr), ntohs(sockaddr.sin_port));
	SendAll(0, buf, retByte);

	return true;

}
Exemplo n.º 11
0
void __cdecl
Message(
    UINT MsgNumber,
    ...
    )

/*++

Routine Description:

    Prints a user message.

Arguments:

    MsgNumber - Internal code on message.

Return Value:

    None.

--*/

{
    va_list valist;

    va_start(valist, MsgNumber);

    DisplayMessage(NULL, MSGSTR, MsgNumber, valist);

    va_end(valist);
}
Exemplo n.º 12
0
void __cdecl
Warning(
    const char *szFilename,
    UINT WarningNumber,
    ...
    )

/*++

Routine Description:

    Prints a warning message.

Arguments:

    Filename - File which caused the warning.

    WarningNumber - Internal error code.

Return Value:

    None.

--*/

{
    va_list valist;

    va_start(valist, WarningNumber);

    DisplayMessage(szFilename, WARNSTR, WarningNumber, valist);

    va_end(valist);
}
Exemplo n.º 13
0
void __cdecl
PostNote(
    const char *szFilename,
    UINT NoteNumber,
    ...
    )

/*++

Routine Description:

    Prints a note user.

Arguments:

    szFilename - File which caused the warning.

    NoteNumber - Internal code on note.

Return Value:

    None.

--*/

{
    va_list valist;

    va_start(valist, NoteNumber);

    DisplayMessage(szFilename, NOTESTR, NoteNumber, valist);

    va_end(valist);
}
Exemplo n.º 14
0
logical pKFZVS :: ExecuteFunction (char *fname, logical chk_opt )
{
  char     actname[ID_SIZE];
  cfte    *cfteptr;
  logical  term      = NO;
BEGINSEQ
  static cfte acttbl[] = { 
                           cfte("GetSparte",ALINK(this,pKFZVS,GetSparte)),
                         };
  static srt  cftesrt(sizeof(acttbl)/CFTE,CFTE,UNDEF,UNDEF,UNDEF,(char *)acttbl,NO);

  if ( !cftesrt.srtkln() )
    cftesrt.srtsor(CFTE_KPS,CFTE_KLN,CFTE_KTP);

  if ( cfteptr = (cfte *)cftesrt.srtigt(cftesrt.srtssr(gvtxstb(actname,fname,ID_SIZE))) )
  {
    if ( chk_opt )                                   LEAVESEQ
    cfteptr->LINKINST(this);
    term = cfteptr->ActionCall();
  }
  else
    term = pVS_base::ExecuteFunction(fname,chk_opt);
  
  if ( term && !chk_opt )
    DisplayMessage();
ENDSEQ
  return(term);
}
Exemplo n.º 15
0
int main(void)
{
	InitHardware();
	dmInit();
	sei();									// enable interrupts

	GoToSleep();
	button |= PB_ACK;

	while(1)
	{
		if (button == PB_RELEASE) {			// short button press
			msg_ptr = DisplayMessage(msg_ptr);
			button |= PB_ACK;
		}
		
		if (button == PB_LONGPRESS) {		// button pressed for some seconds
			dmClearDisplay();
			dmPrintChar(130);				// sad smiley
			_delay_ms(500);
			GoToSleep();
			button |= PB_ACK;
		}
		
	} // of while(1)
}
logical cMainFunctionEdit :: ExecuteFunction (char *fname, logical chk_opt )
{
  char     actname[ID_SIZE];
  cfte    *cfteptr;
  logical  term      = NO;
BEGINSEQ
  static cfte acttbl[] = { 
                           cfte("Compile",ALINK(this,cMainFunctionEdit,Compile)),
                           cfte("ErrorLookup",ALINK(this,cMainFunctionEdit,ErrorLookup)),
                           cfte("Link",ALINK(this,cMainFunctionEdit,Link)),
                         };
  static srt  cftesrt(sizeof(acttbl)/CFTE,CFTE,UNDEF,UNDEF,UNDEF,(char *)acttbl,NO);

  if ( !cftesrt.srtkln() )
    cftesrt.srtsor(CFTE_KPS,CFTE_KLN,CFTE_KTP);

  if ( cfteptr = (cfte *)cftesrt.srtigt(cftesrt.srtssr(gvtxstb(actname,fname,ID_SIZE))) )
  {
    if ( chk_opt )                                   LEAVESEQ
    term = cfteptr->ActionCall(this);
  }
  else
    term = CTX_Control::ExecuteFunction(fname,chk_opt);
  
  if ( term && !chk_opt )
    DisplayMessage();
ENDSEQ
  return(term);
}
Exemplo n.º 17
0
Arquivo: cpu.c Projeto: staring/RosFE
VOID EmulatorException(BYTE ExceptionNumber, LPWORD Stack)
{
    WORD CodeSegment, InstructionPointer;
    PBYTE Opcode;

    ASSERT(ExceptionNumber < 8);

    /* Get the CS:IP */
    InstructionPointer = Stack[STACK_IP];
    CodeSegment = Stack[STACK_CS];
    Opcode = (PBYTE)SEG_OFF_TO_PTR(CodeSegment, InstructionPointer);

    /* Display a message to the user */
    DisplayMessage(L"Exception: %s occured at %04X:%04X\n"
                   L"Opcode: %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X",
                   ExceptionName[ExceptionNumber],
                   CodeSegment,
                   InstructionPointer,
                   Opcode[0],
                   Opcode[1],
                   Opcode[2],
                   Opcode[3],
                   Opcode[4],
                   Opcode[5],
                   Opcode[6],
                   Opcode[7],
                   Opcode[8],
                   Opcode[9]);

    /* Stop the VDM */
    EmulatorTerminate();
    return;
}
logical cClassCodeBase :: ExecuteFunction (char *fname, logical chk_opt )
{
  char     actname[ID_SIZE];
  cfte    *cfteptr;
  logical  term      = NO;
BEGINSEQ
  static cfte acttbl[] = { 
                           cfte("DeleteLine",ALINK(this,cClassCodeBase,DeleteLine)),
                           cfte("FindBalancedPar",ALINK(this,cClassCodeBase,FindBalancedPar)),
                           cfte("GetClassName",ALINK(this,cClassCodeBase,GetClassName)),
                           cfte("GetCurrentOffset",ALINK(this,cClassCodeBase,GetCurrentOffset)),
                           cfte("InsertBlock",ALINK(this,cClassCodeBase,InsertBlock)),
                           cfte("InsertExpression",ALINK(this,cClassCodeBase,InsertExpression)),
                           cfte("InsertSwitch",ALINK(this,cClassCodeBase,InsertSwitch)),
                         };
  static srt  cftesrt(sizeof(acttbl)/CFTE,CFTE,UNDEF,UNDEF,UNDEF,(char *)acttbl,NO);

  if ( !cftesrt.srtkln() )
    cftesrt.srtsor(CFTE_KPS,CFTE_KLN,CFTE_KTP);

  if ( cfteptr = (cfte *)cftesrt.srtigt(cftesrt.srtssr(gvtxstb(actname,fname,ID_SIZE))) )
  {
    if ( chk_opt )                                   LEAVESEQ
    term = cfteptr->ActionCall(this);
  }
  else
    term = cNotifyHighContext::ExecuteFunction(fname,chk_opt);
  
  if ( term && !chk_opt )
    DisplayMessage();
ENDSEQ
  return(term);
}
Exemplo n.º 19
0
void ExamplesMainInit()
{
#ifdef EXAMPLE_DEBUG_ONLY
    // Test for Debug only examples
#ifndef IW_DEBUG
    DisplayMessage("This example is designed to run from a Debug build. Please build the example in Debug mode and run it again.");
    return 0;
#endif
#endif

    IwGxInit();

    //IwResManagerInit();
    //IwGxFontInit();

    // Set screen clear colour
    IwGxSetColClear(0xff, 0xff, 0xff, 0xff); // white background
    IwGxPrintSetColour(0, 0, 0);             // black font

    // Determine if the device has a keyboard
    if (s3eKeyboardGetInt(S3E_KEYBOARD_HAS_KEYPAD) || s3eKeyboardGetInt(S3E_KEYBOARD_HAS_ALPHA))
        g_DeviceHasKeyboard = true;

    // User code init
    ExampleInit();
}
Exemplo n.º 20
0
//---------------------------------------------------------------------
// Display an error box for a given return value.
//
// Since these may be classes or integers, it needs
// to account for both and dump as much information
// as possible.
// \param resultCode - result code to display info from
void CATApp::DisplayError(const CATResult& resultCode, CATWindow* wnd)
{
    if (resultCode == CAT_SUCCESS)
        return;

    CATString errorString = gApp->GetString(resultCode);

    // If the result strings are a class, provide additional
    // information
#ifdef CAT_RESULT_AS_CLASS
    CATString additionalInfo = resultCode.GetDescription();
    if (additionalInfo.IsEmpty() == false)
    {
        errorString << kCRLF << additionalInfo;
    }
    additionalInfo = resultCode.GetFileError();
    if (additionalInfo.IsEmpty() == false)
    {
        errorString << kCRLF << "File: " << additionalInfo;
    }

    errorString << kCRLF << "Source: " << resultCode.GetFilename() << " ( Line " << resultCode.GetLineNumber() << " )";

#endif

    DisplayMessage(errorString,wnd);   
}
Exemplo n.º 21
0
logical sODC_Project :: ExecuteFunction (char *fname, logical chk_opt )
{
  char     actname[ID_SIZE];
  cfte    *cfteptr;
  logical  term      = NO;
BEGINSEQ
  static cfte acttbl[] = { 
                           cfte("GenerateCompile",ALINK(this,sODC_Project,GenerateCompile)),
                           cfte("GetCompileCommand",ALINK(this,sODC_Project,GetCompileCommand)),
                           cfte("GetLinkCommand",ALINK(this,sODC_Project,GetLinkCommand)),
                           cfte("GetProjectPath",ALINK(this,sODC_Project,GetProjectPath)),
                           cfte("InitializeExternalResources",ALINK(this,sODC_Project,InitializeExternalResources)),
                           cfte("SetupReferences",ALINK(this,sODC_Project,SetupReferences)),
                         };
  static srt  cftesrt(sizeof(acttbl)/CFTE,CFTE,UNDEF,UNDEF,UNDEF,(char *)acttbl,NO);

  if ( !cftesrt.srtkln() )
    cftesrt.srtsor(CFTE_KPS,CFTE_KLN,CFTE_KTP);

  if ( cfteptr = (cfte *)cftesrt.srtigt(cftesrt.srtssr(gvtxstb(actname,fname,ID_SIZE))) )
  {
    if ( chk_opt )                                   LEAVESEQ
    term = cfteptr->ActionCall(this);
  }
  else
    term = CTX_Structure::ExecuteFunction(fname,chk_opt);
  
  if ( term && !chk_opt )
    DisplayMessage();
ENDSEQ
  return(term);
}
Exemplo n.º 22
0
//-----------------------------------------------------------------------------
// Main global function
//-----------------------------------------------------------------------------
int main()
{
#ifdef EXAMPLE_DEBUG_ONLY
    // Test for Debug only examples
#ifndef IW_DEBUG
    DisplayMessage("This example is designed to run from a Debug build. Please build the example in Debug mode and run it again.");
    return 0;
#endif
#endif

    //IwGx can be initialised in a number of different configurations to help the linker eliminate unused code.
    //Normally, using IwGxInit() is sufficient.
    //To only include some configurations, see the documentation for IwGxInit_Base(), IwGxInit_GLRender() etc.
    IwGxInit();

    // Example main loop
    ExampleInit();

    // Set screen clear colour
    IwGxSetColClear(0xff, 0xff, 0xff, 0xff);
    IwGxPrintSetColour(128, 128, 128);
    
    while (1)
    {
        s3eDeviceYield(0);
        s3eKeyboardUpdate();
        s3ePointerUpdate();

        int64 start = s3eTimerGetMs();

        bool result = ExampleUpdate();
        if  (
            (result == false) ||
            (s3eKeyboardGetState(s3eKeyEsc) & S3E_KEY_STATE_DOWN) ||
            (s3eKeyboardGetState(s3eKeyAbsBSK) & S3E_KEY_STATE_DOWN) ||
            (s3eDeviceCheckQuitRequest())
            )
            break;

        // Clear the screen
        IwGxClear(IW_GX_COLOUR_BUFFER_F | IW_GX_DEPTH_BUFFER_F);
        RenderButtons();
        RenderSoftkeys();
        ExampleRender();

        // Attempt frame rate
        while ((s3eTimerGetMs() - start) < MS_PER_FRAME)
        {
            int32 yield = (int32) (MS_PER_FRAME - (s3eTimerGetMs() - start));
            if (yield<0)
                break;
            s3eDeviceYield(yield);
        }
    }
    ExampleShutDown();
    DeleteButtons();
    IwGxTerminate();
    return 0;
}
Exemplo n.º 23
0
/*
 * DisplayServerMessage:  Display message from server, extracting any style or color codes.
 *   color and style give default style and color values.
 */
void DisplayServerMessage(char *message, COLORREF start_color, BYTE start_style)
{
   EditBoxStartAdd();

   DisplayMessage(message, start_color, start_style);
   
   EditBoxEndAdd();
}
Exemplo n.º 24
0
unsigned int WINAPI ComThread(void* pParam)
{
	SOCKET clientsock = (SOCKET) pParam;
	SOCKADDR_IN clientaddr;
	int recvByte;
	char buf[BUFFERSIZE];
	while(1)
	{
		recvByte = recv(clientsock, buf, sizeof(buf), 0);
		if(recvByte == SOCKET_ERROR)
		{
			DisplayMessage();	break;
		}
		else if(recvByte == 0)
		{
			DisplayMessage();	break;
		}
		else
		{
			int addrlen = sizeof(clientaddr);
			int retval = getpeername(clientsock, (SOCKADDR*)&clientaddr, &addrlen);
			if(retval == SOCKET_ERROR)
			{
				DisplayMessage();	continue;
			}
			buf[recvByte] = '\0';
			printf("[TCP 서버] IP: %s, Port=%d의 메시지:%s\n",
				inet_ntoa(clientaddr.sin_addr),
				ntohs(clientaddr.sin_port),
				buf);
			retval = send(clientsock, buf, recvByte, 0);
			if(retval == SOCKET_ERROR)
			{
				DisplayMessage();
				break;
			}
			
		}
	}
	closesocket(clientsock);
	printf("\n[TCP 서버] 클라이언트 종료: IP주소=%s,포트번호=%d",
		inet_ntoa(clientaddr.sin_addr),
		ntohs(clientaddr.sin_port));
	return 0;
}
Exemplo n.º 25
0
bool rr::CheckQValueBeforeStart()
{
    if(!l.empty())
    {
        qSort(l.begin(),l.end());
        if(iTimeQuantum == 0)
        {
            DisplayMessage(QVALUE_ZERO);
            return false;
        }
        else if(iTimeQuantum > l.first())
        {
            DisplayMessage(QVALUE_OUT_RANGE);
            return false;
        }
        return true;
    }
}
Exemplo n.º 26
0
short MoreForm :: Init()
{
	if (ip->name.Length() == 0)
		DisplayMessage("Please enter some info about yourself");

	SetValError(0);
   	(ThisThread->HelpInstance())->SetActiveWindow(this);
	return 0;
}
Exemplo n.º 27
0
int HandleCommand ( WORD index )
{
	char   sMsg[80];

	if (index > 0x100 && index < 0x200)
	{
		switch(index)
		{
			case 0x101:
				DisplayMessage("Start all tasks just now ...");
				StartAllTasks();   break;
			case 0x102:
				DisplayMessage("Stop all tasks just now ...");
				StopAllTasks();    break;
		}
	}
	else if (index > 0x00 && index <= 0x0a)
	{
		if (sRunning[index - 1])
		{
			sprintf(sMsg, "Suspend task%d just now ...", index);
			DisplayMessage(sMsg);
			OSTaskSuspend(index);
			sRunning[index - 1] = 0x00;
		}
		else
		{
			sprintf(sMsg, "Resume task%d just now ...", index);
			DisplayMessage(sMsg);
			OSTaskResume(index);
			sRunning[index - 1] = 0x01;
		}
	}
	else if (index > 0x200)
	{
		if (index == 0x201)
			DoHelp();
		else if (index == 0x202)
			DoAbout();

	}

	return 0x00;
}
Exemplo n.º 28
0
int main(int argc, char* argv[])
{
	WSADATA wsa;
	if(WSAStartup(MAKEWORD(2, 2), &wsa) != 0)
	{
		printf("윈도우 소켓 초기화 실패! \n");
		return -1;
	}

	// (socket + bind + listen)
	if(!CreateListenSocket())
	{
		printf("대기 소켓 생성 실패\n");
		return -1;
	}

	// 서버처리
	//===================================================
	int index = 0;
	WSANETWORKEVENTS neEvents;
	
	while(1)
	{
		// 이벤트 시그널 감지
		index = WSAWaitForMultipleEvents(g_SockCnt, EventList,
			FALSE, WSA_INFINITE, FALSE);
		index -= WSA_WAIT_EVENT_0;
		// 이벤트 내용 가져오기 + EventList[index] 이벤트를 넌시그날로 변경
		WSAEnumNetworkEvents( SockList[index], EventList[index], &neEvents);
		if(neEvents.lNetworkEvents & FD_ACCEPT)
		{
			EVENTERRORCHECK(neEvents, FD_ACCEPT_BIT);
			if(AddClient(index) != true)
				continue;
		}
		else if(neEvents.lNetworkEvents & FD_READ || neEvents.lNetworkEvents & FD_WRITE)
		{
			if(neEvents.iErrorCode[FD_READ_BIT] != 0 && neEvents.iErrorCode[FD_WRITE_BIT] != 0)
			{
				DisplayMessage();
				return -1;
			}
			RecvClient(index);
			
		}
		else if(neEvents.lNetworkEvents & FD_CLOSE)
		{
			EVENTERRORCHECK(neEvents, FD_CLOSE_BIT);
				DeleteClient(index);
		}
	}
	//===================================================

	WSACleanup();
	return 0;
}
bool CESTrackFunctions::OnCompileCommand(const char* sCommandLine)
{
	if (!strcmp(sCommandLine, ".fpt"))
	{
		CleanFlightPlan();
		return true;
	}
	if (!strcmp(sCommandLine, ".autodrop"))
	{
		autoDrop = (autoDrop == 1 ? 0 : 1);
		SaveDataToSettings(SETTING_AUTODROP, "Drop Track for landing AC", (autoDrop == 1 ? "1" : "0"));
		if (autoDrop == 1)
			DisplayMessage("AutoDrop ON", "Info");
		else
			DisplayMessage("AutoDrop OFF", "Info");
		return true;
	}
	return false;
}
//
// rhp: Right now, this is the same as simple DisplayMessage, but it will change
// to support print rendering.
//
NS_IMETHODIMP MailEwsMsgMessageService::DisplayMessageForPrinting(const char *aMessageURI,
                                                                  nsISupports *aDisplayConsumer,  
                                                                  nsIMsgWindow *aMsgWindow,
                                                                  nsIUrlListener *aUrlListener,
                                                                  nsIURI **aURL) 
{
  mPrintingOperation = true;
  nsresult rv = DisplayMessage(aMessageURI, aDisplayConsumer, aMsgWindow, aUrlListener, nullptr, aURL);
  mPrintingOperation = false;
  return rv;
}