Exemple #1
0
DWORD WINAPI    GUI_InitIPC (BYTE GUIAdmInstance)
{
  char      _route_name[10];
  DWORD     _listener_id;
  HANDLE    _thread_handle;

  // RouterInit
  if ( ! RouterInit () )
  {
    return DB_ERROR_COMMINIT;
  }

  // Get Route id's
  sprintf (_route_name, "GUIADM%03d", GUIAdmInstance);
  if ( ! CreateConnection (_route_name, &GUIAdmRouteId) )
  {
    return DB_ERROR_COMMINIT;
  }

  // TJG  07-12-1999 : To avoid lossing of messages, the route thar receives from DBService
  //                   will hold 64Ks instead of 6Ks (default from RouterLayer)
  if ( ! SetInputBufferSize (GUIAdmRouteId, GUI_RECV_ROUTE_SOCKET_SIZE) )
  {
    return DB_ERROR_COMMINIT;
  }

  if ( ! GetConnection ("DBGUI000", &DBGUIRouteId) )
  {
    return DB_ERROR_COMMINIT;
  }

  if ( ! GetConnection ("LOGGER000", &LogRouteId) )
  {
    return DB_ERROR_COMMINIT;
  }

  // Start GUI listener thread
  //
  // NOTE: This GUI_Listener conflicts with old draw mechanism,
  //       that is, synchronous messaging between  Draw screen
  //       and DBService.
  //       When GUI_Listener is working, results must be received
  //       through an OCX control to update data.
  //
  _thread_handle = CreateThread ((LPSECURITY_ATTRIBUTES) NULL,
                                 0,
                                 (LPTHREAD_START_ROUTINE) GUI_Listener,
                                 (LPVOID) NULL,
                                 0,
                                 (LPDWORD) &_listener_id);
  if ( _thread_handle == NULL ) 
  {
    return DB_ERROR_COMMINIT;
  }

  return DB_SUCCESS;
}
Exemple #2
0
/*	ExecuteVDT2()

	ExecuteVDT2 is called when the user invokes the VDT2 operation from the command line.
	
	VDT2 applies to the port specified by the /P=<port> flag or, if there is no,
	/P flag, to the currently-selected operations port.
*/
extern "C" int
ExecuteVDT2(VDT2RuntimeParamsPtr p)
{
	VDTPortPtr fp;					// References the port specified by /P flag if not NULL.
	VDTPortPtr pp;
	char portNameOut[MAX_OBJ_NAME+1];
	int commSettingsChanged;
	int err = 0;

	*portNameOut = 0;
	fp = NULL;
	pp = NULL;
	commSettingsChanged = 0;

	if (p->PFlagEncountered) {
		if (err = CheckAndTranslatePortName(p->portName, portNameOut, 0))
			return err;
		fp = FindVDTPort(NULL, portNameOut);			// NULL if setting port to None (offline).
		if (fp == NULL)
			return VDT_ERR_EXPECTED_PORTNAME;
	}

	// Main parameters.
	
	if (p->abortEncountered)
		VDTAbortTerminalOperation();

	if (p->testModeEncountered) {
		if (err = SetTestMode((int)p->testMode))
			return err;
	}

	if (p->DumpTestBufferEncountered)
		DumpTestBuffer();

	// This sets the operations port. We do this before any other keywords that act on a particular port.
	if (p->portEncountered) {
		VDTPortPtr op;
		if (err = GetNumberedVDTPort((int)p->port, &op))		// Find port to which num refers.
			return err;
		VDTSetOperationsPortPtr(op);
	}

	/*	For all of the remaining keywords, we must have a valid port. It can be
		explicitly specified by /P or, if not explicitly specified, we use the
		designated operations port.
	*/
	if (fp != NULL) {
		pp = fp;								// Port specified by explicit /P=<portName> flag.
	}
	else {
		VDTPortPtr op;
		op = VDTGetOperationsPortPtr();				// Get current operations port pointer - may be null.
		if (op == NULL)
			return VDT_ERR_NO_OPERATIONS_PORT_SELECTED;
		if (op->terminalOp)							// If terminal operation in progress,
			return OP_IN_PROGRESS;					// Can't mess with port while operation is in progress. Do abort first.
		pp = op;
	}

	if (p->killioEncountered)
		KillVDTIO(pp);

	if (p->bufferSizeEncountered) {
		if (p->bufferSize>=MINBUFSIZE || p->bufferSize>MAXBUFSIZE) {
			if (err = SetInputBufferSize(pp, (int)p->bufferSize))
				return err;
		}
		else {
			return INVALID_BUFFER;
		}
	}

	if (p->baudEncountered) {
		int baudCode;
		if (err = BaudRateToBaudCode((int)p->baud, &baudCode))
			return err;
		pp->baud = baudCode;
		commSettingsChanged = 1;
	}

	if (p->databitsEncountered) {
		switch((int)p->databits) {
			case 7:
				pp->databits = 0;
				break;
			case 8:
				pp->databits = 1;
				break;
			default:
				return INVALID_DATABITS;
				break;
		}
		commSettingsChanged = 1;
	}

	if (p->echoEncountered) {
		if (p->echo>=0 && p->echo<=1)
			pp->echo = (unsigned short)p->echo;
		else
			return INVALID_ECHO;
	}

	if (p->inEncountered) {
		if (p->inputHandshake>=0 && p->inputHandshake<=2)
			pp->inShake = (unsigned short)p->inputHandshake;
		else
			return INVALID_HANDSHAKE;
		commSettingsChanged = 1;
	}

	if (p->lineEncountered) {
		if (p->online) {
			/*	HR, 9/20/97:
				Because VDT can now open multiple ports, the command "VDT line=1" is now a NOP.
				This is necessary because VDT has no way to know which port to make the terminal
				port.
			*/
		}
		else {
			VDTSetTerminalPortPtr(NULL);				// Set terminal port to "Off Line".
		}
	}

	if (p->outEncountered) {
		if (p->outputHandshake>=0 && p->outputHandshake<=2)
			pp->outShake = (unsigned short)p->outputHandshake;
		else
			return INVALID_HANDSHAKE;
		commSettingsChanged = 1;
	}

	if (p->parityEncountered) {
		// Parameter: p->parity
		if (p->parity>=0 && p->parity<=2)
			pp->parity = (unsigned short)p->parity;
		else
			return INVALID_PARITY;
		commSettingsChanged = 1;
	}

	if (p->stopbitsEncountered) {
		switch((int)p->stopbits) {
			case 1:
				pp->stopbits = 0;
				break;
			case 2:
				pp->stopbits = 1;
				break;
			default:
				return INVALID_STOPBITS;
				break;
		}
		commSettingsChanged = 1;
	}

	if (p->terminalEOLEncountered) {
		if (p->terminalEOL>=0 && p->terminalEOL<=2)
			pp->terminalEOL = (unsigned short)p->terminalEOL;
		else
			return VDT_ERR_INVALID_TERMINAL_EOL;
	}

	if (p->rtsEncountered)
		pp->disableRTS = p->rts==0;

	if (err==0 && commSettingsChanged) {
		KillVDTIO(pp);
		err = SetCommPortSettings(pp);
	}

	return err;
}
Exemple #3
0
//int WINAPI WinMain (HINSTANCE hInstance, 
//                    HINSTANCE hPrevInstance, 
//                    LPSTR     lpCmdLine, 
//                    int       nShowCmd)
VOID ServiceStart (DWORD dwArgc, LPTSTR *lpszArgv)
{
char  ConnectionName[15];
/*------------------------------------------------------------*/
/* Modification: Migration from single thread to multithread  */
/* Create thread calls are changed to _beginthread            */
/* XID on 7-DEC-1998                                          */
/*------------------------------------------------------------*/
// DWORD CreateThreadId;
char  StrAux[128];
int   CommServerNumber;
int   LoggerRouteId, CommServerRouteId;
char  *pStringSub[2];
BYTE  CommServerRedundant;
BYTE  DBServiceDepending;
BYTE  CommServerPreferred;

  // report the status to the service control manager.
  //
  if (!ReportStatusToSCMgr (SERVICE_START_PENDING, // service state
                            NO_ERROR,              // exit code
                            3000))                 // wait hint
    return;

  /* Create the event to stop the service */
  hStopEvent = CreateEvent (NULL, TRUE, FALSE, NULL);

  /*-----------------*/
  /* Init. procedure */
  /*-----------------*/

  /* Sets process priority (Normal class) */
  SetPriorityClass (GetCurrentProcess (), NORMAL_PRIORITY_CLASS);

  /* Modification: Process parameters are got from system registry */
  /* XID on 16-JUL-1998                                            */

  /* Get the CommServer Number CommServer.Ini */
  //CommServerNumber = GetPrivateProfileInt ("GENERAL", "CommServerId", 0,"CommServer.ini");
  if (!GetParameterRegistry (COMM_NUM_COMMSERVER, (unsigned char *) &CommServerNumber))
  {
    CommServerNumber = 0;
  } /* endif */

  /* Get the redundant configuration from the system registry */
  if (!GetParameterRegistry (COMM_REDUNDANT_CONFIGURATION, (unsigned char *) &CommServerRedundant))
  {
    CommServerRedundant = FALSE;
  } /* endif */
  /* Get the redundant configuration from the system registry */
  if (!GetParameterRegistry (COMM_DBSERVICE_DEPENDING, (unsigned char *) &DBServiceDepending))
  {
    DBServiceDepending = TRUE;
  } /* endif */
  if (!GetParameterRegistry (COMM_COMMSERVER_PREFERRED, (unsigned char *) &CommServerPreferred))
  {
    CommServerPreferred = TRUE;
  } /* endif */

  /*-------------------------------*/
  /* Basic Network init. procedure */
  /*-------------------------------*/

  /* Initialize interproccess communication */
  if (!RouterInit ())
  {
    /* Error */
    AddToMessageLog (NULL, 0, EVENTLOG_ERROR_TYPE, SC_SYSTEM,
                     EVLG_STD_ROUTER_FAILED);
    return;
  } /* endif */

  /* Detailed Logging initialization */
  (void) Log_SetProcessName("CommS");
  (void) Log_SetThreadName("SrvcMain");

  /* Get connection to send logger messages */
  sprintf (ConnectionName, "LOGGER%03u", 0);
  if (!GetConnection (ConnectionName, &LoggerRouteId))
  {
    /* Error */
    pStringSub[0] = ConnectionName;
    AddToMessageLog (pStringSub, 1, EVENTLOG_ERROR_TYPE, SC_SYSTEM,
                     EVLG_STD_GET_CONECTION_ERROR);
    return;
  } /* endif */

  /* Create connection to receive online messages from DBService */
  sprintf (ConnectionName, "COMSERV%03u", CommServerNumber);
  if (!CreateConnection (ConnectionName, &CommServerRouteId))
  {
    /* Error */
    pStringSub[0] = ConnectionName;
    AddToMessageLog (pStringSub, 1, EVENTLOG_ERROR_TYPE, SC_SYSTEM,
                     EVLG_STD_CREATE_CONECTION_ERROR);
    sprintf (StrAux, CS_LOG_MSG_00035);
    LogWrite (LoggerRouteId, -1, StrAux, 1);
    return;
  } /* endif */

  /* Start & version message */
  LogWrite (LoggerRouteId, CommServerRouteId, "", 1);
  sprintf (StrAux, CS_LOG_MSG_00036, COMM_SERVER_BUILD_NUMBER, COMM_SERVER_VERSION_DATE);
  LogWrite (LoggerRouteId, CommServerRouteId, StrAux, 1);
  sprintf (StrAux, CS_LOG_MSG_00109);
  LogWrite (LoggerRouteId, CommServerRouteId, StrAux, 1);
  sprintf (StrAux, CS_LOG_MSG_00037);
  LogWrite (LoggerRouteId, CommServerRouteId, StrAux, 1);
  #if defined (HASP_KEY)
    sprintf (StrAux, COMM_SERVER_HASP_ON_STR);
  #else
    sprintf (StrAux, COMM_SERVER_HASP_OFF_STR);
  #endif
  LogWrite (LoggerRouteId, CommServerRouteId, StrAux, 1);
  #if defined (PROT_CONV_LAYER)
    sprintf (StrAux, COMM_SERVER_CONV_ON_STR);
  #else
    sprintf (StrAux, COMM_SERVER_CONV_OFF_STR);
  #endif
  LogWrite (LoggerRouteId, CommServerRouteId, StrAux, 1);
  #if defined (PROT_ENCRYPTION)
    sprintf (StrAux, COMM_SERVER_ENC_ON_STR);
  #else
    sprintf (StrAux, COMM_SERVER_ENC_OFF_STR);
  #endif
  LogWrite (LoggerRouteId, CommServerRouteId, StrAux, 1);
  #if defined (PROT_COMPRESSION)
    sprintf (StrAux, COMM_SERVER_COMP_ON_STR);
  #else
    sprintf (StrAux, COMM_SERVER_COMP_OFF_STR);
  #endif
  LogWrite (LoggerRouteId, CommServerRouteId, StrAux, 1);
  /* Commserver Id */
  sprintf (StrAux, CS_LOG_MSG_00110, CommServerNumber);
  LogWrite (LoggerRouteId, CommServerRouteId, StrAux, 1);
  LogWrite (LoggerRouteId, CommServerRouteId, "", 1);

  /* Redundant configuration */
  if (CommServerRedundant)
  {
    sprintf (StrAux, CS_LOG_MSG_00125);
    LogWrite (LoggerRouteId, CommServerRouteId, StrAux, 1);
    sprintf (StrAux, CS_LOG_MSG_00124
             ,CommServerPreferred
             ,DBServiceDepending);
    LogWrite (LoggerRouteId, CommServerRouteId, StrAux, 1);
    LogWrite (LoggerRouteId, CommServerRouteId, "", 1);
  } /* endif */
  
  /* Set input buffer size for this route.    */
  /* This input buffer has to be large enough */
  /* to receive all the incomming messages    */
  SetInputBufferSize (CommServerRouteId, COMMSERVER_CONNECTION_INPUT_BUFFER_SIZE);

  /*---------------------*/
  /* DB access semaphore */
  /*---------------------*/

  if (!InitDBSection ())
  {
    /* Error */
    sprintf (StrAux, CS_LOG_MSG_00038);
    printf ("%s\n", StrAux);
    LogWrite (LoggerRouteId, CommServerRouteId, StrAux, 1);
    //AddToMessageLog (NULL, 0, EVENTLOG_ERROR_TYPE, SC_SYSTEM,
    //                 EVLG_COMMSERVER_MAP_MEMORY_ERROR);
    sprintf (StrAux, CS_LOG_MSG_00035);
    LogWrite (LoggerRouteId, CommServerRouteId, StrAux, 1);
    return;
  } /* endif */


  /*--------------------*/
  /* Map channel memory */  
  /*--------------------*/

  if (InitChannelMapData () != STATUS_OK)
  {
    /* Error */
    sprintf (StrAux, CS_LOG_MSG_00039);
    printf ("%s\n", StrAux);
    LogWrite (LoggerRouteId, CommServerRouteId, StrAux, 1);
    AddToMessageLog (NULL, 0, EVENTLOG_ERROR_TYPE, SC_SYSTEM,
                     EVLG_COMMSERVER_MAP_MEMORY_ERROR);
    sprintf (StrAux, CS_LOG_MSG_00035);
    LogWrite (LoggerRouteId, CommServerRouteId, StrAux, 1);
    return;
  } /* endif */

  /* Reset CommServer database */
  ResetDB ();

  /* Assign comm. server id. and basic routes */
  DB_PROCESS.CommServerNumber  = CommServerNumber;
  DB_PROCESS.LoggerRouteId     = LoggerRouteId;
  DB_PROCESS.CommServerRouteId = CommServerRouteId;

  /* CommServer redundancy initial state */
  DB_PROCESS.CommServerPartnerState = PROCESS_STATE_NORUNNING;
  DB_PROCESS.CommServerState        = PROCESS_STATE_NORUNNING;
  DB_PROCESS.DBServiceDepending     = DBServiceDepending;
  DB_PROCESS.CommServerPreferred    = CommServerPreferred;

  #if defined (HASP_KEY)
    /* Default hasp check */
    DB_PROCESS.HaspPresent = TRUE;
  #endif

  /*-------------*/
  /* MGL license */
  /*-------------*/
  
  MGL_ReadLicense ();

  /*------------------------*/
  /* Compression algorithms */
  /*------------------------*/

  Util_SplayTreeCompressInit (NULL);
  Util_SplayTreeUncompressInit (NULL);

  /*--------------------------*/
  /* Process critical secions */
  /*--------------------------*/

  InitializeCriticalSection (&DB_PROCESS.CSFreeChannels);
  InitializeCriticalSection (&DB_PROCESS.CSFreeNetworkThreads);
  InitializeCriticalSection (&DB_PROCESS.CSModifyCfg);

  /*---------------------------*/
  /* Other Network connections */
  /*---------------------------*/

  /* Get connection to send message to DBService */
  sprintf (ConnectionName, "DBCOMM%03u", 0);
  if (!GetConnection (ConnectionName, &DB_PROCESS.DBServiceRouteId))
  {
    /* Error */
    sprintf (StrAux, CS_LOG_MSG_00041, ConnectionName);
    LogWrite (DB_PROCESS.LoggerRouteId, DB_PROCESS.CommServerRouteId, StrAux, 1);
    pStringSub[0] = ConnectionName;
    AddToMessageLog (pStringSub, 1, EVENTLOG_ERROR_TYPE, SC_SYSTEM,
                     EVLG_STD_GET_CONECTION_ERROR);
    sprintf (StrAux, CS_LOG_MSG_00035);
    LogWrite (DB_PROCESS.LoggerRouteId, DB_PROCESS.CommServerRouteId, StrAux, 1);
    return;
  } /* endif */

  /* Get connection to send confirm messages */
  sprintf (ConnectionName, "DBCONF%03u", 0);
  if (!GetConnection (ConnectionName, &DB_PROCESS.DBConfirmRouteId))
  {
    /* Error */
    sprintf (StrAux, CS_LOG_MSG_00041, ConnectionName);
    LogWrite (DB_PROCESS.LoggerRouteId, DB_PROCESS.CommServerRouteId, StrAux, 1);
    pStringSub[0] = ConnectionName;
    AddToMessageLog (pStringSub, 1, EVENTLOG_ERROR_TYPE, SC_SYSTEM,
                     EVLG_STD_GET_CONECTION_ERROR);
    sprintf (StrAux, CS_LOG_MSG_00035);
    LogWrite (DB_PROCESS.LoggerRouteId, DB_PROCESS.CommServerRouteId, StrAux, 1);
    return;
  } /* endif */

  /* Get connection to send confirm messages */
  sprintf (ConnectionName, "DBSEQ%03u", 0);
  if (!GetConnection (ConnectionName, &DB_PROCESS.DBSeqRouteId))
  {
    /* Error */
    sprintf (StrAux, CS_LOG_MSG_00041, ConnectionName);
    LogWrite (DB_PROCESS.LoggerRouteId, DB_PROCESS.CommServerRouteId, StrAux, 1);
    pStringSub[0] = ConnectionName;
    AddToMessageLog (pStringSub, 1, EVENTLOG_ERROR_TYPE, SC_SYSTEM,
                     EVLG_STD_GET_CONECTION_ERROR);
    sprintf (StrAux, CS_LOG_MSG_00035);
    LogWrite (DB_PROCESS.LoggerRouteId, DB_PROCESS.CommServerRouteId, StrAux, 1);
    return;
  } /* endif */

  /* Initialize Network layer */
  if (!NetworkInit ())
  {
    /* Error */
    sprintf (StrAux, CS_LOG_MSG_00042);
    LogWrite (DB_PROCESS.LoggerRouteId, DB_PROCESS.CommServerRouteId, StrAux, 1);
    AddToMessageLog (NULL, 0, EVENTLOG_ERROR_TYPE, SC_SYSTEM,
                     EVLG_COMMSERVER_NETWORK_LAYER_INIT_ERROR);
    sprintf (StrAux, CS_LOG_MSG_00035);
    LogWrite (DB_PROCESS.LoggerRouteId, DB_PROCESS.CommServerRouteId, StrAux, 1);
    return;
  } /* endif */

  /*------------------*/
  /* Threads creation */
  /*------------------*/

  /*------------------------------------------------------------*/
  /* Modification: Migration from single thread to multithread  */
  /* Create thread calls are changed to _beginthread            */
  /* XID on 7-DEC-1998                                          */
  /*------------------------------------------------------------*/
  /* Create thread to receive messages from the DbService */
  // if (CreateThread (NULL, MAX_STACK, (LPTHREAD_START_ROUTINE) HostToTermThread, 
  //                   (LPVOID) NULL, 0, &CreateThreadId) == NULL)
  if (_beginthread (HostToTermThread, MAX_STACK, (LPVOID) NULL) == -1)
  {
    /* Error */
    sprintf (StrAux, CS_LOG_MSG_00043);
    LogWrite (DB_PROCESS.LoggerRouteId, DB_PROCESS.CommServerRouteId, StrAux, 1);
    AddToMessageLog (NULL, 0, EVENTLOG_ERROR_TYPE, SC_SYSTEM,
                     EVLG_STD_CREATE_THREAD_ERROR);
    sprintf (StrAux, CS_LOG_MSG_00035);
    LogWrite (DB_PROCESS.LoggerRouteId, DB_PROCESS.CommServerRouteId, StrAux, 1);
    return;
  } /* endif */

  /* Create thread to check channels integrity */
  // if (CreateThread (NULL, MAX_STACK, (LPTHREAD_START_ROUTINE) CheckChannelsThread, 
  //                   (LPVOID) NULL, 0, &CreateThreadId) == NULL)
  if (_beginthread (CheckChannelsThread, MAX_STACK, (LPVOID) NULL) == -1)
  {
    /* Error */
    sprintf (StrAux, CS_LOG_MSG_00045);
    LogWrite (DB_PROCESS.LoggerRouteId, DB_PROCESS.CommServerRouteId, StrAux, 1);
    AddToMessageLog (NULL, 0, EVENTLOG_ERROR_TYPE, SC_SYSTEM,
                     EVLG_STD_CREATE_THREAD_ERROR);
    sprintf (StrAux, CS_LOG_MSG_00035);
    LogWrite (DB_PROCESS.LoggerRouteId, DB_PROCESS.CommServerRouteId, StrAux, 1);
    return;
  } /* endif */

  /* If the redundancy is configured create the failover thread */
  if (CommServerRedundant)
  {
    if (_beginthread (FailOverThread, MAX_STACK, (LPVOID) NULL) == -1)
    {
      /* Error */
      sprintf (StrAux, CS_LOG_MSG_00045);
      LogWrite (DB_PROCESS.LoggerRouteId, DB_PROCESS.CommServerRouteId, StrAux, 1);
      AddToMessageLog (NULL, 0, EVENTLOG_ERROR_TYPE, SC_SYSTEM,
                       EVLG_STD_CREATE_THREAD_ERROR);
      sprintf (StrAux, CS_LOG_MSG_00035);
      LogWrite (DB_PROCESS.LoggerRouteId, DB_PROCESS.CommServerRouteId, StrAux, 1);
      return;
    } /* endif */
  }
  else
  {
    /* In not redundancy case it is always active */
    DB_PROCESS.CommServerState = PROCESS_STATE_ACTIVE;
  } /* endif */

  /*--------------------------*/
  /* CommServer configuration */
  /*--------------------------*/

  /* Offline parameters */
  if (!ReadOfflineDir ())
  {
    /* Error */
    sprintf (StrAux, CS_LOG_MSG_00046);
    LogWrite (DB_PROCESS.LoggerRouteId, DB_PROCESS.CommServerRouteId, StrAux, 1);
    AddToMessageLog (NULL, 0, EVENTLOG_ERROR_TYPE, SC_SYSTEM,
                     EVLG_COMMSERVER_OFFLINE_DIR_ERROR);
    sprintf (StrAux, CS_LOG_MSG_00035);
    LogWrite (DB_PROCESS.LoggerRouteId, DB_PROCESS.CommServerRouteId, StrAux, 1);
    return;
  } /* endif */

  /* Configuration message */
  sprintf (StrAux, CS_LOG_MSG_00047);
  LogWrite (DB_PROCESS.LoggerRouteId, DB_PROCESS.CommServerRouteId, StrAux, 5);

  // report the status to the service control manager.
  //
  if (!ReportStatusToSCMgr (SERVICE_RUNNING,       // service state
                            NO_ERROR,              // exit code
                            3000))                    // wait hint
  {
    sprintf (StrAux, CS_LOG_MSG_00048);
    LogWrite (DB_PROCESS.LoggerRouteId, DB_PROCESS.CommServerRouteId, StrAux, 1);
    sprintf (StrAux, CS_LOG_MSG_00035);
    LogWrite (DB_PROCESS.LoggerRouteId, DB_PROCESS.CommServerRouteId, StrAux, 1);
    return;
  } /* endif */

  // XID on 17/OCT/2002
  // X25 support
  X25_Init ();

  /* Start message */
  AddToMessageLog (NULL, 0, EVENTLOG_INFORMATION_TYPE, SC_SYSTEM,
                   EVLG_STD_SERVICE_STARTED);

  /* Get configuration from DBService */
  if (!RemoteConfiguration ())
  //if (!ConfigureApp ())
  {
    /* Error */
    sprintf (StrAux, CS_LOG_MSG_00049);
    LogWrite (DB_PROCESS.LoggerRouteId, DB_PROCESS.CommServerRouteId, StrAux, 1);
    AddToMessageLog (NULL, 0, EVENTLOG_ERROR_TYPE, SC_SYSTEM,
                     EVLG_COMMSERVER_LOAD_CONFIG_ERROR);
    sprintf (StrAux, CS_LOG_MSG_00035);
    LogWrite (DB_PROCESS.LoggerRouteId, DB_PROCESS.CommServerRouteId, StrAux, 1);

    /* Write the last status in the system registry */
    if (CommServerRedundant)
    {
      GetStatusFromPartnerStatus (PROCESS_STATE_NORUNNING,
                                  DB_PROCESS.CommServerState,
                                  DB_PROCESS.CommServerPartnerState);
    }  /* endif */

    return;
  } /* endif */

  /* Sets main thread to idle priority */
  SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_IDLE);

  /* Configuration message */
  sprintf (StrAux, CS_LOG_MSG_00050);
  LogWrite (DB_PROCESS.LoggerRouteId, DB_PROCESS.CommServerRouteId, StrAux, 5);

  /*-----------------------------*/
  /* Wait for the the stop event */
  /*-----------------------------*/

  WaitForSingleObject (hStopEvent, INFINITE);
  LogWrite (DB_PROCESS.LoggerRouteId, DB_PROCESS.CommServerRouteId, CS_LOG_MSG_00051, 1);

  /* Write the last status in the system registry */
  if (CommServerRedundant)
  {
    GetStatusFromPartnerStatus (PROCESS_STATE_NORUNNING,
                                DB_PROCESS.CommServerState,
                                DB_PROCESS.CommServerPartnerState);
  } /* endif */

  AddToMessageLog (NULL, 0, EVENTLOG_INFORMATION_TYPE, SC_SYSTEM,
                   EVLG_STD_SERVICE_STOPPED);

  return;

} /* main */