wmail: removed hard-coded string lengths.
This commit is contained in:
parent
d969ee2ca6
commit
8f7f9881a0
|
@ -97,4 +97,6 @@ void TRACE( const char *fmt, ... );
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define PREFIX_MATCHES(S, P, CS) ( CS ? strncmp : strncasecmp ) ( (S), (P), sizeof (P) - 1) == 0
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -270,35 +270,35 @@ void ReadConfigFile( bool resetConfigStrings )
|
||||||
if( !Tokenize( buf, &id, &value ))
|
if( !Tokenize( buf, &id, &value ))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if( !strncasecmp( id, "Window.Display", 14 ))
|
if( PREFIX_MATCHES( id, "Window.Display", false ))
|
||||||
{
|
{
|
||||||
if( !( config.givenOptions & CL_DISPLAY ))
|
if( !( config.givenOptions & CL_DISPLAY ))
|
||||||
ReadString( value, line, &config.display );
|
ReadString( value, line, &config.display );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !strncasecmp( id, "Window.NonShaped", 16 ))
|
if( PREFIX_MATCHES( id, "Window.NonShaped", false ))
|
||||||
{
|
{
|
||||||
if( !( config.givenOptions & CL_NOSHAPE ))
|
if( !( config.givenOptions & CL_NOSHAPE ))
|
||||||
ReadBool( value, line, &config.noshape );
|
ReadBool( value, line, &config.noshape );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !strncasecmp( id, "Window.Button.Command", 21 ))
|
if( PREFIX_MATCHES( id, "Window.Button.Command", false ))
|
||||||
{
|
{
|
||||||
if( !( config.givenOptions & CL_RUNCMD ))
|
if( !( config.givenOptions & CL_RUNCMD ))
|
||||||
ReadString( value, line, &config.runCmd );
|
ReadString( value, line, &config.runCmd );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !strncasecmp( id, "Mail.MailBox", 12 ))
|
if( PREFIX_MATCHES( id, "Mail.MailBox", false ))
|
||||||
{
|
{
|
||||||
if( !( config.givenOptions & CL_MAILBOX ))
|
if( !( config.givenOptions & CL_MAILBOX ))
|
||||||
ReadString( value, line, &config.mailBox );
|
ReadString( value, line, &config.mailBox );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !strncasecmp( id, "Mail.ChecksumFile", 17 ))
|
if( PREFIX_MATCHES( id, "Mail.ChecksumFile", false ))
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* No corresponding command-line option.
|
* No corresponding command-line option.
|
||||||
|
@ -307,77 +307,77 @@ void ReadConfigFile( bool resetConfigStrings )
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !strncasecmp( id, "Mail.CheckIntervall", 19 ))
|
if( PREFIX_MATCHES( id, "Mail.CheckIntervall", false ))
|
||||||
{
|
{
|
||||||
if( !( config.givenOptions & CL_CHECKINTERVAL ))
|
if( !( config.givenOptions & CL_CHECKINTERVAL ))
|
||||||
ReadInt( value, line, &config.checkInterval );
|
ReadInt( value, line, &config.checkInterval );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !strncasecmp( id, "Mail.ShowOnlyNew", 16 ))
|
if( PREFIX_MATCHES( id, "Mail.ShowOnlyNew", false ))
|
||||||
{
|
{
|
||||||
if( !( config.givenOptions & CL_NEWMAILONLY ))
|
if( !( config.givenOptions & CL_NEWMAILONLY ))
|
||||||
ReadBool( value, line, &config.newMailsOnly );
|
ReadBool( value, line, &config.newMailsOnly );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !strncasecmp( id, "Ticker.Mode", 11 ))
|
if( PREFIX_MATCHES( id, "Ticker.Mode", false ))
|
||||||
{
|
{
|
||||||
if( !( config.givenOptions & CL_TICKERMODE ))
|
if( !( config.givenOptions & CL_TICKERMODE ))
|
||||||
ReadEnum( value, line, (int *)&config.tickerMode, tickerEnum );
|
ReadEnum( value, line, (int *)&config.tickerMode, tickerEnum );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !strncasecmp( id, "Ticker.Frames", 13 ))
|
if( PREFIX_MATCHES( id, "Ticker.Frames", false ))
|
||||||
{
|
{
|
||||||
if( !( config.givenOptions & CL_FPS ))
|
if( !( config.givenOptions & CL_FPS ))
|
||||||
ReadInt( value, line, &config.fps );
|
ReadInt( value, line, &config.fps );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !strncasecmp( id, "Colors.Symbols", 14 ))
|
if( PREFIX_MATCHES( id, "Colors.Symbols", false ))
|
||||||
{
|
{
|
||||||
if( !( config.givenOptions & CL_SYMBOLCOLOR ))
|
if( !( config.givenOptions & CL_SYMBOLCOLOR ))
|
||||||
ReadString( value, line, &config.symbolColor );
|
ReadString( value, line, &config.symbolColor );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !strncasecmp( id, "Colors.Font", 11 ))
|
if( PREFIX_MATCHES( id, "Colors.Font", false ))
|
||||||
{
|
{
|
||||||
if( !( config.givenOptions & CL_FONTCOLOR ))
|
if( !( config.givenOptions & CL_FONTCOLOR ))
|
||||||
ReadString( value, line, &config.fontColor );
|
ReadString( value, line, &config.fontColor );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !strncasecmp( id, "Colors.Backlight", 16 ))
|
if( PREFIX_MATCHES( id, "Colors.Backlight", false ))
|
||||||
{
|
{
|
||||||
if( !( config.givenOptions & CL_BACKCOLOR ))
|
if( !( config.givenOptions & CL_BACKCOLOR ))
|
||||||
ReadString( value, line, &config.backColor );
|
ReadString( value, line, &config.backColor );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !strncasecmp( id, "Colors.OffLight", 15 ))
|
if( PREFIX_MATCHES( id, "Colors.OffLight", false ))
|
||||||
{
|
{
|
||||||
if( !( config.givenOptions & CL_OFFLIGHTCOLOR ))
|
if( !( config.givenOptions & CL_OFFLIGHTCOLOR ))
|
||||||
ReadString( value, line, &config.offlightColor );
|
ReadString( value, line, &config.offlightColor );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !strncasecmp( id, "Colors.NonShapedFrame", 21 ))
|
if( PREFIX_MATCHES( id, "Colors.NonShapedFrame", false ))
|
||||||
{
|
{
|
||||||
if( !( config.givenOptions & CL_NOSHAPE ))
|
if( !( config.givenOptions & CL_NOSHAPE ))
|
||||||
ReadString( value, line, &config.backgroundColor );
|
ReadString( value, line, &config.backgroundColor );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !strncasecmp( id, "Ticker.X11Font", 14 ))
|
if( PREFIX_MATCHES( id, "Ticker.X11Font", false ))
|
||||||
{
|
{
|
||||||
if( !( config.givenOptions & CL_USEX11FONT ))
|
if( !( config.givenOptions & CL_USEX11FONT ))
|
||||||
ReadString( value, line, &config.useX11Font );
|
ReadString( value, line, &config.useX11Font );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !strncasecmp( id, "Mail.SkipSender", 15 ))
|
if( PREFIX_MATCHES( id, "Mail.SkipSender", false ))
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* No corresponding command-line option.
|
* No corresponding command-line option.
|
||||||
|
@ -388,21 +388,21 @@ void ReadConfigFile( bool resetConfigStrings )
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !strncasecmp( id, "Mail.OnNew.Command", 18 ))
|
if( PREFIX_MATCHES( id, "Mail.OnNew.Command", false ))
|
||||||
{
|
{
|
||||||
if( !( config.givenOptions & CL_CMDONMAIL ))
|
if( !( config.givenOptions & CL_CMDONMAIL ))
|
||||||
ReadString( value, line, &config.cmdOnMail );
|
ReadString( value, line, &config.cmdOnMail );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !strncasecmp( id, "Mail.UseStatusField", 19 ))
|
if( PREFIX_MATCHES( id, "Mail.UseStatusField", false ))
|
||||||
{
|
{
|
||||||
if( !( config.givenOptions & CL_CONSIDERSTATUSFIELD ))
|
if( !( config.givenOptions & CL_CONSIDERSTATUSFIELD ))
|
||||||
ReadBool( value, line, &config.considerStatusField );
|
ReadBool( value, line, &config.considerStatusField );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !strncasecmp( id, "Mail.ReadStatus", 15 ))
|
if( PREFIX_MATCHES( id, "Mail.ReadStatus", false ))
|
||||||
{
|
{
|
||||||
if( !( config.givenOptions & CL_READSTATUS ))
|
if( !( config.givenOptions & CL_READSTATUS ))
|
||||||
ReadString( value, line, &config.readStatus );
|
ReadString( value, line, &config.readStatus );
|
||||||
|
|
|
@ -949,7 +949,7 @@ static void ParseMBoxFile( struct stat *fileStat )
|
||||||
|
|
||||||
while( fgets( buf, sizeof buf, f ) != NULL )
|
while( fgets( buf, sizeof buf, f ) != NULL )
|
||||||
{
|
{
|
||||||
if( strncmp( buf, "From ", 5 ) == 0 ) {
|
if( PREFIX_MATCHES( buf, "From ", true )) {
|
||||||
fromFound = 1;
|
fromFound = 1;
|
||||||
checksum = 0;
|
checksum = 0;
|
||||||
continue;
|
continue;
|
||||||
|
@ -958,7 +958,7 @@ static void ParseMBoxFile( struct stat *fileStat )
|
||||||
if( fromFound )
|
if( fromFound )
|
||||||
UpdateChecksum( &checksum, buf );
|
UpdateChecksum( &checksum, buf );
|
||||||
|
|
||||||
if( fromFound && strncasecmp( buf, "from: ", 6 ) == 0 )
|
if( fromFound && PREFIX_MATCHES( buf, "from: ", false ))
|
||||||
{
|
{
|
||||||
if( SkipSender( buf+6 ))
|
if( SkipSender( buf+6 ))
|
||||||
goto NEXTMAIL;
|
goto NEXTMAIL;
|
||||||
|
@ -974,7 +974,8 @@ static void ParseMBoxFile( struct stat *fileStat )
|
||||||
++numMails;
|
++numMails;
|
||||||
fromFound = 0;
|
fromFound = 0;
|
||||||
checksum = 0;
|
checksum = 0;
|
||||||
} else if( config.considerStatusField && strncasecmp( buf, "status: ", 8 ) == 0 &&
|
} else if( config.considerStatusField &&
|
||||||
|
PREFIX_MATCHES( buf, "status: ", false ) &&
|
||||||
strstr( buf+8, config.readStatus ) == NULL )
|
strstr( buf+8, config.readStatus ) == NULL )
|
||||||
{
|
{
|
||||||
RemoveLastName();
|
RemoveLastName();
|
||||||
|
@ -1009,7 +1010,7 @@ static void ParseMaildirFile( const char *fileName, unsigned long checksum,
|
||||||
|
|
||||||
while( fgets( buf, sizeof buf, f ) != NULL )
|
while( fgets( buf, sizeof buf, f ) != NULL )
|
||||||
{
|
{
|
||||||
if( strncasecmp( buf, "from: ", 6 ) == 0 )
|
if( PREFIX_MATCHES( buf, "from: ", false ))
|
||||||
{
|
{
|
||||||
if( SkipSender( buf+6 ))
|
if( SkipSender( buf+6 ))
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue