Exemple #1
0
/* Find and store all of the directories, and index them in the dpointers array */
long get_directories(void)
{
	char temp[80];
	long count,c,rcnt=0;

	count = getfnl("*", dirs, sizeof(dirs), FA_SUBDIR );
	if (count > 0) {
		if (strbpl(dpointers,300,dirs)!=count) {
			fprintf(stderr, "Too many mailbox directories\n");
			deinitialize();
			exit(1);
		}
		strsrt( dpointers, count );
		for (c=0;c<count;c++) {
			if (dpointers[c][0]=='.') { continue; }
			rcnt++;
		/*	sprintf( temp, "[0][Checking Directory |%s][OK]", dpointers[c] ); */
		/*	form_alert( 1, temp ); */
		}
		sprintf( temp, "[0][You have %ld Mail Directories][OK]", rcnt );
		form_alert( 1, temp );
	} else {
		if (_OSERR) poserr( "DIRS");
		else fprintf(stderr, "Too many mailbox directories\n");
		deinitialize();
		exit(1);
	}
	return(count);
}
RenderableSphericalGrid::~RenderableSphericalGrid(){
    deinitialize();

    // Delete not done in deinitialize because new is done in constructor
    delete[] _varray;
    delete[] _iarray;
}
Exemple #3
0
	SimpleOverlay::~SimpleOverlay()
	{
		if(mInitialized)
		{
			deinitialize();
		}
	}
Exemple #4
0
void OperatorItem::setInitialized(bool value)
{
    if(value == true)
        initialize();
    else
        deinitialize();
}
Exemple #5
0
 OperatorKernel::~OperatorKernel()
 {
     deactivate();
     deinitialize();
     
     for(std::vector<const Input*>::const_iterator iter = m_inputs.begin();
         iter != m_inputs.end();
         ++iter)
     {
         delete *iter;
     }
     
     for(std::vector<const Output*>::const_iterator iter = m_outputs.begin();
         iter != m_outputs.end();
         ++iter)
     {
         delete *iter;
     }
     
     for(std::vector<const Parameter*>::const_iterator iter = m_parameters.begin();
         iter != m_parameters.end();
         ++iter)
     {
         delete *iter;
     }
 }
Exemple #6
0
/**
 ** FIXME - actual support for multiple volumes
 **/
bool CFile::initialize(int volume)
{
    volatile uint8_t err=0;
    mInitialized=false;
    do {
        deinitialize(volume);
        if ( (mFileSystem = (FATFS*)malloc(sizeof(FATFS))) )
        {
            memset(mFileSystem,0,sizeof(FATFS));
            if ( ( err = disk_initialize(volume) ) == FR_OK )
            {
                if ( ( err = disk_status(volume) ) == FR_OK )
                {
                    if ( ( err = f_mount(mFileSystem,"",0) ) == FR_OK )
                    {
                        mInitialized=true;
                    }
                }
            }
            if ( !initialized() )
            {
                free(mFileSystem);
                mFileSystem=NULL;
                disk_init_fail(err);
            }
        }
    } while ( err );
    disk_init_fail(0); // clear the status/diag LEDs
    return mInitialized;
}
Exemple #7
0
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
    int action, device, value;
    unsigned char buffer[64], i, bmRequestType, bRequest;
    unsigned int vendorID, productID, wValue, wIndex, wLength;
    double *ret, *out;

    action = (int)(mxGetScalar(prhs[0]));
    switch (action) {
        case INITIALIZE:
            initialize();
            break;
        case DEINITIALIZE:
            deinitialize();
            break;
        case SET_DEBUG:
            value = (int)(mxGetScalar(prhs[1]));
            set_debug(value);
            break;
        case OPEN_DEVICE:
            vendorID = (unsigned int)(mxGetScalar(prhs[1]));
            productID = (unsigned int)(mxGetScalar(prhs[2]));
            value = (int)(mxGetScalar(prhs[3]));
            value = open_device(vendorID, productID, value);
            plhs[0] = mxCreateDoubleMatrix(1, 1, mxREAL);
            ret = mxGetPr(plhs[0]);
            ret[0] = (double)value;
            break;
        case CLOSE_DEVICE:
            device = (int)(mxGetScalar(prhs[1]));
            value = close_device(device);
            plhs[0] = mxCreateDoubleMatrix(1, 1, mxREAL);
            ret = mxGetPr(plhs[0]);
            ret[0] = (double)value;
            break;
        case NUM_DEVICES_OPEN:
            value = num_devices_open();
            plhs[0] = mxCreateDoubleMatrix(1, 1, mxREAL);
            ret = mxGetPr(plhs[0]);
            ret[0] = (double)value;
            break;
        case CONTROL_TRANSFER:
            device = (int)(mxGetScalar(prhs[1]));
            bmRequestType = (unsigned char)(mxGetScalar(prhs[2]));
            bRequest = (unsigned char)(mxGetScalar(prhs[3]));
            wValue = (unsigned int)(mxGetScalar(prhs[4]));
            wIndex = (unsigned int)(mxGetScalar(prhs[5]));
            wLength = (unsigned int)(mxGetScalar(prhs[6]));
            value = control_transfer(device, bmRequestType, bRequest, wValue, wIndex, wLength, buffer);
            plhs[0] = mxCreateDoubleMatrix(1, 1, mxREAL);
            ret = mxGetPr(plhs[0]);
            ret[0] = (double)value;
            plhs[1] = mxCreateDoubleMatrix(1, 64, mxREAL);
            out = mxGetPr(plhs[1]);
            for (i = 0; i<64; i++)
                out[i] = (double)buffer[i];
            break;
        default:
            mexErrMsgTxt("Illegal action specified.");
    }
}
Exemple #8
0
MidiOutPort_visual::~MidiOutPort_visual() {
   objectCount--;
   if (objectCount == 0) {
      deinitialize();
   } else if (objectCount < 0) {
      cerr << "Error: bad MidiOutPort object count!: " << objectCount << endl;
      exit(1);
   }
}
Exemple #9
0
Common::Error TSageEngine::run() {
	// Basic initialisation
	initialize();

	g_globals->_sceneHandler->registerHandler();
	g_globals->_game->execute();

	deinitialize();
	return Common::kNoError;
}
Exemple #10
0
int main(int argc, char** argv) {
    parse_arguments(argc, argv);

    initialize();
    create_threads();
    join_threads();
    deinitialize();

    return EXIT_SUCCESS;
}
Exemple #11
0
MidiInPort_alsa::~MidiInPort_alsa() {
   objectCount--;
   if (objectCount == 0) {
      deinitialize();
   } else if (objectCount < 0) {
      std::cerr << "Error: bad MidiInPort_alsa object count!: " 
           << objectCount << std::endl;
      exit(1);
   }
}
Exemple #12
0
void main()
{
    char buffer[20000];
    char *commits[1000];
    int numcommits, i;

    numcommits = getHashes(buffer, commits);
    treeInit(commits, numcommits);
    printGraph(commits, numcommits);
    deinitialize(numcommits);
}
Exemple #13
0
Common::Error TitanicEngine::run() {
	initialize();

	// Main event loop
	while (!shouldQuit()) {
		_events->pollEventsAndWait();
	}

	deinitialize();
	return Common::kNoError;
}
bool UeventObserver::initialize()
{
    mListeners.clear();

    if (mUeventFd != -1) {
        return true;
    }

    mThread = new UeventObserverThread(this);
    if (!mThread.get()) {
        ETRACE("failed to create uevent observer thread");
        return false;
    }

    // init uevent socket
    struct sockaddr_nl addr;
    // set the socket receive buffer to 64K
    // NOTE: this is only called for once
    int sz = 64 * 1024;

    memset(&addr, 0, sizeof(addr));
    addr.nl_family = AF_NETLINK;
    addr.nl_pid =  pthread_self() | getpid();
    addr.nl_groups = 0xffffffff;

    mUeventFd = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_KOBJECT_UEVENT);
    if (mUeventFd < 0) {
        DEINIT_AND_RETURN_FALSE("failed to create uevent socket");
    }

    if (setsockopt(mUeventFd, SOL_SOCKET, SO_RCVBUFFORCE, &sz, sizeof(sz))) {
        WTRACE("setsockopt() failed");
        //return false;
    }

    if (bind(mUeventFd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
        DEINIT_AND_RETURN_FALSE("failed to bind scoket");
        return false;
    }

    memset(mUeventMessage, 0, UEVENT_MSG_LEN);

    int exitFds[2];
    if (pipe(exitFds) < 0) {
        ETRACE("failed to make pipe");
        deinitialize();
        return false;
    }
    mExitRDFd = exitFds[0];
    mExitWDFd = exitFds[1];

    return true;
}
Exemple #15
0
void animation_movement_controller::OnFrame( )
{
	m_pKinematicsC->CalculateBones( );
	
	if(CBlend::eFREE_SLOT == m_control_blend->blend)
	{
		deinitialize();
		return;
	}
	if( m_control_blend->blend == CBlend::eAccrue && m_control_blend->blendPower - EPS_L > m_control_blend->blendAmount )
			m_control_blend->timeCurrent =0;
}
int MazurkaTransformer::initialize(int size) {
   if (fftSignalN == size) {
      return 1;
   }

   deinitialize();

   if (size <= 0) {
      return 0;
   }

   fftSignalN   = size;
   fftSignalNd2 = size/2;
   fftSpectrumN = size/2 + 1;

   fftSignal   = (double*)fftw_malloc(fftSignalN * sizeof(double));
   fftSpectrum = (fftw_complex*)fftw_malloc(fftSpectrumN * sizeof(fftw_complex));

   // r2c_1d = real to complex, 1-dimensional
   // signal size = n, spectrum size = (n/2+1) complex numbers
   fftPlan = fftw_plan_dft_r2c_1d(size, fftSignal, fftSpectrum, FFTW_ESTIMATE);
   fftPlan_inverse = fftw_plan_dft_c2r_1d(size, fftSpectrum, fftSignal,
		     FFTW_ESTIMATE);
                     // Also can use: FFTW_ESTIMATE | FFTW_PRESERVE_INPUT
		     // if you don't want the input to be destroyed
		     // during the transform process.

   // http://www.fftw.org/fftw3_doc/Planner-Flags.html#Planner-Flags
   //    FFTW_ESTIMATE
   //    FFTW_MEASURE
   //    FFTW_PATIENT
   //    FFTW_EXHAUSTIVE

   if (fftPlan == NULL || fftPlan_inverse == NULL) {
      deinitialize();
      return 0; // unsuccessful initialization
   }

   return 1; // successful initialization
}
Exemple #17
0
int core_application::app_main(const int argc, const char** argv) {
    init_info init_info;
    construct_init_info(argc, argv, init_info);

    deinit_info deinit_info;
    construct_deinit_info(deinit_info);

    initialize(init_info);
    main_loop();
    deinitialize(deinit_info);

    return 0;
}
Exemple #18
0
/* Find and store all of the mailboxes, and index them in the pointers array */
long get_mailboxes(void)
{
	char temp[80];
	long count;

	count = getfnl("*.MBX", boxes, sizeof(boxes), 0 );
	if (count > 0) {
		if (strbpl(pointers,200,boxes)!=count) {
			fprintf(stderr, "Too many mailbox files\n");
			deinitialize();
			exit(1);
		}
		sprintf( temp, "[0][You have %ld Mailboxes][OK]", count );
		form_alert( 1, temp );
		strsrt( pointers, count );
	} else {
		if (_OSERR) poserr( "FILES");
		else fprintf(stderr, "Too many mailbox files\n");
		deinitialize();
		exit(1);
	}
	return(count);
}
Exemple #19
0
/*
* Library Initialization
*/
void LibraryInitializer::initialize(const std::string& arg_string)
   {
   bool thread_safe = false;

   const std::vector<std::string> arg_list = split_on(arg_string, ' ');
   for(u32bit j = 0; j != arg_list.size(); ++j)
      {
      if(arg_list[j].size() == 0)
         continue;

      std::string name, value;

      if(arg_list[j].find('=') == std::string::npos)
         {
         name = arg_list[j];
         value = "true";
         }
      else
         {
         std::vector<std::string> name_and_value = split_on(arg_list[j], '=');
         name = name_and_value[0];
         value = name_and_value[1];
         }

      bool is_on =
         (value == "1" || value == "true" || value == "yes" || value == "on");

      if(name == "thread_safe")
         thread_safe = is_on;
      }

   try
      {
      /*
      This two stage initialization process is because Library_State's
      constructor will implicitly refer to global state through the
      allocators and so for, so global_state() has to be a valid
      reference before initialize() can be called. Yeah, gross.
      */
      set_global_state(new Library_State);

      global_state().initialize(thread_safe);
      }
   catch(...)
      {
      deinitialize();
      throw;
      }
   }
Exemple #20
0
pool& pool::operator=(pool&& that)
{
	if (this != &that)
	{
		deinitialize();

		blocks_  = that.blocks_;  that.blocks_  = nullptr;
		stride_  = that.stride_;  that.stride_  = 0;
		nblocks_ = that.nblocks_; that.nblocks_ = 0;
		nfree_   = that.nfree_;   that.nfree_   = 0;
		head_    = that.head_;    that.head_    = nullidx;
	}

	return *this;
}
Exemple #21
0
/*************************************************
* Library Initialization                         *
*************************************************/
void LibraryInitializer::initialize(const InitializerOptions& args,
                                    Modules& modules)
   {
   try
      {
      set_global_state(new Library_State);

      global_state().initialize(args, modules);
      }
   catch(...)
      {
      deinitialize();
      throw;
      }
   }
int
main ( /*int argc, char *argv[] */ )
{
  if (!initialize ())
    {
      return 1;
    }

  run_into_screen ();

  run_main_game ();

  deinitialize ();

  return 0;
}
Exemple #23
0
LRESULT CALLBACK WndProc(HWND window, UINT msg, WPARAM wParam, LPARAM lParam)
{
    HDC dstDc;
    PAINTSTRUCT paintInfo;
    BOOL result;

    switch (msg)
    {
    case WM_CREATE:
        if (initFrameBuffer())
            return -1;

        if (!SetTimer(window, SCREEN_UPDATE_TIMER_ID, USER_TIMER_MINIMUM, NULL))
        {
            reportSysError(_T("Failed to create the display update timer."));
            return -1;
        }

        break;
    case WM_DESTROY:
        deinitialize();
        PostQuitMessage(exitCode);
        break;
    case WM_KEYDOWN:
        if (wParam == VK_ESCAPE)
            DestroyWindow(window);
        break;
    case WM_TIMER:
        InvalidateRect(window, NULL, FALSE);
        break;
    case WM_PAINT:
        dstDc = BeginPaint(window, &paintInfo);
        updateScreen();
        BitBlt(dstDc, - (int) bufOffset, 0, WIDTH, HEIGHT, bufDc, 0, 0, SRCCOPY);
        EndPaint(window, &paintInfo);
        updateFps();

        break;
    default:
        return DefWindowProc(window, msg, wParam, lParam);
    }

    return 0;
}
Exemple #24
0
Common::Error CruiseEngine::run() {
	// Initialize backend
	initGraphics(320, 200, false);

	if (!loadLanguageStrings()) {
		error("Could not setup language data for your version");
		return Common::kUnknownError;	// for compilers that don't support NORETURN
	}

	initialize();

	Cruise::changeCursor(Cruise::CURSOR_NORMAL);
	CursorMan.showMouse(true);

	lastTick = 0;
	lastTickDebug = 0;

	mainLoop();

	deinitialize();

	return Common::kNoError;
}
Exemple #25
0
void indri::thread::UtilityThread::run() {
  indri::thread::ScopedLock lock( _lock );

  try {
    UINT64 waitTime = initialize();

    while( _runThread ) {
      bool noTimeout = _quit.wait( _lock, waitTime );

      if( noTimeout )
        continue; // interrupted

      waitTime = work();
    }

    while( hasWork() )
      work();

    deinitialize();
  } catch( lemur::api::Exception& e ) {
    std::cout << "UtilityThread exiting from exception " << e.what() << std::endl;
  }

}
Exemple #26
0
void MonsterManager::reload()
{
    deinitialize();
    initialize();
}
Exemple #27
0
IndexBufferDx::~IndexBufferDx() {
	deinitialize();
}
Exemple #28
0
VertexBufferDx::~VertexBufferDx() {
	deinitialize();
}
Exemple #29
0
CanvasGL::~CanvasGL() {
    deinitialize();
}
Exemple #30
0
jHWRJapanese::~jHWRJapanese()
{
    deinitialize();
}