2007-11-02 17:17:44 +00:00
|
|
|
/*****************************************************************/
|
|
|
|
/* Functions to handle component library files : read functions */
|
|
|
|
/*****************************************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "gr_basic.h"
|
|
|
|
#include "common.h"
|
|
|
|
#include "trigo.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "confirm.h"
|
|
|
|
#include "kicad_string.h"
|
|
|
|
#include "gestfich.h"
|
2009-04-05 20:49:15 +00:00
|
|
|
#include "appl_wxstruct.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "program.h"
|
|
|
|
#include "libcmp.h"
|
|
|
|
#include "general.h"
|
|
|
|
#include "protos.h"
|
|
|
|
|
2007-11-02 17:17:44 +00:00
|
|
|
/* Local Functions */
|
2009-04-05 20:49:15 +00:00
|
|
|
static LibEDA_BaseStruct* GetDrawEntry( WinEDA_DrawFrame* frame, FILE* f,
|
|
|
|
char* Line, int* LineNum );
|
|
|
|
static bool AddAliasNames( EDA_LibComponentStruct* LibEntry, char* line );
|
|
|
|
static void InsertAlias( PriorQue** PQ, EDA_LibComponentStruct* LibEntry,
|
|
|
|
int* NumOfParts );
|
|
|
|
static int AddFootprintFilterList( EDA_LibComponentStruct* LibEntryLibEntry,
|
|
|
|
FILE* f, char* Line, int* LineNum );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
// If this code was written in C++ then this would not be needed.
|
|
|
|
static wxString currentLibraryName;
|
2007-12-05 20:54:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
/****************************************************************************/
|
2007-11-02 17:17:44 +00:00
|
|
|
/** Function LoadLibraryName
|
|
|
|
* Routine to load the given library name. FullLibName should hold full path
|
|
|
|
* of file name to open, while LibName should hold only its name.
|
2009-05-16 05:38:38 +00:00
|
|
|
* If library already exists, it is NOT reloaded.
|
2007-11-02 17:17:44 +00:00
|
|
|
* @return : new lib or NULL
|
|
|
|
*/
|
2009-04-05 20:49:15 +00:00
|
|
|
/****************************************************************************/
|
|
|
|
LibraryStruct* LoadLibraryName( WinEDA_DrawFrame* frame,
|
|
|
|
const wxString& FullLibName,
|
|
|
|
const wxString& LibName )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-24 15:10:46 +00:00
|
|
|
int NumOfParts;
|
|
|
|
FILE* f;
|
|
|
|
LibraryStruct* NewLib;
|
|
|
|
PriorQue* Entries;
|
2009-04-05 20:49:15 +00:00
|
|
|
wxFileName fn;
|
2007-08-24 15:10:46 +00:00
|
|
|
|
|
|
|
if( ( NewLib = FindLibrary( LibName ) ) != NULL )
|
|
|
|
{
|
|
|
|
if( NewLib->m_FullFileName == FullLibName )
|
|
|
|
return NewLib;
|
|
|
|
FreeCmpLibrary( frame, LibName );
|
|
|
|
}
|
|
|
|
|
|
|
|
NewLib = NULL;
|
|
|
|
|
|
|
|
f = wxFopen( FullLibName, wxT( "rt" ) );
|
|
|
|
if( f == NULL )
|
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
msg.Printf( _( "Library <%s> not found" ), FullLibName.GetData() );
|
|
|
|
DisplayError( frame, msg );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2008-09-13 18:59:57 +00:00
|
|
|
currentLibraryName = FullLibName;
|
|
|
|
|
2007-08-24 15:10:46 +00:00
|
|
|
NewLib = new LibraryStruct( LIBRARY_TYPE_EESCHEMA, LibName, FullLibName );
|
|
|
|
|
|
|
|
Entries = LoadLibraryAux( frame, NewLib, f, &NumOfParts );
|
|
|
|
if( Entries != NULL )
|
|
|
|
{
|
|
|
|
NewLib->m_Entries = Entries;
|
|
|
|
NewLib->m_NumOfParts = NumOfParts;
|
|
|
|
|
|
|
|
if( g_LibraryList == NULL )
|
|
|
|
g_LibraryList = NewLib;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
LibraryStruct* tmplib = g_LibraryList;
|
|
|
|
while( tmplib->m_Pnext )
|
|
|
|
tmplib = tmplib->m_Pnext;
|
|
|
|
|
|
|
|
tmplib->m_Pnext = NewLib;
|
|
|
|
}
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
fn = FullLibName;
|
|
|
|
fn.SetExt( DOC_EXT );
|
|
|
|
LoadDocLib( frame, fn.GetFullPath(), NewLib->m_Name );
|
2007-08-24 15:10:46 +00:00
|
|
|
}
|
2009-04-05 20:49:15 +00:00
|
|
|
else
|
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
SAFE_DELETE( NewLib );
|
|
|
|
}
|
2007-08-24 15:10:46 +00:00
|
|
|
fclose( f );
|
|
|
|
return NewLib;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-05-16 05:38:38 +00:00
|
|
|
/** Function LoadLibraries
|
|
|
|
* Clear all already loaded libraries and load all librairies
|
2009-04-29 17:09:00 +00:00
|
|
|
* given in frame->m_ComponentLibFiles
|
2007-08-24 15:10:46 +00:00
|
|
|
*/
|
2009-04-29 17:09:00 +00:00
|
|
|
void LoadLibraries( WinEDA_SchematicFrame* frame )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
wxFileName fn;
|
|
|
|
wxString msg, tmp;
|
2009-04-29 17:09:00 +00:00
|
|
|
unsigned ii, iimax = frame->m_ComponentLibFiles.GetCount();
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2009-04-11 15:50:31 +00:00
|
|
|
// Free the unwanted libraries (i.e. not in list) but keep the cache lib
|
2007-08-24 15:10:46 +00:00
|
|
|
LibraryStruct* nextlib, * lib = g_LibraryList;
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2007-08-24 15:10:46 +00:00
|
|
|
for( ; lib != NULL; lib = nextlib )
|
|
|
|
{
|
|
|
|
nextlib = lib->m_Pnext;
|
|
|
|
if( lib->m_IsLibCache )
|
|
|
|
continue;
|
|
|
|
|
2009-04-29 17:09:00 +00:00
|
|
|
// is this library in "wanted list" frame->m_ComponentLibFiles ?
|
|
|
|
if( frame->m_ComponentLibFiles.Index( lib->m_Name ) == wxNOT_FOUND )
|
2009-04-05 20:49:15 +00:00
|
|
|
FreeCmpLibrary( frame, lib->m_Name );
|
2007-08-24 15:10:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Load missing libraries (if any)
|
|
|
|
for( ii = 0; ii < iimax; ii++ )
|
|
|
|
{
|
2009-04-29 17:09:00 +00:00
|
|
|
fn = frame->m_ComponentLibFiles[ii];
|
2009-04-05 20:49:15 +00:00
|
|
|
fn.SetExt( CompLibFileExtension );
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
if( !fn.IsOk() )
|
2007-08-24 15:10:46 +00:00
|
|
|
continue;
|
2007-11-02 17:17:44 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
if( !fn.FileExists() )
|
|
|
|
{
|
2009-04-08 18:06:22 +00:00
|
|
|
tmp = wxGetApp().FindLibraryPath( fn );
|
2009-04-05 20:49:15 +00:00
|
|
|
if( !tmp )
|
|
|
|
{
|
2009-05-16 05:38:38 +00:00
|
|
|
msg.Printf( _( "Library file <%s> not found." ), fn.GetName().c_str() );
|
|
|
|
wxMessageBox( msg, _( "Library Load Error" ), wxOK | wxICON_ERROR, frame );
|
2009-04-05 20:49:15 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
tmp = fn.GetFullPath();
|
|
|
|
}
|
2007-11-02 17:17:44 +00:00
|
|
|
|
2008-10-05 10:56:43 +00:00
|
|
|
// Loaded library statusbar message
|
2009-04-05 20:49:15 +00:00
|
|
|
msg = _( "Library " ) + tmp;
|
2007-11-02 17:17:44 +00:00
|
|
|
frame->PrintMsg( msg );
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
if( LoadLibraryName( frame, tmp, fn.GetName() ) )
|
2008-10-05 10:56:43 +00:00
|
|
|
msg += _( " loaded" );
|
2007-08-24 15:10:46 +00:00
|
|
|
else
|
2008-10-05 10:56:43 +00:00
|
|
|
msg += _( " error!" );
|
2007-11-02 17:17:44 +00:00
|
|
|
|
2009-04-11 15:50:31 +00:00
|
|
|
frame->PrintMsg( msg );
|
2009-04-10 14:57:10 +00:00
|
|
|
}
|
2007-08-24 15:10:46 +00:00
|
|
|
|
|
|
|
// reorder the linked list to match the order filename list:
|
|
|
|
int NumOfLibs;
|
|
|
|
for( NumOfLibs = 0, lib = g_LibraryList; lib != NULL; lib = lib->m_Pnext )
|
|
|
|
{
|
|
|
|
lib->m_Flags = 0;
|
|
|
|
NumOfLibs++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( NumOfLibs == 0 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
LibraryStruct** libs =
|
2007-11-02 17:17:44 +00:00
|
|
|
(LibraryStruct**) MyZMalloc( sizeof(LibraryStruct*) * (NumOfLibs + 2) );
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2007-11-02 17:17:44 +00:00
|
|
|
int jj = 0;
|
2009-04-29 17:09:00 +00:00
|
|
|
for( ii = 0; ii < frame->m_ComponentLibFiles.GetCount(); ii++ )
|
2007-08-24 15:10:46 +00:00
|
|
|
{
|
|
|
|
if( jj >= NumOfLibs )
|
|
|
|
break;
|
2009-04-29 17:09:00 +00:00
|
|
|
fn = frame->m_ComponentLibFiles[ii];
|
2009-04-10 14:53:24 +00:00
|
|
|
lib = FindLibrary( fn.GetName() );
|
2007-08-24 15:10:46 +00:00
|
|
|
if( lib )
|
|
|
|
{
|
|
|
|
lib->m_Flags = 1;
|
|
|
|
libs[jj++] = lib;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Put lib cache at end of list */
|
|
|
|
for( lib = g_LibraryList; lib != NULL; lib = lib->m_Pnext )
|
|
|
|
{
|
|
|
|
if( lib->m_Flags == 0 )
|
|
|
|
libs[jj++] = lib;
|
|
|
|
}
|
|
|
|
|
|
|
|
libs[jj] = NULL;
|
|
|
|
|
|
|
|
/* Change the linked list pointers */
|
|
|
|
for( ii = 0; libs[ii] != NULL; ii++ )
|
|
|
|
libs[ii]->m_Pnext = libs[ii + 1];
|
|
|
|
|
|
|
|
g_LibraryList = libs[0];
|
|
|
|
|
|
|
|
MyFree( libs );
|
|
|
|
|
|
|
|
for( lib = g_LibraryList; lib != NULL; lib = lib->m_Pnext )
|
|
|
|
lib->m_Flags = 0;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2007-11-02 17:17:44 +00:00
|
|
|
/**************************************************************/
|
|
|
|
/** Function FreeCmpLibrary
|
|
|
|
* Routine to remove and free a library from the current loaded libraries.
|
|
|
|
*/
|
2009-04-05 20:49:15 +00:00
|
|
|
/**************************************************************/
|
|
|
|
void FreeCmpLibrary (wxWindow* frame, const wxString& LibName)
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-24 15:10:46 +00:00
|
|
|
int NumOfLibs = NumOfLibraries();
|
|
|
|
LibraryStruct* Lib, * TempLib;
|
|
|
|
|
|
|
|
if( NumOfLibs == 0 )
|
|
|
|
{
|
|
|
|
DisplayError( frame, wxT( "No libraries are loaded" ), 20 );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Search for this library name: */
|
|
|
|
for( Lib = g_LibraryList; Lib != NULL; Lib = Lib->m_Pnext )
|
|
|
|
{
|
|
|
|
if( LibName == Lib->m_Name )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( Lib == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( Lib == g_LibraryList )
|
|
|
|
g_LibraryList = Lib->m_Pnext;
|
|
|
|
else
|
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
for( TempLib = g_LibraryList; TempLib->m_Pnext != Lib;
|
|
|
|
TempLib = TempLib->m_Pnext )
|
2007-08-24 15:10:46 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
TempLib->m_Pnext = TempLib->m_Pnext->m_Pnext;
|
|
|
|
}
|
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
SAFE_DELETE( Lib );
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2007-11-02 17:17:44 +00:00
|
|
|
/* The removed librairy can be the current library in libedit.
|
|
|
|
* If so, clear the current library in libedit */
|
2007-08-24 15:10:46 +00:00
|
|
|
if( Lib == CurrentLib )
|
|
|
|
CurrentLib = NULL;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/******************************/
|
2007-11-02 17:17:44 +00:00
|
|
|
/** GetLibNames()
|
|
|
|
* Routine to return pointers to all library names.
|
2007-08-24 15:10:46 +00:00
|
|
|
* User is responsible to deallocate memory
|
|
|
|
*/
|
2009-04-05 20:49:15 +00:00
|
|
|
/******************************/
|
|
|
|
const wxChar** GetLibNames()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-24 15:10:46 +00:00
|
|
|
int ii, NumOfLibs = NumOfLibraries();
|
|
|
|
const wxChar** Names;
|
|
|
|
LibraryStruct* Lib;
|
|
|
|
|
2007-11-02 17:17:44 +00:00
|
|
|
Names = (const wxChar**) MyZMalloc( sizeof(wxChar*) * (NumOfLibs + 1) );
|
2007-08-24 15:10:46 +00:00
|
|
|
for( ii = 0, Lib = g_LibraryList; Lib != NULL; Lib = Lib->m_Pnext, ii++ )
|
|
|
|
{
|
|
|
|
Names[ii] = Lib->m_Name.GetData();
|
|
|
|
}
|
|
|
|
|
|
|
|
Names[ii] = NULL;
|
|
|
|
|
|
|
|
return Names;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-02 17:17:44 +00:00
|
|
|
/** Function LibraryEntryCompare
|
|
|
|
* Routine to compare two EDA_LibComponentStruct for the PriorQue module.
|
|
|
|
* Comparison (insensitive case) is based on Part name.
|
|
|
|
*/
|
2009-04-05 20:49:15 +00:00
|
|
|
int LibraryEntryCompare (EDA_LibComponentStruct* LE1,
|
|
|
|
EDA_LibComponentStruct* LE2)
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-24 15:10:46 +00:00
|
|
|
return LE1->m_Name.m_Text.CmpNoCase( LE2->m_Name.m_Text );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2008-10-01 17:34:55 +00:00
|
|
|
/**************************************************/
|
|
|
|
/* Routine to load a library from given open file */
|
|
|
|
/**************************************************/
|
2009-04-05 20:49:15 +00:00
|
|
|
PriorQue* LoadLibraryAux( WinEDA_DrawFrame* frame, LibraryStruct* Library,
|
|
|
|
FILE* libfile, int* NumOfParts )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-24 15:10:46 +00:00
|
|
|
int LineNum = 0;
|
|
|
|
char Line[1024];
|
|
|
|
PriorQue* PQ = NULL;
|
|
|
|
EDA_LibComponentStruct* LibEntry;
|
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
wxBusyCursor ShowWait; // Display a Busy Cursor..
|
|
|
|
|
|
|
|
*NumOfParts = 0;
|
|
|
|
|
|
|
|
if( GetLine( libfile, Line, &LineNum, sizeof(Line) ) == NULL )
|
|
|
|
{
|
|
|
|
msg = _( "File <" ) + Library->m_Name + _( "> is empty!" );
|
|
|
|
DisplayError( frame, msg );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( strnicmp( Line, LIBFILE_IDENT, 10 ) != 0 )
|
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
msg = _( "File <" ) + Library->m_Name +
|
|
|
|
_( "> is NOT EESCHEMA library!" );
|
2007-08-24 15:10:46 +00:00
|
|
|
DisplayError( frame, msg );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( Library )
|
|
|
|
Library->m_Header = CONV_FROM_UTF8( Line );
|
|
|
|
|
|
|
|
PQInit( &PQ );
|
|
|
|
PQCompFunc( (PQCompFuncType) LibraryEntryCompare );
|
|
|
|
|
|
|
|
while( GetLine( libfile, Line, &LineNum, sizeof(Line) ) )
|
|
|
|
{
|
|
|
|
if( strnicmp( Line, "$HEADER", 7 ) == 0 )
|
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
if( Library && !Library->ReadHeader( libfile, &LineNum ) )
|
2007-08-24 15:10:46 +00:00
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
msg = _( "Library <" ) + Library->m_Name +
|
|
|
|
_( "> header read error" );
|
|
|
|
DisplayError( frame, msg, 30 );
|
2007-08-24 15:10:46 +00:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( strnicmp( Line, "DEF", 3 ) == 0 )
|
|
|
|
{
|
|
|
|
/* Read one DEF/ENDDEF part entry from library: */
|
2009-04-05 20:49:15 +00:00
|
|
|
LibEntry = Read_Component_Definition( frame, Line, libfile,
|
|
|
|
&LineNum );
|
2007-08-24 15:10:46 +00:00
|
|
|
if( LibEntry )
|
|
|
|
{
|
|
|
|
/* If we are here, this part is O.k. - put it in: */
|
|
|
|
++ * NumOfParts;
|
|
|
|
PQInsert( &PQ, LibEntry );
|
|
|
|
InsertAlias( &PQ, LibEntry, NumOfParts );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return PQ;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
/* Analyse la ligne de description du champ de la forme:
|
|
|
|
* Fn "CA3130" 150 -200 50 H V
|
|
|
|
* ou n = 0 (REFERENCE), 1 (VALUE) , 2 .. 11 = autres champs, facultatifs
|
|
|
|
*/
|
|
|
|
/*****************************************************************************/
|
|
|
|
static bool GetLibEntryField ( EDA_LibComponentStruct* LibEntry, char* line,
|
|
|
|
wxString& errorMsg )
|
|
|
|
{
|
|
|
|
LibDrawField* field = new LibDrawField();
|
|
|
|
|
|
|
|
if ( !field->Load( line, errorMsg ) )
|
|
|
|
{
|
|
|
|
SAFE_DELETE( field );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch( field->m_FieldId )
|
|
|
|
{
|
|
|
|
case REFERENCE:
|
|
|
|
LibEntry->m_Prefix = *field;
|
|
|
|
SAFE_DELETE( field );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VALUE:
|
|
|
|
LibEntry->m_Name = *field;
|
|
|
|
SAFE_DELETE( field );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
LibEntry->m_Fields.PushBack( field );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
/* Routine to Read a DEF/ENDDEF part entry from given open file.
|
|
|
|
*/
|
|
|
|
/*****************************************************************************/
|
2008-12-04 21:43:20 +00:00
|
|
|
EDA_LibComponentStruct* Read_Component_Definition( WinEDA_DrawFrame* frame,
|
|
|
|
char* Line,
|
|
|
|
FILE* f,
|
|
|
|
int* LineNum )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-24 15:10:46 +00:00
|
|
|
int unused;
|
2007-09-21 13:23:51 +00:00
|
|
|
char* p;
|
|
|
|
char* name;
|
|
|
|
char* prefix = NULL;
|
2007-11-02 17:17:44 +00:00
|
|
|
|
2007-08-24 15:10:46 +00:00
|
|
|
EDA_LibComponentStruct* LibEntry = NULL;
|
|
|
|
bool Res;
|
2009-04-05 20:49:15 +00:00
|
|
|
wxString Msg, errorMsg;
|
2007-08-24 15:10:46 +00:00
|
|
|
|
|
|
|
p = strtok( Line, " \t\r\n" );
|
|
|
|
|
|
|
|
if( strcmp( p, "DEF" ) != 0 )
|
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
Msg.Printf( wxT( "DEF command expected in line %d, aborted." ),
|
|
|
|
*LineNum );
|
2007-08-24 15:10:46 +00:00
|
|
|
DisplayError( frame, Msg );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Read DEF line: */
|
2009-04-05 20:49:15 +00:00
|
|
|
char drawnum = 0;
|
|
|
|
char drawname = 0;
|
|
|
|
|
2007-08-24 15:10:46 +00:00
|
|
|
LibEntry = new EDA_LibComponentStruct( NULL );
|
|
|
|
|
2007-09-21 13:23:51 +00:00
|
|
|
if( ( name = strtok( NULL, " \t\n" ) ) == NULL /* Part name: */
|
2009-04-05 20:49:15 +00:00
|
|
|
|| ( prefix = strtok( NULL, " \t\n" ) ) == NULL /* Prefix name: */
|
|
|
|
|| ( p = strtok( NULL, " \t\n" ) ) == NULL /* NumOfPins: */
|
|
|
|
|| sscanf( p, "%d", &unused ) != 1
|
|
|
|
|| ( p = strtok( NULL, " \t\n" ) ) == NULL /* TextInside: */
|
|
|
|
|| sscanf( p, "%d", &LibEntry->m_TextInside ) != 1
|
|
|
|
|| ( p = strtok( NULL, " \t\n" ) ) == NULL /* DrawNums: */
|
|
|
|
|| sscanf( p, "%c", &drawnum ) != 1
|
|
|
|
|| ( p = strtok( NULL, " \t\n" ) ) == NULL /* DrawNums: */
|
|
|
|
|| sscanf( p, "%c", &drawname ) != 1
|
|
|
|
|| ( p = strtok( NULL, " \t\n" ) ) == NULL /* m_UnitCount: */
|
|
|
|
|| sscanf( p, "%d", &LibEntry->m_UnitCount ) != 1 )
|
2007-08-24 15:10:46 +00:00
|
|
|
{
|
|
|
|
Msg.Printf( wxT( "Wrong DEF format in line %d, skipped." ), *LineNum );
|
|
|
|
DisplayError( frame, Msg );
|
|
|
|
while( GetLine( f, Line, LineNum, 1024 ) )
|
|
|
|
{
|
|
|
|
p = strtok( Line, " \t\n" );
|
|
|
|
if( stricmp( p, "ENDDEF" ) == 0 )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
2007-11-02 17:17:44 +00:00
|
|
|
else /* Update infos read from the line "DEF" */
|
2007-08-24 15:10:46 +00:00
|
|
|
{
|
|
|
|
LibEntry->m_DrawPinNum = (drawnum == 'N') ? FALSE : TRUE;
|
|
|
|
LibEntry->m_DrawPinName = (drawname == 'N') ? FALSE : TRUE;
|
2007-11-02 17:17:44 +00:00
|
|
|
|
2007-08-24 15:10:46 +00:00
|
|
|
/* Copy part name and prefix. */
|
2007-09-21 13:23:51 +00:00
|
|
|
strupper( name );
|
|
|
|
if( name[0] != '~' )
|
|
|
|
LibEntry->m_Name.m_Text = CONV_FROM_UTF8( name );
|
2007-08-24 15:10:46 +00:00
|
|
|
else
|
|
|
|
{
|
2007-09-21 13:23:51 +00:00
|
|
|
LibEntry->m_Name.m_Text = CONV_FROM_UTF8( &name[1] );
|
2007-08-24 15:10:46 +00:00
|
|
|
LibEntry->m_Name.m_Attributs |= TEXT_NO_VISIBLE;
|
|
|
|
}
|
|
|
|
|
2007-09-21 13:23:51 +00:00
|
|
|
if( strcmp( prefix, "~" ) == 0 )
|
2007-08-24 15:10:46 +00:00
|
|
|
{
|
|
|
|
LibEntry->m_Prefix.m_Text.Empty();
|
|
|
|
LibEntry->m_Prefix.m_Attributs |= TEXT_NO_VISIBLE;
|
|
|
|
}
|
|
|
|
else
|
2007-09-21 13:23:51 +00:00
|
|
|
LibEntry->m_Prefix.m_Text = CONV_FROM_UTF8( prefix );
|
2007-08-24 15:10:46 +00:00
|
|
|
|
|
|
|
// Copy optional infos
|
2009-04-05 20:49:15 +00:00
|
|
|
// m_UnitSelectionLocked param
|
|
|
|
if( ( p = strtok( NULL, " \t\n" ) ) != NULL )
|
2007-08-24 15:10:46 +00:00
|
|
|
{
|
|
|
|
if( *p == 'L' )
|
|
|
|
LibEntry->m_UnitSelectionLocked = TRUE;
|
|
|
|
}
|
|
|
|
if( ( p = strtok( NULL, " \t\n" ) ) != NULL ) /* Type Of Component */
|
|
|
|
{
|
|
|
|
if( *p == 'P' )
|
|
|
|
LibEntry->m_Options = ENTRY_POWER;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-11-02 17:17:44 +00:00
|
|
|
/* Read next lines */
|
2007-08-24 15:10:46 +00:00
|
|
|
while( GetLine( f, Line, LineNum, 1024 ) )
|
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
p = strtok( Line, " \t\n" );
|
|
|
|
|
|
|
|
/* This is the error flag ( if an error occurs, Res = FALSE) */
|
|
|
|
Res = TRUE;
|
2007-08-24 15:10:46 +00:00
|
|
|
|
|
|
|
if( (Line[0] == 'T') && (Line[1] == 'i') )
|
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
Res = LibEntry->LoadDateAndTime( Line );
|
2007-08-24 15:10:46 +00:00
|
|
|
}
|
|
|
|
else if( Line[0] == 'F' )
|
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
Res = GetLibEntryField( LibEntry, Line, errorMsg );
|
2007-08-24 15:10:46 +00:00
|
|
|
}
|
|
|
|
else if( strcmp( p, "ENDDEF" ) == 0 )
|
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
p = strtok( Line, " \t\n" );
|
2007-08-24 15:10:46 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if( strcmp( p, "DRAW" ) == 0 )
|
|
|
|
{
|
|
|
|
LibEntry->m_Drawings = GetDrawEntry( frame, f, Line, LineNum );
|
|
|
|
}
|
|
|
|
else if( strncmp( p, "ALIAS", 5 ) == 0 )
|
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
p = strtok( NULL, "\r\n" );
|
2007-08-24 15:10:46 +00:00
|
|
|
Res = AddAliasNames( LibEntry, p );
|
|
|
|
}
|
|
|
|
else if( strncmp( p, "$FPLIST", 5 ) == 0 )
|
|
|
|
{
|
|
|
|
Res = AddFootprintFilterList( LibEntry, f, Line, LineNum );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
Msg.Printf( wxT( "Undefined command \"%s\" in line %d, skipped." ),
|
|
|
|
p, *LineNum );
|
2007-08-24 15:10:46 +00:00
|
|
|
frame->PrintMsg( Msg );
|
|
|
|
}
|
|
|
|
|
2007-11-02 17:17:44 +00:00
|
|
|
/* End line or block analysis: test for an error */
|
2007-08-24 15:10:46 +00:00
|
|
|
if( !Res )
|
|
|
|
{ /* Something went wrong there. */
|
2009-04-05 20:49:15 +00:00
|
|
|
if( errorMsg.IsEmpty() )
|
2009-05-21 17:42:42 +00:00
|
|
|
Msg.Printf( wxT( "Error at line %d of library \n\"%s\",\nlibrary not loaded" ),
|
2009-04-05 20:49:15 +00:00
|
|
|
*LineNum, currentLibraryName.GetData() );
|
|
|
|
else
|
2009-05-21 17:42:42 +00:00
|
|
|
Msg.Printf( wxT( "Error <%s> at line %d of library \n\"%s\",\nlibrary not loaded" ),
|
2009-04-05 20:49:15 +00:00
|
|
|
errorMsg.c_str(), *LineNum,
|
|
|
|
currentLibraryName.GetData() );
|
2007-08-24 15:10:46 +00:00
|
|
|
DisplayError( frame, Msg );
|
2008-11-24 06:53:43 +00:00
|
|
|
SAFE_DELETE( LibEntry );
|
2007-08-24 15:10:46 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If we are here, this part is O.k. - put it in: */
|
|
|
|
LibEntry->SortDrawItems();
|
|
|
|
return LibEntry;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* Routine to load a DRAW definition from given file. Note "DRAW" line has *
|
|
|
|
* been read already. Reads upto and include ENDDRAW, or an error (NULL ret). *
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
static LibEDA_BaseStruct* GetDrawEntry (WinEDA_DrawFrame* frame, FILE* f,
|
|
|
|
char* Line, int* LineNum)
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
wxString MsgLine, errorMsg;
|
|
|
|
bool entryLoaded;
|
|
|
|
LibEDA_BaseStruct* Tail = NULL;
|
|
|
|
LibEDA_BaseStruct* New = NULL;
|
|
|
|
LibEDA_BaseStruct* Head = NULL;
|
2007-08-24 15:10:46 +00:00
|
|
|
|
|
|
|
while( TRUE )
|
|
|
|
{
|
|
|
|
if( GetLine( f, Line, LineNum, 1024 ) == NULL )
|
|
|
|
{
|
|
|
|
DisplayError( frame, wxT( "File ended prematurely" ) );
|
|
|
|
return Head;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( strncmp( Line, "ENDDRAW", 7 ) == 0 )
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
New = NULL;
|
|
|
|
|
|
|
|
switch( Line[0] )
|
|
|
|
{
|
|
|
|
case 'A': /* Arc */
|
2009-04-05 20:49:15 +00:00
|
|
|
New = ( LibEDA_BaseStruct* ) new LibDrawArc();
|
|
|
|
entryLoaded = New->Load( Line, errorMsg );
|
2007-08-24 15:10:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'C': /* Circle */
|
2009-04-05 20:49:15 +00:00
|
|
|
New = ( LibEDA_BaseStruct* ) new LibDrawCircle();
|
|
|
|
entryLoaded = New->Load( Line, errorMsg );
|
2007-08-24 15:10:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'T': /* Text */
|
2009-04-05 20:49:15 +00:00
|
|
|
New = ( LibEDA_BaseStruct* ) new LibDrawText();
|
|
|
|
entryLoaded = New->Load( Line, errorMsg );
|
2007-08-24 15:10:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'S': /* Square */
|
2009-04-05 20:49:15 +00:00
|
|
|
New = ( LibEDA_BaseStruct* ) new LibDrawSquare();
|
|
|
|
entryLoaded = New->Load( Line, errorMsg );
|
2007-08-24 15:10:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'X': /* Pin Description */
|
2009-04-05 20:49:15 +00:00
|
|
|
New = ( LibEDA_BaseStruct* ) new LibDrawPin();
|
|
|
|
entryLoaded = New->Load( Line, errorMsg );
|
2007-08-24 15:10:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'P': /* Polyline */
|
2009-04-05 20:49:15 +00:00
|
|
|
New = ( LibEDA_BaseStruct* ) new LibDrawPolyline();
|
|
|
|
entryLoaded = New->Load( Line, errorMsg );
|
2007-08-24 15:10:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2009-05-21 17:42:42 +00:00
|
|
|
MsgLine.Printf( wxT( "Undefined DRAW command in line %d\n%s, aborted." ),
|
|
|
|
*LineNum, Line );
|
2007-08-24 15:10:46 +00:00
|
|
|
DisplayError( frame, MsgLine );
|
|
|
|
return Head;
|
|
|
|
}
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
if( !entryLoaded )
|
2007-08-24 15:10:46 +00:00
|
|
|
{
|
2009-05-21 17:42:42 +00:00
|
|
|
MsgLine.Printf( wxT( "Error <%s %s> in DRAW command %c in line %d, aborted." ),
|
|
|
|
errorMsg.c_str(), MsgLine.c_str(),
|
|
|
|
Line[0], *LineNum );
|
2007-08-24 15:10:46 +00:00
|
|
|
DisplayError( frame, MsgLine );
|
2008-11-24 06:53:43 +00:00
|
|
|
SAFE_DELETE( New );
|
2007-08-24 15:10:46 +00:00
|
|
|
|
|
|
|
/* FLush till end of draw: */
|
2009-04-05 20:49:15 +00:00
|
|
|
do
|
|
|
|
{
|
|
|
|
if( GetLine( f, Line, LineNum, 1024 ) == NULL )
|
2007-08-24 15:10:46 +00:00
|
|
|
{
|
|
|
|
DisplayError( frame, wxT( "File ended prematurely" ) );
|
|
|
|
return Head;
|
|
|
|
}
|
2009-04-05 20:49:15 +00:00
|
|
|
} while( strncmp( Line, "ENDDRAW", 7 ) != 0 );
|
2007-08-24 15:10:46 +00:00
|
|
|
|
|
|
|
return Head;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( Head == NULL )
|
|
|
|
Head = Tail = New;
|
|
|
|
else
|
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
Tail->SetNext( New );
|
|
|
|
Tail = New;
|
2007-08-24 15:10:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return Head;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************
|
2008-12-04 21:43:20 +00:00
|
|
|
* Routine to find the library given its name. *
|
2007-06-05 12:10:51 +00:00
|
|
|
*****************************************************************************/
|
2008-12-04 21:43:20 +00:00
|
|
|
LibraryStruct* FindLibrary (const wxString& Name)
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-24 15:10:46 +00:00
|
|
|
LibraryStruct* Lib = g_LibraryList;
|
|
|
|
|
|
|
|
while( Lib )
|
|
|
|
{
|
|
|
|
if( Lib->m_Name == Name )
|
|
|
|
return Lib;
|
|
|
|
Lib = Lib->m_Pnext;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/*****************************************************************************
|
2008-12-04 21:43:20 +00:00
|
|
|
* Routine to find the number of libraries currently loaded. *
|
2007-06-05 12:10:51 +00:00
|
|
|
*****************************************************************************/
|
2009-04-05 20:49:15 +00:00
|
|
|
int NumOfLibraries()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-24 15:10:46 +00:00
|
|
|
int ii;
|
|
|
|
LibraryStruct* Lib = g_LibraryList;
|
|
|
|
|
|
|
|
for( ii = 0; Lib != NULL; Lib = Lib->m_Pnext )
|
|
|
|
ii++;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-24 15:10:46 +00:00
|
|
|
return ii;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/********************************************************************/
|
|
|
|
/* Read the alias names (in buffer line) and add them in alias list
|
2007-08-24 15:10:46 +00:00
|
|
|
* names are separated by spaces
|
|
|
|
*/
|
2009-04-05 20:49:15 +00:00
|
|
|
/********************************************************************/
|
|
|
|
static bool AddAliasNames (EDA_LibComponentStruct* LibEntry, char* line )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-24 15:10:46 +00:00
|
|
|
char* text;
|
|
|
|
wxString name;
|
|
|
|
|
|
|
|
text = strtok( line, " \t\r\n" );
|
|
|
|
|
|
|
|
while( text )
|
|
|
|
{
|
|
|
|
name = CONV_FROM_UTF8( text );
|
|
|
|
LibEntry->m_AliasList.Add( name );
|
|
|
|
text = strtok( NULL, " \t\r\n" );
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/********************************************************************/
|
|
|
|
/* create in library (in list PQ) aliases of the "root" component LibEntry*/
|
2009-04-05 20:49:15 +00:00
|
|
|
/********************************************************************/
|
|
|
|
static void InsertAlias (PriorQue** PQ, EDA_LibComponentStruct* LibEntry,
|
|
|
|
int* NumOfParts)
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-24 15:10:46 +00:00
|
|
|
EDA_LibCmpAliasStruct* AliasEntry;
|
|
|
|
unsigned ii;
|
|
|
|
|
|
|
|
if( LibEntry->m_AliasList.GetCount() == 0 )
|
2007-11-02 17:17:44 +00:00
|
|
|
return; /* No alias for this component */
|
2007-08-24 15:10:46 +00:00
|
|
|
|
|
|
|
for( ii = 0; ii < LibEntry->m_AliasList.GetCount(); ii++ )
|
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
AliasEntry =
|
|
|
|
new EDA_LibCmpAliasStruct( LibEntry->m_AliasList[ii],
|
|
|
|
LibEntry->m_Name.m_Text.GetData() );
|
2007-08-24 15:10:46 +00:00
|
|
|
|
|
|
|
++ * NumOfParts;
|
|
|
|
PQInsert( PQ, AliasEntry );
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-24 15:10:46 +00:00
|
|
|
|
|
|
|
/*******************************************************/
|
|
|
|
/* Routines de lecture des Documentation de composants */
|
|
|
|
/*******************************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
/* Routine to load a library from given open file.*/
|
2009-04-05 20:49:15 +00:00
|
|
|
int LoadDocLib( WinEDA_DrawFrame* frame, const wxString& FullDocLibName,
|
|
|
|
const wxString& Libname )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-24 15:10:46 +00:00
|
|
|
int LineNum = 0;
|
|
|
|
char Line[1024], * Name, * Text;
|
|
|
|
EDA_LibComponentStruct* Entry;
|
|
|
|
FILE* f;
|
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
f = wxFopen( FullDocLibName, wxT( "rt" ) );
|
|
|
|
if( f == NULL )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if( GetLine( f, Line, &LineNum, sizeof(Line) ) == NULL )
|
2007-11-02 17:17:44 +00:00
|
|
|
{
|
2007-09-21 13:23:51 +00:00
|
|
|
/* pas de lignes utiles */
|
2007-08-24 15:10:46 +00:00
|
|
|
fclose( f );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( strnicmp( Line, DOCFILE_IDENT, 10 ) != 0 )
|
|
|
|
{
|
|
|
|
DisplayError( frame, wxT( "File is NOT EESCHEMA doclib!" ) );
|
|
|
|
fclose( f );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
while( GetLine( f, Line, &LineNum, sizeof(Line) ) )
|
|
|
|
{
|
|
|
|
if( strncmp( Line, "$CMP", 4 ) != 0 )
|
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
msg.Printf( wxT( "$CMP command expected in line %d, aborted." ),
|
|
|
|
LineNum );
|
2007-08-24 15:10:46 +00:00
|
|
|
DisplayError( frame, msg );
|
|
|
|
fclose( f );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Read one $CMP/$ENDCMP part entry from library: */
|
|
|
|
Name = strtok( Line + 5, "\n\r" );
|
2009-04-05 20:49:15 +00:00
|
|
|
wxString cmpname;
|
|
|
|
cmpname = CONV_FROM_UTF8( Name );
|
2007-08-24 15:10:46 +00:00
|
|
|
Entry = FindLibPart( cmpname.GetData(), Libname, FIND_ALIAS );
|
|
|
|
while( GetLine( f, Line, &LineNum, sizeof(Line) ) )
|
|
|
|
{
|
|
|
|
if( strncmp( Line, "$ENDCMP", 7 ) == 0 )
|
|
|
|
break;
|
|
|
|
Text = strtok( Line + 2, "\n\r" );
|
|
|
|
|
|
|
|
switch( Line[0] )
|
|
|
|
{
|
|
|
|
case 'D':
|
|
|
|
if( Entry )
|
|
|
|
Entry->m_Doc = CONV_FROM_UTF8( Text );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'K':
|
|
|
|
if( Entry )
|
|
|
|
Entry->m_KeyWord = CONV_FROM_UTF8( Text );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'F':
|
|
|
|
if( Entry )
|
|
|
|
Entry->m_DocFile = CONV_FROM_UTF8( Text );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose( f );
|
|
|
|
return 1;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
/* read the FootprintFilter List stating with:
|
2007-08-24 15:10:46 +00:00
|
|
|
* FPLIST
|
|
|
|
* and ending with:
|
|
|
|
* ENDFPLIST
|
|
|
|
*/
|
2009-04-05 20:49:15 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
int AddFootprintFilterList(EDA_LibComponentStruct* LibEntryLibEntry,
|
|
|
|
FILE* f, char* Line, int* LineNum)
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-24 15:10:46 +00:00
|
|
|
for( ; ; )
|
|
|
|
{
|
|
|
|
if( GetLine( f, Line, LineNum, 1024 ) == NULL )
|
|
|
|
{
|
|
|
|
DisplayError( NULL, wxT( "File ended prematurely" ) );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( stricmp( Line, "$ENDFPLIST" ) == 0 )
|
|
|
|
{
|
|
|
|
break; /*normal exit on end of list */
|
|
|
|
}
|
|
|
|
|
|
|
|
LibEntryLibEntry->m_FootprintList.Add( CONV_FROM_UTF8( Line + 1 ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|