コード例 #1
0
ファイル: appl.c プロジェクト: liyunlulu1990/replFs
int
main() {

  int fd;
  int loopCnt;
  int byteOffset= 0;
  char strData[MaxBlockLength];

  char fileName[32] = "writeTest.txt";

  /*****************************/
  /* Initialize the system     */
  /*****************************/
  
  if( InitReplFs( ReplFsPort, 0, 1 ) < 0 ) {
    fprintf( stderr, "Error initializing the system\n" );
    return( ErrorExit );
  }

  /*****************************/
  /* Open the file for writing */
  /*****************************/

  fd = OpenFile( fileName );
  if ( fd < 0 ) {
    fprintf( stderr, "Error opening file '%s'\n", fileName );
    return( ErrorExit );
  }

  /**************************************/
  /* Write incrementing numbers to the file */
  /**************************************/

  for ( loopCnt=0; loopCnt<8; loopCnt++ ) {
    sprintf( strData, "%d\n", loopCnt );

#ifdef DEBUG
    printf( "%d: Writing '%s' to file.\n", loopCnt, strData );
#endif

    if ( WriteBlock( fd, strData, byteOffset, strlen( strData ) ) < 0 ) {
      printf( "Error writing to file %s [LoopCnt=%d]\n", fileName, loopCnt );
      return( ErrorExit );
    }
    byteOffset += strlen( strData );
    
  }

  /**********************************************/
  /* Can we commit the writes to the server(s)? */
  /**********************************************/
  if ( Commit( fd ) < 0 ) {
    printf( "Could not commit changes to File '%s'\n", fileName );
    return( ErrorExit );
  }

  /**************************************/
  /* Close the writes to the server(s) */
  /**************************************/
  if ( CloseFile( fd ) < 0 ) {
    printf( "Error Closing File '%s'\n", fileName );
    return( ErrorExit );
  }

  printf( "Writes to file '%s' complete.\n", fileName );

  return( NormalExit );
}
コード例 #2
0
BOOL MSrv_Advert_Player::AdvPlayerPlay(void)
{
    BOOL bRet = FALSE;
    clock_t start_t = 0, end_t = 0;

    // Video.TS
    char *u8FileName = NULL;
    u8FileName = SystemInfo::GetInstance()->GetVideoFileName();

    if(MM_interface->AddEventRecipient(&MSrv_Advert_Player::EventHandler))
    {
        bRet=TRUE;
    }
    else
    {
        MM_interface->MM_Finalize();
        return bRet;
    }

	//EosTek Patch Begin
    if(OpenFile(u8FileName) || OpenFile(SystemInfo::GetInstance()->GetVideoFileNameAlternative()))
    {
        bRet=TRUE;
    }
	//EosTek Patch End
    else
    {
        printf("Open file fail\n");
        MM_interface->RemoveEventRecipient(&MSrv_Advert_Player::EventHandler);
        MM_interface->MM_Finalize();

        return bRet;
    }
    /*if autodetect flag on, force disable 3D auto-detect for Ad player*/
    if (TRUE == MSrv_Control_common::GetMSrv3DManager()->Get3DFormatDetectFlag())
    {
        MSrv_Control_common::GetMSrv3DManager()->Set3DFormatDetectFlag(FALSE);
        m_bRestore3DdetectFlag = TRUE;
    }
    // Initialization
    mm_init_flag = FALSE;
    mm_init_fail = FALSE;
    mm_decode_flag = FALSE;
    m_pMediaFile1st = (&m_stMediaFileInfo[E_MEDIAFILE_ID_FIRST]);
    m_pMediaFile2nd = (&m_stMediaFileInfo[E_MEDIAFILE_ID_SECOND]);
    m_pMediaFile3rd = (&m_stMediaFileInfo[E_MEDIAFILE_ID_THIRD]);
    m_pMediaFile4th = (&m_stMediaFileInfo[E_MEDIAFILE_ID_FOURTH]);
    memset(&stMedia, 0, sizeof(ST_MEDIA_INFO));
    stMedia.u32EncryptingType = 0;

    stMedia.u64Version      = MM_IF_VERSION;
    stMedia.u32StructureSize = (U32)sizeof(ST_MEDIA_INFO);
    stMedia.u32FileID = (U32)m_pMediaFile1st;
    stMedia.u32FileSecondID = (U32)m_pMediaFile2nd;
    stMedia.u32FileThirdID = (U32)m_pMediaFile3rd;
    stMedia.u32FileFourthID = (U32)m_pMediaFile4th;
    stMedia.u64FileLength = m_stMediaFileInfo[E_MEDIAFILE_ID_FIRST].u64FileLength;
    stMedia.eMediaType = E_PLAYER_MEDIA_TYPE_VIDEO;

    #if (ADVERT_BOOTING_ENABLE == 1)
    stMedia.eAppType = E_MM_PLAYER_AP_ADVERT;
    #endif


    stMedia.eMediaFileType = E_MEDIA_FILE_TYPE_MASS_STORAGE;
    stMedia.u32CtlFlag = 0;
    stMedia.u32CtlFlag |= E_PLAYER_CTL_FLAG_ENABLE_AUDIO_HANDLER;

    printf("\n---------------------- AD_CREATE_MEDIA_ITEM ----------------------\n");
    if(MM_interface->MM_CreateMediaItem(stMedia, &u32Item) == E_PLAYER_OK)
    {
        printf("\nMM_CreateMediaItem done\n");
        bRet=TRUE;
    }
    else
    {
        printf("\nMM_CreateMediaItem fail\n");
        return bRet;
    }

    start_t = clock();
    do
    {
        usleep(10);
        end_t = clock();
    }while((!mm_init_flag) && (!mm_init_fail) &&
                (((end_t - start_t)/CLOCKS_PER_SEC) <= 10));

    if(!mm_init_flag)
    {
        bRet = FALSE;
        return bRet;
    }

    printf("\n---------------------- AD_PLAY_START ----------------------\n");
    if(MM_interface->MM_Play(u32Item) == E_PLAYER_OK)
    {
        printf("MM_Play done\n");
        bRet=TRUE;
    }
    else
    {
        printf("MM_Play fail\n");
        return bRet;
    }

    return bRet;
}
コード例 #3
0
ファイル: DHSVMChannel.c プロジェクト: Lizzy0Sun/DHSVM_RBM
/* -------------------------------------------------------------
   InitChannelDump
   ------------------------------------------------------------- */
void InitChannelDump(OPTIONSTRUCT *Options, CHANNEL * channel, 
					 char *DumpPath)
{
  char buffer[NAMESIZE];

  if (channel->streams != NULL) {
    sprintf(buffer, "%sStream.Flow", DumpPath);
    OpenFile(&(channel->streamout), buffer, "w", TRUE);
    sprintf(buffer, "%sStreamflow.Only", DumpPath);
    OpenFile(&(channel->streamflowout), buffer, "w", TRUE);
    /* output files for John's RBM model */
	if (Options->StreamTemp) {
      //inflow to segment
      sprintf(buffer, "%sInflow.Only", DumpPath);
      OpenFile(&(channel->streaminflow), buffer, "w", TRUE);
      // outflow ( redundant but it's a check
      sprintf(buffer, "%sOutflow.Only", DumpPath);
      OpenFile(&(channel->streamoutflow), buffer, "w", TRUE);
      // total incoming short wave
      sprintf(buffer, "%sISW.Only", DumpPath);
      OpenFile(&(channel->streamISW), buffer, "w", TRUE);
	  //net incoming short wave
      sprintf(buffer, "%sNSW.Only", DumpPath);
      OpenFile(&(channel->streamNSW), buffer, "w", TRUE);
      // total incoming long wave
      sprintf(buffer, "%sILW.Only", DumpPath);
      OpenFile(&(channel->streamILW), buffer, "w", TRUE);
	  // net incoming long wave
	  sprintf(buffer, "%sNLW.Only", DumpPath);
      OpenFile(&(channel->streamNLW), buffer, "w", TRUE);
      //Vapor pressure
      sprintf(buffer, "%sVP.Only", DumpPath);
      OpenFile(&(channel->streamVP), buffer, "w", TRUE);
      //wind speed
      sprintf(buffer, "%sWND.Only", DumpPath);
      OpenFile(&(channel->streamWND), buffer, "w", TRUE);
      //air temperature
      sprintf(buffer, "%sATP.Only", DumpPath);
      OpenFile(&(channel->streamATP), buffer, "w", TRUE);
	  //beam radiation
      sprintf(buffer, "%sBeam.Only", DumpPath);
      OpenFile(&(channel->streamBeam), buffer, "w", TRUE);
	  //diffuse radiation
      sprintf(buffer, "%sDiffuse.Only", DumpPath);
      OpenFile(&(channel->streamDiffuse), buffer, "w", TRUE);
	  //skyview
      sprintf(buffer, "%sSkyview.Only", DumpPath);
      OpenFile(&(channel->streamSkyView), buffer, "w", TRUE);
	}
  }
  if (channel->roads != NULL) {
    sprintf(buffer, "%sRoad.Flow", DumpPath);
    OpenFile(&(channel->roadout), buffer, "w", TRUE);
    sprintf(buffer, "%sRoadflow.Only", DumpPath);
    OpenFile(&(channel->roadflowout), buffer, "w", TRUE);

  }
}
コード例 #4
0
bool ReadScriptDescriptor::OpenFile(const string& filename) {
	return OpenFile(filename, false);
}
コード例 #5
0
ファイル: InodeRegular.cpp プロジェクト: sahil9912/haiku
status_t
Inode::Open(int mode, OpenFileCookie* cookie)
{
	ASSERT(cookie != NULL);

	MutexLocker locker(fStateLock);

	OpenDelegationData data;
	data.fType = OPEN_DELEGATE_NONE;
	if (fOpenState == NULL) {
		RevalidateFileCache();

		OpenState* state = new(std::nothrow) OpenState;
		if (state == NULL)
			return B_NO_MEMORY;

		state->fInfo = fInfo;
		state->fFileSystem = fFileSystem;
		state->fMode = mode & O_RWMASK;
		status_t result = OpenFile(state, mode, &data);
		if (result != B_OK) {
			delete state;
			return result;
		}

		fFileSystem->AddOpenFile(state);
		fOpenState = state;
		cookie->fOpenState = state;
		locker.Unlock();
	} else {
		fOpenState->AcquireReference();
		cookie->fOpenState = fOpenState;
		locker.Unlock();

		int newMode = mode & O_RWMASK;
		int oldMode = fOpenState->fMode & O_RWMASK;
		if (oldMode != newMode && oldMode != O_RDWR) {
			if (oldMode == O_RDONLY)
				RecallReadDelegation();

			status_t result = OpenFile(fOpenState, O_RDWR, &data);
			if (result != B_OK) {
				locker.Lock();
				ReleaseOpenState();
				return result;
			}
			fOpenState->fMode = O_RDWR;
		} else {
			int newMode = mode & O_RWMASK;
			uint32 allowed = 0;
			if (newMode == O_RDWR || newMode == O_RDONLY)
				allowed |= R_OK;
			if (newMode == O_RDWR || newMode == O_WRONLY)
				allowed |= W_OK;

			status_t result = Access(allowed);
			if (result != B_OK) {
				locker.Lock();
				ReleaseOpenState();
				return result;
			}
		}
	}

	if ((mode & O_TRUNC) == O_TRUNC) {
		struct stat st;
		st.st_size = 0;
		WriteStat(&st, B_STAT_SIZE);
		file_cache_set_size(fFileCache, 0);
	}

	cookie->fFileSystem = fFileSystem;
	cookie->fMode = mode;
	cookie->fLocks = NULL;

	if (data.fType != OPEN_DELEGATE_NONE) {
		Delegation* delegation
			= new(std::nothrow) Delegation(data, this, fOpenState->fClientID);
		if (delegation != NULL) {
			delegation->fInfo = fOpenState->fInfo;
			delegation->fFileSystem = fFileSystem;
			SetDelegation(delegation);
		}
	}

	return B_OK;
}
コード例 #6
0
ファイル: enqueue.c プロジェクト: Pawamoy-Sandbox/enqueue
void ModifyTask(Task* p) { // modif quand CMD.wd
	p->demand=1;
	OpenFile(DEFAULT_EDITOR, PATH_TO_TASKS, p->id);
	//~ ReloadTask(p->id);
	p->demand=0;
}
コード例 #7
0
ファイル: enqueue.c プロジェクト: Pawamoy-Sandbox/enqueue
void ListAllTasks(Task* p) {
	OpenFile("ls", PATH_TO_TASKS, NULL);
}
コード例 #8
0
ファイル: XMLEdit.C プロジェクト: ahota/visit_intel
void
XMLEdit::newdoc()
{
    OpenFile(tr("untitled.xml"));
}
コード例 #9
0
ファイル: gfx.cpp プロジェクト: domino14/SpaceWars2
int Load_Bitmap_File(BITMAP_FILE_PTR bitmap, char *filename)
{
// this function opens a bitmap file and loads the data into bitmap

int file_handle,  // the file handle
    index;        // looping index


UCHAR   *temp_buffer = NULL; // used to convert 24 bit images to 16 bit
OFSTRUCT file_data;          // the file data information

// open the file if it exists
if ((file_handle = OpenFile(filename,&file_data,OF_READ))==-1)
   return(0);


// now load the bitmap file header
_lread(file_handle, &bitmap->bitmapfileheader,sizeof(BITMAPFILEHEADER));

// test if this is a bitmap file
if (bitmap->bitmapfileheader.bfType!=0x4D42)
   {
   // close the file
   _lclose(file_handle);

   // return error
   return(0);

   } // end if

// now we know this is a bitmap, so read in all the sections

// first the bitmap infoheader

// now load the bitmap file header
_lread(file_handle, &bitmap->bitmapinfoheader,sizeof(BITMAPINFOHEADER));

// now load the color palette if there is one
if (bitmap->bitmapinfoheader.biBitCount == 8)
   {
   _lread(file_handle, &bitmap->palette,256*sizeof(PALETTEENTRY));

   // now set all the flags in the palette correctly and fix the reversed 
   // BGR RGBQUAD data format
   for (index=0; index < 256; index++)
       {
       // reverse the red and green fields
       int temp_color                = bitmap->palette[index].peRed;
       bitmap->palette[index].peRed  = bitmap->palette[index].peBlue;
       bitmap->palette[index].peBlue = temp_color;
       
       // always set the flags word to this
       bitmap->palette[index].peFlags = PC_NOCOLLAPSE;
       } // end for index

    } // end if

// finally the image data itself
_lseek(file_handle,-(int)(bitmap->bitmapinfoheader.biSizeImage),SEEK_END);

// now read in the image, if the image is 8 or 16 bit then simply read it
// but if its 24 bit then read it into a temporary area and then convert
// it to a 16 bit image

if (bitmap->bitmapinfoheader.biBitCount==8 || bitmap->bitmapinfoheader.biBitCount==16 || 
    bitmap->bitmapinfoheader.biBitCount==24)
   {
   // delete the last image if there was one
   if (bitmap->buffer)
       free(bitmap->buffer);

   // allocate the memory for the image
   if (!(bitmap->buffer = (UCHAR *)malloc(bitmap->bitmapinfoheader.biSizeImage)))
      {
      // close the file
      _lclose(file_handle);

      // return error
      return(0);
      } // end if

   // now read it in
   _lread(file_handle,bitmap->buffer,bitmap->bitmapinfoheader.biSizeImage);

   } // end if
else
   {
   // serious problem
   return(0);

   } // end else

#if 0
// write the file info out 
printf("\nfilename:%s \nsize=%d \nwidth=%d \nheight=%d \nbitsperpixel=%d \ncolors=%d \nimpcolors=%d",
        filename,
        bitmap->bitmapinfoheader.biSizeImage,
        bitmap->bitmapinfoheader.biWidth,
        bitmap->bitmapinfoheader.biHeight,
		bitmap->bitmapinfoheader.biBitCount,
        bitmap->bitmapinfoheader.biClrUsed,
        bitmap->bitmapinfoheader.biClrImportant);

#endif

// close the file
_lclose(file_handle);

// flip the bitmap
Flip_Bitmap(bitmap->buffer, 
            bitmap->bitmapinfoheader.biWidth*(bitmap->bitmapinfoheader.biBitCount/8), 
            bitmap->bitmapinfoheader.biHeight);

// return success

return(1);

} // end Load_Bitmap_File
コード例 #10
0
ファイル: vtkDCMParser.cpp プロジェクト: fedral/paper
vtkDCMParser::vtkDCMParser(const char *filename)
{
  Init();
  OpenFile(filename);
}
コード例 #11
0
ファイル: jdlv.cpp プロジェクト: epiktetov/juego-de-la-vida
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
jdlvFrame::jdlvFrame (const char *fileToLoad) : nextWorld(NULL),
  isChanged(false),
    eM(elModeView), genNo(0), curColor(0), speed(3), timerID(0)
{
  QFont fixedFont(jdlvFONTFACENAME, jdlvFONTSIZE);
        fixedFont.setStyleHint(QFont::TypeWriter);
  primeWorld = new_elMundoA();
  vista = new elVista (this, primeWorld); setCentralWidget(vista);
  vista->setMinimumSize(720, 480);
  //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  QToolBar *bottom = new permanentToolBar("ctrl", this);
  bottom->setFloatable(false);
  bottom->setMovable  (false);
  bottom->setIconSize(QSize(28,25));
  showTimeCB = new QAction(QIcon(":/time.png"), QString("time"), this);
  showInfoPB = new QAction(QIcon(":/info.png"), QString("info"), this);
  connect(showTimeCB, SIGNAL(triggered(bool)), this, SLOT(ToggleTime(bool)));
  connect(showInfoPB, SIGNAL(triggered()),     this, SLOT(ShowInfo()));
  bottom->addAction(showTimeCB);
  bottom->addAction(showInfoPB);         showInfoPB->setEnabled(false); //+
  bottom->addWidget(new QLabel(" "));
  //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  QActionGroup *modeGroup = new QActionGroup(this);
  modeEdit = new QAction(QIcon(":/pen-in-box.png"),QString("Edit (X)"),  this);
  modeView = new QAction(QIcon(":/eye-half.png"),  QString("View (Z)"),  this);
  setColor = new QAction(QIcon(":/empty1.png"),    QString("color"),     this);
  connect(modeView, SIGNAL(triggered()), this, SLOT(SetModeView()));
  connect(modeEdit, SIGNAL(triggered()), this, SLOT(SetModeEdit()));
  connect(setColor, SIGNAL(triggered()), this, SLOT(PopupColorMenu()));
  showTimeCB->setCheckable(true);
  modeEdit  ->setCheckable(true); modeEdit->setShortcut(QKeySequence("X"));
  modeView  ->setCheckable(true); modeView->setShortcut(QKeySequence("Z"));
  modeView  ->setChecked  (true);
  modeGroup->addAction(modeView); bottom->addAction(modeView);
  modeGroup->addAction(modeEdit); bottom->addAction(modeEdit);
                                  bottom->addAction(setColor);
  //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  QMenu *file_menu = menuBar()->addMenu("File");
  openFile =  new QAction(QIcon(":/book.png"), QString("Open.."), this);
  reLoad = new QAction(QIcon(":/reload1.png"), QString("reload"), this);
  connect(openFile, SIGNAL(triggered()), this, SLOT(OpenFile()));
  connect(reLoad,   SIGNAL(triggered()), this, SLOT(DoReload()));
  file_menu->addAction(openFile);
  file_menu->addAction(reLoad);        reLoad->setEnabled(false);
  //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  QMenu *edit_menu = menuBar()->addMenu("Edit");
  deleteSelected = new QAction(QString("delete"), this);
  deleteSelected->setShortcut(QKeySequence("Del"));
  cropSelected   = new QAction(QString("crop"), this);
  pasteClipboard =
            new QAction(QIcon(":/win-paste.png"),   QString("paste"),    this);
  copyCLR = new QAction(QIcon(":/export-blue.png"), QString("copy"),     this);
  copyBnW = new QAction(QIcon(":/export-mono.png"), QString("copy b/w"), this);
  newWin = new QAction(QIcon(":/windows1.png"),   QString("new window"), this);
  bottom->addAction(pasteClipboard);     pasteClipboard->setEnabled(false); //+
  bottom->addAction(copyCLR); copyCLR->setShortcut(QKeySequence("Ctrl+C"));
  bottom->addAction(copyBnW);
  bottom->addAction(newWin);       newWin->setEnabled(false); //+
  connect(deleteSelected, SIGNAL(triggered()), this, SLOT(DeleteSelected()));
  connect(  cropSelected, SIGNAL(triggered()), this, SLOT(  CropSelected()));
  connect(pasteClipboard, SIGNAL(triggered()), this, SLOT(PasteClipboard()));
  connect(copyCLR, SIGNAL(triggered()), this, SLOT(CopyCLR()));
  connect(copyBnW, SIGNAL(triggered()), this, SLOT(CopyBnW()));
  connect(newWin, SIGNAL(triggered()), this, SLOT(NewWindow()));
  edit_menu->addAction(deleteSelected);
  edit_menu->addAction(  cropSelected); edit_menu->addSeparator();
  edit_menu->addAction(pasteClipboard); edit_menu->addAction(copyCLR);
                                        edit_menu->addAction(copyBnW);
  //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  colorMenu = menuBar()->addMenu("Color");
#define ADD_colorMenu(ico,text,shortcut) \
  colorMenu->addAction(*ico,text)->setShortcut(QKeySequence(shortcut))
  ADD_colorMenu(enBlancoIco,            "blanco",     "B");
  ADD_colorMenu(enRojoIco,              "rojo (red)", "R");
  ADD_colorMenu(enCastanoIco, Utf8("castaño (brown)"),"C");
  ADD_colorMenu(enVerdeIco,          "verde (green)", "V");
  ADD_colorMenu(enAzulIco,             "azul (blue)", "A");
  colorMenu->addSeparator();
  colorMenu->addAction("random Bicolor")->setShortcut(QKeySequence("Ctrl+B"));
  colorMenu->addAction("random Recolor")->setShortcut(QKeySequence("Ctrl+R"));
  colorMenu->addAction("Un-color all")  ->setShortcut(QKeySequence("Ctrl+U"));
  connect(colorMenu, SIGNAL(triggered(QAction*)),
               this, SLOT(SelectColor(QAction*)));
  //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  QLabel *magIcon = new QLabel; magIcon->setPixmap(QPixmap(":/zoom3.png"));
  magText = new QLabel(QString("+1"));
  magText->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
  magText->setFont(fixedFont);
  magText->setMinimumSize(QSize(30,25));     bottom->addWidget(magText);
                                             bottom->addWidget(magIcon);
  fitView = new QAction(QIcon(":/full-size.png"), QString("fit"), this);
  connect(fitView, SIGNAL(triggered()), this, SLOT(DoFitView()));
  bottom->addAction(fitView);
  //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  QMenu *play_menu = menuBar()->addMenu("Play");
  playGen = new QLabel(QString("0"));
  playGen->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
  playGen->setMinimumSize(QSize(66,25));
  prevGen =  new QAction(QIcon(":/step-back.png"),    QString("back"), this);
  nextGen =  new QAction(QIcon(":/go-forward.png") ,  QString("step"), this);
  playStop = new QAction(QIcon(":/fast-forward.png"), QString("go!"),  this);
  connect(prevGen,  SIGNAL(triggered()), this, SLOT(DoPrevGen()));
  connect(nextGen,  SIGNAL(triggered()), this, SLOT(DoNextGen()));
  connect(playStop, SIGNAL(triggered()), this, SLOT(DoPlayStop()));
  play_menu->addAction(nextGen);
  play_menu->addAction(playStop);
  play_menu->addAction(prevGen); prevGen->setEnabled(false);
  //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  speedSlider = new QSlider(Qt::Horizontal, this);
  speedSlider->setMinimum(1); speedSlider->setValue(speed);
  speedSlider->setMaximum(4); speedSlider->setMaximumSize(50,22);
  speedSlider->setSingleStep(1);
  speedSlider->setTickInterval(1);
  speedSlider->setTickPosition(QSlider::TicksBelow);
  connect(speedSlider, SIGNAL(valueChanged(int)), this, SLOT(ChangeSpeed(int)));
  bottom->addWidget(playGen);
  bottom->addAction(nextGen);
  bottom->addWidget(speedSlider);
  bottom->addAction(playStop);
  addToolBar(Qt::BottomToolBarArea, bottom);
  //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  if (fileToLoad) LoadTheWorld(fileToLoad);
  else                       SetWinTitle();
  show(); raise();
}
コード例 #12
0
ファイル: OPEN.C プロジェクト: dtison/imageprep
int OpenImage (int nFlags, LONG lParam)
{
    FARPROC   lpfnOpenDlg;
    int       hInFile = 0;                   
    int       nError = EC_ERROR;             
    int       nFileType;                
    OFSTRUCT  Of;
    ATOM  Atom;
    WORD  wBytes;
    int         hTempFile;
    int         nErr = FALSE;

    /*  First get szOpenFileName filled in   */

    switch (nFlags)
    {
        case SCAN_OPEN:
            CleanFiles ();
            Atom = (ATOM) LOWORD (lParam);
            wBytes = GlobalGetAtomName (Atom, szOpenFileName, 128);
            GlobalDeleteAtom (Atom);
            GetNameFromPath ((LPSTR) szImageName, (LPSTR) szOpenFileName);
            bIsCurrTemp = FALSE;
            bImageModified = FALSE;
        break;

        case USER_OPEN:
    //      CleanFiles ();  BUG HERE????
            lpfnOpenDlg = MakeProcInstance ((FARPROC)OpenDlgProc, hInstIP);
            hInFile = DialogBox (hInstIP, "FILEDLG", hWndIP, lpfnOpenDlg);
            FreeProcInstance (lpfnOpenDlg);
            if (hInFile)
            {
                CleanFiles ();          // Put here instead of before call to dialog
                _lclose (hInFile);      // Kludge..

                /*  Always get image name from path.  Optionally also update the szOpenDir  */

                GetNameFromPath ((LPSTR) szImageName, (LPSTR) szOpenFileName);

                if (szOpenFileName [1] == ':')  // Look for A: or B:, if neither, remember open drive/directory
                {
                    if (! (szOpenFileName [0] == 'A' || szOpenFileName[0] == 'B' || szOpenFileName[0] == 'a' || szOpenFileName[0] == 'b'))
                    {
                        SeparateFile ((LPSTR) szOpenDir, (LPSTR) szImageName, (LPSTR)szOpenFileName);
                        _fstrcpy ((LPSTR) szSaveDir, (LPSTR) szOpenDir);
                    }
                }

                bIsCurrTemp = FALSE;


            }
            else
                nErr = USER_ABANDON;
            bImageModified = FALSE;
        break;

        case COMMAND_LINE_OPEN:
            CleanFiles ();
            _fstrcpy ((LPSTR)szOpenFileName, (LPSTR) lParam);
            GetNameFromPath ((LPSTR) szImageName, (LPSTR) szOpenFileName);
            bIsCurrTemp = FALSE;
            bImageModified = FALSE;
        break;

        case TOOLS_OPEN:
            _fstrcpy ((LPSTR)szOpenFileName, (LPSTR) lParam);
            bIsCurrTemp = TRUE;
        break;

        case OIC_OPEN:
        case AUTO_CONVERT_OPEN:
            _fstrcpy ((LPSTR)szOpenFileName, (LPSTR) lParam);
            bIsCurrTemp = TRUE;
            bImageModified = FALSE;
        break;

        case CLIPBOARD_OPEN:
            CleanFiles ();
            Atom = (ATOM) LOWORD (lParam);
            wBytes = GlobalGetAtomName (Atom, szOpenFileName, 128);
            GlobalDeleteAtom (Atom);
            _fstrcpy ((LPSTR) szImageName, (LPSTR) "Untitled");
            bIsCurrTemp = TRUE;
            bImageModified = FALSE;
        break;

        case GENERIC_OPEN:
        case UNDO_OPEN:
            _fstrcpy ((LPSTR)szOpenFileName, (LPSTR) lParam);
        break;

    }

    if (nErr != 0)
        return (nErr);

    hInFile = OpenFile ((LPSTR)szOpenFileName, (LPOFSTRUCT)&Of, OF_READWRITE);

    if (hInFile <= 0)
    {
        if (hInFile == 0)
        hInFile = IDCANCEL;
        nError = hInFile;
        return (nError);
    }

    /* Identify and Import File    */

    if (image_active)
    {
        _fstrcpy ((LPSTR) szTempPath,  (LPSTR) szOpenFileName);     // Store it somewhere

        SendMessage (hWndDisplay, WM_CLOSE, 0, 0);    // Close that baby down!

        if (nFlags == USER_OPEN)                      // So we don't re-display dialog
            nFlags = COMMAND_LINE_OPEN;
        else
            if (nFlags == CLIPBOARD_OPEN)
                nFlags = GENERIC_OPEN;                   

        _lclose (hInFile);

        PostMessage (hWndIP, WM_SHOWIMAGE, nFlags, (LONG) (LPSTR) szTempPath); // Re-prime the pump

        return (0);
    }

    _fstrcpy ((LPSTR) szCurrFileName, (LPSTR) szOpenFileName);  // For having UNDO cap.  5/91

    _llseek (hInFile, 0L, 0);

    nFileType = IdentFormat (hInFile, (LPSTR) szOpenFileName);
    if (nFileType < 0)
    {
        /* File type unknown    */

        _lclose (hInFile);
        hImportFile = 0; 
        return (nFileType);
    }

        switch (nFileType)
        {
            case IDFMT_CCPI:
            {
                char Buffer [128];

                GetTempFileName (0, (LPSTR) "OIC", 0, (LPSTR) Buffer);
                #ifndef DECIPHER
                /* If file type is compressed cpi, decompress first, then re-open     */
                hTempFile = DecompressCPI (hInFile ,(LPSTR) Buffer);
                if (hTempFile > 0)
                {
                    _lclose (hInFile);
                    return (OpenImage (OIC_OPEN, (LONG) (LPSTR) Buffer));
                }
                else
                    return (hTempFile);
    
            }
                #else
            return (EC_UFILETYPE);
                #endif
            break;
    
            case IDFMT_WMF:
            {
                char Buffer [128];
                WORD Retval;

                wUserImportType = (WORD) nFileType;
                GetTempFileName (0, (LPSTR) "WMF", 0, (LPSTR) Buffer);
                Retval = wmfImportMetaFile (hWndIP, hInFile, (LPSTR) Buffer);
                if (Retval == 0)
                {
                    _lclose (hInFile);
                    return (OpenImage (OIC_OPEN, (LONG) (LPSTR) Buffer));
                }
                else
                    return (USER_ABANDON);
    
            }
            break;

            case IDFMT_CPI:
            break;
    
            default:
    
            if (bDoDisplay)           // If we are going to actually display the thing, we may need to do some stuff first..
            if (bAutoConvert)
            {
                /*  Now if opened image is not CPI, save as CPI and re-open as CPI  */
    
                if (wImportType != IDFMT_CPI)
                    if (bAutoConvert)
                    {
                        wUserImportType = (WORD) nFileType;
                        hImportFile = hInFile;
                        SetState (IMPORT_TYPE, nFileType);  
                        nError = ImportFile();
                        if (nError != 0)
                            return (nError);
                        else
                            return (DoSave (SAVE_TO_CPI)); 
                    }
            }
            break;
        }

    hImportFile = hInFile;      
    SetState (IMPORT_TYPE, nFileType);  
    if (! wUserImportType)
        wUserImportType = wImportType;
    nError = ImportFile();

    if (nError >= 0)
        if (! bDoDisplay)
            PostMessage (hWndIP, WM_COMMAND, IDM_SAVE, 0L);

    return (nError);
}
コード例 #13
0
ファイル: InitUnitHydrograph.c プロジェクト: michaeco/D-SEM
/*****************************************************************************
  Function name: InitUnitHydrograph()

  Purpose      :

  Required     :

  Returns      : void

  Modifies     :

  Comments     :
*****************************************************************************/
void InitUnitHydrograph(LISTPTR Input, MAPSIZE * Map, TOPOPIX ** TopoMap,
			UNITHYDR *** UnitHydrograph, float **Hydrograph,
			UNITHYDRINFO * HydrographInfo)
{
  const char *Routine = "InitUnitHydrograph()";
  char VarName[BUFSIZE + 1];	/* Variable name */
  FILE *HydrographFile;
  int MaxTravelTime;
  int NumberType;
  int TravelTimeStep;
  int WaveLength;
  int i;
  int j;
  int x;
  int y;
  STRINIENTRY StrEnv[] = {
    {"ROUTING", "TRAVEL TIME FILE", "", NULL},
    {"ROUTING", "UNIT HYDROGRAPH FILE", "", NULL},
    {NULL, NULL, "", NULL}
  };
  unsigned short *Travel;

  printf("Initializing unit hydrograph\n");

  /* Read the key-entry pairs from the [ROUTING] section of the input file */
  for (i = 0; StrEnv[i].SectionName; i++) {
    GetInitString(StrEnv[i].SectionName, StrEnv[i].KeyName, StrEnv[i].Default,
		  StrEnv[i].VarStr, (unsigned long) BUFSIZE, Input);
    if (!StrEnv[i].VarStr)
      ReportError(StrEnv[i].KeyName, 51);
  }

  /* Read the travel times */
  GetVarName(006, 0, VarName);
  GetVarNumberType(006, &NumberType);
  if (!(Travel = (unsigned short *) calloc(Map->NX * Map->NY,
					   SizeOfNumberType(NumberType))))
    ReportError((char *) Routine, 1);

  Read2DMatrix(StrEnv[travel_file].VarStr, Travel, NumberType, Map->NY,
	       Map->NX, 0, VarName);

  /* Assign the travel times to the correct pixels */
  for (y = 0, i = 0; y < Map->NY; y++)
    for (x = 0; x < Map->NX; x++, i++)
      TopoMap[y][x].Travel = Travel[i];
  free(Travel);

  /* Read the unit hydrograph file */
  OpenFile(&HydrographFile, StrEnv[hydrograph_file].VarStr, "r", FALSE);
  fscanf(HydrographFile, "%d", &MaxTravelTime);
  HydrographInfo->MaxTravelTime = MaxTravelTime;

  if (!(HydrographInfo->WaveLength =
	(int *) calloc(MaxTravelTime, sizeof(int))))
    ReportError((char *) Routine, 1);
  if (!(*UnitHydrograph =
	(UNITHYDR **) calloc(MaxTravelTime, sizeof(UNITHYDR *))))
    ReportError((char *) Routine, 1);

  for (i = 0; i < MaxTravelTime; i++) {

    fscanf(HydrographFile, "%d %d", &TravelTimeStep, &WaveLength);
    if (i != TravelTimeStep - 1)
      ReportError(StrEnv[hydrograph_file].VarStr, 46);
    HydrographInfo->WaveLength[i] = WaveLength;

    if (!((*UnitHydrograph)[i] =
	  (UNITHYDR *) calloc(WaveLength, sizeof(UNITHYDR))))
      ReportError((char *) Routine, 1);

    for (j = 0; j < WaveLength; j++) {
      fscanf(HydrographFile, "%d %f",
	     &((*UnitHydrograph)[i][j].TimeStep),
	     &((*UnitHydrograph)[i][j].Fraction));
    }
  }

  HydrographInfo->TotalWaveLength =
    (*UnitHydrograph)[MaxTravelTime - 1][WaveLength - 1].TimeStep + 1;

  if (!(*Hydrograph = (float *) calloc(HydrographInfo->TotalWaveLength,
				       sizeof(float))))
    ReportError((char *) Routine, 1);

  fclose(HydrographFile);
}
コード例 #14
0
ファイル: jtwain.cpp プロジェクト: bluearth/orca2
BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
   if (fdwReason == DLL_PROCESS_ATTACH)
   {
       // Save instance handle for later access in other functions.

       g_hinstDLL = hinstDLL;

       // Create a buffer for holding the Windows directory path.

       char szPath [150]; // Probably only 140 is needed, but why not be safe?

       // Retrieve the path of the Windows directory.

       GetWindowsDirectory (szPath, 128);

       // Obtain number of characters copied into the buffer.

       int iLen = lstrlen (szPath);

       // Path ends in a backslash character if the directory is the root.
       // Otherwise, path does not end in backslash. In that case, we must
       // append a backslash character to the path.

       if (iLen != 0 && szPath [iLen-1] != '\\')
           lstrcat (szPath, "\\");

       // Append TWAIN_32.DLL to the path. This is the 32-bit TWAIN DLL that
       // we need to communicate with.

	   lstrcat (szPath, "TWAIN_32.DLL");

       // If the TWAIN_32.DLL file exists in the path (which is determined by
       // opening and closing that file), attempt to load TWAIN_32.DLL into
       // the calling process's address space.

       OFSTRUCT ofs;
       if (OpenFile (szPath, &ofs, OF_EXIST) != -1)
           g_hLib = LoadLibrary (szPath);

       // Report failure if TWAIN_32.DLL cannot be loaded and terminate the
       // JTWAIN DLL.

       if (g_hLib == 0)
       {
           MessageBox (0, "Unable to open TWAIN_32.DLL", "JTWAIN", MB_OK);
           return FALSE;
       }

       // Attempt to retrieve DSM_Entry() function address.

       g_pDSM_Entry = (DSMENTRYPROC) GetProcAddress (g_hLib, "DSM_Entry");

       // Report failure if DSM_Entry() function not found in TWAIN_32.DLL
       // and terminate the JTWAIN DLL.

       if (g_pDSM_Entry == 0)
       {
           MessageBox (0, "Unable to fetch DSM_Entry address", "JTWAIN", 
                       MB_OK);
           return FALSE;
       }

       // Initialize g_AppID. This structure is passed to DSM_Entry() in each
       // function call.

       g_AppID.Id = 0;
       g_AppID.Version.MajorNum = 1;
       g_AppID.Version.MinorNum = 0;
       g_AppID.Version.Language = TWLG_ENGLISH_USA;
       g_AppID.Version.Country = TWCY_USA;

       lstrcpy (g_AppID.Version.Info, "JTWAIN 1.0");

       g_AppID.ProtocolMajor = TWON_PROTOCOLMAJOR;
       g_AppID.ProtocolMinor = TWON_PROTOCOLMINOR;
       g_AppID.SupportedGroups = DG_CONTROL | DG_IMAGE;

       lstrcpy (g_AppID.Manufacturer, "Jeff Friesen");
       lstrcpy (g_AppID.ProductFamily, "Java-based Image Capture");
       lstrcpy (g_AppID.ProductName, "JTWAIN");
   }
   else
   if (fdwReason == DLL_PROCESS_DETACH)
   {
       // If the TWAIN_32.DLL library was loaded, remove it from memory.

       if (g_hLib != 0)
           FreeLibrary (g_hLib);
   }

   return TRUE;
}
コード例 #15
0
ファイル: main_amiga.c プロジェクト: AndrewCRMartin/AMPlot
/*>HandleEvent(APTR object)
   ------------------------
   Dispatch menu events.
   12.03.92 Original.
   30.03.92 Modified MenuEdit to call OpenFile() directly.
   31.03.92 Modified MenuSave to call SaveAsFile() directly.
   05.05.92 Added Rexx menu handling
   12.06.92 Removed fill grey/hatch items and replaced with requester
   02.07.92 Added MenuPalette
   13.07.92 Added MenuScrBack
   20.07.92 Added DEMO_VERSION conditional
   07.08.92 Added RemoveFills()
*/
HandleEvent(APTR object)
{
   if(object == (APTR)MenuOpen)     { OpenFile(object);        return(0); }
   if(object == (APTR)MenuSave)     { SaveAsFile(object);      return(0); }
   if(object == (APTR)MenuSaveAs)   { SaveAsFile(object);      return(0); }
   if(object == (APTR)MenuEdit)     { OpenFile(object);        return(0); }
   if(object == (APTR)MenuPaper)    { SetPaper(object);        return(0); }
   if(object == (APTR)MenuSetPens)  { SetPens(object);         return(0); }
   if(object == (APTR)MenuPalette)  { SetPalette(object);      return(0); }
   if(object == (APTR)MenuScrBack)  { ScreenToBack(MyScreen);  return(0); }
   if(object == (APTR)MenuAbout)    { About(object);           return(0); }
   if(object == (APTR)MenuQuit)     { QuitProgram(object);     return(0); }
#ifndef DEMO_VERSION
   if(object == (APTR)MenuPS)       { PlotPS(object);          return(0); }
   if(object == (APTR)MenuHPGL)     { PlotHPGL(object);        return(0); }
   if(object == (APTR)MenuDR2D)     { PlotDR2D(object);        return(0); }
#endif
   if(object == (APTR)MenuXY)       { StyleXY(object);         return(0); }
   if(object == (APTR)MenuScatter)  { StyleScatter(object);    return(0); }
   if(object == (APTR)MenuBar)      { StyleBar(object);        return(0); }
   if(object == (APTR)MenuPie)      { StylePie(object);        return(0); }
   if(object == (APTR)MenuErrors)   { ToggleErrors(object);    return(0); }
   if(object == (APTR)MenuEject)    { EjectSlice(object);      return(0); }
   if(object == (APTR)MenuLineSet)  { SetLine(object);         return(0); }
   if(object == (APTR)MenuBarSet)   { SetBar(object);          return(0); }
   if(object == (APTR)MenuPieSet)   { SetPie(object);          return(0); }
   if(object == (APTR)MenuLogX)     { ToggleLogX(object);      return(0); }
   if(object == (APTR)MenuLogY)     { ToggleLogY(object);      return(0); }
   if(object == (APTR)MenuBoxed)    { ToggleBoxed(object);     return(0); }
   if(object == (APTR)MenuGrid)     { ToggleGrid(object);      return(0); }
   if(object == (APTR)MenuAxes)     { SetAxes(object);         return(0); }
   if(object == (APTR)MenuFZero)    { ToggleFZero(object);     return(0); }
   if(object == (APTR)MenuTitle)    { SetTitle(object);        return(0); }
   if(object == (APTR)MenuAxTitle)  { SetAxTitle(object);      return(0); }
   if(object == (APTR)MenuAxLabel)  { SetAxLabel(object);      return(0); }
   if(object == (APTR)MenuKey)      { SetKey(object);          return(0); }
   if(object == (APTR)MenuLabel)    { SetLabel(object);        return(0); }
   if(object == (APTR)MenuPen)      { ChangePen(object);       return(0); }
   if(object == (APTR)MenuFillType) { FillControl(object);     return(0); }
   if(object == (APTR)MenuRegress)  { SetRegress(object);      return(0); }
   if(object == (APTR)MenuRobust)   { ToggleRobust(object);    return(0); }
   if(object == (APTR)MenuFourier)  { SetFourier(object);      return(0); }
   if(object == (APTR)MenuRexxFit)  { RexxFit(object);         return(0); }
   if(object == (APTR)MenuRexx)     { InstallMacro(object);    return(0); }
   if(object == (APTR)MenuRunRexx)  { RunMacro(object);        return(0); }
   if(object == (APTR)MenuDebRexx)  { ToggleRexxDeb(object);   return(0); }
   if(object == (APTR)MenuLS1)      { SetLineDash(object);     return(0); }
   if(object == (APTR)MenuLS2)      { SetLineDash(object);     return(0); }
   if(object == (APTR)MenuLS3)      { SetLineDash(object);     return(0); }
   if(object == (APTR)MenuLS4)      { SetLineDash(object);     return(0); }
   if(object == (APTR)MenuLS5)      { SetLineDash(object);     return(0); }
   if(object == (APTR)MenuLS6)      { SetLineDash(object);     return(0); }
   if(object == (APTR)MenuFT1)      { SetFillType(object);     return(0); }
   if(object == (APTR)MenuFT2)      { SetFillType(object);     return(0); }
   if(object == (APTR)MenuFT3)      { SetFillType(object);     return(0); }
   if(object == (APTR)MenuFT4)      { SetFillType(object);     return(0); }
   if(object == (APTR)MenuFT5)      { SetFillType(object);     return(0); }
   if(object == (APTR)MenuFT6)      { SetFillType(object);     return(0); }
   if(object == (APTR)MenuNoFills)  { RemoveFills(object);     return(0); }

   return(0);
}
コード例 #16
0
ファイル: CLSource.hpp プロジェクト: GRGSIBERIA/TinyCL
		/**
		* ソースコードを管理するためのクラス
		* \param[in] filename ファイル名
		* \param[in] kernelName カーネル名
		* \param[in] type ソースコードの種類
		*/
		CLSource(const std::string& filename, const std::string& kernelName, const SourceType type)
			: fileName(filename), kernelName(kernelName), type(type)
		{
			OpenFile();
		}
コード例 #17
0
bool PoeditApp::OnInit()
{
    if (!wxApp::OnInit())
        return false;

#if defined(__WXMAC__)
    wxSystemOptions::SetOption(wxMAC_TEXTCONTROL_USE_SPELL_CHECKER, 1);
#endif

#ifdef __WXMAC__
    SetExitOnFrameDelete(false);
#endif

#if defined(__UNIX__) && !defined(__WXMAC__)
    wxString home = wxGetHomeDir() + "/";

    // create Poedit cfg dir, move ~/.poedit to ~/.poedit/config
    // (upgrade from older versions of Poedit which used ~/.poedit file)
    if (!wxDirExists(home + ".poedit"))
    {
        if (wxFileExists(home + ".poedit"))
            wxRenameFile(home + ".poedit", home + ".poedit2");
        wxMkdir(home + ".poedit");
        if (wxFileExists(home + ".poedit2"))
            wxRenameFile(home + ".poedit2", home + ".poedit/config");
    }
#endif

    SetVendorName("Vaclav Slavik");
    SetAppName("Poedit");

#if defined(__WXMAC__)
    #define CFG_FILE (wxStandardPaths::Get().GetUserConfigDir() + "/net.poedit.Poedit.cfg")
#elif defined(__UNIX__)
    #define CFG_FILE (home + ".poedit/config")
#else
    #define CFG_FILE wxEmptyString
#endif

#ifdef __WXMAC__
    // upgrade from the old location of config file:
    wxString oldcfgfile = wxStandardPaths::Get().GetUserConfigDir() + "/poedit.cfg";
    if (wxFileExists(oldcfgfile) && !wxFileExists(CFG_FILE))
    {
        wxRenameFile(oldcfgfile, CFG_FILE);
    }
#endif

    wxConfigBase::Set(
        new wxConfig(wxEmptyString, wxEmptyString, CFG_FILE, wxEmptyString, 
                     wxCONFIG_USE_GLOBAL_FILE | wxCONFIG_USE_LOCAL_FILE));
    wxConfigBase::Get()->SetExpandEnvVars(false);

    wxImage::AddHandler(new wxGIFHandler);
    wxImage::AddHandler(new wxPNGHandler);
    wxXmlResource::Get()->InitAllHandlers();

#if defined(__WXMAC__)
    wxXmlResource::Get()->Load(wxStandardPaths::Get().GetResourcesDir() + "/*.xrc");
#elif defined(__WXMSW__)
	wxStandardPaths::Get().DontIgnoreAppSubDir();
    wxXmlResource::Get()->Load(wxStandardPaths::Get().GetResourcesDir() + "\\Resources\\*.xrc");
#else
    InitXmlResource();
#endif

    SetDefaultCfg(wxConfig::Get());

    wxArtProvider::PushBack(new PoeditArtProvider);

    SetupLanguage();

#ifdef __WXMAC__
    wxMenuBar::MacSetCommonMenuBar(wxXmlResource::Get()->LoadMenuBar("mainmenu_mac_global"));
    // so that help menu is correctly merged with system-provided menu
    // (see http://sourceforge.net/tracker/index.php?func=detail&aid=1600747&group_id=9863&atid=309863)
    s_macHelpMenuTitleName = _("&Help");
#endif

    FileHistory().Load(*wxConfig::Get());

#ifdef USE_TRANSMEM
    // NB: It's important to do this before TM is used for the first time.
    TranslationMemory::MoveLegacyDbIfNeeded();
#endif

    // NB: opening files or creating empty window is handled differently on
    //     Macs, using MacOpenFile() and MacNewFile(), so don't create empty
    //     window if no files are given on command line; but still support
    //     passing files on command line
    if (!gs_filesToOpen.empty())
    {
        for (size_t i = 0; i < gs_filesToOpen.GetCount(); i++)
            OpenFile(gs_filesToOpen[i]);
        gs_filesToOpen.clear();
    }
#ifndef __WXMAC__
    else
    {
        OpenNewFile();
    }
#endif // !__WXMAC__

#ifdef USE_SPARKLE
    Sparkle_Initialize(CheckForBetaUpdates());
#endif // USE_SPARKLE

#ifdef __WXMSW__
    const char *appcast = "http://releases.poedit.net/appcast-win";

    if ( CheckForBetaUpdates() )
    {
        // Beta versions use unstable feed.
        appcast = "http://releases.poedit.net/appcast-win/beta";
    }

    win_sparkle_set_appcast_url(appcast);
    win_sparkle_init();
#endif

    return true;
}
コード例 #18
0
ファイル: dosio.c プロジェクト: perabuss/np2wii
FILEH file_open_rb(const char *path) {

	return(OpenFile(path));
}
コード例 #19
0
ファイル: enqueue.c プロジェクト: Pawamoy-Sandbox/enqueue
void OpenConfig(Task* p) {
	OpenFile(DEFAULT_EDITOR, PATH_TO_CONFIG, NULL);
	// reload config
	GetConfig();
}
コード例 #20
0
ファイル: InitDump.c プロジェクト: Lizzy0Sun/DHSVM
/*******************************************************************************
  Function name: InitPixDump()

  Purpose      : Initialize the pixel dumps.  This information is in the
         [OUTPUT] section of the input file

  Required     :
    LISTPTR Input         - Linked list with input strings
    MAPSIZE *Map          - Information about basin extent
    uchar **BasinMask     - Basin mask
    char *Path            - Directory to write output to
    int NPix              - Number of pixels to dump
    PIXDUMP **Pix         - Array of pixels to dump

  Returns      : number of accepted dump pixels (i.e. in the mask, etc)

  Modifies     : NPix and its members

  Comments     :
*******************************************************************************/
int InitPixDump(LISTPTR Input, MAPSIZE *Map, uchar **BasinMask, char *Path,
  int NPix, PIXDUMP **Pix, OPTIONSTRUCT *Options)
{
  char *Routine = "InitPixDump";
  char Str[BUFSIZE + 1];
  double North;
  double East;
  int i;			/* counter */
  int j;
  int ok;
  char temp_name[BUFSIZE + 1];
  char KeyName[name + 1][BUFSIZE + 1];
  char *KeyStr[] = {
    "NORTH COORDINATE",
    "EAST COORDINATE",
    "NAME"
  };
  char *SectionName = "OUTPUT";
  char VarStr[name + 1][BUFSIZE + 1];

  ok = 0;

  if (!(*Pix = (PIXDUMP *)calloc(NPix, sizeof(PIXDUMP))))
    ReportError(Routine, 1);

  for (i = 0; i < NPix; i++) {

    /* Read the key-entry pairs from the input file */
    for (j = 0; j <= name; j++) {
      sprintf(KeyName[j], "%s %d", KeyStr[j], i + 1);
      GetInitString(SectionName, KeyName[j], "", VarStr[j],
        (unsigned long)BUFSIZE, Input);
    }

    /* Assign the entries to the appropriate variables */
    if (!CopyDouble(&North, VarStr[north], 1))
      ReportError(KeyName[north], 51);

    if (!CopyDouble(&East, VarStr[east], 1))
      ReportError(KeyName[east], 51);

    if (IsEmptyStr(VarStr[name]))
      ReportError(KeyName[name], 51);
    strcpy(temp_name, VarStr[name]);

    /* Convert map coordinates to matrix coordinates */
    (*Pix)[i].Loc.N = Round(((Map->Yorig - 0.5 * Map->DY) - North) / Map->DY);
    (*Pix)[i].Loc.E = Round((East - (Map->Xorig + 0.5 * Map->DX)) / Map->DX);

    if (!InArea(Map, &((*Pix)[i].Loc)) ||
      !INBASIN(BasinMask[(*Pix)[i].Loc.N][(*Pix)[i].Loc.E])) {
      printf("Ignoring dump command for pixel named %s \n", temp_name);
    }
    else {
      printf("Accepting dump command for pixel named %s \n", temp_name);
      sprintf(Str, "%s", temp_name);
      sprintf((*Pix)[ok].OutFile.FileName, "%sPixel.%s", Path, Str);
      (*Pix)[ok].Loc.N = (*Pix)[i].Loc.N;
      (*Pix)[ok].Loc.E = (*Pix)[i].Loc.E;
      OpenFile(&((*Pix)[ok].OutFile.FilePtr), (*Pix)[ok].OutFile.FileName, "w", TRUE);
      ok++;
    }
  }
  return ok;
}
コード例 #21
0
ファイル: main.c プロジェクト: yamma-ma/KABURAGI
int main(int argc, char** argv)
{
	static APPLICATION application = {0};
	
	static APPLICATION_LABELS labels =
	{
		"English",
		{"OK", "Apply", "Cancel", "Normal", "Reverse", "Edit Selection", "Window",
			"Close Window", "Dock Left", "Dock Right", "Full Screen", "Reference Image Window",
			"Move Top Left", "Hot Key", "Loading...", "Saving..."},
		{"pixel", "Length", "Angle", "_BG", "Loop", "Preview", "Interval", "minute", "Detail", "Target",
			"Clip Board", "Name", "Type", "Resolution", "Center", "Straight", "Grow", "Mode", "Red", "Green", "Blue",
			"Cyan", "Magenta", "Yellow", "Key Plate", "Add", "Delete"},
		{"File", "New", "Open", "Open as Layer", "Save", "Save as", "Close", "Quit", "Edit", "Undo", "Redo",
			"Copy", "Copy Visible", "Cut", "Paste", "Clipboard", "Transform", "Projection", "Canvas",
			"Change Resolution", "Change Canvas Size", "Flip Canvas Horizontally", "Flip Canvas Vertically",
			"Switch _BG Color", "Change 2nd _BG Color", "Change ICC Profile", "Layer", "_New Layer(Color)",
			"_New Layer(Vector)", "_New Layer Set", "_New 3D Modeling Layer", "_Copy Layer", "_Delete Layer",
			"Fill with _FG Color", "Fill with Pattern", "Rasterize Layer", "Merge Down", "_Flatten Image",
			"_Visible to Layer", "Visible Copy", "Select", "None", "Invert", "All", "Grow", "Shrink", "View", "Zoom",
			"Zoom _In", "Zoom _Out", "Actual Size", "Reverse Horizontally", "Rotate", "Reset Roatate",
			"Display Filters", "Nothing", "Gray Scale", "Gray Scale (YIQ)", "Filters", "Blur", "Motion Blur",
			"Gaussian Blur", "Brightness & Contrast", "Hue & Saturation", "Levels", "Tone Curve",
			"Luminosity to Opacity", "Color to Alpha", "Colorize with Under Layer", "Gradation Map",
			"Map with Detect Max Black Value", "Transparency as White", "Fill with Vector", "Render", "Cloud",
			"Fractal", "Plug-in", "Script", "Help", "Version"
		},
		{"New", "New Canvas", "Width", "Height", "2nd BG Color", "Adopt ICC Profile?", "Preset", "Add Preset",
			"Swap Height and Width"},
		{"Tool Box", "Initialize", "New Brush", "Smooth", "Quality", "Rate", "Gaussian", "Average", "Magnification",
			"Brush Size", "Scale", "Flow", "Pressure", "Extend Range", "Blur", "OutLine Hardness",
			"Color Extends", "Start Distance of Drag and Move", "Anti Alias", "Change Text Color", "Horizonal",
			"Vertical", "Style", "Normal", "Bold", "Italic", "Oblique", "Balloon", "Balloon Has Edge", "Line Color",
			"Fill Color", "Line Width", "Change Line Width", "Manually Set", "Aspect Ratio", "Centering Horizontally",
			"Centering Vertically", "Adjust Range to Text", "Number of Edge,", "Edge Size", "Edge Size Random",
			"Edge Distance Random", "Number of Children", "Start Child Size", "End Child Size", "Reverse",
			"Reverse Horizontally", "Reverse Vertically", "Blend Mode", "Hue", "Saturation", "Brightness", "Contrast",
			"Distance", "Rotate Start", "Rotate Speed", "Random Rotate", "Rotate to Brush Direction", "Size Range",
			"Rotate Range", "Random Size", "Clockwise", "Counter Clockwise", "Both Direction", "Minimum Degree",
			"Minumum Distance", "Minimum Pressure", "Enter", "Out", "Enter & Out", "Mix", "Reverse FG BG",
			"Devide Stroke", "Delete Stroke", "Target", "Stroke", "Prior Angle", "Control Point", "Free", "Scale",
			"Free Shape", "Rotate", "Preference", "Name", "Copy Brush", "Change Brush", "Delete Brush", "Texture",
			"Strength", "No Texture", "Add Color", "Delete Color", "Load Pallete", "Add Pallete", "Write Pallete",
			"Clear Pallete", "Pick Mode", "Single Pixel", "Average Color", "Open Path", "Close Path", "Update",
			"Frequency", "Cloud Color", "Persistence", "Random Seed", "Use Random", "Update Immediately",
			"Number of Octaves", "Linear", "Cosine", "Cubic", "Colorize", "Start Editting 3D Model",
			"Finish Editting 3D Model", "Scatter", "Scatter Size", "Scatter Range", "Random Size Scatter",
			"Random Flow Scatter", "Bevel", "Round", "Mitter", "Normal Brush",
			{"Pencil", "Hard Pen", "Air Brush", "Old Air Brush", "Water Color Brush", "Picker Brush", "Eraser", "Bucket",
				"Pattern Fill", "Blur Tool", "Smudge", "Mix Brush", "Gradation", "Text Tool", "Stamp Tool",
				"Image Brush", "Image Blend\nBrush", "Picker Image Brush", "Script Brush", "Custom Brush", "PLUG_IN"},
			{"Detection Target", "Detect from ... ", "Pixels Color", "Pixel Color + Alpha",
				"Alpha", "Active Layer", "Under Layer", "Canvas", "Threshold", "Detection Area", "Normal", "Large"},
			{"Select/Release", "Move Control Point", "Change Pressure", "Delete Control Point",
				"Move Stroke", "Copy & Move Stroke", "Joint Stroke"},
			{"Circle", "Eclipse", "Triangle", "Square", "Rhombus", "Hexagon", "Star", "Pattern", "Image"}
		},
		{"Layer", "Layer", "Vector", "Layer Set", "Text", "3D Modeling", "Add Layer", "Add Vector Layer",
			"Add Layer Set", "Add 3D Modeling Layer", "Rename Layer", "Reorder Layer", "Opacity to Selection Area",
			"Opacity Add Selection Area", "Pasted Layer", "Under Layer", "Mixed Under Layer", "Blend Mode", "Opacity",
			"Masking with Under Layer", "Lock Opacity",
			{"Normal", "Add", "Multiply", "Screen", "Overlay", "Lighten", "Darken", "Dodge", "Burn",
				"Hard Light", "Soft Light", "Difference", "Exclusion", "Hue", "Saturation", "Color",
				"Luminosity", "Binalize"}},
		{"Random (Straight)", "Bidirection"},
		{"Compress", "Quality", "Write Opacity Data", "Write ICC Profile Data", "Save before close the image?",
			"There are some images with unsaved changes.", "There is Backup File.\nRecover it?"},
		{"Navigtion"},
		{"Preference", "Base Settings", "Auto Save", "Theme", "Default",
			"There is a conflict to set a hot key.", "Language", "Backup File Directory",
			"Show Preview Window on Taskbar", "Draw with Touch", "Scale Change and Move Canvas with Change",
			"Set Back Ground Color"},
		{"Execute Back Up..."}
	};

	static FRACTAL_LABEL fractal_labels =
	{
		"Triangle", "Transform", "Variations", "Colors", "Random",
		"Weight", "Symmetry", "Linear", "Sinusoidal", "Spherical",
		"Swirl", "Shorseshoe", "Polar", "Handkerchief", "Heart", "Disc",
		"Spiral", "Hyperbolic", "Diamond", "Ex", "Julia", "Bent", "Waves",
		"Fish Eye", "Pop Corn", "Preserve Weights", "Update", "Update Immediately",
		"Adjust", "Rendering", "Gamma", "Brightness", "Vibrancy", "Camera", "Zoom",
		"Option", "Oversample", "Filter Radius", "Forced Symmetry", "Type",
		"Order", "None", "Bilateral", "Rotational", "Dihedral", "Mutation",
		"Directions", "Controls", "Speed", "Trend", "Auto Zoom", "Add", "Delete",
		"Flip Horizontal", "Flip Vertical", "Flip Horizontal All",
		"Flip Vertical All", "Use Random", "Rest", "Create ID"
	};

	void *tbb = NULL;

#if defined(CHECK_MEMORY_POOL) && CHECK_MEMORY_POOL != 0
	_CrtSetDbgFlag(_CRTDBG_CHECK_ALWAYS_DF);
#endif

#if defined(USE_3D_LAYER) && USE_3D_LAYER != 0
	application.flags |= APPLICATION_HAS_3D_LAYER;
	tbb = TbbObjectNew();
#endif

	{
		gchar *raw_path;

		application.labels = &labels;
		application.fractal_labels = &fractal_labels;

#if GTK_MAJOR_VERSION <= 2
		gtk_set_locale();
#endif
		gtk_init(&argc, &argv);

#if defined(USE_3D_LAYER) && USE_3D_LAYER != 0
		gtk_gl_init(&argc, &argv);
#endif

		raw_path = g_locale_to_utf8(argv[0], -1, NULL, NULL, NULL);
		application.current_path = g_path_get_dirname(raw_path);

		InitializeApplication(&application, INITIALIZE_FILE_NAME);
		g_free(raw_path);
	}

	/*
	{
		cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 500, 500);
		cairo_t *cairo_p = cairo_create(surface);

		cairo_scale(cairo_p, 1, 2);
		cairo_arc(cairo_p, 100, 100, 50, 0, 2*G_PI);
		cairo_fill(cairo_p);

		cairo_surface_write_to_png(surface, "test.png");

		cairo_destroy(cairo_p);
	}
	*/

	if(argc > 1)
	{
		gchar *file_path = g_locale_to_utf8(argv[1], -1, NULL, NULL, NULL);

		OpenFile(file_path, &application);

		g_free(file_path);

#ifdef _PROFILING
		return 0;
#endif
	}

	gtk_main();

#if defined(USE_3D_LAYER) && USE_3D_LAYER != 0
	DeleteTbbObject(tbb);
#endif

	return 0;
}
コード例 #22
0
ファイル: InitDump.c プロジェクト: Lizzy0Sun/DHSVM
 /*******************************************************************************
   Function name: InitDump()

   Purpose      : Read the model output information from the options file, and
                  organize what to output when.  This information is in the
          [OUTPUT] section

   Required     :
     LISTPTR Input         - Linked list with input strings
     OPTIONSTRUCT *Options - Mode options
     MAPSIZE *Map          - Information about basin area
     int MaxSoilLayers     - Maximum number of soil layers
     int MaxVegLayers      - Maximum number of vegetation layers
     int Dt                - Time step in seconds
     TOPOPIX **TopoMap     - Information about terrain characteristics
     DUMPSTRUCT *Dump      - Information on what to output when

   Returns      : void

   Modifies     : Members of Dump

   Comments     :
 *****************************************************************************/
void InitDump(LISTPTR Input, OPTIONSTRUCT *Options, MAPSIZE *Map, int MaxSoilLayers, 
  int MaxVegLayers, int Dt, TOPOPIX **TopoMap, DUMPSTRUCT *Dump, int *NGraphics,
  int **which_graphics)
{
  char *Routine = "InitDump";
  int i;
  int x;			/* counter */
  int y;			/* counter */
  int NImageVars;		/* Number of different variables for which to
                   dump images */
  int NMapVars;			/* Number of different variables for which to
                   dump maps */
  int temp_count;
  uchar **BasinMask;
  char sumoutfile[100];


  STRINIENTRY StrEnv[] = {
    {"OUTPUT", "OUTPUT DIRECTORY", "", ""},
    {"OUTPUT", "INITIAL STATE DIRECTORY", "", ""},
    {"OUTPUT", "NUMBER OF OUTPUT PIXELS", "", ""},
    {"OUTPUT", "NUMBER OF MODEL STATES", "", ""},
    {"OUTPUT", "NUMBER OF MAP VARIABLES", "", ""},
    {"OUTPUT", "NUMBER OF IMAGE VARIABLES", "", ""},
    {"OUTPUT", "NUMBER OF GRAPHICS", "", ""},
    {NULL, NULL, "", NULL},
  };

  printf("Initializing dump procedures\n");

  /* Get the key-entry pairs from the input file */
  for (i = 0; StrEnv[i].SectionName; i++)
    GetInitString(StrEnv[i].SectionName, StrEnv[i].KeyName, StrEnv[i].Default,
      StrEnv[i].VarStr, (unsigned long)BUFSIZE, Input);

  /* Assign the entries to the variables */
  if (IsEmptyStr(StrEnv[output_path].VarStr))
    ReportError(StrEnv[output_path].KeyName, 51);
  strcpy(Dump->Path, StrEnv[output_path].VarStr);

  // delete any previous failure_summary.txt file
  sprintf(sumoutfile, "%sfailure_summary.txt", Dump->Path);
  if (remove(sumoutfile) != -1)
    printf(" - removed old version of failure_summary.txt\n");

  if (IsEmptyStr(StrEnv[initial_state_path].VarStr))
    strcpy(Dump->InitStatePath, Dump->Path);
  strcpy(Dump->InitStatePath, StrEnv[initial_state_path].VarStr);

  if (IsEmptyStr(StrEnv[npixels].VarStr))
    Dump->NPix = 0;
  else if (!CopyInt(&(Dump->NPix), StrEnv[npixels].VarStr, 1) || Dump->NPix < 0)
    ReportError(StrEnv[npixels].KeyName, 51);

  if (IsEmptyStr(StrEnv[nstates].VarStr))
    Dump->NStates = 0;
  else if (!CopyInt(&(Dump->NStates), StrEnv[nstates].VarStr, 1))
    ReportError(StrEnv[nstates].KeyName, 51);

  if (IsEmptyStr(StrEnv[nmapvars].VarStr))
    NMapVars = 0;
  else if (!CopyInt(&NMapVars, StrEnv[nmapvars].VarStr, 1) || NMapVars < 0)
    ReportError(StrEnv[nmapvars].KeyName, 51);

  if (IsEmptyStr(StrEnv[nimagevars].VarStr))
    NImageVars = 0;
  else if (!CopyInt(&NImageVars, StrEnv[nimagevars].VarStr, 1) ||
    NImageVars < 0)
    ReportError(StrEnv[nimagevars].KeyName, 51);

  if (IsEmptyStr(StrEnv[ngraphics].VarStr))
    *NGraphics = 0;
  else if (!CopyInt(NGraphics, StrEnv[ngraphics].VarStr, 1) || *NGraphics < 0)
    ReportError(StrEnv[ngraphics].KeyName, 51);

  if (Options->Extent == POINT)
    *NGraphics = 0;

  Dump->NMaps = NMapVars + NImageVars;

  // Open file for recording aggregated values for entire basin
  sprintf(Dump->Aggregate.FileName, "%sAggregated.Values", Dump->Path);
  OpenFile(&(Dump->Aggregate.FilePtr), Dump->Aggregate.FileName, "w", TRUE);

  // Open file for recording mass balance for entire basin
  sprintf(Dump->Balance.FileName, "%sMass.Balance", Dump->Path);
  OpenFile(&(Dump->Balance.FilePtr), Dump->Balance.FileName, "w", TRUE);

  sprintf(Dump->FinalBalance.FileName, "%sMass.Final.Balance", Dump->Path);
  OpenFile(&(Dump->FinalBalance.FilePtr), Dump->FinalBalance.FileName, "w", TRUE);

  if (Options->Extent != POINT) {
    /* Read remaining information from dump info file */
    if (Dump->NStates > 0)
      InitStateDump(Input, Dump->NStates, &(Dump->DState));

    /* if Dump->NStates < 0, the state will be dumped every time step, this is
       done directly in ExecDump */
    if (!(BasinMask = (uchar **)calloc(Map->NY, sizeof(uchar *))))
      ReportError(Routine, 1);
    for (y = 0; y < Map->NY; y++)
      if (!(BasinMask[y] = (uchar *)calloc(Map->NX, sizeof(uchar))))
        ReportError(Routine, 1);

    for (y = 0; y < Map->NY; y++)
      for (x = 0; x < Map->NX; x++)
        BasinMask[y][x] = TopoMap[y][x].Mask;

    if (Dump->NPix > 0) {
      temp_count = InitPixDump(Input, Map, BasinMask, Dump->Path, Dump->NPix,
        &(Dump->Pix), Options);

      if (temp_count == 0) {
        Dump->NPix = 0;
        printf("no candidate dump pixels accepted \n");
      }
      else {
        Dump->NPix = temp_count;
        printf("total number of accepted dump pixels %d \n", Dump->NPix);
      }
    }
    for (y = 0; y < Map->NY; y++)
      free(BasinMask[y]);
    free(BasinMask);

    if (Dump->NMaps > 0)
      InitMapDump(Input, Map, MaxSoilLayers, MaxVegLayers, Dump->Path,
        Dump->NMaps, NMapVars, &(Dump->DMap));
    if (NImageVars > 0)
      InitImageDump(Input, Dt, Map, MaxSoilLayers, MaxVegLayers, Dump->Path,
        Dump->NMaps, NImageVars, &(Dump->DMap));

    if (*NGraphics > 0)
      InitGraphicsDump(Input, *NGraphics, &which_graphics);

    /* if no network open unit hydrograph file */
    if (!(Options->HasNetwork)) {
      sprintf(Dump->Stream.FileName, "%sStream.Flow", Dump->Path);
      OpenFile(&(Dump->Stream.FilePtr), Dump->Stream.FileName, "w", TRUE);
    }
  }
}
コード例 #23
0
ファイル: SW_Files.c プロジェクト: ryanmurf/SOILWAT
void SW_F_read(const char *s) {
	/* =================================================== */
	/* enter with the name of the first file to read for
	 * the filenames, or NULL.  If null, then read files.in
	 * or whichever filename was set previously. see init().
	 *
	 * 1/24/02 - replaced [re]alloc with StrDup()
	 *         - added facility for log-to-file. logfp depends
	 *             on having executed SW_F_read().
	 */

	FILE *f;
	int lineno = 0, fileno = 0;
	char buf[FILENAME_MAX];

	if (!isnull(s))
		init(s); /* init should be run by SW_F_Construct() */

	MyFileName = SW_F_name(eFirst);
	f = OpenFile(MyFileName, "r");

	while (GetALine(f, inbuf)) {

		switch (lineno) {
		case 5:
			strcpy(weather_prefix, inbuf);
			break;
		case 12:
			strcpy(output_prefix, inbuf);
			break;

		default:
			if (++fileno == SW_NFILES)
				break;

			if (!isnull(InFiles[fileno]))
				Mem_Free(InFiles[fileno]);
			strcpy(buf, _ProjDir);
			strcat(buf, inbuf);
			InFiles[fileno] = Str_Dup(buf);
		}

		lineno++;
	}

	if (fileno < eEndFile - 1) {
		CloseFile(&f);
		LogError(stdout, LOGFATAL, "Too few files (%d) in %s", fileno, MyFileName);
	}

	CloseFile(&f);

#if !defined(STEPWAT) && !defined(RSOILWAT)
	if (0 == strcmp(InFiles[eLog], "stdout")) {
		logfp = stdout;
	} else if (0 == strcmp(InFiles[eLog], "stderr")) {
		logfp = stderr;
	} else {
		logfp = OpenFile(SW_F_name(eLog), "w");
	}
#endif

}
コード例 #24
0
bool OGRShapeDataSource::Open( GDALOpenInfo* poOpenInfo,
                              bool bTestOpen, bool bForceSingleFileDataSource )

{
    CPLAssert( nLayers == 0 );

    const char * pszNewName = poOpenInfo->pszFilename;
    const bool bUpdate = poOpenInfo->eAccess == GA_Update;
    papszOpenOptions = CSLDuplicate( poOpenInfo->papszOpenOptions );

    pszName = CPLStrdup( pszNewName );

    bDSUpdate = bUpdate;

    bSingleFileDataSource = CPL_TO_BOOL(bForceSingleFileDataSource);

/* -------------------------------------------------------------------- */
/*      If bSingleFileDataSource is TRUE we don't try to do anything    */
/*      else.                                                           */
/*      This is only utilized when the OGRShapeDriver::Create()         */
/*      method wants to create a stub OGRShapeDataSource for a          */
/*      single shapefile.  The driver will take care of creating the    */
/*      file by calling ICreateLayer().                                 */
/* -------------------------------------------------------------------- */
    if( bSingleFileDataSource )
        return true;

/* -------------------------------------------------------------------- */
/*      Is the given path a directory or a regular file?                */
/* -------------------------------------------------------------------- */
    if( !poOpenInfo->bStatOK )
    {
        if( !bTestOpen )
            CPLError( CE_Failure, CPLE_AppDefined,
                      "%s is neither a file or directory, Shape access failed.",
                      pszNewName );

        return false;
    }

/* -------------------------------------------------------------------- */
/*      Build a list of filenames we figure are Shape files.            */
/* -------------------------------------------------------------------- */
    if( !poOpenInfo->bIsDirectory )
    {
        if( !OpenFile( pszNewName, bUpdate ) )
        {
            if( !bTestOpen )
                CPLError(
                    CE_Failure, CPLE_OpenFailed,
                    "Failed to open shapefile %s.  "
                    "It may be corrupt or read-only file accessed in "
                    "update mode.",
                    pszNewName );

            return false;
        }

        bSingleFileDataSource = true;

        return true;
    }
    else
    {
        char **papszCandidates = VSIReadDir( pszNewName );
        const int nCandidateCount = CSLCount( papszCandidates );
        bool bMightBeOldCoverage = false;
        std::set<CPLString> osLayerNameSet;

        for( int iCan = 0; iCan < nCandidateCount; iCan++ )
        {
            const char *pszCandidate = papszCandidates[iCan];
            const char *pszLayerName = CPLGetBasename(pszCandidate);
            CPLString osLayerName(pszLayerName);
#ifdef WIN32
            // On Windows, as filenames are case insensitive, a shapefile layer
            // can be made of foo.shp and FOO.DBF, so to detect unique layer
            // names, put them upper case in the unique set used for detection.
            osLayerName.toupper();
#endif

            if( EQUAL(pszCandidate,"ARC") )
                bMightBeOldCoverage = true;

            if( strlen(pszCandidate) < 4
                || !EQUAL(pszCandidate+strlen(pszCandidate)-4,".shp") )
                continue;

            char *pszFilename =
                CPLStrdup(CPLFormFilename(pszNewName, pszCandidate, NULL));

            osLayerNameSet.insert(osLayerName);
#ifdef IMMEDIATE_OPENING
            if( !OpenFile( pszFilename, bUpdate )
                && !bTestOpen )
            {
                CPLError(
                    CE_Failure, CPLE_OpenFailed,
                    "Failed to open shapefile %s.  "
                    "It may be corrupt or read-only file accessed in "
                    "update mode.",
                    pszFilename );
                CPLFree( pszFilename );
                CSLDestroy( papszCandidates );
                return false;
            }
#else
            oVectorLayerName.push_back(pszFilename);
#endif
            CPLFree( pszFilename );
        }

        // Try and .dbf files without apparent associated shapefiles.
        for( int iCan = 0; iCan < nCandidateCount; iCan++ )
        {
            const char  *pszCandidate = papszCandidates[iCan];
            const char  *pszLayerName = CPLGetBasename(pszCandidate);
            CPLString osLayerName(pszLayerName);
#ifdef WIN32
            osLayerName.toupper();
#endif

            // We don't consume .dbf files in a directory that looks like
            // an old style Arc/Info (for PC?) that unless we found at least
            // some shapefiles.  See Bug 493.
            if( bMightBeOldCoverage && osLayerNameSet.size() == 0 )
                continue;

            if( strlen(pszCandidate) < 4
                || !EQUAL(pszCandidate+strlen(pszCandidate)-4, ".dbf") )
                continue;

            if( osLayerNameSet.find(osLayerName) != osLayerNameSet.end() )
                continue;

            // We don't want to access .dbf files with an associated .tab
            // file, or it will never get recognised as a mapinfo dataset.
            bool bFoundTAB = false;
            for( int iCan2 = 0; iCan2 < nCandidateCount; iCan2++ )
            {
                const char *pszCandidate2 = papszCandidates[iCan2];

                if( EQUALN(pszCandidate2, pszLayerName, strlen(pszLayerName))
                    && EQUAL(pszCandidate2 + strlen(pszLayerName), ".tab") )
                    bFoundTAB = true;
            }

            if( bFoundTAB )
                continue;

            char *pszFilename =
                CPLStrdup(CPLFormFilename(pszNewName, pszCandidate, NULL));

            osLayerNameSet.insert(osLayerName);

#ifdef IMMEDIATE_OPENING
            if( !OpenFile( pszFilename, bUpdate )
                && !bTestOpen )
            {
                CPLError(
                    CE_Failure, CPLE_OpenFailed,
                    "Failed to open dbf file %s.  "
                    "It may be corrupt or read-only file accessed in "
                    "update mode.",
                    pszFilename );
                CPLFree( pszFilename );
                CSLDestroy( papszCandidates );
                return false;
            }
#else
            oVectorLayerName.push_back(pszFilename);
#endif
            CPLFree( pszFilename );
        }

        CSLDestroy( papszCandidates );

#ifdef IMMEDIATE_OPENING
        const int nDirLayers = nLayers;
#else
        const int nDirLayers = static_cast<int>(oVectorLayerName.size());
#endif

        CPLErrorReset();

        return nDirLayers > 0 || !bTestOpen;
    }
}
コード例 #25
0
void cSoftPlayer::FileReplay() {
        AVPacket  pkt;
        int ret;
        int PacketCount=0;
        int64_t PTS=0;
        int64_t lastPTS=0;

        pollTimeouts=0;
	pause=false;
	forward=true;
	new_forward=true;
	speed=-1;
	new_speed=-1;
        AudioIdx=-1;
        VideoIdx=-1;
	reading=true;

        OpenFile(filename);
        newFile=false;


        if (!ic) {
	   printf("ic is null!!\n");
	   reading= false;
	   return;
	};

        if (Receiver && (Streams & SOFTDEVICE_VIDEO_STREAM) ) {
                Receiver->StopTransfer();
	        DeviceClear();
        };
        if (Receiver && !(Streams & SOFTDEVICE_VIDEO_STREAM) )
                Receiver->StartTransfer();
       
        ResetDevice(Streams);
        while ( running && reading && !newFile) {
                if ( PollDevice(Streams) ) {
                        //PLDBG("poll timeout!!!\n");
                        pollTimeouts++;
                        if (pollTimeouts > 100) {
                                PLDBG("Too many poll timeouts! Reseting device.\n");
                                ResetDevice(Streams);
                                pollTimeouts=0;
                        };
                        continue;
                } else pollTimeouts=0;

                // seek forward / backward
                if (skip) {
                        PLDBG("player skip %d curr pts: %lld, lastPTS %lld\n",skip,
                                        SoftDevice->GetSTC()/9*1000,lastPTS);
                        //av_seek_frame(ic,-1,
                        //   (SoftDevice->GetSTC()/9+skip*100)*100);
#if LIBAVFORMAT_BUILD > 4618
                        av_seek_frame(ic,-1,
                                        (SoftDevice->GetSTC()/9+skip*10000)*100,
                                        AVSEEK_FLAG_BACKWARD);
#else
                        av_seek_frame(ic,-1,
                                        (SoftDevice->GetSTC()/9+skip*10000)*100);
#endif
                        PLDBG("clear\n");
                        skip=0;
                        ResetDevice(Streams);
                        //SoftDevice->ClearPacketQueue();
                        PLDBG("clear finished\n");
                };

                if ( speed != new_speed ) {
                        PLDBG("speed change\n");
                        ResetDevice(Streams);
                        //  if (new_speed!=-1) 
                        //        av_seek_frame(ic,-1,SoftDevice->GetSTC()/9*100);

                        //                        if (new_speed != -1)
                        //                                cPlayer::DeviceTrickSpeed(2);
                        //                        else cPlayer::DeviceTrickSpeed(1);

                        fast_STC=SoftDevice->GetSTC()/9*100;
                        forward = new_forward;
                        speed = new_speed;
                };

                if ( speed!=-1 ) {
                        int step=5*100000; // 5 zehntel sek.
                        if (!forward)
                                step=-step;
                        fast_STC+=step;
#if LIBAVFORMAT_BUILD > 4618
                        av_seek_frame(ic,-1,fast_STC,
                                        AVSEEK_FLAG_BACKWARD);
#else
                        av_seek_frame(ic,-1,fast_STC);
#endif

                        PKTDBG("fast_STC %lld diff %lld forward %d step %d\n",
                                        fast_STC,PTS-lastPTS,forward,step);
                };

                ret = av_read_frame(ic, &pkt);
                //ret = av_read_packet(ic, &pkt);
                PacketCount++;
                if (ret < 0) {
                        printf("Error (%d) reading packet!\n",ret);
                        reading=false;
                        continue;
                }
                
                if (pause) {
                        FreezeDevice(Streams,1);
                        while (pause && running && reading)
                                usleep(10000);
                        FreezeDevice(Streams,0);
                };
 
                lastPTS=PTS;
                PTS=pkt.pts;

                RemuxAndQueue(pkt);

                if (PacketCount == 200)
                        dump_format(ic, 0, "test", 0);

                // update duration (FIXME does that help?)
                duration=ic->duration;
                int currPos= SoftDevice->GetSTC()*AV_TIME_BASE/(9*10000);
                if (duration<currPos)
                        duration=currPos;
        }
	//if (running) 
	//   DeviceFlush(20000);
	PLDBG("Before FlushDevice %d %d \n",running,newFile);
        if (running && !newFile) {
                FlushDevice(Streams);
        };

        ResetDevice(Streams);

};
コード例 #26
0
ファイル: ScreenSave.cpp プロジェクト: cwilko/voxelMap
int SaveScreen() {

	// String buffers for the filenames
	
	char test[] = "anim\\pic";
	char format[] = ".bmp";

	char file[40];
	char file2[40];
	char file3[40];

	// Create the correct file paths and names in the buffers

	sprintf(file, "anim\\pic%d.bmp", frame++);
	sprintf(file3, "Work___Win32_Release\\anim\\pic%d.bmp", frame );
	sprintf(file2, "Work___Win32_Release\\%s", file);

	// Create a pointer to a screen buffer

	UCHAR *screen_buffer = NULL;

	// Assign the pointer to the display

	screen_buffer = (UCHAR *) ddsd.lpSurface;

	// Set the pixel position to the lower left corner

	screen_buffer += (SCREEN_WIDTH * (SCREEN_HEIGHT - 1));


	// Open pic0.bmp for writing

	#define BITMAP_ID        0x4D42				// this is the universal id for a bitmap

	int      file_handle;						// the file handle
	bitmap_file_ptr bitmap = new bitmap_file;	// the bitmap header structure


	OFSTRUCT file_data;							// the file data information

	// open the file if it exists

	if ((file_handle = OpenFile(file,&file_data,OF_READWRITE))==-1)
		return(0);
 
	// Now load the bitmap file header
	
	_lread(file_handle, &bitmap->bitmapfileheader,sizeof(BITMAPFILEHEADER));

	// Test if this is a bitmap file
	if (bitmap->bitmapfileheader.bfType!=BITMAP_ID) {
	
		// close the file
		_lclose(file_handle);
 
		// return error
		return(0);

	} // end if


	// Load the bitmap file header
	
	_lread(file_handle, &bitmap->bitmapinfoheader,sizeof(BITMAPINFOHEADER));


	// Write the palette to the file
	_lwrite(file_handle, (char*) colour_palette,256*sizeof(PALETTEENTRY));
	
	
	// Find the start of the image data
	_lseek(file_handle,-(int)(bitmap->bitmapinfoheader.biSizeImage),SEEK_END);


	// Overwrite the image data in the file

	for (int i=0; i<SCREEN_HEIGHT; i++) {

		_lwrite(file_handle,(char*) screen_buffer,SCREEN_WIDTH * sizeof(UCHAR));
		screen_buffer -= SCREEN_WIDTH;
	
	}


	// Deallocate bitmap header
	delete bitmap;

	// close the file
	_lclose(file_handle);

	// Copy the file to another ( for animation frames )

	CopyFile(file2, file3,TRUE);

	return 1;

}
コード例 #27
0
ファイル: husk.cpp プロジェクト: fdncred/pdfstreamdumper
int main(int argc, char* argv[])
{
	int break_mode = 0;
    int fHand = NULL;
	int foff = 0;
	OFSTRUCT o;
	WSADATA WsaDat;	
	
	if ( WSAStartup(MAKEWORD(1,1), &WsaDat) !=0  ){  
		printf("WSAStartup failed exiting.."); 
		return 0;
	}

	for(int i=1; i<argc; i++){
		
		if(strstr(argv[i],"/h") > 0 ){usage(); return 0;}
		if(strstr(argv[i],"/?") > 0 ){usage(); return 0;}
		if(strstr(argv[i],"-h") > 0 ){usage(); return 0;}
		if(strstr(argv[i],"-?") > 0 ){usage(); return 0;}

		if(strstr(argv[i],"/break") > 0 )  break_mode=1;

		if(strstr(argv[i],"/fopen") > 0 ){ 
			if(i+1 >= argc){
				printf("/fhand no argument found\n");
				exit(0);
			}else{
				char* target = argv[i+1];
				fHand = OpenFile(target, &o , OF_READ);
				if(fHand==HFILE_ERROR){
					printf("Option /fopen Could not open file %s\r\n", target);
					printf("Press any key to continue...\r\n");
					getch();

				}else{
					printf("Successfully opened a handle (0x%X) to %s\r\n", fHand, target);
				}
			}
		}

		if(strstr(argv[i],"/va") > 0 ){
			if(i+1 >= argc){
				printf("Invalid option /va must specify 0xBase-0xSize as next arg\n");
				exit(0);
			}
		    char *ag = strdup(argv[i+1]);
			char *sz;
			unsigned int size=0;
			unsigned int base=0;
			if (( sz = strstr(ag, "-")) != NULL)
			{
				*sz = '\0';
				sz++;
				size = strtol(sz, NULL, 16);
				base = strtol(ag, NULL, 16);
				int r = (int)VirtualAlloc((void*)base, size, MEM_RESERVE | MEM_COMMIT, 0x40 );
				printf("VirtualAlloc(base=%x, size=%x) = %x - %x\n", base, size, r, r+size);
				if(r==0){ printf("ErrorCode: %x\nAborting...\n", GetLastError()); exit(0);}
				//0x57 = ERROR_INVALID_PARAMETER 

			}else{
				printf("Invalid option /va must specify 0xBase-0xSize as next arg\n");
				exit(0);
			}
		}

		if(strstr(argv[i],"/dll") > 0 ){
			if(i+1 >= argc){
				printf("Invalid option /dll must specify dll to load as next arg\n");
				exit(0);
			}
			int hh = (int)LoadLibrary(argv[i+1]);
			printf("LoadLibrary(%s) = 0x%x\n", argv[i+1], hh);
		}

		if(strstr(argv[i],"/foff") > 0 ){
			if(i+1 >= argc){
				printf("Invalid option /foff must specify start file offset as next arg\n");
				exit(0);
			}
			foff = strtol(argv[i+1], NULL, 16);
			printf("Starting at file offset 0x%x\n", foff);
		}


	}

	unsigned char* c = (unsigned char*)buf;
	if(foff > 0) printf("Start opcodes: %04x    %02x %02x %02x %02x %02x\n", foff, c[foff],c[foff+1],c[foff+2],c[foff+3],c[foff+4]);

	int* pBuf = buf;

	_asm{
		   mov eax, pBuf
		   mov ebx, foff
		   mov ecx, break_mode
		   add eax, ebx
		   cmp ecx, 1
		   jnz no_break
		   int 3
no_break:
		   jmp eax
	}



}
コード例 #28
0
bool MythCommFlagPlayer::RebuildSeekTable(
    bool showPercentage, StatusCallback cb, void* cbData)
{
    int percentage = 0;
    uint64_t myFramesPlayed = 0, pmap_first = 0,  pmap_last  = 0;

    killdecoder = false;
    framesPlayed = 0;
    using_null_videoout = true;

    // clear out any existing seektables
    player_ctx->LockPlayingInfo(__FILE__, __LINE__);
    if (player_ctx->playingInfo)
    {
        player_ctx->playingInfo->ClearPositionMap(MARK_KEYFRAME);
        player_ctx->playingInfo->ClearPositionMap(MARK_GOP_START);
        player_ctx->playingInfo->ClearPositionMap(MARK_GOP_BYFRAME);
    }
    player_ctx->UnlockPlayingInfo(__FILE__, __LINE__);

    if (OpenFile() < 0)
        return false;

    SetPlaying(true);

    if (!InitVideo())
    {
        VERBOSE(VB_IMPORTANT,
                LOC_ERR + "RebuildSeekTable unable to initialize video");
        SetPlaying(false);
        return false;
    }

    ClearAfterSeek();

    int save_timeout = 1001;
    MythTimer flagTime, ui_timer, inuse_timer, save_timer;
    flagTime.start();
    ui_timer.start();
    inuse_timer.start();
    save_timer.start();

    DecoderGetFrame(kDecodeNothing,true);

    if (showPercentage)
    {
        if (totalFrames)
            printf("             ");
        else
            printf("      ");
        fflush( stdout );
    }

    int prevperc = -1;
    while (!GetEof())
    {
        if (inuse_timer.elapsed() > 2534)
        {
            inuse_timer.restart();
            player_ctx->LockPlayingInfo(__FILE__, __LINE__);
            if (player_ctx->playingInfo)
                player_ctx->playingInfo->UpdateInUseMark();
            player_ctx->UnlockPlayingInfo(__FILE__, __LINE__);
        }

        if (save_timer.elapsed() > save_timeout)
        {
            // Give DB some breathing room if it gets far behind..
            if (myFramesPlayed - pmap_last > 5000)
                usleep(200 * 1000);

            // If we're already saving, just save a larger block next time..
            if (RebuildSaver::GetCount(decoder) < 1)
            {
                pmap_last = myFramesPlayed;
                QThreadPool::globalInstance()->start(
                    new RebuildSaver(decoder, pmap_first, pmap_last));
                pmap_first = pmap_last + 1;
            }

            save_timer.restart();
        }

        if (ui_timer.elapsed() > 98)
        {
            ui_timer.restart();

            if (totalFrames)
            {
                float elapsed = flagTime.elapsed() * 0.001f;
                int flagFPS = (elapsed > 0.0f) ?
                    (int)(myFramesPlayed / elapsed) : 0;

                percentage = myFramesPlayed * 100 / totalFrames;
                if (cb)
                    (*cb)(percentage, cbData);

                if (showPercentage)
                {
                    printf( "\b\b\b\b\b\b\b\b\b\b\b\b\b" );
                    printf( "%3d%%/%5dfps", percentage, flagFPS );
                    fflush( stdout );
                }
		if (percentage % 10 == 0 && prevperc != percentage)
                {
                    prevperc = percentage;
		    VERBOSE(VB_GENERAL, QString("%1%/%2""fps")
                                        .arg(percentage).arg(flagFPS));
                }
            }
            else 
            {
                if (showPercentage)
                {
                    printf( "\b\b\b\b\b\b" );
                    printf( "%6lld", (long long)myFramesPlayed );
                    fflush( stdout );
                }
                if (myFramesPlayed % 1000 == 0)
                    VERBOSE(VB_GENERAL, QString("%1").arg(myFramesPlayed));
            }
        }

        if (DecoderGetFrame(kDecodeNothing,true))
            myFramesPlayed = decoder->GetFramesRead();
    }

    if (showPercentage)
    {
        if (totalFrames)
            printf( "\b\b\b\b\b\b\b" );
        printf( "\b\b\b\b\b\b           \b\b\b\b\b\b\b\b\b\b\b" );
        fflush( stdout );
    }

    SaveTotalDuration();

    SetPlaying(false);
    killdecoder = true;

    QThreadPool::globalInstance()->start(
        new RebuildSaver(decoder, pmap_first, myFramesPlayed));
    RebuildSaver::Wait(decoder);

    return true;
}
コード例 #29
0
ファイル: code_f90.c プロジェクト: kangasno/TUT-MCM-KPP
void Use_F90()
{ 
  WriteElm 	    = F90_WriteElm;
  WriteSymbol 	    = F90_WriteSymbol;  
  WriteAssign 	    = F90_WriteAssign;
  WriteComment 	    = F90_WriteComment;
  DeclareConstant   = F90_DeclareConstant;
  Declare           = F90_Declare;
  ExternDeclare     = F90_ExternDeclare;
  GlobalDeclare     = F90_GlobalDeclare;
  InitDeclare       = F90_InitDeclare;

  FunctionStart     = F90_FunctionStart;
  FunctionPrototipe = F90_FunctionPrototipe;
  FunctionBegin     = F90_FunctionBegin;
  FunctionEnd       = F90_FunctionEnd;

  OpenFile( &param_headerFile,   rootFileName, "_Parameters.f90", "Parameter Module File" );
  /*  mz_rs_20050117+ */
  OpenFile( &initFile, rootFileName, "_Initialize.f90", "Initialization File" );
  /*  mz_rs_20050117- */
  /* mz_rs_20050518+ no driver file if driver = none */
  if( strcmp( driver, "none" ) != 0 )
    OpenFile( &driverFile, rootFileName, "_Main.f90", "Main Program File" );
  /* mz_rs_20050518- */
  OpenFile( &integratorFile, rootFileName, "_Integrator.f90", 
                   "Numerical Integrator (Time-Stepping) File" );
  OpenFile( &linalgFile, rootFileName, "_LinearAlgebra.f90", 
                   "Linear Algebra Data and Routines File" );
  OpenFile( &functionFile, rootFileName, "_Function.f90", 
                   "The ODE Function of Chemical Model File" );
  OpenFile( &jacobianFile, rootFileName, "_Jacobian.f90", 
                   "The ODE Jacobian of Chemical Model File" );
  OpenFile( &rateFile, rootFileName, "_Rates.f90", 
                   "The Reaction Rates File" );
  if ( useStochastic )
    OpenFile( &stochasticFile, rootFileName, "_Stochastic.f90", 
                   "The Stochastic Chemical Model File" );
  if ( useStoicmat ) {
     OpenFile( &stoichiomFile, rootFileName, "_Stoichiom.f90", 
                   "The Stoichiometric Chemical Model File" );
     OpenFile( &sparse_stoicmFile, rootFileName, "_StoichiomSP.f90", 
                   "Sparse Stoichiometric Data Structures File" );
  }		   
  OpenFile( &utilFile, rootFileName, "_Util.f90", 
                   "Auxiliary Routines File" );
  /* OpenFile( &sparse_dataFile, rootFileName, "_Sparse.f90",
                       "Sparse Data Module File" );*/
  OpenFile( &global_dataFile, rootFileName, "_Global.f90", "Global Data Module File" );
  if ( useJacSparse ) {
     OpenFile( &sparse_jacFile, rootFileName, "_JacobianSP.f90",
         "Sparse Jacobian Data Structures File" );  
  }
  if ( useHessian ) {
     OpenFile( &hessianFile, rootFileName, "_Hessian.f90", "Hessian File" );
     OpenFile( &sparse_hessFile, rootFileName, "_HessianSP.f90",
         "Sparse Hessian Data Structures File" );
  }     
  OpenFile( &mapFile, rootFileName, ".map", 
                   "Map File with Human-Readable Information" );
  OpenFile( &monitorFile, rootFileName, "_Monitor.f90", 
                   "Utility Data Module File" );
} 
コード例 #30
0
ファイル: Player.cpp プロジェクト: fastget/CCPlayer_On_iOS
void CCPlayer::Run()
{
    int isAllModuleAreDeaded = 0;
    while(m_bRunning)
    {
        SmartPtr<Event> event;
        if(PopFrontMessage(event))
        {
            switch(event.GetPtr()->type)
            {
                case COMMAND_TYPE_ENUM_OPEN:
                {
                    sleep(5);
                    
                    std::string mediaUrl = any_cast<std::string>(event.GetPtr()->anyParams);
                    
                    int ret = OpenFile(mediaUrl);
                    
                    if (ret == SUCCESS)
                    {
                        CCModuleManager::AddModule(MESSAGE_OBJECT_ENUM_DATA_MANAGER);
                    }
                    
                    if(ret == SUCCESS && g_pPlayerContext->m_asIndex != -1)
                    {
                        CCModuleManager::AddModule(MESSAGE_OBJECT_ENUM_AUDIO_DECODER);
                        CCModuleManager::AddModule(MESSAGE_OBJECT_ENUM_AUDIO_RENDER);
                    }
                    
                    if(ret == SUCCESS && g_pPlayerContext->m_vsIndex != -1)
                    {
                        CCModuleManager::AddModule(MESSAGE_OBJECT_ENUM_VIDEO_DECODER);
                        CCModuleManager::AddModule(MESSAGE_OBJECT_ENUM_VIDEO_RENDER);
                    }
                    
                    if(m_pIPlayerDelegate != NULL)
                    {
                        m_pIPlayerDelegate->OnCommandOpen(ret);
                    }
                    
                }
                break;
                case COMMAND_TYPE_ENUM_CONTINUE:
                {
                    CCMessageCenter::GetInstance()->PostMessage(MESSAGE_OBJECT_ENUM_PLAYER,
                                                                MESSAGE_OBJECT_ENUM_AUDIO_RENDER,
                                                                MESSAGE_TYPE_ENUM_AUDIO_CONTINUE,
                                                                Any());

                    CCMessageCenter::GetInstance()->PostMessage(MESSAGE_OBJECT_ENUM_PLAYER,
                                                                MESSAGE_OBJECT_ENUM_VIDEO_RENDER,
                                                                MESSAGE_TYPE_ENUM_VIDEO_CONTINUE,
                                                                Any());
                }
                break;
                case COMMAND_TYPE_ENUM_PAUSE:
                {
                        CCMessageCenter::GetInstance()->PostMessage(MESSAGE_OBJECT_ENUM_PLAYER,
                                                                    MESSAGE_OBJECT_ENUM_AUDIO_RENDER,
                                                                    MESSAGE_TYPE_ENUM_AUDIO_PAUSE,
                                                                    Any());

                        CCMessageCenter::GetInstance()->PostMessage(MESSAGE_OBJECT_ENUM_PLAYER,
                                                                    MESSAGE_OBJECT_ENUM_VIDEO_RENDER,
                                                                    MESSAGE_TYPE_ENUM_VIDEO_PAUSE,
                                                                    Any());
                }
                break;
                //the user stop the player
                case COMMAND_TYPE_ENUM_STOP:
                {
                    PostMessage(MESSAGE_OBJECT_ENUM_PLAYER,
                                MESSAGE_OJBECT_ENUM_ALL,
                                MESSAGE_TYPE_ENUM_CLIENT_STOP,
                                Any());
                }
                break;
                case MESSAGE_TYPE_ENUM_SET_VOLUME:
                {
                    float volume = any_cast<float>(event.GetPtr()->anyParams);
                    g_pPlayerContext->m_pALWrapper->SetVolume(volume);
                }
                break;
                case MESSAGE_TYPE_ENUM_AUDIO_RENDER_DEADED:
                {
                    CCModuleManager::DeleteModule(MESSAGE_OBJECT_ENUM_AUDIO_RENDER);
                    
                    isAllModuleAreDeaded += AUDIO_RENDER_DEADED;
                    
                    if (isAllModuleAreDeaded == ALL_MODULE_ARE_DEADED)
                    {
                        DestructPlayerSystem();
                    }
                }
                break;
                case MESSAGE_TYPE_ENUM_AUDIO_DECODER_DEADED:
                {
                    CCModuleManager::DeleteModule(MESSAGE_OBJECT_ENUM_AUDIO_DECODER);
                    
                    isAllModuleAreDeaded += AUDIO_DECODER_DEADED;
                    
                    if (isAllModuleAreDeaded == ALL_MODULE_ARE_DEADED)
                    {
                        DestructPlayerSystem();
                    }
                }
                break;
                case MESSAGE_TYPE_ENUM_VIDEO_RENDER_DEADED:
                {
                    CCModuleManager::DeleteModule(MESSAGE_OBJECT_ENUM_VIDEO_RENDER);
                    
                    isAllModuleAreDeaded += VIDEO_RENDER_DEADED;
                    
                    if (isAllModuleAreDeaded == ALL_MODULE_ARE_DEADED)
                    {
                        DestructPlayerSystem();
                    }
                }
                break;
                case MESSAGE_TYPE_ENUM_VIDEO_DECODER_DEADED:
                {
                    CCModuleManager::DeleteModule(MESSAGE_OBJECT_ENUM_VIDEO_DECODER);
                    
                    isAllModuleAreDeaded += VIDEO_DECODER_DEADED;
                    
                    if (isAllModuleAreDeaded == ALL_MODULE_ARE_DEADED)
                    {
                        DestructPlayerSystem();
                    }
                }
                    break;
                case MESSAGE_OBJECT_ENUM_DATA_MANAGER_DEADED:
                {
                    CCModuleManager::DeleteModule(MESSAGE_OBJECT_ENUM_DATA_MANAGER);
                    
                    isAllModuleAreDeaded += DATA_MANAGER_DEADED;
                    
                    if (isAllModuleAreDeaded == ALL_MODULE_ARE_DEADED)
                    {
                        DestructPlayerSystem();
                    }
                }
                break;
            }
        }else // end if get a message
        {
            //if nothing to do , just wait 10 ms , don't warry
            usleep(10 * 1000);
        }
    } // end of switch case
}