mac support fixes

This commit is contained in:
dickelbeck 2007-08-18 11:47:56 +00:00
parent 4987c15ed7
commit 4ca51f7554
1 changed files with 261 additions and 250 deletions

View File

@ -9,7 +9,7 @@
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#ifdef __UNIX__ #if defined (__UNIX__) || defined (__APPLE__)
#define stricmp strcasecmp #define stricmp strcasecmp
#define strnicmp strncasecmp #define strnicmp strncasecmp
#endif #endif
@ -17,91 +17,91 @@
/* Pads-pcb sample: /* Pads-pcb sample:
*PADS-PCB* *PADS-PCB*
*PART* *PART*
C1 CHIP_D * C1 CHIP_D
C2 C1206 * C2 C1206
C3 CHIP_B * C3 CHIP_B
C4 CHIP_B * C4 CHIP_B
D1 CHIP_B * D1 CHIP_B
JP1 unknown * JP1 unknown
*
*NET* *NET*
*SIGNAL* N03791 *SIGNAL* N03791
C3.1 R1.1 JP2.7 U1.3 * C3.1 R1.1 JP2.7 U1.3
*SIGNAL* VCC *SIGNAL* VCC
U2.14 Y1.8 JP5.2 U3.2 C1.1 U1.20 JP1.8 JP1.3 * U2.14 Y1.8 JP5.2 U3.2 C1.1 U1.20 JP1.8 JP1.3
C5.2 C6.1 C7.2 U1.7 Y1.7 * C5.2 C6.1 C7.2 U1.7 Y1.7
*SIGNAL* N01384 *SIGNAL* N01384
JP5.1 U1.1 * JP5.1 U1.1
*SIGNAL* N02594 *SIGNAL* N02594
*END* *END*
*/ */
/* Generic netlist sample: /* Generic netlist sample:
$BeginNetlist * $BeginNetlist
$BeginComponentList * $BeginComponentList
*
$BeginComponent * $BeginComponent
TimeStamp=32568D1E * TimeStamp=32568D1E
Footprint= * Footprint=
Reference=JP1 * Reference=JP1
Value=CONN_8X2 * Value=CONN_8X2
Libname=CONN_8X2 * Libname=CONN_8X2
$BeginPinList * $BeginPinList
1=GND * 1=GND
2=REF10_1 * 2=REF10_1
3=GND * 3=GND
4=REF11_1 * 4=REF11_1
5=GND * 5=GND
6=REF7_1 * 6=REF7_1
7=GND * 7=GND
8=REF9_1 * 8=REF9_1
9=GND * 9=GND
10=REF6_1 * 10=REF6_1
11=GND * 11=GND
12=REF8_1 * 12=REF8_1
13=GND * 13=GND
14=REF4_1 * 14=REF4_1
15=GND * 15=GND
16=REF5_1 * 16=REF5_1
$EndPinList * $EndPinList
$EndComponent * $EndComponent
*
$BeginComponent * $BeginComponent
TimeStamp=325679C1 * TimeStamp=325679C1
Footprint= * Footprint=
Reference=RR1 * Reference=RR1
Value=9x1K * Value=9x1K
Libref=RR9 * Libref=RR9
$BeginPinList * $BeginPinList
1=VCC * 1=VCC
2=REF5_1 * 2=REF5_1
3=REF4_1 * 3=REF4_1
4=REF8_1 * 4=REF8_1
5=REF6_1 * 5=REF6_1
6=REF9_1 * 6=REF9_1
7=REF7_1 * 7=REF7_1
8=REF11_1 * 8=REF11_1
9=REF10_1 * 9=REF10_1
10=? * 10=?
$EndPinList * $EndPinList
$EndComponent * $EndComponent
$EndComponentList * $EndComponentList
*
$BeginNets * $BeginNets
Net 0 "" * Net 0 ""
Net 1 "GND" * Net 1 "GND"
BUS1 31 * BUS1 31
U3 19 * U3 19
U3 10 * U3 10
U3 1 * U3 1
Net 172 "" * Net 172 ""
BUS1 32 * BUS1 32
Net 173 "" * Net 173 ""
BUS1 30 * BUS1 30
$EndNets * $EndNets
*
$EndNetlist * $EndNetlist
*/ */
char* GetLine( FILE* File, char* Line, int* LineNum, int SizeLine ); char* GetLine( FILE* File, char* Line, int* LineNum, int SizeLine );
@ -109,7 +109,6 @@ int ReadAndWriteComponentDataSection(FILE * InFile, FILE * OutFile, int *LineNum
int ReadAndWriteNetsDataSection( FILE* InFile, FILE* OutFile, int* LineNumber ); int ReadAndWriteNetsDataSection( FILE* InFile, FILE* OutFile, int* LineNumber );
class ComponentDataClass class ComponentDataClass
{ {
public: public:
@ -124,6 +123,8 @@ public:
{ {
InitData(); InitData();
} }
void InitData( void ) void InitData( void )
{ {
m_TimeStamp = 0; m_TimeStamp = 0;
@ -197,14 +198,16 @@ char Line[1024];
/****************************************************************/ /****************************************************************/
int ReadAndWriteComponentDataSection( FILE* InFile, FILE* OutFile, int* LineNumber ) int ReadAndWriteComponentDataSection( FILE* InFile, FILE* OutFile, int* LineNumber )
/****************************************************************/ /****************************************************************/
/* Read the Components Section from the Generic Netlist and create Components section in Pads-Pcb format /* Read the Components Section from the Generic Netlist and create Components section in Pads-Pcb format
For the component section only reference and footprint are used. * For the component section only reference and footprint are used.
Create lines like: * Create lines like:
C1 CHIP_D * C1 CHIP_D
C2 unknown * C2 unknown
*/ */
{ {
char Line[1024]; char Line[1024];
class ComponentDataClass ComponentData; class ComponentDataClass ComponentData;
char* ident, * data; char* ident, * data;
@ -213,7 +216,9 @@ char * ident, *data;
if( stricmp( Line, "$BeginPinList" ) == 0 ) if( stricmp( Line, "$BeginPinList" ) == 0 )
{ {
while( GetLine( InFile, Line, LineNumber, sizeof(Line) ) ) while( GetLine( InFile, Line, LineNumber, sizeof(Line) ) )
if ( stricmp(Line, "$EndPinList") == 0 ) break; if( stricmp( Line, "$EndPinList" ) == 0 )
break;
continue; continue;
} }
@ -228,7 +233,8 @@ char * ident, *data;
} }
ident = strtok( Line, "=\n\r" ); ident = strtok( Line, "=\n\r" );
data = strtok( NULL, "=\n\r" ); data = strtok( NULL, "=\n\r" );
if ( data == NULL ) continue; if( data == NULL )
continue;
if( stricmp( Line, "TimeStamp" ) == 0 ) if( stricmp( Line, "TimeStamp" ) == 0 )
{ {
ComponentData.m_TimeStamp = atol( data ); ComponentData.m_TimeStamp = atol( data );
@ -259,13 +265,15 @@ char * ident, *data;
return 1; return 1;
} }
/****************************************************************/ /****************************************************************/
int ReadAndWriteNetsDataSection( FILE* InFile, FILE* OutFile, int* LineNumber ) int ReadAndWriteNetsDataSection( FILE* InFile, FILE* OutFile, int* LineNumber )
/****************************************************************/ /****************************************************************/
/* Read the Nets Section from the Generic Netlist and create Nets section in Pads-Pcb format /* Read the Nets Section from the Generic Netlist and create Nets section in Pads-Pcb format
create info type: * create info type:
*SIGNAL* N03791 *SIGNAL* N03791
C3.1 R1.1 JP2.7 U1.3 * C3.1 R1.1 JP2.7 U1.3
*/ */
{ {
char Line[1024]; char Line[1024];
@ -273,7 +281,8 @@ char * ident, *netnum, *netname, * pin;
while( GetLine( InFile, Line, LineNumber, sizeof(Line) ) ) while( GetLine( InFile, Line, LineNumber, sizeof(Line) ) )
{ {
if ( stricmp(Line, "$EndNets") == 0 ) return 0; if( stricmp( Line, "$EndNets" ) == 0 )
return 0;
ident = strtok( Line, " \n\r" ); ident = strtok( Line, " \n\r" );
if( stricmp( ident, "Net" ) == 0 ) if( stricmp( ident, "Net" ) == 0 )
{ {
@ -288,7 +297,8 @@ char * ident, *netnum, *netname, * pin;
fprintf( OutFile, "*SIGNAL* %s\n", netname ); fprintf( OutFile, "*SIGNAL* %s\n", netname );
} }
else else
{ // Create the line like: C3.1 R1.1 JP2.7 U1.3 {
// Create the line like: C3.1 R1.1 JP2.7 U1.3
pin = strtok( NULL, " \n\r" ); pin = strtok( NULL, " \n\r" );
fprintf( OutFile, " %s.%s\n", ident, pin ); fprintf( OutFile, " %s.%s\n", ident, pin );
} }
@ -301,19 +311,20 @@ char * ident, *netnum, *netname, * pin;
/*****************************************************************/ /*****************************************************************/
char* GetLine( FILE* File, char* Line, int* LineNum, int SizeLine ) char* GetLine( FILE* File, char* Line, int* LineNum, int SizeLine )
/*****************************************************************/ /*****************************************************************/
/* Return a non empty line /* Return a non empty line
increment *LineNum for each read line * increment *LineNum for each read line
Comment lines (starting by '#') are skipped * Comment lines (starting by '#') are skipped
*/ */
{ {
do { do {
if (fgets(Line, SizeLine, File) == NULL) return NULL; if( fgets( Line, SizeLine, File ) == NULL )
if( LineNum ) *LineNum += 1; return NULL;
} while (Line[0] == '#' || Line[0] == '\n' || Line[0] == '\r' || if( LineNum )
Line[0] == 0); *LineNum += 1;
} while( Line[0] == '#' || Line[0] == '\n' || Line[0] == '\r'
|| Line[0] == 0 );
strtok( Line, "\n\r" ); strtok( Line, "\n\r" );
return Line; return Line;
} }