Ejemplo n.º 1
0
int IOCreat( char *name )
{

   LONG         handle;
   my_file      *p;

//  if( !MayRelinquishControl ) return( -1 );
                                                                    _DBG_IO(( "Creating %s. Open RC(%d)\r\n", name, ccode ));
    ccode = OpenServer( OpenFile, name, &handle,
                        FILE_ATTRIB_MASK, FILE_OPEN_PRIVS );
    if( ccode == 0 ) {
        ccode = WriteFile( 0, handle, 0, 0, "" );
    } else {
        ccode = OpenServer( CreateFile, name, &handle, 0, 0 );
                                                                    _DBG_IO(( "Creating %s. Create RC(%d)\r\n", name, ccode ));
    }
    if( ccode == 0 ) {
        p = FindFile();
        p->handle = handle;
        p->routine = ReadServer;
        p->seekpos = 0;
        p->filesize = 0;
        p->file_type = FILE_SERVER;
    }
    return( ccode ? ErrorCode() : ( p->handlenum + FIRST_HANDLE ) );
}
Ejemplo n.º 2
0
int main(void)
{
   OpenServer();
   xlprintf(LOG_ADVISORY)("Entering main.");
	while(1)
	{
		WakeableSleep(SLEEP_FOREVER);
	}
   return 1;
}
Ejemplo n.º 3
0
// 开启服务
void CSocketServerDlg::OnBnClickedButtonOpen()
{
	// TODO: 在此添加控件通知处理程序代码
	OpenServer();
	CWnd *pWnd = GetDlgItem(IDC_BUTTON_OPEN);
	pWnd->EnableWindow(FALSE);
	pWnd = GetDlgItem(IDC_BUTTON_CLOSE);
	pWnd->EnableWindow(TRUE);

}
Ejemplo n.º 4
0
int main( int argc, char **argv ) /*FOLD00*/
{
	if( argc < 2 )
	{
		printf( WIDE("Usage: %s [scUu]\n"), argv[0] );
		printf( WIDE("  s - server\n") );
		printf( WIDE("  c - client\n") );
		printf( WIDE(" s and c may be specified together to test single-process\n") );
      return 0;
	}
	while( argc > 1 )
	{
		char *p = argv[1];
		while( p[0] )
		{
			switch( p[0]  )
			{
			case 's':
			case 'S':
            l.flags.bServer = 1;
            break;
			case 'c':
			case 'C':
            l.flags.bClient = 1;
				break;
			}
         p++;
		}
		argv++;
      argc--;
	}
	if( l.flags.bServer )
	{
      OpenServer();
	}
	if( l.flags.bClient )
	{
      OpenClient();
		if( l.MsgBaseClient != INVALID_INDEX )
		{
		   // all tests are client based.
			Test1Byte();
		   // all tests are client based.
			Test1000Byte();
		}
	}
	else if( l.flags.bServer ) // hang out here waiting for clients...
      WakeableSleep( SLEEP_FOREVER );
   return 0;
}
Ejemplo n.º 5
0
int IOOpen( char *openname, int openmode )
{
    BYTE        isdos;
    LONG        handle;
    BYTE        filename[14];
    BYTE        loadpath[256];
    my_file     *p;
    LONG        filesize;
    struct      find_t  dta;

//  if( !MayRelinquishControl ) return( -1 );
    if( openmode == O_RDONLY ) {
        ccode = OpenFileUsingSearchPath( (BYTE *)openname, &handle, &isdos,
                                         loadpath, filename, FALSE, 0 );
        AppendStr( (char *)loadpath, (char *)filename );
                                                                    _DBG_IO(( ( ccode==0 ? "Opened %s." : "" ), loadpath ));
    } else {
        ccode = OpenServer( OpenFile, openname, &handle,
                            FILE_ATTRIB_MASK, FILE_OPEN_PRIVS );
                                                                    _DBG_IO(( "Opened %s.", openname ));
        isdos = FALSE;
    }
                                                                    _DBG_IO(( " RC(%d). Handle=%8x\r\n", ccode, handle ));
    if( ccode == 0 ) {
        p = FindFile();
        p->handle = handle;
        p->seekpos = 0;
        p->file_type = isdos ? FILE_DOS : FILE_SERVER;
        if( isdos ) {
            p->routine = ReadDOS;
            ccode = INWDOSFindFirstFile( loadpath, 0, &dta );
            p->filesize = dta.size;
        } else {
            ccode = GetFileSize( 0, p->handle, &filesize );
            p->routine = ReadServer;
            p->filesize = filesize;
        }
        if( openmode != O_RDONLY ) {
            p->routine = NULL;
        }
                                                                    _DBG_IO(( ( ccode != 0 ? "    Size failed - ccode %d\r\n" : "" ), ccode ));
                                                                    _DBG_IO(( ( ccode == 0 ? "    Size is %d\r\n" : "" ), p->filesize ));
    }
    return( ccode ? ErrorCode() : ( p->handlenum + FIRST_HANDLE ) );
}
/* State behaviour */
void behaviour_h2h_start_connect(state_ptr state)
{
  uint8_t i;
  /* Set events to react to */
  state->back = h2h_start_connect_to_main;
  state->h2h_start_connect = h2h_start_connect_to_h2h_ongoing;

  /* Do state actions */

  /*Clean devices names */
  for( i = 1; i < 5;i++)
  {
    item_area_set_text(&menu_h2h_devices.items[i].item.area," ");
    menu_h2h_devices.items[i].item.area.is_active = GUI_INACTIVE;
  }
  item_area_set_text(&menu_h2h_devices.items[6].item.area,"Searching for devices...");
  /* Set menu */
  osMutexWait(mutex_menuHandle, osWaitForever);
  menu_copy(&menu_h2h_devices, &current_menu);
  osMutexRelease(mutex_menuHandle);

  /* Display menu */
  for (i = 0; i < menu_h2h_devices.item_num; i++)
  {
    while (osMailPut(queue_lcdHandle, (void *) &menu_h2h_devices.items[i]) != osOK)
    {
      osDelay(1);
    }
  }

  /* Do state actions */
  /* We close and reopen the spp port in case of "zombie" connection*/
  CloseServer();
  OpenServer(); 
  Inquiry(TIMEOUT);
}
Ejemplo n.º 7
0
int main( int argc, char **argv )
{
   NetworkStart();
	if( argc < 2 )
	{
		printf( WIDE("Usage: %s [scUu]\n"), argv[0] );
		printf( WIDE("  s - server\n") );
		printf( WIDE("  c - client\n") );
		printf( WIDE("  U - use a unix socket instead of tcp\n") );
      printf( WIDE("  u - use a UDP socket instead of tcp\n") );
		printf( WIDE(" s and c may be specified together to test single-process\n") );
      return 0;
	}
	while( argc > 1 )
	{
		char *p = argv[1];
		while( p[0] )
		{
			switch( p[0]  )
			{
			case 's':
			case 'S':
            l.flags.bServer = 1;
            break;
			case 'c':
			case 'C':
            l.flags.bClient = 1;
				break;
			case 'U':
				l.flags.bUnix = 1;
            l.flags.bUDP = 0;
				break;
			case 'u':
				l.flags.bUDP = 1;
            l.flags.bUnix = 0;
            break;
			}
         p++;
		}
		argv++;
      argc--;
	}
	if( l.flags.bServer )
	{
      OpenServer();
	}
	if( l.flags.bClient )
	{
      OpenClient();
	}
	if( l.flags.bClient )
	{
	// all tests are client based.
		if( l.flags.bUDP )
		{
         UDPTest1Byte();
		}
		else
			TCPTest1Byte();
	// all tests are client based.
		if( l.flags.bUDP )
		{
         UDPTest1000Byte();
		}
		else
			TCPTest1000Byte();
	}
	else
      WakeableSleep( 10000 );
   return 0;
}
Ejemplo n.º 8
0
BOOL FILESET::RefreshStatus (BOOL fNotify, ULONG *pStatus)
{
   BOOL rc = TRUE;
   DWORD status = 0;

   if (m_fStatusOutOfDate && (m_wGhost & GHOST_HAS_SERVER_ENTRY))
      {
      m_fStatusOutOfDate = FALSE;

      if (fNotify)
         NOTIFYCALLBACK::SendNotificationToAll (evtRefreshStatusBegin, GetIdentifier());

      LPSERVER lpServer;
      if ((lpServer = OpenServer (&status)) == NULL)
         rc = FALSE;
      else
         {
         PVOID hCell;
         PVOID hVOS;
         if ((hVOS = lpServer->OpenVosObject (&hCell, &status)) == NULL)
            rc = FALSE;
         else
            {
            WORKERPACKET wp;
            wp.wpVosVolumeGet.hCell = hCell;
            wp.wpVosVolumeGet.hServer = hVOS;
            wp.wpVosVolumeGet.idPartition = NO_PARTITION;
            wp.wpVosVolumeGet.idVolume = m_idVolume;

            LPAGGREGATE lpAggregate;
            if ((lpAggregate = m_lpiAggregate->OpenAggregate()) != NULL)
               {
               wp.wpVosVolumeGet.idPartition = lpAggregate->GetID();
               lpAggregate->Close();
               }

            if (!Worker_DoTask (wtaskVosVolumeGet, &wp, &status))
               rc = FALSE;
            else
               {
               SetStatusFromVOS (&wp.wpVosVolumeGet.Data);

               if ((lpAggregate = m_lpiAggregate->OpenAggregate()) != NULL)
                  {
                  lpAggregate->InvalidateAllocation();
                  lpAggregate->Close();
                  }
               }

            lpServer->CloseVosObject();
            }

         lpServer->Close();
         }

      if (fNotify)
         NOTIFYCALLBACK::SendNotificationToAll (evtRefreshStatusEnd, GetIdentifier(), ((rc) ? 0 : status));
      }

   if (pStatus && !rc)
      *pStatus = status;
   return TRUE;
}
Ejemplo n.º 9
0
BOOL SERVICE::RefreshStatus (BOOL fNotify, ULONG *pStatus)
{
   BOOL rc = TRUE;
   DWORD status = 0;

   if (m_fStatusOutOfDate)
      {
      m_fStatusOutOfDate = FALSE;

      if (fNotify)
         NOTIFYCALLBACK::SendNotificationToAll (evtRefreshStatusBegin, GetIdentifier());

      LPSERVER lpServer;
      if ((lpServer = OpenServer (&status)) == NULL)
         rc = FALSE;
      else
         {
         PVOID hCell;
         PVOID hBOS;
         if ((hBOS = lpServer->OpenBosObject (&hCell, &status)) == NULL)
            rc = FALSE;
         else
            {
            SERVICESTATUS ss;
            if (!lstrcmp (m_szName, TEXT("BOS")))
               {
               memset (&ss, 0x00, sizeof(SERVICESTATUS));
               AfsClass_UnixTimeToSystemTime (&ss.timeLastStart, 0);
               AfsClass_UnixTimeToSystemTime (&ss.timeLastStop, 0);
               AfsClass_UnixTimeToSystemTime (&ss.timeLastFail, 0);
               ss.nStarts = 1;
               ss.dwErrLast = 0;
               ss.dwSigLast = 0;
               ss.type = SERVICETYPE_SIMPLE;
               ss.state = SERVICESTATE_RUNNING;
               }
            else
               {
               WORKERPACKET wp;
               wp.wpBosProcessInfoGet.hServer = hBOS;
               wp.wpBosProcessInfoGet.pszService = m_szName;

               if (!Worker_DoTask (wtaskBosProcessInfoGet, &wp, &status))
                  rc = FALSE;
               else
                  {
                  memcpy (&ss, &wp.wpBosProcessInfoGet.ss, sizeof(SERVICESTATUS));

                  // Get the service's current state
                  //
                  wp.wpBosProcessExecutionStateGet.hServer = hBOS;
                  wp.wpBosProcessExecutionStateGet.pszService = m_szName;
                  wp.wpBosProcessExecutionStateGet.pszAuxStatus = ss.szAuxStatus;
                  if (!Worker_DoTask (wtaskBosProcessExecutionStateGet, &wp, &status))
                     ss.state = SERVICESTATE_STOPPED;
                  else
                     ss.state = wp.wpBosProcessExecutionStateGet.state;

                  // Get the service's notifier
                  //
                  ss.szNotifier[0] = TEXT('\0');
                  wp.wpBosProcessNotifierGet.hServer = hBOS;
                  wp.wpBosProcessNotifierGet.pszService = m_szName;
                  wp.wpBosProcessNotifierGet.pszNotifier = ss.szNotifier;;
                  Worker_DoTask (wtaskBosProcessNotifierGet, &wp, &status);

                  // Get the service's parameters
                  //
                  ss.szParams[0] = TEXT('\0');

                  WORKERPACKET wpBegin;
                  wpBegin.wpBosProcessParameterGetBegin.hServer = hBOS;
                  wpBegin.wpBosProcessParameterGetBegin.pszService = m_szName;
                  if (Worker_DoTask (wtaskBosProcessParameterGetBegin, &wpBegin, &status))
                     {
                     for (;;)
                        {
                        TCHAR szParam[ 256 ];
                        WORKERPACKET wpNext;
                        wpNext.wpBosProcessParameterGetNext.hEnum = wpBegin.wpBosProcessParameterGetBegin.hEnum;
                        wpNext.wpBosProcessParameterGetNext.pszParam = szParam;

                        if (!Worker_DoTask (wtaskBosProcessParameterGetNext, &wpNext, &status))
                           {
                           if (status == ADMITERATORDONE)
                              status = 0;
                           else
                              rc = FALSE;
                           break;
                           }

                        if (ss.szParams[0] != TEXT('\0'))
                           lstrcat (ss.szParams, TEXT(" "));
                        lstrcat (ss.szParams, szParam);
                        }

                     WORKERPACKET wpDone;
                     wpDone.wpBosProcessParameterGetDone.hEnum = wpBegin.wpBosProcessParameterGetBegin.hEnum;
                     Worker_DoTask (wtaskBosProcessParameterGetDone, &wpDone);
                     }

                  // Strip trailing CR/LF characters
                  //
                  size_t cch = lstrlen (ss.szAuxStatus);
                  while (cch && (ss.szAuxStatus[ cch-1 ] == TEXT('\r') || ss.szAuxStatus[ cch-1 ] == TEXT('\n')))
                     ss.szAuxStatus[ cch-- ] = TEXT('\0');

                  cch = lstrlen (ss.szParams);
                  while (cch && (ss.szParams[ cch-1 ] == TEXT('\r') || ss.szParams[ cch-1 ] == TEXT('\n')))
                     ss.szParams[ cch-- ] = TEXT('\0');

                  cch = lstrlen (ss.szNotifier);
                  while (cch && (ss.szNotifier[ cch-1 ] == TEXT('\r') || ss.szNotifier[ cch-1 ] == TEXT('\n')))
                     ss.szNotifier[ cch-- ] = TEXT('\0');
                  }
               }

            if (rc)
               {
               memcpy (&m_ss, &ss, sizeof(SERVICESTATUS));
               }

            lpServer->CloseBosObject();
            }

         lpServer->Close();
         }

      if (fNotify)
         NOTIFYCALLBACK::SendNotificationToAll (evtRefreshStatusEnd, GetIdentifier(), ((rc) ? 0 : status));
      }

   if (pStatus && !rc)
      *pStatus = status;
   return TRUE;
}