Exemplo n.º 1
0
extern "C" APIRET APIENTRY _InitServerConnection(char *ExternMachine, ULONG *obj)
{
  char buf[256];
  int  rc;

  /* init time */
  _FreePM_current_time = time(NULL);
  _FreePM_start        = _FreePM_current_time;

  rc = QueryProcessType();

  if(rc == 4)
    _FreePM_detachedMode = 1;

  if (ExternMachine)
  {
     sprintf(buf,"\\\\%s\\%s",ExternMachine, FREEPM_BASE_PIPE_NAME);
  } else {
     strcpy(buf, FREEPM_BASE_PIPE_NAME);
  }
  strcpy(PipeName, buf);

  pF_pipe = new NPipe(PipeName, CLIENT_MODE);

  rc = pF_pipe->Open();

  if (rc)
    return rc;

  rc = pF_pipe->HandShake();

  if (rc ==  HAND_SHAKE_ERROR)
  {
      pF_pipe->Close();
      delete pF_pipe;

      return rc;
  }
  //todo
  *obj = (APIRET)pF_pipe;

  return 0;
}
Exemplo n.º 2
0
extern "C" int cmain(int narg, char *arg[], char *envp[])
{
    int i,j,rc;
    HMODULE hDeviceLib;

    /* init pm comm. lib */
    //init(0);

    /* semaphore setup */
    rc = SetupSemaphore();
    if(rc)
    {
        if(rc == 2)
            printf("%s %s already running\n",_FreePM_Application_Name, _FreePM_Application_Vers);
        exit(rc);
    }
    //atexit(&FreePM_cleanup);
    //SetupSignals();

    rc = QueryProcessType();

    if(rc == 4)
        _FreePM_detachedMode = 1;

    /* init time */
    getCurrentTime();
    _FreePM_start = _FreePM_current_time;

    /* init debug */
    _db_init(_FreePMconfig.Log.log, FPMs_config.debugOptions);

    if(_FreePM_detachedMode)
    {
        debug(1, 0) ("Starting in detached mode %s version %s...\n",_FreePM_Application_Name, _FreePM_Application_Vers);
    } else {
        debug(1, 0) ("Starting %s version %s...\n",_FreePM_Application_Name, _FreePM_Application_Vers);
    }

    /* read config */
    FPMs_config.Read("fpmsrv.ini");
    /* init debug again */
    _db_init(_FreePMconfig.Log.log, FPMs_config.debugOptions);

    /* load device driver */

    debug(1, 0) ("Loading driver %s\n",FPMs_config.deviceName);

    if (!DosLoadModule(NULL, 0, FPMs_config.deviceName, &hDeviceLib))
    {
        debug(1, 0) ("Module loaded\n");
        if (DosQueryProcAddr(hDeviceLib, 0, "FPM_DeviceStart",
                             (PFN*)&FPM_DeviceStart))
        {
            debug(1, 0) ("Error initialize driver\n");
            exit(1);
        };
        debug(1, 0) ("Address found\n");

    } else {
        debug(1, 0) ("Error loading driver module\n");
        exit(1);
    }

    /* init pipes  */

    startServerThreads(&handler);

//  rc = session.AddDesktop(FPM_DEV_PMWIN,
//                           _FreePMconfig.desktop.nx,
//                           _FreePMconfig.desktop.ny,
//                           _FreePMconfig.desktop.bytesPerPixel,
//                           &_FreePMconfig.desktop.pp);
    debug(1, 0)("nx=%lu, ny=%lu, bpp=%lu\n", FPMs_config.DesktopNx,
                FPMs_config.DesktopNy,
                FPMs_config.BytesPerPel);
    rc = session.AddDesktop(FPM_DEV_PMWIN,
                            FPMs_config.DesktopNx,
                            FPMs_config.DesktopNy,
                            FPMs_config.BytesPerPel,
                            &_FreePMconfig.desktop.pp);

    debug(1, 1)("session.AddDesktop rc=%i\n",rc);

    debug(1, 1)("SRV main: Main idle loop\n");
    /* Main idle loop */
    /*
    debug(1, 1)("LSthreads.n %d\n", LSthreads.n);
    debug(1, 1)("LSthreads.Nclients %d\n", LSthreads.Nclients);
    debug(1, 1)("LSthreads.n %d\n", LSthreads.n); */

    for(i=0; ; i++)
    {
        for(j=0; j< LSthreads.n; j++)
        {
            debug(1, 1)("(%i,%i) ",LSthreads.thread_id[j],LSthreads.state[j] );
        }
        debug(1, 1)("%i   \r",LSthreads.Nclients);

        fflush(stdout);
        DosSleep(100);
    }

    rc = session.DelDesktop(0);

    debug(1, 1)("session.DelDesktop(0) rc=%i\n",rc);

    debug(1, 1) ("Normal Shutting down...\n");
    exit(0);
}