wmail: add static to declarations of lots of variables and functions.

This commit is contained in:
Jeremy Sowden 2019-05-27 22:52:15 +01:00 committed by Carlos R. Mafra
parent 86a8f6f0a1
commit 254328761e
2 changed files with 106 additions and 102 deletions

View file

@ -75,12 +75,13 @@ typedef struct { char *id; int value; } enumList_t;
// local prototypes // local prototypes
bool ReadString( const char *from, unsigned int line, char **to ); static bool ReadString( const char *from, unsigned int line, char **to );
bool ReadEnum( const char *from, unsigned int line, int *to, const enumList_t *enumList ); static bool ReadEnum( const char *from, unsigned int line, int *to,
bool ReadBool( const char *from, unsigned int line, bool *to ); const enumList_t *enumList );
bool ReadInt( const char *from, unsigned int line, int *to ); static bool ReadBool( const char *from, unsigned int line, bool *to );
bool IsWhiteSpace( const char *chr ); static bool ReadInt( const char *from, unsigned int line, int *to );
const char *SkipWhiteSpaces( const char *str ); static bool IsWhiteSpace( const char *chr );
static const char *SkipWhiteSpaces( const char *str );
// current configuration // current configuration
config_t config = { config_t config = {
@ -107,7 +108,7 @@ config_t config = {
}; };
// enumeration names for ticker mode // enumeration names for ticker mode
enumList_t tickerEnum[] = static enumList_t tickerEnum[] =
{ {
{ "address", TICKER_ADDRESS }, { "address", TICKER_ADDRESS },
{ "familyname", TICKER_FAMILYNAME }, { "familyname", TICKER_FAMILYNAME },
@ -115,7 +116,7 @@ enumList_t tickerEnum[] =
{ NULL, 0 } { NULL, 0 }
}; };
bool Tokenize( const char *line, const char **id, const char **value ) static bool Tokenize( const char *line, const char **id, const char **value )
{ {
int len; int len;
const char *token1, *token2; const char *token1, *token2;
@ -143,7 +144,7 @@ bool Tokenize( const char *line, const char **id, const char **value )
return false; return false;
} }
void AddSenderToSkipList( char *sender ) static void AddSenderToSkipList( char *sender )
{ {
int numNames, i; int numNames, i;
char **skipName, **newList; char **skipName, **newList;
@ -222,7 +223,7 @@ void ResetConfigStrings( void )
} }
} }
void PostProcessConfiguration( void ) static void PostProcessConfiguration( void )
{ {
if( config.display == NULL ) if( config.display == NULL )
config.display = strdup( WMAIL_DISPLAY ); config.display = strdup( WMAIL_DISPLAY );
@ -351,7 +352,7 @@ void ReadConfigFile( bool resetConfigStrings )
PostProcessConfiguration(); PostProcessConfiguration();
} }
bool ReadString( const char *from, unsigned int line, char **to ) static bool ReadString( const char *from, unsigned int line, char **to )
{ {
if( *from++ == '"' ) { if( *from++ == '"' ) {
const char *trailingQuote; const char *trailingQuote;
@ -416,7 +417,7 @@ bool ReadString( const char *from, unsigned int line, char **to )
return false; return false;
} }
bool ReadBool( const char *from, unsigned int line, bool *to ) static bool ReadBool( const char *from, unsigned int line, bool *to )
{ {
if( !strcasecmp( from, "on" ) || !strcasecmp( from, "yes" ) || !strcasecmp( from, "true" )) if( !strcasecmp( from, "on" ) || !strcasecmp( from, "yes" ) || !strcasecmp( from, "true" ))
*to = true; *to = true;
@ -432,7 +433,7 @@ bool ReadBool( const char *from, unsigned int line, bool *to )
return true; return true;
} }
bool ReadInt( const char *from, unsigned int line, int *to ) static bool ReadInt( const char *from, unsigned int line, int *to )
{ {
int value = 0; int value = 0;
@ -475,7 +476,8 @@ bool ReadInt( const char *from, unsigned int line, int *to )
return true; return true;
} }
bool ReadEnum( const char *from, unsigned int line, int *to, const enumList_t *enumList ) static bool ReadEnum( const char *from, unsigned int line, int *to,
const enumList_t *enumList )
{ {
int index; int index;
@ -493,12 +495,12 @@ bool ReadEnum( const char *from, unsigned int line, int *to, const enumList_t *e
return false; return false;
} }
bool IsWhiteSpace( const char *chr ) static bool IsWhiteSpace( const char *chr )
{ {
return ( chr != NULL && ( *chr == ' ' || *chr == '\t' || *chr == '\n' )) ? true : false; return ( chr != NULL && ( *chr == ' ' || *chr == '\t' || *chr == '\n' )) ? true : false;
} }
const char *SkipWhiteSpaces( const char *str ) static const char *SkipWhiteSpaces( const char *str )
{ {
const char *c; const char *c;

View file

@ -103,27 +103,27 @@ typedef enum {
static unsigned long lastTimeOut; static unsigned long lastTimeOut;
static sig_atomic_t caughtSig; static sig_atomic_t caughtSig;
mail_state_t state = STATE_NOMAIL; static mail_state_t state;
int numMails = 0; static int numMails;
bool namesChanged = false; static bool namesChanged;
bool buttonPressed = false; static bool buttonPressed;
bool readConfigFile = false; static bool readConfigFile;
bool isMaildir = false; static bool isMaildir;
bool forceRead = false; static bool forceRead;
bool forceRedraw = true; static bool forceRedraw = true;
time_t lastModifySeconds = 0; static time_t lastModifySeconds;
time_t lastAccessSeconds = 0; static time_t lastAccessSeconds;
Pixmap mainPixmap; static Pixmap mainPixmap;
Pixmap mainPixmap_mask; static Pixmap mainPixmap_mask;
Pixmap symbolsPixmap; static Pixmap symbolsPixmap;
Pixmap charsPixmap; static Pixmap charsPixmap;
Pixmap numbersPixmap; static Pixmap numbersPixmap;
Pixmap buttonPixmap; static Pixmap buttonPixmap;
Pixmap outPixmap; static Pixmap outPixmap;
GC tickerGC; static GC tickerGC;
XFontStruct *tickerFS = NULL; static XFontStruct *tickerFS;
name_t *names = NULL; static name_t *names;
name_t *curTickerName = NULL; static name_t *curTickerName;
static DAProgramOption options[] = { static DAProgramOption options[] = {
{"-display", NULL, "display to use", DOString, False, {&config.display}}, {"-display", NULL, "display to use", DOString, False, {&config.display}},
@ -162,38 +162,39 @@ static DAProgramOption options[] = {
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// prototypes // prototypes
void PreparePixmaps( bool freeThemFirst ); static void PreparePixmaps( bool freeThemFirst );
static void ExitHandler( int sig ); static void ExitHandler( int sig );
void TimedOut( void ); static void TimedOut( void );
void CheckTimeOut( bool force ); static void CheckTimeOut( bool force );
void CheckMBox( void ); static void CheckMBox( void );
void CheckMaildir( void ); static void CheckMaildir( void );
int TraverseDirectory( const char *name, bool isNewMail ); static int TraverseDirectory( const char *name, bool isNewMail );
name_t *GetMail( unsigned long checksum ); static name_t *GetMail( unsigned long checksum );
void UpdatePixmap( bool flashMailSymbol ); static void UpdatePixmap( bool flashMailSymbol );
void ParseMBoxFile( struct stat *fileStat ); static void ParseMBoxFile( struct stat *fileStat );
void ParseMaildirFile( const char *fileName, unsigned long checksum, static void ParseMaildirFile( const char *fileName, unsigned long checksum,
struct stat *fileStat, bool isNewMail ); struct stat *fileStat, bool isNewMail );
char *ParseFromField( char *buf ); static char *ParseFromField( char *buf );
bool SkipSender( char *address ); static bool SkipSender( char *address );
void InsertName( char *name, unsigned long checksum, flag_t flag ); static void InsertName( char *name, unsigned long checksum, flag_t flag );
void RemoveLastName( void ); static void RemoveLastName( void );
void ClearAllNames( void ); static void ClearAllNames( void );
void DrawTickerX11Font( void ); static void DrawTickerX11Font( void );
void DrawTickerBuildinFont( void ); static void DrawTickerBuildinFont( void );
void ButtonPressed( int button, int state, int x, int y ); static void ButtonPressed( int button, int state, int x, int y );
void ButtonReleased( int button, int state, int x, int y ); static void ButtonReleased( int button, int state, int x, int y );
char *XpmColorLine( const char *colorName, char *colorLine, bool disposeLine ); static char *XpmColorLine( const char *colorName, char *colorLine,
void ReadChecksumFile( void ); bool disposeLine );
void WriteChecksumFile( bool writeAll ); static void ReadChecksumFile( void );
void UpdateChecksum( unsigned long *checksum, const char *buf ); static void WriteChecksumFile( bool writeAll );
void RemoveChecksumFile( void ); static void UpdateChecksum( unsigned long *checksum, const char *buf );
void SetMailFlags( flag_t flag ); static void RemoveChecksumFile( void );
void MarkName( unsigned long checksum ); static void SetMailFlags( flag_t flag );
void DetermineState( void ); static void MarkName( unsigned long checksum );
void UpdateConfiguration( void ); static void DetermineState( void );
void CleanupNames( void ); static void UpdateConfiguration( void );
bool HasTickerWork( void ); static void CleanupNames( void );
static bool HasTickerWork( void );
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -305,7 +306,7 @@ int main( int argc, char **argv )
} }
DASetCallbacks( &callbacks ); DASetCallbacks( &callbacks );
DASetTimeout (1000 / config.fps); DASetTimeout( 1000 / config.fps );
XStringListToTextProperty( &name, 1, &windowName ); XStringListToTextProperty( &name, 1, &windowName );
XSetWMName( DADisplay, DAWindow, &windowName ); XSetWMName( DADisplay, DAWindow, &windowName );
@ -318,7 +319,7 @@ int main( int argc, char **argv )
return 0; return 0;
} }
void PreparePixmaps( bool freeMem ) static void PreparePixmaps( bool freeMem )
{ {
// simple recoloring of the raw xpms befor creating Pixmaps of them // simple recoloring of the raw xpms befor creating Pixmaps of them
// this works as long as you don't "touch" the images... // this works as long as you don't "touch" the images...
@ -448,7 +449,7 @@ void PreparePixmaps( bool freeMem )
DASetShape( mainPixmap_mask ); DASetShape( mainPixmap_mask );
} }
void MarkName( unsigned long checksum ) static void MarkName( unsigned long checksum )
{ {
name_t *name; name_t *name;
@ -462,7 +463,7 @@ void MarkName( unsigned long checksum )
} }
} }
void DetermineState( void ) static void DetermineState( void )
{ {
name_t *name; name_t *name;
@ -481,7 +482,7 @@ void DetermineState( void )
} }
} }
void ReadChecksumFile( void ) static void ReadChecksumFile( void )
{ {
FILE *f = fopen( config.checksumFileName, "rb" ); FILE *f = fopen( config.checksumFileName, "rb" );
if( f != NULL ) while( !feof( f )) { if( f != NULL ) while( !feof( f )) {
@ -496,7 +497,7 @@ void ReadChecksumFile( void )
fclose( f ); fclose( f );
} }
void WriteChecksumFile( bool writeAll ) static void WriteChecksumFile( bool writeAll )
{ {
FILE *f; FILE *f;
TRACE( "writing checksums:" ); TRACE( "writing checksums:" );
@ -517,7 +518,7 @@ void WriteChecksumFile( bool writeAll )
fclose( f ); fclose( f );
} }
void UpdateChecksum( unsigned long *checksum, const char *buf ) static void UpdateChecksum( unsigned long *checksum, const char *buf )
{ {
if( buf != NULL ) { if( buf != NULL ) {
unsigned int i, len = strlen( buf ); unsigned int i, len = strlen( buf );
@ -527,7 +528,7 @@ void UpdateChecksum( unsigned long *checksum, const char *buf )
} }
} }
void RemoveChecksumFile( void ) static void RemoveChecksumFile( void )
{ {
TRACE( "removing checksum-file\n" ); TRACE( "removing checksum-file\n" );
remove( config.checksumFileName ); remove( config.checksumFileName );
@ -538,7 +539,7 @@ static void ExitHandler( int sig )
caughtSig = 1; caughtSig = 1;
} }
void TimedOut( void ) static void TimedOut( void )
{ {
if (caughtSig) { if (caughtSig) {
ClearAllNames(); ClearAllNames();
@ -549,7 +550,7 @@ void TimedOut( void )
CheckTimeOut( true ); CheckTimeOut( true );
} }
void CheckTimeOut( bool force ) static void CheckTimeOut( bool force )
{ {
static int checkMail = 0; static int checkMail = 0;
@ -586,7 +587,7 @@ void CheckTimeOut( bool force )
checkMail = 0; checkMail = 0;
} }
void CheckMBox( void ) static void CheckMBox( void )
{ {
struct stat fileStat; struct stat fileStat;
@ -623,7 +624,7 @@ void CheckMBox( void )
} }
} }
void CheckMaildir( void ) static void CheckMaildir( void )
{ {
DIR *dir = NULL; DIR *dir = NULL;
int lastState = state; int lastState = state;
@ -683,7 +684,7 @@ void CheckMaildir( void )
forceRedraw = true; forceRedraw = true;
} }
int TraverseDirectory( const char *name, bool isNewMail ) static int TraverseDirectory( const char *name, bool isNewMail )
{ {
DIR *dir = NULL; DIR *dir = NULL;
int mails = 0; int mails = 0;
@ -732,7 +733,7 @@ int TraverseDirectory( const char *name, bool isNewMail )
return mails; return mails;
} }
name_t *GetMail( unsigned long checksum ) static name_t *GetMail( unsigned long checksum )
{ {
name_t *name; name_t *name;
@ -743,7 +744,7 @@ name_t *GetMail( unsigned long checksum )
return NULL; return NULL;
} }
void UpdatePixmap( bool flashMailSymbol ) static void UpdatePixmap( bool flashMailSymbol )
{ {
int drawCount, i; int drawCount, i;
@ -797,7 +798,7 @@ void UpdatePixmap( bool flashMailSymbol )
DASetPixmap( outPixmap ); DASetPixmap( outPixmap );
} }
void ParseMBoxFile( struct stat *fileStat ) static void ParseMBoxFile( struct stat *fileStat )
{ {
char buf[1024]; char buf[1024];
struct utimbuf timeStruct; struct utimbuf timeStruct;
@ -862,7 +863,7 @@ NEXTMAIL:
utime( config.mailBox, &timeStruct ); utime( config.mailBox, &timeStruct );
} }
void ParseMaildirFile( const char *fileName, unsigned long checksum, static void ParseMaildirFile( const char *fileName, unsigned long checksum,
struct stat *fileStat, bool isNewMail ) struct stat *fileStat, bool isNewMail )
{ {
char buf[1024]; char buf[1024];
@ -901,7 +902,7 @@ void ParseMaildirFile( const char *fileName, unsigned long checksum,
utime( fileName, &timeStruct ); utime( fileName, &timeStruct );
} }
char *ParseFromField( char *buf ) static char *ParseFromField( char *buf )
{ {
parse_state_t state = STATE_FULLNAME; parse_state_t state = STATE_FULLNAME;
int fullNameEncoded = 0; int fullNameEncoded = 0;
@ -1076,7 +1077,7 @@ char *ParseFromField( char *buf )
} }
} }
bool SkipSender( char *address ) static bool SkipSender( char *address )
{ {
char **skipName; char **skipName;
int len = strlen( address ); int len = strlen( address );
@ -1100,7 +1101,7 @@ bool SkipSender( char *address )
return false; return false;
} }
void InsertName( char *name, unsigned long checksum, flag_t flag ) static void InsertName( char *name, unsigned long checksum, flag_t flag )
{ {
name_t *item; name_t *item;
@ -1121,7 +1122,7 @@ void InsertName( char *name, unsigned long checksum, flag_t flag )
namesChanged = true; namesChanged = true;
} }
void RemoveLastName( void ) static void RemoveLastName( void )
{ {
if( names != NULL ) { if( names != NULL ) {
name_t *name = names; name_t *name = names;
@ -1131,7 +1132,7 @@ void RemoveLastName( void )
} }
} }
void ClearAllNames( void ) static void ClearAllNames( void )
{ {
name_t *name, *nextName; name_t *name, *nextName;
@ -1148,7 +1149,7 @@ void ClearAllNames( void )
namesChanged = true; namesChanged = true;
} }
void SetMailFlags( flag_t flag ) static void SetMailFlags( flag_t flag )
{ {
name_t *name; name_t *name;
@ -1156,7 +1157,7 @@ void SetMailFlags( flag_t flag )
name->flag |= flag; name->flag |= flag;
} }
void DrawTickerX11Font( void ) static void DrawTickerX11Font( void )
{ {
// 49x21+7+20 out-drawable size // 49x21+7+20 out-drawable size
@ -1194,7 +1195,7 @@ void DrawTickerX11Font( void )
} }
} }
void DrawTickerBuildinFont( void ) static void DrawTickerBuildinFont( void )
{ {
// 49x21+7+20 out-drawable size // 49x21+7+20 out-drawable size
// 14x21 font-character size // 14x21 font-character size
@ -1261,7 +1262,7 @@ void DrawTickerBuildinFont( void )
} }
} }
void ButtonPressed( int button, int state, int x, int y ) static void ButtonPressed( int button, int state, int x, int y )
{ {
if( x >= 35 && x <= 59 && y >= 47 && y <= 59 ) { if( x >= 35 && x <= 59 && y >= 47 && y <= 59 ) {
buttonPressed = true; buttonPressed = true;
@ -1273,7 +1274,7 @@ void ButtonPressed( int button, int state, int x, int y )
CheckTimeOut( false ); CheckTimeOut( false );
} }
void ButtonReleased( int button, int state, int x, int y ) static void ButtonReleased( int button, int state, int x, int y )
{ {
buttonPressed = false; buttonPressed = false;
forceRedraw = true; forceRedraw = true;
@ -1288,7 +1289,7 @@ void ButtonReleased( int button, int state, int x, int y )
CheckTimeOut( false ); CheckTimeOut( false );
} }
void GetHexColorString( const char *colorName, char *xpmLine ) static void GetHexColorString( const char *colorName, char *xpmLine )
{ {
XColor color; XColor color;
@ -1302,7 +1303,8 @@ void GetHexColorString( const char *colorName, char *xpmLine )
WARNING( "unknown colorname: \"%s\"\n", colorName ); WARNING( "unknown colorname: \"%s\"\n", colorName );
} }
char *XpmColorLine( const char *colorName, char *colorLine, bool disposeLine ) static char *XpmColorLine( const char *colorName, char *colorLine,
bool disposeLine )
{ {
char *newLine = strdup( colorLine ); char *newLine = strdup( colorLine );
char *from = strrchr( newLine, '#' ); char *from = strrchr( newLine, '#' );
@ -1324,7 +1326,7 @@ char *XpmColorLine( const char *colorName, char *colorLine, bool disposeLine )
return newLine; return newLine;
} }
void UpdateConfiguration( void ) static void UpdateConfiguration( void )
{ {
struct stat fileStat; struct stat fileStat;
@ -1350,7 +1352,7 @@ void UpdateConfiguration( void )
DASetTimeout (1000 / config.fps); DASetTimeout (1000 / config.fps);
} }
void CleanupNames( void ) static void CleanupNames( void )
{ {
name_t *name, *last = NULL, *nextName; name_t *name, *last = NULL, *nextName;
@ -1377,7 +1379,7 @@ void CleanupNames( void )
} }
} }
bool HasTickerWork( void ) static bool HasTickerWork( void )
{ {
name_t *nextTickerName; name_t *nextTickerName;