コード例 #1
0
ファイル: compose.c プロジェクト: RomanHargrave/xwadtools
/*
** find a picture.
** must=TRUE is picture must exist
** returns picture type
*/
static Int16 CMPOloadPic (
  Int32			*size,
  struct WADINFO	*rwad,
  char			*file,
  const char		*DataDir,
  const char		*Dir,
  const char		*nam,
  const char		*filenam,
  Int16			Type,
  Int16			OfsX,
  Int16			OfsY
)
{ int res=PICNONE;
  if(MakeFileName(file,DataDir,Dir,"",filenam,"ppm")==TRUE)
     res=PICPPM;
  else if(MakeFileName(file,DataDir,Dir,"",filenam,"bmp")==TRUE)
     res=PICBMP;
  else if(MakeFileName(file,DataDir,Dir,"",filenam,"gif")==TRUE)
  {
    static int gif_warning = 0;
    res=PICGIF;
    if (! gif_warning)
    {
      Warning ("PC10", "GIF support may go away in the future");
      gif_warning = 1;
    }
  }
  else if(CMPOcopyFromWAD(size,rwad,DataDir,Dir,nam,filenam)==TRUE)
     return PICWAD;
  if(res!=PICNONE)
    *size = PICsaveInWAD(rwad,file,Type,OfsX,OfsY,res);
  else if(Type!=PLUMP)
    Warning("PC90", "could not find file %s, .ppm, .bmp or .gif",file);
  return res;
}
コード例 #2
0
ファイル: plotps.cpp プロジェクト: BackupTheBerlios/kicad-svn
void WinEDA_PlotPSFrame::CreatePSFile(int AllPages, int pagesize)
/*************************************************************/
{
wxString PlotFileName, ShortFileName;
BASE_SCREEN *screen;
Ki_PageDescr * PlotSheet, * RealSheet;
int BBox[4];
wxPoint plot_offset;

	SchematicCleanUp(NULL);
	g_PlotFormat = PLOT_FORMAT_POST;

	screen = ActiveScreen;
	if ( AllPages == TRUE )
	{
		screen = ScreenSch;
	}
	while( screen )
	{
		PlotSheet = screen->m_CurrentSheet;
		RealSheet = &g_Sheet_A4;
		if ( pagesize == PAGE_SIZE_AUTO ) RealSheet = PlotSheet;
		else if ( pagesize == PAGE_SIZE_A )	RealSheet = &g_Sheet_A;

		/* Calcul des limites de trace en 1/1000 pouce */
		BBox[0] = BBox[1] = g_PlotMargin;	// Plot margin in 1/1000 inch
		BBox[2] = RealSheet->m_Size.x - g_PlotMargin;
		BBox[3] = RealSheet->m_Size.y - g_PlotMargin;

		/* Calcul des echelles de conversion */
		g_PlotScaleX = SCALE_PS *
					(float) (BBox[2] - BBox[0]) /
					PlotSheet->m_Size.x;
		g_PlotScaleY = SCALE_PS *
					(float) (BBox[3] - BBox[1]) /
					PlotSheet->m_Size.y;

		plot_offset.x = 0;
		plot_offset.y = PlotSheet->m_Size.y;

		wxSplitPath(screen->m_FileName.GetData(), (wxString*) NULL,
				&ShortFileName, (wxString*) NULL);
		wxString dirbuf = wxGetCwd() + STRING_DIR_SEP;
		if( ! ShortFileName.IsEmpty() )
			PlotFileName = MakeFileName(dirbuf, ShortFileName, wxT(".ps"));
		else PlotFileName = MakeFileName(dirbuf, g_DefaultSchematicFileName, wxT(".ps"));

		PlotOneSheetPS(PlotFileName,screen, RealSheet, BBox, plot_offset);
		screen = (BASE_SCREEN*)screen->Pnext;
		if (AllPages == FALSE ) screen = NULL;
	}
}
コード例 #3
0
void WinEDA_PlotHPGLFrame::Plot_Schematic_HPGL(int Select_PlotAll, int HPGL_SheetSize)
/***********************************************************************************/
{
wxString PlotFileName, ShortFileName;
BASE_SCREEN *screen;
Ki_PageDescr * PlotSheet;
wxSize SheetSize;
wxPoint SheetOffset, PlotOffset;
int margin;

	SchematicCleanUp(NULL);
	g_PlotFormat = PLOT_FORMAT_HPGL;

	screen = ActiveScreen;
	if ( Select_PlotAll == TRUE )
	{
		screen = ScreenSch;
	}
	while( screen )
	{
		ReturnSheetDims(screen, SheetSize, SheetOffset);
		/* Calcul des echelles de conversion */
		g_PlotScaleX = Scale_X * SCALE_HPGL ;
		g_PlotScaleY = Scale_Y * SCALE_HPGL ;

		margin = 400;	// Margin in mils
		PlotSheet = screen->m_CurrentSheet;
		g_PlotScaleX = g_PlotScaleX * (SheetSize.x - 2 * margin)/ PlotSheet->m_Size.x;
		g_PlotScaleY = g_PlotScaleY * (SheetSize.y - 2 * margin) / PlotSheet->m_Size.y;

		/* calcul des offsets */
		PlotOffset.x = - (int)(SheetOffset.x * SCALE_HPGL);
		PlotOffset.y = (int)( (SheetOffset.y + SheetSize.y) * SCALE_HPGL);
		PlotOffset.x -= (int)(margin * SCALE_HPGL);
		PlotOffset.y += (int)(margin * SCALE_HPGL);

		wxSplitPath(screen->m_FileName.GetData(), (wxString*) NULL,
				&ShortFileName, (wxString*) NULL);
		wxString dirbuf = wxGetCwd() + STRING_DIR_SEP;
		if( ! ShortFileName.IsEmpty() )
			PlotFileName = MakeFileName(dirbuf, ShortFileName, wxT(".plt"));
		else PlotFileName = MakeFileName(dirbuf, g_DefaultSchematicFileName, wxT(".plt"));

		InitPlotParametresHPGL(PlotOffset, g_PlotScaleX, g_PlotScaleY);
		Plot_1_Page_HPGL(PlotFileName,screen);
		screen = (BASE_SCREEN*)screen->Pnext;
		if ( Select_PlotAll == FALSE ) screen = NULL;
	}

	m_MsgBox->AppendText(_("** Plot End **\n"));
}
コード例 #4
0
ファイル: ifhelp.c プロジェクト: mingpen/OpenNT
/* Given a filename and a list of directories, find the first directory
 * that contains the file, and copy it into the buffer.  Note that in the
 * library version, you can give an environment style path, but not in the
 * DLL version.
 */
INT
GetDirOfFile(LPWSTR lpszFileName,
    LPWSTR lpszPathName,
    DWORD wSize,
    LPWSTR *lplpszDirs)
{
  WCHAR szFileName[_MAX_PATH];
  HANDLE hfRes;
  INT nFileLen, nPathLen;
  BOOL bDoDefaultOpen = TRUE;
  LPWSTR *lplpFirstDir;
  LPWSTR lpszDir;

  nFileLen = wcslen(lpszFileName);

  for (lplpFirstDir=lplpszDirs; *lplpFirstDir && bDoDefaultOpen;
        ++lplpFirstDir)
    {
      lpszDir = *lplpFirstDir;

      if (nFileLen+wcslen(lpszDir) >= _MAX_PATH-1)
          continue;
      MakeFileName(szFileName, lpszDir, lpszFileName, ARRAYSIZE(szFileName));

TryOpen:
    if ((hfRes = CreateFile(szFileName, GENERIC_READ,
            FILE_SHARE_READ, NULL, OPEN_EXISTING,
            FILE_FLAG_SEQUENTIAL_SCAN, NULL)) != (HANDLE)-1)
        {
          CloseHandle(hfRes);
          for (lpszDir=szFileName; *lpszDir; lpszDir++)
              if (*lpszDir == TEXT('\\'))
                  nPathLen = lpszDir - (LPWSTR)szFileName;

          /* This gets rid of the '\' if this is not the root of a drive
           */
          if (nPathLen <= 3)
              ++nPathLen;

          /* Account for the terminating NULL, and make sure wSize is in bounds
           * then NULL terminate the string in the appropriate place so that
           * we can just do an wcscpy.
           */
          --wSize;
          szFileName[(int)wSize<nPathLen ? wSize : nPathLen] = 0;
          wcscpy(lpszPathName, szFileName);

          return(nPathLen);
        }
    }

  if (bDoDefaultOpen)
    {
      bDoDefaultOpen = FALSE;
      wcscpy(szFileName, lpszFileName);
      goto TryOpen;
    }

  return(0);
}
コード例 #5
0
ファイル: extract.c プロジェクト: RomanHargrave/xwadtools
/*
** try to save entry as BitMap .BMP
*/
static Bool XTRbmpSave(Int16 *pinsrX,Int16 *pinsrY,struct WADDIR  *entry,
		 PICTYPE type,const char *DataDir,const char *dir,struct
		 WADINFO *info,IMGTYPE Picture,Bool WSafe, cusage_t *cusage)
{  Bool res;
   Int32 start=entry->start;
   Int32 size =entry->size;
   char *name=entry->name;
   char  *buffer;
   char *extens=NULL;

   if(size<8L) return FALSE;
   switch(Picture)
   { case PICGIF: extens="GIF";break;
     case PICBMP: extens="BMP";break;
     case PICPPM: extens="PPM";break;
     case PICTGA: extens="TGA";break;
     default: Bug("EX47", "Invalid img type %d", (int) Picture);
   }
   res = MakeFileName(file,DataDir,dir,"",name,extens);
   if((WSafe==TRUE)&&(res==TRUE))
   { Warning("EX48", "Will not overwrite file %s",file);
     return TRUE;
   }
   buffer=(char  *)Malloc(size);
   WADRseek(info,start);
   WADRreadBytes(info,buffer,size);
   res = PICsaveInFile(file,type,buffer,size,pinsrX,pinsrY,Picture, name,
       cusage);
   if(res==TRUE)Detail("EX49", "Saved picture as %s", fname (file));
   Free(buffer);
   return res;
}
コード例 #6
0
ファイル: cvpcb.cpp プロジェクト: BackupTheBerlios/kicad-svn
bool WinEDA_App::OnInit(void)
{
wxString msg;
wxString currCWD = wxGetCwd();

	EDA_Appl = this;
	InitEDA_Appl( wxT("cvpcb") );

    if ( m_Checker && m_Checker->IsAnotherRunning() ) 
    { 
        if ( ! IsOK(NULL, _("Cvpcb is already running, Continue?") ) )
			return false; 
    }
	
	GetSettings();					// read current setup

	wxSetWorkingDirectory(currCWD); // mofifie par GetSetting
	SetRealLibraryPath( wxT("modules") );

	if(argc > 1 )
		{
		NetInNameBuffer = argv[1];
		NetNameBuffer = argv[1];
		}

	if ( ! NetInNameBuffer.IsEmpty() )
		wxSetWorkingDirectory( wxPathOnly(NetInNameBuffer) );
	g_DrawBgColor = BLACK;

	Read_Config(NetInNameBuffer);

	m_CvpcbFrame = new WinEDA_CvpcbFrame(this, Main_Title);

	msg.Printf( wxT("Modules: %d"), nblib);
	m_CvpcbFrame->SetStatusText(msg,2);

	// Show the frame
	SetTopWindow(m_CvpcbFrame);

	m_CvpcbFrame->Show(TRUE);

	listlib();
	m_CvpcbFrame->BuildModListBox();

	if( ! NetInNameBuffer.IsEmpty() ) /* nom de fichier passe a la commande */
		{
		FFileName = MakeFileName(NetDirBuffer,
							NetInNameBuffer, NetInExtBuffer);

		m_CvpcbFrame->ReadNetListe();
		}
	else		/* Mise a jour du titre de la fenetre principale */
		{
 		msg.Printf( wxT("%s {%s%c} [no file]"),
			Main_Title.GetData(), wxGetCwd().GetData(), DIR_SEP);
		m_CvpcbFrame->SetTitle(msg);
		}

  return TRUE;
}
コード例 #7
0
ファイル: Storage.c プロジェクト: 0xE0F/ir-system
// Сохранение кода в хранилище
bool Save(IRCode *code, const uint16_t number)
{
	FIL file;
	FRESULT res;
	UINT bw;
	uint16_t crc = 0xFFFF;

	char fName[8 + 1 + 3 + 1] = {'\0'}; // 8 name, + .bin + \0

	if (!StorageInit) {
		print("Storage not init\n\r");
		return false;
	}

	crc = GetCrc(code);
	code->Crc = crc;

	MakeFileName(number, fName);
	res = f_open(&file, fName, FA_CREATE_ALWAYS | FA_WRITE);
	f_sync(&file);
	if (res) {
		printf("Create file error: %d\n\r", res);
		return false;
	}

	res = f_write(&file, code, sizeof(IRCode), &bw);
	f_sync(&file);
	if (res || bw != sizeof(IRCode)) {
		printf("Write file error: %d, bytes to write: %d\n\r", res, bw);
		return false;
	}
	f_close(&file);

	return true;
}
コード例 #8
0
ファイル: gtest-filepath.cpp プロジェクト: wllxyz/study
// Returns a pathname for a file that does not currently exist. The pathname
// will be directory/base_name.extension or
// directory/base_name_<number>.extension if directory/base_name.extension
// already exists. The number will be incremented until a pathname is found
// that does not already exist.
// Examples: 'dir/foo_test.xml' or 'dir/foo_test_1.xml'.
// There could be a race condition if two or more processes are calling this
// function at the same time -- they could both pick the same filename.
FilePath FilePath::GenerateUniqueFileName(const FilePath& directory,
                                          const FilePath& base_name,
                                          const char* extension) {
  FilePath full_pathname;
  int number = 0;
  do {
    full_pathname.Set(MakeFileName(directory, base_name, number++, extension));
  } while (full_pathname.FileOrDirectoryExists());
  return full_pathname;
}
コード例 #9
0
ファイル: main.c プロジェクト: ABratovic/open-watcom-v2
static  void  openFiles( void )
/*****************************/

{
/*  C.L. May 22, 91 */
    char        sp_buf[ _MAX_PATH2 ];
    char        *ext;
    size_t      len;

    _splitpath2( objName, sp_buf, NULL, NULL, &rootName, &ext );
    len = strlen( rootName ) + 1;
    rootName = memcpy( AllocMem( len ), rootName, len );
    if( ext[ 0 ] == '\0' ) {
        /* search with '.obj' or '.o' extension first */
        ObjFile = OpenBinRead( MakeFileName( objName, objExt ) );
        if( ObjFile == NULL ) {
            /* try without extension */
            ObjFile = OpenBinRead( objName );
        }
    } else {
        /* extension specified */
        ObjFile = OpenBinRead( objName );
    }
/**/
    if( ObjFile == NULL ) {
//        ObjFile = OpenBinRead( MakeFileName( objName, objExt ) );
//        if( ObjFile == NULL ) {
            SysError( ERR_NOT_OPEN_OBJ, true );
//        }
    }
    if( lstReqd ) {
        if( lstName == NULL ) {
            Output = OpenTxtWrite( MakeFileName( rootName, "lst" ) );
        } else {
            Output = OpenTxtWrite( lstName );
        }
        if( Output == NULL ) {
            CloseBin( ObjFile );
            SysError( ERR_NOT_OPEN_LIST, true );
        }
    }
}
コード例 #10
0
void Invoke( const char *invfile, int len, char_ring *parmlist )
{
    handle      hndl;

    hndl = LocalFullPathOpen( invfile, len, "dbg", TxtBuff, TXT_LEN );
    if( hndl == NIL_HANDLE ) {
        MakeFileName( TxtBuff, invfile, "dbg", 0 );
        FreeRing( parmlist );
        Error( ERR_NONE, LIT_ENG( ERR_FILE_NOT_OPEN ), TxtBuff );
    }
    DoInvoke( hndl, TxtBuff, parmlist );
}
コード例 #11
0
ファイル: find.cpp プロジェクト: BackupTheBerlios/kicad-svn
int WinEDA_FindFrame::ExploreAllLibraries(const wxString & wildmask, wxString & FindList)
/****************************************************************************************/
{
wxString FullFileName;
FILE * file;
int nbitems = 0, LineNum = 0;
char Line[2048], *name;
	
	FullFileName = MakeFileName(g_RealLibDirBuffer, wxT("*"), g_LibExtBuffer);
	
	FullFileName = wxFindFirstFile(FullFileName);
	while ( ! FullFileName.IsEmpty() )
	{
		file = wxFopen(FullFileName, wxT("rt"));
		if (file == NULL) continue;
 
		while (GetLine(file, Line, &LineNum, sizeof(Line)) )
		{
			if (strnicmp(Line, "DEF", 3) == 0)
			{ /* Read one DEF part from library: DEF 74LS00 U 0 30 Y Y 4 0 N */
				strtok(Line, " \t\r\n");
				name = strtok(NULL, " \t\r\n");
				wxString st_name = CONV_FROM_UTF8(name);
				if( WildCompareString(wildmask, st_name, FALSE) )
				{
					nbitems ++;
					if ( ! FindList.IsEmpty() ) FindList += wxT("\n");
					FindList << _("Found ") << CONV_FROM_UTF8(name)
							<< _(" in lib ") << FullFileName;
				}
			}
			else if (strnicmp(Line, "ALIAS", 5) == 0)
			{ /* Read one ALIAS part from library: ALIAS 74HC00 74HCT00 7400 74LS37 */
				strtok(Line, " \t\r\n");
				while ( (name = strtok(NULL, " \t\r\n")) != NULL )
				{
					wxString st_name = CONV_FROM_UTF8(name);
					if( WildCompareString( wildmask, st_name, FALSE) )
					{
						nbitems ++;
						if ( ! FindList.IsEmpty() ) FindList += wxT("\n");
						FindList << _("Found ") << CONV_FROM_UTF8(name)
								<< _(" in lib ") << FullFileName;
					}
				}
			}
		}
		fclose(file);
		FullFileName = wxFindNextFile();
	}

	return nbitems;
}
コード例 #12
0
ファイル: MACROIMP.CPP プロジェクト: hkaiser/TRiAS
HRESULT MakeRootStorage(LPSTORAGE *ppIStorage, LPCSTR pPathName)
{           
HRESULT hr = NOERROR;

DWORD dwMode = STGM_READWRITE | STGM_SHARE_EXCLUSIVE | 
				STGM_TRANSACTED ;

char *pNameToUse = new char [_MAX_PATH];

LPSTORAGE pIStorage = *ppIStorage;
	
	if (NULL == pNameToUse || NULL == pPathName)
		return ResultFromScode(E_FAIL);
	
	// alte ProjektStruktur, eigenes DocFile erzeugen/öffnen  
	// erstellt Pfadnamen
	hr = MakeFileName (pPathName, pNameToUse, "str");
	if (FAILED(hr))			
		return hr;
		
// Funktionen machen Addref(), Release() im Destruktor (Memberpointer Rootstorage)
	USES_CONVERSION;
	hr = StgOpenStorage (A2OLE(pNameToUse), NULL, dwMode, 0, 0, &pIStorage);
	if (FAILED(hr)) {
		if (GetScode(hr) == STG_E_FILENOTFOUND) {
		// neu anlegen
			dwMode |= STGM_CREATE;

			hr = StgCreateDocfile (A2OLE(pNameToUse), dwMode, 0, &pIStorage);
			delete (pNameToUse);
			if (FAILED(hr)) return hr;
				
			// GUID reinschreiben (Kontrollmöglichkeit)
			hr = WriteClassStg (pIStorage, CLSID_ScriptContainer);				
			if (FAILED(hr)) {
				pIStorage -> Release();
				return hr;
		    }
		}
		else {
		    delete (pNameToUse);
		    return hr;
		}
	} else delete (pNameToUse);

	hr = TestclsID (pIStorage, CLSID_ScriptContainer);
	if (FAILED(hr)) { pIStorage -> Release(); return hr; }

	*ppIStorage = pIStorage;

	return NOERROR;
}
コード例 #13
0
ファイル: Log.cpp プロジェクト: jiafenggit/mylib
void CTonyXiaoLog::GetFileName(void) //获取当前文件名
		{
	time_t tNow; //当前时间戳变量
	unsigned long ulDeltaT = 0; //△t 变量
	if ('\0' == m_szFileName[0]) //如果是第一次启动,文件名为空
			{
		MakeFileName(); //无条件创造个文件名,返回
		goto CTonyXiaoLog_GetFileName_End_Porcess;
	}
	time(&tNow); //求得当前时间
	ulDeltaT = (unsigned long) tNow - m_tFileNameMake; //计算△t
	if (LOG_FILE_CHANGE_NAME_PRE_SECONDS <= ulDeltaT) {
		MakeFileName(); //如果△t 超过3600 秒,创造文件名返回
		goto CTonyXiaoLog_GetFileName_End_Porcess;
	}
	if (LOG_FILE_SIZE_MAX <= m_nFileSize) //如果当前文件大小尺寸超出1G
			{
		MakeFileName(); //创造文件名返回
		goto CTonyXiaoLog_GetFileName_End_Porcess;
	}
	CTonyXiaoLog_GetFileName_End_Porcess: return;
}
コード例 #14
0
ファイル: SIOCTRL.CPP プロジェクト: mauriciogsc/Taliman
   bool SIO_SequentialIO ::
             DeleteFile(       char * FileNameParm ,
                         const char * DefaultExtensionParm )
   {

   #ifdef _DEBUG
      EXC_ASSERT( FileNameParm != NULL ) ;
   #endif

      MakeFileName( FileNameParm , DefaultExtensionParm ) ;
      return remove( SequentialFileName.GetString( )) == 0 ;

   } // End of function: SIO  !Delete file
コード例 #15
0
ファイル: GENC.C プロジェクト: Mikelle02/GameMaker
int loadspecany(const char *file,const char *ext,const char *path,unsigned int bytes, char *addr)
  {
  FILE *fp;
  char result;
  char srchfor[6];
  char fname[MAXFILENAMELEN];
  
  MakeFileName(fname,path,file,ext);

  if ( (fp=fopen(fname,"rb")) ==NULL) return(FALSE);
  fread(addr,bytes,1,fp);
  fclose(fp);
  return(TRUE);
  }
コード例 #16
0
bool WinEDA_App::OnInit(void)
{
wxString FFileName;

	EDA_Appl = this;
	InitEDA_Appl( wxT("gerbview") );

	if(argc > 1) FFileName = MakeFileName(wxEmptyString, argv[1], g_PhotoFilenameExt);

	ScreenPcb = new PCB_SCREEN(NULL, m_GerberFrame, PCB_FRAME);
	ActiveScreen = ScreenPcb;
	GetSettings();
    if ( m_Checker && m_Checker->IsAnotherRunning() )
    {
        if ( ! IsOK(NULL, _("Gerbview is already running, Continue?") ) )
			return false;
    }


	g_DrawBgColor = BLACK;

	m_GerberFrame = new WinEDA_GerberFrame(NULL, this, wxT("GerbView"),
				 wxPoint(0,0), wxSize(600,400) );
	m_GerberFrame->SetTitle(Main_Title);
	ScreenPcb->SetParentFrame(m_GerberFrame);
	m_GerberFrame->m_Pcb = new BOARD(NULL, m_GerberFrame);

	SetTopWindow(m_GerberFrame);
	m_GerberFrame->Show(TRUE);

	m_GerberFrame->m_Pcb = new BOARD(NULL, m_GerberFrame);
	m_GerberFrame->Zoom_Automatique(TRUE);

	/* Load file specified in the command line. */
	if( ! FFileName.IsEmpty() )
	{
		wxString path = wxPathOnly(FFileName);
		wxSetWorkingDirectory(path);
		Read_Config();
		if ( wxFileExists(FFileName) )
		{
			wxClientDC dc(m_GerberFrame->DrawPanel);
			m_GerberFrame->DrawPanel->PrepareGraphicContext(&dc);
			m_GerberFrame->LoadOneGerberFile(FFileName, &dc, FALSE);
		}
	}
	else Read_Config();

	return TRUE;
}
コード例 #17
0
ファイル: extract.c プロジェクト: Doom-Utils/deutex
/*
** try to save entry
*/
static bool XTRbmpSave(int16_t * pinsrX, int16_t * pinsrY,
                       struct WADDIR *entry, PICTYPE type,
                       const char *DataDir, const char *dir, struct
                       WADINFO *info, IMGTYPE Picture, bool WSafe,
                       cusage_t * cusage)
{
    bool res;
    int32_t start = entry->start;
    int32_t size = entry->size;
    char *name = entry->name;
    char *buffer;
    char *extens = NULL;

    if (size < 8L)
        return false;
    switch (Picture) {
#ifdef HAVE_LIBPNG
    case PICPNG:
        extens = "PNG";
        break;
#endif
    case PICGIF:
        extens = "GIF";
        break;
    case PICBMP:
        extens = "BMP";
        break;
    case PICPPM:
        extens = "PPM";
        break;
    default:
        Bug("EX47", "Invalid img type %d", (int) Picture);
    }
    res = MakeFileName(file, DataDir, dir, "", name, extens);
    if (res && WSafe) {
        Warning("EX48", "Will not overwrite file %s", file);
        return true;
    }
    buffer = (char *) Malloc(size);
    WADRseek(info, start);
    WADRreadBytes(info, buffer, size);
    res =
        PICsaveInFile(file, type, buffer, size, pinsrX, pinsrY, Picture,
                      name, cusage);
    if (res)
        Detail("EX49", "Saved picture as %s", fname(file));
    free(buffer);
    return res;
}
コード例 #18
0
ファイル: neolog.cpp プロジェクト: neoguojing/neolibs
void CNEOLog::GetFileName(void)
{
    time_t tNow;
    unsigned long ulDeltaT=0;  //变化量
    if('\0'==m_szFileName[0])  //如果第一次启动,文件名位空
    {
       MakeFileName();
       goto CNEOLog_GetFileName_End;
    }
    time(&tNow);
    ulDeltaT=(unsigned long)tNow-m_tFileNameMake;  //计算变化量
    if(LOG_FILE_CHANGE_NAME_PRE_SECONDS<=ulDeltaT)
    {
       MakeFileName();                            //时间超过一小时,返回
       goto CNEOLog_GetFileName_End;
    }
    if(LOG_FILE_SIZE_MAX<=m_nFileSize)
    {
       MakeFileName();                            
       goto CNEOLog_GetFileName_End;
    }
CNEOLog_GetFileName_End:
    return;
}
コード例 #19
0
void Invoke( char *invfile, int len, char_ring *parmlist )
{
    char        *invname;
    handle      hndl;

    _AllocA( invname, len + 1 );
    memcpy( invname, invfile, len );
    invname[ len ] = '\0';
    hndl = LocalFullPathOpen( invname, "dbg", TxtBuff, TXT_LEN );
    if( hndl == NIL_HANDLE ) {
        MakeFileName( TxtBuff, invname, "dbg", 0 );
        FreeRing( parmlist );
        Error( ERR_NONE, LIT( ERR_FILE_NOT_OPEN ), TxtBuff );
    }
    DoInvoke( hndl, TxtBuff, parmlist );
}
コード例 #20
0
ファイル: cvers.c プロジェクト: ankitvb/shock-turbulence
void makefilename( char rs[]    , int len, 
                    char path[]  , char prefix[], int *version ,
		    int Lpath    , int Lprefix                  )
{
   char *result, *cpath, *cprefix ;
   
   cpath   = stringToC(path  , Lpath  );
   cprefix = stringToC(prefix, Lprefix);

   result = MakeFileName(cpath,cprefix,*version) ;
   
   stringToF77(result,rs,len);
   free(cpath);  
   free(cprefix);
   free(result);
}
コード例 #21
0
ファイル: neolog.cpp プロジェクト: neoguojing/neolibs
CNEOLog::CNEOLog(CNEOLowDebug *pDebug,
        CNEOMemPoolWithLock *pMemPool,        //内存指针池
        const char *szLogPath,                      //日志路径
        const char *szAppName,                      //应用名
        int nHoldFileMax,                 //保存的最大文件数
        bool bSyslogFlag,                //日志级别开关
        bool bDebugFlag,
        bool bDebug2Flag,
        bool bDebug3Flag,
        bool bPrintfToScrFlag          //是否向屏幕打印
        ):m_Lock(),m_pDebug(pDebug),m_pMemPool(pMemPool)
{
    //m_pDebug=pDebug;
    //m_pMemPool=pMemPool;
    //拦截信息
    m_pInfoOutCallback=m_pDebug->pInfoOutCallback;
    m_pInfoOutCallbackParam=m_pDebug->pInfoOutCallbackParam;
    memset(m_szFilePath,0,sizeof(m_szFilePath));
    memset(m_szFileName,0,sizeof(m_szFileName));
    //利用debug输出启动标志
    m_pDebug->DebugToFile("CNEOLog:start~\n");
    //获得文件的基准字符
    FULL_NAME(szLogPath,szAppName,m_szFilePath,"");//在debug文件中定义
    //获得文件目录名的保存文件名
    FULL_NAME(szLogPath,szAppName,m_szFileInfoName,"info");
    //清空当前文件名缓冲
    NEO_CLEAN_CHAR_BUFFER(m_szFileName);//在某个文件中定义
    m_nFileSize=0;
    m_bSysLogFlag=bSyslogFlag;
    m_bDebugFlag=bDebugFlag;
    m_bDebug2Flag=bDebug2Flag;
    m_bDebug3Flag=bDebug3Flag;
    m_bPrintfToScrFlag=bPrintfToScrFlag;
    m_nHoldFileMax=nHoldFileMax;
    m_pFileInfoQueue=new CNEOMemQueue(m_pDebug,m_pMemPool,"CNEOLog::m_pFileInfoQueue");
    if(m_pFileInfoQueue)//申请成功,注册到内存池
    {
       m_pMemPool->Register(m_pFileInfoQueue,"CNEOLog::m_pFileInfoQueue");
    }
    m_pFileInfoQueue->ReadFromFile(m_szFileInfoName);//读入上次保留的文件名信息
    MakeFileName();                                  // 定制文件名
}
コード例 #22
0
ファイル: SIOCTRL.CPP プロジェクト: mauriciogsc/Taliman
   bool SIO_SequentialIO ::
             ExistsFile(       char * FileNameParm ,
                         const char * DefaultExtensionParm )
   {

   #ifdef _DEBUG
      EXC_ASSERT( FileNameParm != NULL ) ;
   #endif

      MakeFileName( FileNameParm , DefaultExtensionParm ) ;
      FILE * pArq = fopen( SequentialFileName.GetString( ) , "rt" ) ;
      if ( pArq != NULL )
      {
         fclose( pArq ) ;
         return true ;
      } /* if */

      return false ;

   } // End of function: SIO  !Verify if file exists for reading
コード例 #23
0
ファイル: Log.cpp プロジェクト: jiafenggit/mylib
CTonyXiaoLog::CTonyXiaoLog(
		CTonyLowDebug* pDebug, //参数介绍略
		CTonyMemoryPoolWithLock* pMemPool, char* szLogPath, char* szAppName,
		int nHoldFileMax, bool bSyslogFlag, bool bDebugFlag, bool bDebug2Flag,
		bool bDebug3Flag, bool bPrintf2ScrFlag) {
	m_pDebug = pDebug; //保留Debug 对象指针
	m_pMemPool = pMemPool; //保留内存池指针
//请注意,这里从Debug 对象中获得拦截回调函数信息
	m_pInfoOutCallback = m_pDebug->m_pInfoOutCallback;
	m_pInfoOutCallbackParam = m_pDebug->m_pInfoOutCallbackParam;
//利用debug 输出启动标志
	TONY_DEBUG("CTonyXiaoLog: Start!\n");
//获得日志文件名基准字符串,这里主要使用输入的路径名和应用名生成基本名
//如路径是“/var”,应用名是“test_project”,
//则基准名为“/var/test_project”,
//这样,以后的文件名,就是在这个基本名后加时间戳实现
//如:/var/test_project_Thu_Jul_16_14_31_44_2009.log
	FULL_NAME(szLogPath, szAppName, m_szFilePath, "");
//获得日志文件名目录的保存文件名
//如:/var/test_project.info
	FULL_NAME(szLogPath, szAppName, m_szFileInfoName, "info");
//清空当前文件名缓冲区
	TONY_CLEAN_CHAR_BUFFER (m_szFileName);
//当前文件尺寸设置为0
	m_nFileSize = 0;
	m_bSyslogFlag = bSyslogFlag; //保存Debug 级别开关变量
	m_bDebugFlag = bDebugFlag; //为false 的级别将不会被输出
	m_bDebug2Flag = bDebug2Flag;
	m_bDebug3Flag = bDebug3Flag;
	m_bPrintf2ScrFlag = bPrintf2ScrFlag; //保存屏幕输出开关
	m_nHoldFileMax = nHoldFileMax; //保存最大保留文件个数
	m_pFileInfoQueue = new CTonyXiaoMemoryQueue( //实例化文件目录队列对象
			pDebug, m_pMemPool, "CTonyXiaoLog::m_pFileInfoQueue");
	if (m_pFileInfoQueue) //如果创建成功,注册到内存池
	{
		m_pMemPool->Register(m_pFileInfoQueue,
				"CTonyXiaoLog::m_pFileInfoQueue");
	}
	m_pFileInfoQueue->ReadFromFile(m_szFileInfoName); //读入上次保留的文件名信息
	MakeFileName(); //根据当前时间戳,定制一个文件名
}
コード例 #24
0
ファイル: compose.c プロジェクト: RomanHargrave/xwadtools
/*
** Can't handle PATCHES redefined from WAD
*/
static Bool CMPOcopyFromWAD (
  Int32			*size,
  struct WADINFO	*rwad,
  const char		*DataDir,
  const char		*Dir,
  const char		*nam,
  const char		*filenam
)
{  static struct WADINFO pwad;
   Int16 entry;
   if(MakeFileName(file,DataDir,Dir,"",filenam,"WAD")!=TRUE)
     return FALSE;
   WADRopenR(&pwad,file);
   entry=WADRfindEntry(&pwad,nam);
   if(entry>=0)
   { *size=WADRwriteWADentry(rwad,&pwad,entry);
   }
   WADRclose(&pwad);
   if(entry<=0)return FALSE;
   return TRUE;
}
コード例 #25
0
ファイル: Storage.c プロジェクト: 0xE0F/ir-system
// Чтение из хранилища
bool Open(IRCode *code, const uint16_t number)
{
	char fName[8 + 1 + 3 + 1] = {'\0'}; // 8 name, + .bin + \0
	FRESULT res;
	FIL file;
	UINT btr = 0;
	uint16_t crc = 0xFFFF;

	if (!StorageInit) {
		print("Storage not init\n\r");
		return false;
	}

	if (!code) {
		print("Null pointer reference\n\r");
		return false;
	}

	MakeFileName(number, fName);
	res = f_open(&file, fName, FA_OPEN_EXISTING | FA_READ);
//	f_sync(&file);

	if (res) {
		printf("Error open file: %s, res: %d\n\r", fName, res);
		return false;
	}

	res = f_read(&file, code, sizeof(IRCode), &btr);
//	f_sync(&file);

	if (res || btr != sizeof(IRCode)) {
		printf("Error reading file: %d, bytes to read: %d\n\r", res, btr);
		return false;
	}

	f_close(&file);

	crc = GetCrc(code);
	return crc == code->Crc;
}
コード例 #26
0
void	MakeFileNameByProcess(wchar_t* output, size_t cchOutput, HANDLE process, const wchar_t* destFolder, const wchar_t* prefix, const wchar_t* ext)
{
	if (output != NULL && cchOutput > 0)
	{
		// 폴더 얻기
		wchar_t tempDir[MAX_PATH] = { 0, };
		if (destFolder != NULL)
		{
			::wcscpy_s(tempDir, _countof(tempDir), destFolder);
		}
		else	// 폴더가 지정되지 않았다면 프로세스가 존재하는 폴더를 선택한다.
		{
			GetProcessFolder(process, tempDir, _countof(tempDir));
		}

		// 프로세스 이름 얻기
		wchar_t processName[_MAX_FNAME] = { 0, };
		GetProcessName(process, processName, _countof(processName));

		MakeFileName(output, cchOutput, processName, tempDir, prefix, ext);
	}
}
コード例 #27
0
/*****************************************************************************
* Routine to save an EESchema file.											 *
* FileSave controls how the file is to be saved - under what name.			 *
* Returns TRUE if the file has been saved.									 *
*****************************************************************************/
bool WinEDA_SchematicFrame::SaveEEFile(BASE_SCREEN *Window, int FileSave)
{
wxString msg;
wxString Name, BakName;
const wxChar **LibNames;
char * layer, *width;
int ii, shape;
bool Failed = FALSE;
EDA_BaseStruct *Phead;
Ki_PageDescr * PlotSheet;
FILE *f;
wxString dirbuf;

	if ( Window == NULL ) Window = ActiveScreen;

	/* If no name exists in the window yet - save as new. */
	if( Window->m_FileName.IsEmpty() ) FileSave = FILE_SAVE_NEW;

	switch (FileSave)
	{
		case FILE_SAVE_AS:
			dirbuf = wxGetCwd() + STRING_DIR_SEP;
			Name = MakeFileName(dirbuf, Window->m_FileName, g_SchExtBuffer);
			/* Rename the old file to a '.bak' one: */
			BakName = Name;
			if ( wxFileExists(Name) )
			{
				ChangeFileNameExt(BakName, wxT(".bak"));
				wxRemoveFile(BakName);	/* delete Old .bak file */
				if( ! wxRenameFile(Name, BakName) )
				{
					DisplayError(this, wxT("Warning: unable to rename old file"), 10);
				}
			}
			break;

		case FILE_SAVE_NEW:
		{
			wxString mask = wxT("*") + g_SchExtBuffer;
			Name = EDA_FileSelector(_("Schematic files:"),
					wxEmptyString,					/* Chemin par defaut */
					Window->m_FileName,				/* nom fichier par defaut, et resultat */
					g_SchExtBuffer,		/* extension par defaut */
					mask,				/* Masque d'affichage */
					this,
					wxSAVE,
					FALSE
					);
			if ( Name.IsEmpty() ) return FALSE;

			Window->m_FileName = Name;
			dirbuf = wxGetCwd() + STRING_DIR_SEP;
			Name = MakeFileName(dirbuf, Name, g_SchExtBuffer);

			break;
		}

		default: break;
	}

	if ((f = wxFopen(Name, wxT("wt"))) == NULL)
	{
		msg = _("Failed to create file ") + Name;
		DisplayError(this, msg);
		return FALSE;
	}

	msg = _("Save file ") + Name;
	Affiche_Message(msg);

	LibNames = GetLibNames();
	BakName.Empty();	// temporary buffer!
	for (ii = 0; LibNames[ii] != NULL; ii++)
	{
		if (ii > 0) BakName += wxT(",");
		BakName += LibNames[ii];
	}
	MyFree( LibNames);

	if (fprintf(f, "%s %s %d\n", EESCHEMA_FILE_STAMP,
		SCHEMATIC_HEAD_STRING, EESCHEMA_VERSION) == EOF ||
		fprintf(f, "LIBS:%s\n", CONV_TO_UTF8(BakName)) == EOF)
	{
		DisplayError(this, _("File write operation failed."));
		fclose(f);
		return FALSE;
	}

	Window->ClrModify();

	SaveLayers(f);
	/* Sauvegarde des dimensions du schema, des textes du cartouche.. */
	
	PlotSheet = Window->m_CurrentSheet;
	fprintf(f,"$Descr %s %d %d\n",CONV_TO_UTF8(PlotSheet->m_Name),
			PlotSheet->m_Size.x, PlotSheet->m_Size.y);

	fprintf(f,"Sheet %d %d\n",Window->m_SheetNumber, Window->m_NumberOfSheet);
	fprintf(f,"Title \"%s\"\n",CONV_TO_UTF8(Window->m_Title));
	fprintf(f,"Date \"%s\"\n",CONV_TO_UTF8(Window->m_Date));
	fprintf(f,"Rev \"%s\"\n",CONV_TO_UTF8(Window->m_Revision));
	fprintf(f,"Comp \"%s\"\n",CONV_TO_UTF8(Window->m_Company));
	fprintf(f,"Comment1 \"%s\"\n", CONV_TO_UTF8(Window->m_Commentaire1));
	fprintf(f,"Comment2 \"%s\"\n", CONV_TO_UTF8(Window->m_Commentaire2));
	fprintf(f,"Comment3 \"%s\"\n", CONV_TO_UTF8(Window->m_Commentaire3));
	fprintf(f,"Comment4 \"%s\"\n", CONV_TO_UTF8(Window->m_Commentaire4));

	fprintf(f,"$EndDescr\n");

	/* Sauvegarde des elements du dessin */
	Phead = Window->EEDrawList;
	while (Phead)
		{
		switch(Phead->m_StructType)
			{
			case DRAW_LIB_ITEM_STRUCT_TYPE:		  /* Its a library item. */
				SavePartDescr( f, (EDA_SchComponentStruct *) Phead);
				break;

			case DRAW_SHEET_STRUCT_TYPE:	   /* Its a Sheet item. */
				SaveSheetDescr( f, (DrawSheetStruct *) Phead);
				break;

			case DRAW_SEGMENT_STRUCT_TYPE:		 /* Its a Segment item. */
				#undef STRUCT
				#define STRUCT ((EDA_DrawLineStruct *) Phead)
				layer = "Notes"; width = "Line";
				if (STRUCT->m_Layer == LAYER_WIRE) layer = "Wire";
				if (STRUCT->m_Layer == LAYER_BUS) layer = "Bus";
				if( STRUCT->m_Width != GR_NORM_WIDTH) layer = "Bus";
				if (fprintf(f, "Wire %s %s\n", layer, width ) == EOF)
					{
					Failed = TRUE; break;
					}
				if (fprintf(f, "\t%-4d %-4d %-4d %-4d\n",
						STRUCT->m_Start.x,STRUCT->m_Start.y,
						STRUCT->m_End.x,STRUCT->m_End.y) == EOF)
					{
					Failed = TRUE; break;
					}
				break;

			case DRAW_BUSENTRY_STRUCT_TYPE:		 /* Its a Raccord item. */
				#undef STRUCT
				#define STRUCT ((DrawBusEntryStruct *) Phead)
				layer = "Wire"; width = "Line";
				if (STRUCT->m_Layer == LAYER_BUS)
					{
					layer = "Bus"; width = "Bus";
					}

				if (fprintf(f, "Entry %s %s\n", layer, width) == EOF)
					{
					Failed = TRUE; break;
					}
				if( fprintf(f, "\t%-4d %-4d %-4d %-4d\n",
						STRUCT->m_Pos.x,STRUCT->m_Pos.y,
						STRUCT->m_End().x,STRUCT->m_End().y) == EOF)
						{
						Failed = TRUE; break;
						}
				break;

			case DRAW_POLYLINE_STRUCT_TYPE:		  /* Its a polyline item. */
				#undef STRUCT
				#define STRUCT ((DrawPolylineStruct *) Phead)
				layer = "Notes"; width = "Line";
				if (STRUCT->m_Layer == LAYER_WIRE) layer = "Wire";
				if (STRUCT->m_Layer == LAYER_BUS) layer = "Bus";
				if( STRUCT->m_Width != GR_NORM_WIDTH) width = "Bus";
				if (fprintf(f, "Poly %s %s %d\n",
							width, layer, STRUCT->m_NumOfPoints) == EOF)
					{
					Failed = TRUE; break;
					}
				for (ii = 0; ii < STRUCT->m_NumOfPoints; ii++)
					{
					if (fprintf(f, "\t%-4d %-4d\n",
						STRUCT->m_Points[ii*2],
						STRUCT->m_Points[ii*2+1]) == EOF)
						{
						Failed = TRUE;
						break;
						}
					}
				break;

			case DRAW_JUNCTION_STRUCT_TYPE:	/* Its a connection item. */
				#undef STRUCT
				#define STRUCT ((DrawJunctionStruct *) Phead)
				if (fprintf(f, "Connection ~ %-4d %-4d\n",
					STRUCT->m_Pos.x, STRUCT->m_Pos.y) == EOF)
					{
					Failed = TRUE;
					}
				break;

			case DRAW_NOCONNECT_STRUCT_TYPE:	/* Its a NoConnection item. */
				#undef STRUCT
				#define STRUCT ((DrawNoConnectStruct *) Phead)
				if (fprintf(f, "NoConn ~ %-4d %-4d\n",
					STRUCT->m_Pos.x, STRUCT->m_Pos.y) == EOF)
					{
					Failed = TRUE;
					}
				break;

			case DRAW_TEXT_STRUCT_TYPE:			/* Its a text item. */
				#undef STRUCT
				#define STRUCT ((DrawTextStruct *) Phead)
				if (fprintf(f, "Text Notes %-4d %-4d %-4d %-4d ~\n%s\n",
						STRUCT->m_Pos.x, STRUCT->m_Pos.y,
						STRUCT->m_Orient, STRUCT->m_Size.x,
						CONV_TO_UTF8(STRUCT->m_Text)) == EOF)
					Failed = TRUE;
				break;


			case DRAW_LABEL_STRUCT_TYPE:		/* Its a label item. */
				#undef STRUCT
				#define STRUCT ((DrawLabelStruct *) Phead)
				shape = '~';
				if (fprintf(f, "Text Label %-4d %-4d %-4d %-4d %c\n%s\n",
						STRUCT->m_Pos.x, STRUCT->m_Pos.y,
						STRUCT->m_Orient, STRUCT->m_Size.x, shape,
						CONV_TO_UTF8(STRUCT->m_Text)) == EOF)
					Failed = TRUE;
				break;


			case DRAW_GLOBAL_LABEL_STRUCT_TYPE: /* Its a Global label item. */
				#undef STRUCT
				#define STRUCT ((DrawGlobalLabelStruct *) Phead)
				shape = STRUCT->m_Shape;
			if (fprintf(f, "Text GLabel %-4d %-4d %-4d %-4d %s\n%s\n",
						STRUCT->m_Pos.x, STRUCT->m_Pos.y,
						STRUCT->m_Orient,	STRUCT->m_Size.x,
						SheetLabelType[shape],
						CONV_TO_UTF8(STRUCT->m_Text)) == EOF)
					Failed = TRUE;
				break;

			case DRAW_MARKER_STRUCT_TYPE:	/* Its a marker item. */
				#undef STRUCT
				#define STRUCT ((DrawMarkerStruct *) Phead)
				if( STRUCT->GetComment() ) msg = STRUCT->GetComment();
				else msg.Empty();
				if (fprintf(f, "Kmarq %c %-4d %-4d \"%s\" F=%X\n",
								(int) STRUCT->m_Type + 'A',
								STRUCT->m_Pos.x, STRUCT->m_Pos.y,
								CONV_TO_UTF8(msg), STRUCT->m_MarkFlags) == EOF)
					{
					Failed = TRUE;
					}
				break;

			case DRAW_SHEETLABEL_STRUCT_TYPE :
			case DRAW_PICK_ITEM_STRUCT_TYPE :
				break;

			default:
				break;
			}

		if (Failed)
			{
			DisplayError(this, _("File write operation failed."));
			break;
			}

		Phead = Phead->Pnext;
		}
	if (fprintf(f, "$EndSCHEMATC\n") == EOF) Failed = TRUE;

	fclose(f);

	if (FileSave == FILE_SAVE_NEW) Window->m_FileName = Name;

	return !Failed;
}
コード例 #28
0
/*
 * ProcImgSymInfo -- initialize symbolic information
 *
 * Note: This function should try to open files locally first, for two
 * reasons:
 * 1) If a local file is open as remote, then local caching may interfere with
 *    file operations (notably seeks with DIO_SEEK_CUR)
 * 2) Remote access goes through extra layer of indirection; this overhead
 *    is completely unnecessary for local debugging.
 */
static bool ProcImgSymInfo( image_entry *image )
{
    file_handle fh;
    unsigned    last;
    char        buff[TXT_LEN];
    char        *symfile_name;
    const char  *nopath;
    size_t      len;

    image->deferred_symbols = false;
    if( _IsOff( SW_LOAD_SYMS ) )
        return( NO_MOD );
    if( image->symfile_name != NULL ) {
        last = DIP_PRIOR_MAX;
        fh = PathOpen( image->symfile_name, strlen( image->symfile_name ), "sym" );
        if( fh == NIL_HANDLE ) {
            nopath = SkipPathInfo( image->symfile_name, OP_REMOTE );
            fh = PathOpen( nopath, strlen( nopath ), "sym" );
            if( fh == NIL_HANDLE ) {
                /* try the sym file without an added extension */
                fh = FileOpen( image->symfile_name, OP_READ );
            }
        }
    } else {
        last = DIP_PRIOR_EXPORTS - 1;
        fh = FileOpen( image->image_name, OP_READ );
        if( fh == NIL_HANDLE ) {
            fh = FileOpen( image->image_name, OP_READ | OP_REMOTE );
        }
    }
    if( fh != NIL_HANDLE ) {
        if( CheckLoadDebugInfo( image, fh, DIP_PRIOR_MIN, last ) ) {
            return( true );
        }
        FileClose( fh );
    }
    if( image->symfile_name != NULL )
        return( false );
    _AllocA( symfile_name, strlen( image->image_name ) + 1 );
    strcpy( symfile_name, image->image_name );
    symfile_name[ExtPointer( symfile_name, OP_REMOTE ) - symfile_name] = NULLCHAR;
    len = MakeFileName( buff, symfile_name, "sym", OP_REMOTE );
    _Alloc( image->symfile_name, len + 1 );
    if( image->symfile_name != NULL ) {
        memcpy( image->symfile_name, buff, len + 1 );
        fh = FileOpen( image->symfile_name, OP_READ );
        if( fh == NIL_HANDLE ) {
            fh = FileOpen( image->symfile_name, OP_READ | OP_REMOTE );
        }
        if( fh == NIL_HANDLE ) {
            fh = PathOpen( image->symfile_name, strlen( image->symfile_name ), "" );
        }
        if( fh != NIL_HANDLE ) {
            if( CheckLoadDebugInfo( image, fh, DIP_PRIOR_MIN, DIP_PRIOR_MAX ) ) {
                return( true );
            }
            FileClose( fh );
        }
        _Free( image->symfile_name );
    }
    image->symfile_name = NULL;
    if( _IsOff( SW_NO_EXPORT_SYMS ) ) {
        if( _IsOn( SW_DEFER_SYM_LOAD ) ) {
            image->deferred_symbols = true;
        } else {
            fh = FileOpen( image->image_name, OP_READ | OP_REMOTE );
            if( fh != NIL_HANDLE ) {
                if( CheckLoadDebugInfo( image, fh, DIP_PRIOR_EXPORTS - 1, DIP_PRIOR_MAX ) ) {
                    return( true );
                }
                FileClose( fh );
            }
        }
    }
    return( false );
}
コード例 #29
0
int listlib(void)
/*********************/
/* Routine lisant la liste des librairies, et generant la liste chainee
 des modules disponibles
*/
{
char buffer[1024];
wxString FullLibName;
int errorlevel = 0, end;
int flag_librairie;
STOREMOD * ItemLib;
unsigned ii;
	
	if( BaseListePkg )	/* Liste Deja existante, a supprimer */
		{
		FreeMemoryModules(); BaseListePkg = NULL;
		}

	if ( g_LibName_List.GetCount() == 0 ) return -4;

	/* init recherche */
	SetRealLibraryPath("modules");
	nblib = 0;

	/* Lecture des Librairies */
	for( ii= 0 ; ii < g_LibName_List.GetCount(); ii++)
	{
		/* Calcul du nom complet de la librairie */
		FullLibName = MakeFileName(g_RealLibDirBuffer, g_LibName_List[ii], LibExtBuffer);
		/* acces a une librairie */
		if ((name_libmodules = fopen(FullLibName.GetData(),"rt"))  == NULL )
		{
			sprintf(cbuf,_("Library file <%s> not found"),FullLibName.GetData());
			DisplayError(NULL, cbuf, 20);
			continue;
		}

		/* Controle du type de la librairie : */
		flag_librairie = 0;
		fgets(buffer,32,name_libmodules) ;
		if( strncmp(buffer,ENTETE_LIBRAIRIE,L_ENTETE_LIB) != 0 )
			{
			sprintf(cbuf,_("Library file <%s> is not a module library"),
					FullLibName.GetData());
			DisplayError(NULL, cbuf, 20);
			fclose(name_libmodules); continue;
			}

		/* Lecture du nombre de composants */
		fseek(name_libmodules,0,0) ;

		 /* lecture nom des composants : */
		end = 0;
		while( !end && fgets(buffer,255,name_libmodules) != NULL )
			{
			if(strnicmp(buffer,"$INDEX",6) == 0 )
				{
				while( fgets(buffer,255,name_libmodules) != NULL )
					{
					if(strnicmp(buffer,"$EndINDEX",6) == 0 )
						{ end = 1; break; }
				
					ItemLib = (STOREMOD * ) MyZMalloc( sizeof(STOREMOD) );
					ItemLib->Pnext = BaseListePkg;
					BaseListePkg = ItemLib;
					ItemLib->Type = STRUCT_MODULE ;

					strncpy(ItemLib->Module,StrPurge(buffer),
											sizeof(ItemLib->Module)-1);
					strncpy(ItemLib->LibName,FullLibName.GetData(),
											sizeof(ItemLib->LibName)-1);

					nblib++;
					}
				if( !end ) errorlevel = -3;
				}
			}
		fclose(name_libmodules);
		ReadDocLib(FullLibName );
	}

	/* classement alphabetique: */
	if( BaseListePkg )
		BaseListePkg = TriListeModules(BaseListePkg, nblib);

	return(errorlevel) ;
}
コード例 #30
0
//
// TABLE LEVEL output of auditdb command. 
// ***Only one table and one file in the auditdb arguments can be specified***
//
// It might throw the exception CeSqlException if fail in querying something from Ingres Database.
// If you have the list of columns, then provide it !.
// If the list of columns is null, then the function will query the list of columns !
// strTempTable [OUT]: receives the output of the temporary table name
BOOL IJA_TableAuditdbOutput (
    CaQueryTransactionInfo* pQueryInfo,
    CaTemporarySession* pSession, 
    CString& strTempTable, 
    CTypedPtrList<CObList, CaColumn*>* pListColumn,
	CString& strGranteeList)
{
	CString strDatabase;
	CString strDatabaseOwner;
	CString strTable;
	CString strTableOwner;
	CString strStatement;
	CString strLocalIngresTemp = theApp.m_strLocalIITemporary;
	if (strLocalIngresTemp.IsEmpty())
		return FALSE;
#ifdef MAINWIN
	strLocalIngresTemp += _T("/");
#else
	strLocalIngresTemp += _T("\\");
#endif

	class CaLocalData
	{
	public:
		CaLocalData(BOOL bLocal):m_bLocal(bLocal), m_strFile(_T("")){}
		virtual ~CaLocalData()
		{
			while (!m_listObject.IsEmpty())
				delete m_listObject.RemoveHead();
			//
			// Prepare to delete the files (*.trl) outputed from AUDITDB:
			if (m_bLocal)
			{
				if (!m_strFile.IsEmpty() && (_taccess(m_strFile, 0) != -1))
					DeleteFile (m_strFile);
			}
		};
		
		BOOL m_bLocal;
		CString m_strFile;
		CTypedPtrList<CObList, CaColumn*> m_listObject;
	};
	//
	// On the local node, do not use the remote command (RMCMD)
	BOOL bOnLocal = pSession->IsLocalNode();
	
	CaLocalData localData(bOnLocal);
	BOOL bQueryColumns = pListColumn? FALSE: TRUE;
	if (bQueryColumns)
	{
		if (IJA_QueryColumn (pQueryInfo, localData.m_listObject))
			pListColumn = &(localData.m_listObject);
	}

	CString csRmcmdOutPut;
	BOOL bResult = TRUE;

	ASSERT (pSession);
	if (!pSession)
		return FALSE;

	pQueryInfo->GetTable (strTable, strTableOwner);
	//
	// Get temp table name
	if (!GetTempAuditTableName(strTempTable, (LPCTSTR)strTable, (LPCTSTR)pQueryInfo->GetConnectedUser()))
	{
		//
		// Error while generating a temporary file name.
		CString strMsg;
		strMsg.LoadString(IDS_FAIL_TO_GENERATE_TEMPFILE);
		
		AfxMessageBox (strMsg);
		return FALSE;
	}
	
	//
	// Generate & Create the table to contain the audited table rows:
	// -------------------------------------------------------------
	CString strSyntaxCreateTable;
	BOOL bCreate = RCRD_GenerateTemporaryTableSyntax((LPCTSTR)strTempTable, pListColumn, strSyntaxCreateTable, bOnLocal);
	if (!bCreate) 
	{
		CString strMsg;
		strMsg.LoadString(IDS_FAIL_TO_GENERATE_TEMPTABLE);

		AfxMessageBox (strMsg);
		return FALSE;
	}
	CaLowlevelAddAlterDrop param (pQueryInfo->GetNode(), strDatabase, strSyntaxCreateTable);

	//
	// Create the temporary table in the current session:
	// --------------------------------------------------
	param.NeedSession(FALSE);
	//
	// This function will throw exception if failed:
	bCreate = param.ExecuteStatement(NULL);

	if (!bOnLocal)
	{
		param.SetStatement(_T("commit"));
		//
		// This function will throw exception if failed:
		bCreate = param.ExecuteStatement(NULL);
		if (!strGranteeList.IsEmpty()) {
			CString csStatement;
			csStatement.Format("grant select on %s to %s",(LPCTSTR)strTempTable, (LPCTSTR) strGranteeList);
			param.SetStatement((LPCTSTR)csStatement);
			// This function will throw exception in case of failure
			bCreate = param.ExecuteStatement(NULL);
			param.SetStatement(_T("commit"));
			// This function will throw exception in case of failure
			bCreate = param.ExecuteStatement(NULL);
		}
	}

	//
	// Construct parameters for the need of generating AUDITDB Syntax:
	CString strFile;
	CStringList listFile;
	CTypedPtrList < CObList, CaIjaTable* > listTable;
	
	//
	// TODO: Construct the directory path on the local machine:
	//       On remote machine the file name is generate by the utility adbtofst on NT machine
	//       or used the pipe on unix machine see adbtofst 
	if (!bOnLocal)
	{
		strFile = _T("");
	}
	else
	{

		CString strAcceptedFileName = strTempTable;
		MakeFileName(strAcceptedFileName);

		strFile.Format (_T("%s%s.trl"), (LPCTSTR)strLocalIngresTemp, (LPCTSTR)strAcceptedFileName);
	}

	listFile.AddTail (strFile);
	listTable.AddTail (new CaIjaTable(strTable, strTableOwner));
	localData.m_strFile = strFile;
	//
	// Generate AUDITDB syntax:
	BOOL bSyntax = FALSE; // FALSE generate syntax for the standard auditdb command
	                      // TRUE  generate syntax for adbtofst
	if (!bOnLocal)
		bSyntax = TRUE;

	RCRD_GenerateAuditdbSyntax (pQueryInfo, listTable, listFile, strStatement, pQueryInfo->GetConnectedUser(),bSyntax);
	while (!listTable.IsEmpty())
		delete listTable.RemoveHead();

	if (bOnLocal) 
	{
		CString strError = _T("");
		//
		// Execute the AUDITDB command:
		bCreate = PROCESS_Execute (strStatement, strError);
		if (!bCreate) 
		{
			if (!strError.IsEmpty())
				AfxMessageBox (strError);
			return FALSE;
		}
		//
		// Check if the file has been successfuly created:
		if (_taccess(strFile, 0) == -1)
		{
			//
			// auditdb ...-file=<file name>, has failed to create file.
			CString strMsg;
			strMsg.LoadString(IDS_AUDITDB_FAILS_TO_CREATE_FILE);

			AfxMessageBox (strMsg);
			return FALSE;
		}
		//
		// Copy the binary data of audited table to the newly created Table:
		strStatement.Format (
			_T("copy table session.%s () from '%s'"), 
			(LPCTSTR)strTempTable,
			(LPCTSTR)strFile);
		param.SetStatement(strStatement);

		//
		// This function will throw exception if failed:
		param.ExecuteStatement(NULL);
		param.SetStatement(_T("commit")); // the table is temporary anyhow. need to commit because of potential "set session authorization" statements
		bCreate = param.ExecuteStatement(NULL);
	}
	else
	//
	// Execute ADBTOFST at the remote machine through RMCMD:
	{
		//
		// At this point, it requires that no sessions are opened !
		pSession->Release();
		
		//Generate adbtofst syntax
		CString AdbToFstSyntax;
		CString strDatabase;
		CString strDatabaseOwner;

		pQueryInfo->GetDatabase (strDatabase, strDatabaseOwner);

		AdbToFstSyntax.Format(_T("adbtofst -u%s %s %s %s"),
		    (LPCTSTR)pQueryInfo->GetConnectedUser(),
		    (LPCTSTR)strTempTable,(LPCTSTR)strDatabase,
		    (LPCTSTR)strStatement);
		//
		// Execute the ADBTOFST command on the remote machine:
		bCreate = ExecRmcmdTestOutPut ((LPTSTR)(LPCTSTR)pQueryInfo->GetNode(), (LPTSTR)(LPCTSTR)AdbToFstSyntax,CMD_FASTLOAD,csRmcmdOutPut); 
		if (!bCreate) {
			//
			// Error While executing the AdbToFst Command:\n\n%1
			CString strMsg;
			if (csRmcmdOutPut.Find("E_DM1601_FLOAD_OPEN_DB")>=0)
				AfxFormatString1(strMsg, IDS_FAIL_TO_EXECUTE_ADBTOFST, (LPCTSTR)csRmcmdOutPut);
			else 
				strMsg = csRmcmdOutPut;
			AfxMessageBox (strMsg);
			DropTempTable(pSession, (LPCTSTR)strTempTable, bOnLocal);
			return FALSE;
		}

		//
		// Reopen the previous session:
		pSession->Open();
		if (!pSession->IsConnected())
		{
			//
			// Failedto get Session.
			CString strMsg;
			strMsg.LoadString (IDS_FAIL_TO_GETSESSION);
			AfxMessageBox (strMsg);

			DropTempTable(pSession, (LPCTSTR)strTempTable, bOnLocal);
			return FALSE;
		}
		param.NeedSession(FALSE);
	}

	return TRUE;
}