JWM Source Documentation
Data Structures | Macros | Functions
misc.h File Reference

Miscellaneous functions and macros. More...

Go to the source code of this file.

Data Structures

struct  StringMappingType
 Mapping between a string and integer. More...
 

Macros

#define ARRAY_LENGTH(a)   (sizeof(a) / sizeof(a[0]))
 Get the length of an array.
 
#define Min(x, y)   ( (x) > (y) ? (y) : (x) )
 Return the minimum of two values.
 
#define Max(x, y)   ( (x) > (y) ? (x) : (y) )
 Return the maximum of two values.
 

Functions

char IsSpace (char ch, unsigned int *lineNumber)
 Determine if a character is a space character.
 
void ExpandPath (char **path)
 Perform shell-like macro path expansion.
 
void Trim (char *str)
 Trim leading and trailing whitespace from a string.
 
char * CopyString (const char *str)
 Copy a string.
 
float ParseFloat (const char *str)
 Read a float in a locale-independent way.
 
int FindValue (const StringMappingType *mapping, int count, const char *key)
 Find a value in a string mapping.
 
const char * FindKey (const StringMappingType *mapping, int count, int value)
 Find a key in a string mapping.
 
int StrCmpNoCase (const char *a, const char *b)
 Case insensitive string compare.
 

Detailed Description

Miscellaneous functions and macros.

Author
Joe Wingbermuehle
Date
2004-2006

Definition in file misc.h.

Macro Definition Documentation

#define ARRAY_LENGTH (   a)    (sizeof(a) / sizeof(a[0]))
#define Max (   x,
 
)    ( (x) > (y) ? (x) : (y) )
#define Min (   x,
 
)    ( (x) > (y) ? (y) : (x) )

Function Documentation

char* CopyString ( const char *  str)
void ExpandPath ( char **  path)

Perform shell-like macro path expansion.

Parameters
pathThe path to expand (possibly reallocated).

Definition at line 151 of file misc.c.

References Assert, GetSymbolName(), Release, ReplaceSymbol(), and ScreenType::x.

Referenced by AddIconPath(), LoadImageBackground(), SetPathString(), TokenizeFile(), and TokenizePipe().

const char* FindKey ( const StringMappingType mapping,
int  count,
int  value 
)

Find a key in a string mapping.

This uses linear search.

Parameters
mappingThe mapping.
valueThe value to find.
countThe number of items in the mapping.
Returns
The key or NULL if not found.

Definition at line 264 of file misc.c.

References StringMappingType::key, and ScreenType::x.

Referenced by GetTokenTypeName().

int FindValue ( const StringMappingType mapping,
int  count,
const char *  key 
)

Find a value in a string mapping.

This uses binary search.

Parameters
mappingThe mapping.
keyThe item to find.
countThe number of items in the mapping.
Returns
The value or -1 if not found.

Definition at line 243 of file misc.c.

References Assert, StringMappingType::value, and ScreenType::x.

Referenced by LookupType(), ParseAttribute(), ParseGroupOption(), ParseKey(), ParseLayer(), ParsePopupStyle(), ParseTextAlignment(), ParseTokenValue(), SetBackground(), SetTrayHorizontalAlignment(), and SetTrayVerticalAlignment().

char IsSpace ( char  ch,
unsigned int *  lineNumber 
)

Determine if a character is a space character.

Parameters
chThe character to check.
lineNumberThe line number to update.

Definition at line 21 of file misc.c.

Referenced by GetRootMenuIndexFromString(), Tokenize(), and Trim().

float ParseFloat ( const char *  str)

Read a float in a locale-independent way.

Parameters
strThe string containing the float.
Returns
The float.

Definition at line 229 of file misc.c.

Referenced by ParseOpacity().

int StrCmpNoCase ( const char *  a,
const char *  b 
)

Case insensitive string compare.

Definition at line 276 of file misc.c.

References ToLower().

Referenced by LoadImage().

void Trim ( char *  str)

Trim leading and trailing whitespace from a string.

Parameters
strThe string to trim.

Definition at line 177 of file misc.c.

References Assert, IsSpace(), and ScreenType::x.

Referenced by AddIconPath(), and ReadValue().

joewing.net / Projects / JWM