Пример #1
0
            virtual bool RegisterTypes( int nFactoryType, bool bUnregister )
            {
                bool bRet = CPluginBaseMinimal::RegisterTypes( nFactoryType, bUnregister );

                if ( bRet )
                {
                    eFactoryType enFactoryType = eFactoryType( nFactoryType );

                    if ( enFactoryType == FT_All || enFactoryType == FT_Flownode )
                    {
                        IFlowSystem* pFlow = NULL;

                        if ( gEnv && gEnv->pSystem && !gEnv->pSystem->IsQuitting() && gEnv->pGameFramework && ( pFlow = gEnv->pGameFramework->GetIFlowSystem() ) )
                        {
                            if ( !bUnregister )
                            {
                                // Register all flownodes of this plugin in the crygame loading this plugin
                                for ( CG2AutoRegFlowNodeBase* pFactory = CG2AutoRegFlowNodeBase::m_pFirst; pFactory; pFactory = pFactory->m_pNext )
                                {
                                    TFlowNodeTypeId nTypeId = pFlow->RegisterType( pFactory->m_sClassName, pFactory );

                                    if ( nTypeId != InvalidFlowNodeTypeId )
                                    {
                                        LogAlways( "Flownode Class(%s) Ptr(%p) TypeId(%d) registered.", SAFESTR( pFactory->m_sClassName ), pFactory, ( int )nTypeId );
                                    }

                                    else
                                    {
                                        LogError( "Flownode Class(%s) Ptr(%p) couldn't register.", SAFESTR( pFactory->m_sClassName ), pFactory );
                                        //bRet = false;
                                    }
                                }
                            }

                            else
                            {
                                // Unregister all flownodes of this plugin
                                for ( CG2AutoRegFlowNodeBase* pFactory = CG2AutoRegFlowNodeBase::m_pFirst; pFactory; pFactory = pFactory->m_pNext )
                                {
                                    // A shame unregistering flownodes types still will produce errors later on in sandbox (then when clicked on)
                                    // it would be much better if UnregisterTypes would automatically unload and set related flownodes to missing status.
                                    bool bUnregistered = pFlow->UnregisterType( pFactory->m_sClassName );

                                    LogAlways( "Flownode Class(%s) Ptr(%p) Ret(%s) unregistered.", SAFESTR( pFactory->m_sClassName ), pFactory );
                                }
                            }
                        }

                        else if ( CG2AutoRegFlowNodeBase::m_pFirst )
                        {
                            LogWarning( "Flownodes couldn't be un/registered" );
                            //bRet = false;
                        }

                        // else there where no flownodes to register
                    }
                }

                return bRet;
            };
Пример #2
0
void
Log_Init(const char *filename)
{
   time_t ltime;

   if (!filename) {
      return;
   }

   if (file_exists(filename)) {
      file_rotate(filename, 10);
   }

   logState.lock = mutex_alloc();
   logState.f = fopen(filename, "a");
   if (logState.f == NULL) {
      printf(LGPFX" Failed to create log file '%s'\n", filename);
   }
   file_chmod(filename, 0600);
   strncpy(logState.filePath, filename, sizeof logState.filePath);

   ltime = time(NULL);

   LogAlways(LGPFX" new log session: %s", asctime(localtime(&ltime)));
}
Пример #3
0
void TestAlways(int expect, char *buff, log_components_t component, char *string)
{
  char compare[2048];
  sprintf(compare, "%s: %s", LogComponents[component].comp_str, string);
  buff[0] = '\0';
  LogAlways(component, "%s", string);
  if (expect && strcmp(compare, buff) != 0 || !expect && buff[0] != '\0')
    {
      LogTest("FAILURE: %s produced \"%s\" expected \"%s\"", string, buff, compare);
      exit(1);
    }
  LogTest("SUCCESS: %s produced \"%s\"", string, buff);
}
Пример #4
0
void uid2grp_release_group_data(struct group_data *gdata)
{
	unsigned int refcount;

	PTHREAD_MUTEX_lock(&gdata->lock);
	refcount = --gdata->refcount;
	PTHREAD_MUTEX_unlock(&gdata->lock);

	if (refcount == 0) {
		gsh_free(gdata->groups);
		gsh_free(gdata);
	} else if (refcount == (unsigned int)-1) {
		LogAlways(COMPONENT_IDMAPPER, "negative refcount on gdata: %p",
			  gdata);
	}
}
Пример #5
0
/**
 *  Tests about Log streams and special printf functions.
 */
void Test1(char *str, char *file)
{
	char tempstr[2048];
	struct display_buffer buffer = { sizeof(tempstr), tmpstr, tmpstr };
	int i;

	SetComponentLogFile(COMPONENT_INIT, "STDOUT");
	LogAlways(COMPONENT_INIT, "%s", "Starting Log Tests");
	LogTest("My PID = %d", getpid());

	LogTest("------------------------------------------------------");
	LogTest("Test conversion of log levels between string and integer");
	for (i = NIV_NULL; i < NB_LOG_LEVEL; i++) {
		int j;
		if (strcmp(tabLogLevel[i].str, ReturnLevelInt(i)) != 0) {
			LogTest(
			     "FAILURE: Log level %d did not convert to %s, it converted to %s",
			     i, tabLogLevel[i].str, ReturnLevelInt(i));
			exit(1);
		}
		j = ReturnLevelAscii(tabLogLevel[i].str);
		if (j != i) {
			LogTest(
			     "FAILURE: Log level %s did not convert to %d, it converted to %d",
			     tabLogLevel[i].str, i, j);
			exit(1);
		}
	}

	LogTest("------------------------------------------------------");

	LogTest("\nTesting possible environment variable");
	LogTest("COMPONENT_MEMCORRUPT debug level is %s",
		ReturnLevelInt(LogComponents[COMPONENT_MEMCORRUPT].
			       comp_log_level));
	LogFullDebug(COMPONENT_MEMCORRUPT,
		     "This should appear if environment is set properly");

	LogTest("------------------------------------------------------");
	LogTest("Send some messages to various files");
	SetComponentLogFile(COMPONENT_DISPATCH, "STDERR");
	LogEvent(COMPONENT_DISPATCH, "This should go to stderr");
	SetComponentLogFile(COMPONENT_DISPATCH, "STDOUT");
	LogEvent(COMPONENT_DISPATCH, "This should go to stdout");
	SetComponentLogFile(COMPONENT_DISPATCH, "SYSLOG");
	LogEvent(COMPONENT_DISPATCH, "This should go to syslog (verf = %s)",
		 str);
	LogTest("About to set %s", file);
	SetComponentLogFile(COMPONENT_DISPATCH, file);
	LogTest("Got it set");
	LogEvent(COMPONENT_DISPATCH, "This should go to %s", file);

	/* Set up for tests that will verify what was actually produced by log
	 * messages. This is used to test log levels and to test the
	 * log_vnsprintf function.
	 */
	/** @todo FSF: this can be done by setting the right header flags and
	 * peeking at the context buffer.
	 */
	SetComponentLogBuffer(COMPONENT_MAIN, &buffer);
	SetComponentLogBuffer(COMPONENT_INIT, &buffer);

	LogTest("------------------------------------------------------");
	LogTest("Test all levels of log filtering");
	SetComponentLogLevel(COMPONENT_MAIN, NIV_NULL);
	TestAlways(true, tempstr, COMPONENT_MAIN, "LogAlways (should print)");
	TestMajor(false, tempstr, COMPONENT_MAIN, "LogMajor (shouldn't print)");
	TestCrit(false, tempstr, COMPONENT_MAIN, "LogCrit (shouldn't print)");
	TestEvent(false, tempstr, COMPONENT_MAIN, "LogEvent (shouldn't print)");
	TestDebug(false, tempstr, COMPONENT_MAIN, "LogDebug (shouldn't print)");
	TestFullDebug(false, tempstr, COMPONENT_MAIN,
		      "LogFullDebug (shouldn't print)");
	SetComponentLogLevel(COMPONENT_MAIN, NIV_MAJOR);
	TestAlways(true, tempstr, COMPONENT_MAIN, "LogAlways (should print)");
	TestMajor(true, tempstr, COMPONENT_MAIN, "LogMajor (should print)");
	TestCrit(false, tempstr, COMPONENT_MAIN, "LogCrit (shouldn't print)");
	TestEvent(false, tempstr, COMPONENT_MAIN, "LogEvent (shouldn't print)");
	TestDebug(false, tempstr, COMPONENT_MAIN, "LogDebug (shouldn't print)");
	TestFullDebug(false, tempstr, COMPONENT_MAIN,
		      "LogFullDebug (shouldn't print)");
	SetComponentLogLevel(COMPONENT_MAIN, NIV_CRIT);
	TestAlways(true, tempstr, COMPONENT_MAIN, "LogAlways (should print)");
	TestMajor(true, tempstr, COMPONENT_MAIN, "LogMajor (should print)");
	TestCrit(true, tempstr, COMPONENT_MAIN, "LogCrit (should print)");
	TestEvent(false, tempstr, COMPONENT_MAIN, "LogEvent (shouldn't print)");
	TestDebug(false, tempstr, COMPONENT_MAIN, "LogDebug (shouldn't print)");
	TestFullDebug(false, tempstr, COMPONENT_MAIN,
		      "LogFullDebug (shouldn't print)");
	SetComponentLogLevel(COMPONENT_MAIN, NIV_EVENT);
	TestAlways(true, tempstr, COMPONENT_MAIN, "LogAlways (should print)");
	TestMajor(true, tempstr, COMPONENT_MAIN, "LogMajor (should print)");
	TestCrit(true, tempstr, COMPONENT_MAIN, "LogCrit (should print)");
	TestEvent(true, tempstr, COMPONENT_MAIN, "LogEvent (should print)");
	TestDebug(false, tempstr, COMPONENT_MAIN, "LogDebug (shouldn't print)");
	TestFullDebug(false, tempstr, COMPONENT_MAIN,
		      "LogFullDebug (shouldn't print)");
	SetComponentLogLevel(COMPONENT_MAIN, NIV_DEBUG);
	TestAlways(true, tempstr, COMPONENT_MAIN, "LogAlways (should print)");
	TestMajor(true, tempstr, COMPONENT_MAIN, "LogMajor (should print)");
	TestCrit(true, tempstr, COMPONENT_MAIN, "LogCrit (should print)");
	TestEvent(true, tempstr, COMPONENT_MAIN, "LogEvent (should print)");
	TestDebug(true, tempstr, COMPONENT_MAIN, "LogDebug (should print)");
	TestFullDebug(false, tempstr, COMPONENT_MAIN,
		      "LogFullDebug (shouldn't print)");
	SetComponentLogLevel(COMPONENT_MAIN, NIV_FULL_DEBUG);
	TestAlways(true, tempstr, COMPONENT_MAIN, "LogAlways (should print)");
	TestMajor(true, tempstr, COMPONENT_MAIN, "LogMajor (should print)");
	TestCrit(true, tempstr, COMPONENT_MAIN, "LogCrit (should print)");
	TestEvent(true, tempstr, COMPONENT_MAIN, "LogEvent (should print)");
	TestDebug(true, tempstr, COMPONENT_MAIN, "LogDebug (should print)");
	TestFullDebug(true, tempstr, COMPONENT_MAIN,
		      "LogFullDebug (should print)");
}
Пример #6
0
/**
 *  Tests about Log streams and special printf functions.
 */
int Test1(char *str, char *file)
{
  char tempstr[2048];
  int  i;

  SetComponentLogFile(COMPONENT_INIT, "STDOUT");
  LogAlways(COMPONENT_INIT, "%s", "Starting Log Tests");
  LogTest("My PID = %d", getpid());

  LogTest("------------------------------------------------------");

  LogTest("Test ERR_DUMMY");
  LogTest("A numerical error : error %%d = %%J%%R, in ERR_DUMMY_2 %%J%%R");
  log_snprintf(tempstr, sizeof(tempstr),
               "A numerical error : error %d = %J%R, in ERR_DUMMY_2 %J%R",
               ERR_SIGACTION, ERR_SYS, ERR_SIGACTION, ERR_DUMMY, ERR_DUMMY_2);
  LogTest("%s", tempstr);
  LogTest("A numerical error : error %d = %J%R, in ERR_DUMMY_1 %J%R",
          ERR_OPEN, ERR_SYS, ERR_OPEN, ERR_DUMMY, ERR_DUMMY_1);

  LogTest("------------------------------------------------------");
  LogTest("Test conversion of log levels between string and integer");
  for (i = NIV_NULL; i < NB_LOG_LEVEL; i++)
    {
      int j;
      if (strcmp(tabLogLevel[i].str, ReturnLevelInt(i)) != 0)
        {
          LogTest("FAILURE: Log level %d did not convert to %s, it converted to %s",
                  i, tabLogLevel[i].str, ReturnLevelInt(i));
          exit(1);
        }
      j = ReturnLevelAscii(tabLogLevel[i].str);
      if (j != i)
        {
          LogTest("FAILURE: Log level %s did not convert to %d, it converted to %d",
                  tabLogLevel[i].str, i, j);
          exit(1);
        }
    }

  LogTest("------------------------------------------------------");

  log_snprintf(tempstr, sizeof(tempstr), "Test log_snprintf");
  LogTest("%s", tempstr);
  LogTest("\nTesting LogError function");
  LogError(COMPONENT_CONFIG, ERR_SYS, ERR_MALLOC, EINVAL);
  LogTest("\nTesting possible environment variable");
  LogTest("COMPONENT_MEMCORRUPT debug level is %s",
          ReturnLevelInt(LogComponents[COMPONENT_MEMCORRUPT].comp_log_level));
  LogFullDebug(COMPONENT_MEMCORRUPT,
               "This should appear if environment is set properly");

  LogTest("------------------------------------------------------");
  LogTest("Send some messages to various files");
  SetComponentLogFile(COMPONENT_DISPATCH, "STDERR");
  LogEvent(COMPONENT_DISPATCH, "This should go to stderr");
  SetComponentLogFile(COMPONENT_DISPATCH, "STDOUT");
  LogEvent(COMPONENT_DISPATCH, "This should go to stdout");
  SetComponentLogFile(COMPONENT_DISPATCH, "SYSLOG");
  LogEvent(COMPONENT_DISPATCH, "This should go to syslog (verf = %s)", str);
  LogTest("About to set %s", file);
  SetComponentLogFile(COMPONENT_DISPATCH, file);
  LogTest("Got it set");
  LogEvent(COMPONENT_DISPATCH, "This should go to %s", file);

  /*
   * Set up for tests that will verify what was actually produced by log messages.
   * This is used to test log levels and to test the log_vnsprintf function.
   */
  SetComponentLogBuffer(COMPONENT_MAIN, tempstr);
  SetComponentLogBuffer(COMPONENT_INIT, tempstr);

#ifdef _SNMP_ADM_ACTIVE
  {
    snmp_adm_type_union param;
    int rc;
    strcpy(param.string, "FAILED");

    LogTest("------------------------------------------------------");
    LogTest("Test SNMP functions");
    SetLevelDebug(NIV_DEBUG);

    rc = getComponentLogLevel(&param, (void *)COMPONENT_ALL);
    LogTest("getComponentLogLevel(&param, (void *)COMPONENT_ALL) rc=%d result=%s",
            rc, param.string);
    if (rc != 0)
    {
      LogTest("FAILURE");
      exit(1);
    }
    strcpy(param.string, "NIV_EVENT");
    rc = setComponentLogLevel(&param, (void *)COMPONENT_MAIN);
    LogTest("setComponentLogLevel(&param, (void *)COMPONENT_MAIN) rc=%d", rc);
    if (rc != 0)
    {
      LogTest("FAILURE");
      exit(1);
    }
    TestAlways    (TRUE,  tempstr, COMPONENT_MAIN, "LogAlways (should print)");
    TestMajor     (TRUE,  tempstr, COMPONENT_MAIN, "LogMajor (should print)");
    TestCrit      (TRUE,  tempstr, COMPONENT_MAIN, "LogCrit (should print)");
    TestEvent     (TRUE,  tempstr, COMPONENT_MAIN, "LogEvent (should print)");
    TestDebug     (FALSE, tempstr, COMPONENT_MAIN, "LogDebug (shouldn't print)");
    TestFullDebug (FALSE, tempstr, COMPONENT_MAIN, "LogFullDebug (shouldn't print)");
    TestAlways    (TRUE,  tempstr, COMPONENT_INIT, "LogAlways (should print)");
    TestMajor     (TRUE,  tempstr, COMPONENT_INIT, "LogMajor (should print)");
    TestCrit      (TRUE,  tempstr, COMPONENT_INIT, "LogCrit (should print)");
    TestEvent     (TRUE,  tempstr, COMPONENT_INIT, "LogEvent (should print)");
    TestDebug     (TRUE,  tempstr, COMPONENT_INIT, "LogDebug (should print)");
    TestFullDebug (FALSE, tempstr, COMPONENT_INIT, "LogFullDebug (shouldn't print)");
  }
#endif /* _SNMP_ADM_ACTIVE */

  LogTest("------------------------------------------------------");
  LogTest("Test all levels of log filtering");
  SetComponentLogLevel(COMPONENT_MAIN, NIV_NULL);
  TestAlways    (TRUE,  tempstr, COMPONENT_MAIN, "LogAlways (should print)");
  TestMajor     (FALSE, tempstr, COMPONENT_MAIN, "LogMajor (shouldn't print)");
  TestCrit      (FALSE, tempstr, COMPONENT_MAIN, "LogCrit (shouldn't print)");
  TestEvent     (FALSE, tempstr, COMPONENT_MAIN, "LogEvent (shouldn't print)");
  TestDebug     (FALSE, tempstr, COMPONENT_MAIN, "LogDebug (shouldn't print)");
  TestFullDebug (FALSE, tempstr, COMPONENT_MAIN, "LogFullDebug (shouldn't print)");
  SetComponentLogLevel(COMPONENT_MAIN, NIV_MAJOR);
  TestAlways    (TRUE,  tempstr, COMPONENT_MAIN, "LogAlways (should print)");
  TestMajor     (TRUE,  tempstr, COMPONENT_MAIN, "LogMajor (should print)");
  TestCrit      (FALSE, tempstr, COMPONENT_MAIN, "LogCrit (shouldn't print)");
  TestEvent     (FALSE, tempstr, COMPONENT_MAIN, "LogEvent (shouldn't print)");
  TestDebug     (FALSE, tempstr, COMPONENT_MAIN, "LogDebug (shouldn't print)");
  TestFullDebug (FALSE, tempstr, COMPONENT_MAIN, "LogFullDebug (shouldn't print)");
  SetComponentLogLevel(COMPONENT_MAIN, NIV_CRIT);
  TestAlways    (TRUE,  tempstr, COMPONENT_MAIN, "LogAlways (should print)");
  TestMajor     (TRUE,  tempstr, COMPONENT_MAIN, "LogMajor (should print)");
  TestCrit      (TRUE,  tempstr, COMPONENT_MAIN, "LogCrit (should print)");
  TestEvent     (FALSE, tempstr, COMPONENT_MAIN, "LogEvent (shouldn't print)");
  TestDebug     (FALSE, tempstr, COMPONENT_MAIN, "LogDebug (shouldn't print)");
  TestFullDebug (FALSE, tempstr, COMPONENT_MAIN, "LogFullDebug (shouldn't print)");
  SetComponentLogLevel(COMPONENT_MAIN, NIV_EVENT);
  TestAlways    (TRUE,  tempstr, COMPONENT_MAIN, "LogAlways (should print)");
  TestMajor     (TRUE,  tempstr, COMPONENT_MAIN, "LogMajor (should print)");
  TestCrit      (TRUE,  tempstr, COMPONENT_MAIN, "LogCrit (should print)");
  TestEvent     (TRUE,  tempstr, COMPONENT_MAIN, "LogEvent (should print)");
  TestDebug     (FALSE, tempstr, COMPONENT_MAIN, "LogDebug (shouldn't print)");
  TestFullDebug (FALSE, tempstr, COMPONENT_MAIN, "LogFullDebug (shouldn't print)");
  SetComponentLogLevel(COMPONENT_MAIN, NIV_DEBUG);
  TestAlways    (TRUE,  tempstr, COMPONENT_MAIN, "LogAlways (should print)");
  TestMajor     (TRUE,  tempstr, COMPONENT_MAIN, "LogMajor (should print)");
  TestCrit      (TRUE,  tempstr, COMPONENT_MAIN, "LogCrit (should print)");
  TestEvent     (TRUE,  tempstr, COMPONENT_MAIN, "LogEvent (should print)");
  TestDebug     (TRUE,  tempstr, COMPONENT_MAIN, "LogDebug (should print)");
  TestFullDebug (FALSE, tempstr, COMPONENT_MAIN, "LogFullDebug (shouldn't print)");
  SetComponentLogLevel(COMPONENT_MAIN, NIV_FULL_DEBUG);
  TestAlways    (TRUE,  tempstr, COMPONENT_MAIN, "LogAlways (should print)");
  TestMajor     (TRUE,  tempstr, COMPONENT_MAIN, "LogMajor (should print)");
  TestCrit      (TRUE,  tempstr, COMPONENT_MAIN, "LogCrit (should print)");
  TestEvent     (TRUE,  tempstr, COMPONENT_MAIN, "LogEvent (should print)");
  TestDebug     (TRUE,  tempstr, COMPONENT_MAIN, "LogDebug (should print)");
  TestFullDebug (TRUE,  tempstr, COMPONENT_MAIN, "LogFullDebug (should print)");
}
Пример #7
0
void vktraceviewer::onTraceFileLoaded(bool bSuccess, vktraceviewer_trace_file_info fileInfo, const QString& controllerFilename)
{
    QApplication::restoreOverrideCursor();

    if (fileInfo.packetCount == 0)
    {
        LogWarning("The trace file has 0 packets.");
    }
    else if (fileInfo.pPacketOffsets == NULL)
    {
        LogError("No packet offsets read from trace file.");
        bSuccess = false;
    }

    if (!bSuccess)
    {
        LogAlways("...FAILED!");
        QMessageBox::critical(this, tr("Error"), tr("Could not open trace file."));
        close_trace_file();

        if (m_bGeneratingTrace)
        {
            // if the user was generating a trace file, but the trace failed to load,
            // then re-spawn the generate trace dialog.
            prompt_generate_trace();
        }
    }
    else
    {
        m_traceFileInfo = fileInfo;

        setWindowTitle(QString(m_traceFileInfo.filename) + " - " + g_PROJECT_NAME);
        LogAlways("...success!");

        // update settings to reflect the currently open file
        g_settings.trace_file_to_open = vktrace_allocate_and_copy(m_traceFileInfo.filename);
        vktraceviewer_settings_updated();

#ifndef USE_STATIC_CONTROLLER_LIBRARY
        if (!controllerFilename.isEmpty())
        {
            m_pController = m_controllerFactory.Load(controllerFilename.toStdString().c_str());
        }
#else
        m_pController = vtvCreateQController();
#endif

        if (m_pController != NULL)
        {
            connect(m_pController, SIGNAL(OutputMessage(VktraceLogLevel, const QString&)), this, SLOT(OnOutputMessage(VktraceLogLevel, const QString&)));
            connect(m_pController, SIGNAL(OutputMessage(VktraceLogLevel, uint64_t, const QString&)), this, SLOT(OnOutputMessage(VktraceLogLevel, uint64_t, const QString&)));

            // Merge in settings from the controller.
            // This won't replace settings that may have already been loaded from disk.
            vktrace_SettingGroup_merge(m_pController->GetSettings(), &g_pAllSettings, &g_numAllSettings);

            // now update the controller with the loaded settings
            m_pController->UpdateFromSettings(g_pAllSettings, g_numAllSettings);

            //// trace file was loaded, now attempt to open additional session data
            //if (load_or_create_session(filename.c_str(), m_pTraceReader) == false)
            //{
            //    // failing to load session data is not critical, but may result in unexpected behavior at times.
            //    vktraceviewer_output_error("VkTraceViewer was unable to create a session folder to save viewing information. Functionality may be limited.");
            //}

            // Update the UI with the controller
            m_pController->LoadTraceFile(&m_traceFileInfo, this);
        }

        // update toolbar
        ui->searchTextBox->setEnabled(true);
        ui->searchPrevButton->setEnabled(true);
        ui->searchNextButton->setEnabled(true);

        ui->action_Close->setEnabled(true);
        ui->actionExport_API_Calls->setEnabled(true);

        ui->prevDrawcallButton->setEnabled(true);
        ui->nextDrawcallButton->setEnabled(true);

        // reset flag indicating that the ui may have been generating a trace file.
        m_bGeneratingTrace = false;

        GenerateTraceFileStats();
    }
Пример #8
0
static status_t VBoxGuestHaikuAttach(const pci_info *pDevice)
{
    status_t status;
    int rc = VINF_SUCCESS;
    int iResId = 0;
    struct VBoxGuestDeviceState *pState = &sState;
    static const char * const   s_apszGroups[] = VBOX_LOGGROUP_NAMES;
    PRTLOGGER                   pRelLogger;

    cUsers = 0;

    /*
     * Initialize IPRT R0 driver, which internally calls OS-specific r0 init.
     */
    rc = RTR0Init(0);
    if (RT_FAILURE(rc))
    {
        LogFunc(("RTR0Init failed.\n"));
        return ENXIO;
    }

#ifdef DO_LOG
    /*
     * Create the release log.
     * (We do that here instead of common code because we want to log
     * early failures using the LogRel macro.)
     */
    rc = RTLogCreate(&pRelLogger, 0|RTLOGFLAGS_PREFIX_THREAD /* fFlags */, "all",
                     "VBOX_RELEASE_LOG", RT_ELEMENTS(s_apszGroups), s_apszGroups,
                     RTLOGDEST_STDOUT | RTLOGDEST_DEBUGGER | RTLOGDEST_USER, NULL);
dprintf(MODULE_NAME ": RTLogCreate: %d\n", rc);
    if (RT_SUCCESS(rc))
    {
        //RTLogGroupSettings(pRelLogger, g_szLogGrp);
        //RTLogFlags(pRelLogger, g_szLogFlags);
        //RTLogDestinations(pRelLogger, "/var/log/vboxguest.log");
        RTLogRelSetDefaultInstance(pRelLogger);
        RTLogSetDefaultInstance(pRelLogger);//XXX
    }
#endif
    Log((MODULE_NAME ": plip!\n"));
    LogAlways((MODULE_NAME ": plop!\n"));

    /*
     * Allocate I/O port resource.
     */
    pState->uIOPortBase = pDevice->u.h0.base_registers[0];
    //XXX check flags for IO ?
    if (pState->uIOPortBase)
    {
        /*
         * Map the MMIO region.
         */
        uint32 phys = pDevice->u.h0.base_registers[1];
        //XXX check flags for mem ?
        pState->VMMDevMemSize    = pDevice->u.h0.base_register_sizes[1];
        pState->iVMMDevMemAreaId = map_physical_memory("VirtualBox Guest MMIO",
            phys, pState->VMMDevMemSize, B_ANY_KERNEL_BLOCK_ADDRESS,
            B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA, &pState->pMMIOBase);

        if (pState->iVMMDevMemAreaId > 0 && pState->pMMIOBase)
        {
            /*
             * Call the common device extension initializer.
             */
            rc = VBoxGuestInitDevExt(&g_DevExt, pState->uIOPortBase,
                                     pState->pMMIOBase, pState->VMMDevMemSize,
#if ARCH_BITS == 64
                                     VBOXOSTYPE_Haiku_x64,
#else
                                     VBOXOSTYPE_Haiku,
#endif
                                     VMMDEV_EVENT_MOUSE_POSITION_CHANGED);
            if (RT_SUCCESS(rc))
            {
                /*
                 * Add IRQ of VMMDev.
                 */
                pState->iIrqResId = pDevice->u.h0.interrupt_line;
                rc = VBoxGuestHaikuAddIRQ(pState);
                if (RT_SUCCESS(rc))
                {
                    dprintf(MODULE_NAME ": loaded successfully\n");
                    return 0;
                }
                else
                    dprintf((MODULE_NAME ":VBoxGuestInitDevExt failed.\n"));
                VBoxGuestDeleteDevExt(&g_DevExt);
            }
            else
                dprintf((MODULE_NAME ":VBoxGuestHaikuAddIRQ failed.\n"));
        }
        else
            dprintf((MODULE_NAME ":MMIO region setup failed.\n"));
    }
    else
        dprintf((MODULE_NAME ":IOport setup failed.\n"));

    RTR0Term();
    return ENXIO;
}