spBase
Loading...
Searching...
No Matches
Basic Functions

Macros

#define spStrCaseEq(s1, s2)   ((s1 != NULL) && (s2 != NULL) && (spStrCaseCmp((s1), (s2)) == 0) ? 1 : 0)
 
#define spStrNCaseEq(s1, s2, n)   ((s1 != NULL) && (s2 != NULL) && (spStrNCaseCmp((s1), (s2), n) == 0) ? 1 : 0)
 
#define spStrVCaseEq(s1, s2)   ((s1 != NULL) && (s2 != NULL) && (spStrNCaseCmp((s1), (s2), (int)strlen(s2)) == 0) ? 1 : 0)
 
#define strcaseeq(s1, s2)   spStrCaseEq(s1, s2)
 
#define strncaseeq(s1, s2, n)   spStrNCaseEq(s1, s2, n)
 
#define strvcaseeq(s1, s2)   spStrVCaseEq(s1, s2)
 
#define strwhite(string)   spStrWhite(string)
 

Enumerations

enum  spFileKind {
  SP_FILE_KIND_UNKNOWN = -1 , SP_FILE_KIND_DOCUMENT = 0 , SP_FILE_KIND_SOURCE = 1 , SP_FILE_KIND_CONFIG = 2 ,
  SP_FILE_KIND_INCLUDE = 3 , SP_FILE_KIND_PICTURE = 10 , SP_FILE_KIND_FIGURE = 11 , SP_FILE_KIND_MUSIC = 20 ,
  SP_FILE_KIND_SOUND = 21 , SP_FILE_KIND_MOVIE = 25 , SP_FILE_KIND_APPLICATION = 30 , SP_FILE_KIND_LIBRARY = 31 ,
  SP_FILE_KIND_ARCHIVE = 40 , SP_FILE_KIND_URI = 50
}
 

Message Display

void spSetWarningFlag (int flag)
 
void spWarning (const char *format,...)
 
void spSetMessageFlag (int flag)
 
void spMessage (const char *format,...)
 
void spError (int status, const char *format,...)
 
void spProgError (const char *func_name, const char *format,...)
 
void spSetDebugStdout (int flag)
 
void spSetDebugLevel (int level)
 
int spGetDebugLevel (void)
 
void spDebug (int level, const char *func_name, const char *format,...)
 

System Control

void spSleep (int sec)
 
void spMSleep (int msec)
 
long spGetProcessId (void)
 
spBool spExecBrowser (const char *base_url, const char *sub_url, spBool local_path)
 

String Management

int spStrCaseCmp (const char *s1, const char *s2)
 
int spStrNCaseCmp (const char *s1, const char *s2, int n)
 
int spStrWhite (const char *string)
 
char * spSkipWhite (const char *string)
 
char * xspStrCat (const char *orig, const char *src)
 
char * spStrCat (char *dest, int destsize, const char *src)
 
char * spStrCopy (char *dest, int destsize, const char *src)
 
char * spGetSuffix (const char *name)
 
int spEqSuffix (const char *file1, const char *file2)
 
spBool spRemoveNSuffix (char *path, char *removed_suffix, int suffixsize)
 
spBool spRemoveSuffix (char *path, char *removed_suffix)
 
spBool spReplaceNSuffix (char *path, int pathsize, const char *suffix)
 
spBool spReplaceSuffix (char *path, const char *suffix)
 
int spConvertToEscapedString (char *escaped, int bufsize, const char *string, const char *charlist)
 
int spConvertFromEscapedString (char *string, int bufsize, const char *escaped, const char *charlist)
 

File and Directory

FILE * spOpenFile (const char *path, const char *mode)
 
int spCloseFile (FILE *stream)
 
int spSeekFile (FILE *stream, spFileOffset offset, int origin)
 
int spSeekFile64 (FILE *stream, spLong64 offset, int origin)
 
spFileOffset spTellFile (FILE *stream)
 
spBool spGetFileInfo (const char *path, spBool *dir_flag, spFileOffset *size)
 
spBool spExists (const char *path)
 
spBool spIsExist (const char *path)
 
spBool spIsFile (const char *path)
 
spBool spIsDir (const char *path)
 
spBool spCreateDir (const char *path, unsigned short mode)
 
spBool spCreateDirRecursive (const char *path, unsigned short mode)
 
spBool spRemoveDir (const char *path)
 
spBool spRemoveFile (const char *path)
 
spBool spRenameFile (const char *oldpath, const char *newpath)
 

File and Directory Names

spBool spAddDirSeparator (char *dir)
 
spBool spRemoveDirSeparator (char *dir)
 
spBool spIsExactName (const char *name)
 
char * xspGetExactName (const char *name)
 
char * spGetBaseName (const char *name)
 
char * xspGetBaseName (const char *name)
 
char * spGetDirName (char *filename)
 
char * xspGetDirName (const char *filename)
 
char * xspGetReadablePath (const char *real_path)
 
char * xspGetRealPath (const char *readable_path)
 
char * xspCutPathList (const char *pathlist, int col)
 
char * xspAppendPathList (const char *pathlist, const char *new_list)
 
char * xspPrependPathList (const char *pathlist, const char *new_list)
 

System and Application Directory

const char * spGetCurrentDir (void)
 
char * xspGetCurrentDir (void)
 
const char * spGetHomeDir (void)
 
char * xspGetHomeDir (void)
 
const char * spGetTempDir (void)
 
char * xspGetTempDir (void)
 
spBool spSetApplicationId (const char *id)
 
const char * spGetCompanyId (void)
 
const char * spGetApplicationId (void)
 
const char * spGetVersionId (void)
 
const char * spCreateApplicationDir (spBool *id_depend, spBool *version_depend)
 
const char * spGetApplicationDir (spBool *version_depend)
 
char * xspGetApplicationDir (spBool *version_depend)
 
const char * spGetApplicationTempDir (void)
 
char * xspGetApplicationTempDir (void)
 
spBool spSetApplicationTempDir (const char *dir)
 
char * xspGetDocumentDir (spFileKind file_kind)
 

Numeric Functions

double spRound (double x)
 
double spFix (double x)
 
double spFrac (double x)
 
double spRem (double x, double y)
 
long spFactorial (int n)
 
void spNFtos (char *buf, int bufsize, double x)
 
void spFtos (char *buf, double x)
 
long spNextPow2 (long n)
 

Type Conversion

int spGetBitByte (int samp_bit, spBool *float_flag)
 
double spGetBitNormalizeFactor (int samp_bit)
 
long spConvertDoubleToBitWeighted (double *idata, long length, void *odata, int samp_bit, double weight)
 
long spConvertDoubleToBit (double *idata, long length, void *odata, int samp_bit, double max)
 
long spConvertDoubleToClippedBitWeighted (double *idata, long length, void *odata, int samp_bit, double weight)
 
long spConvertDoubleToClippedBit (double *idata, long length, void *odata, int samp_bit, double max)
 
long spConvertBitToDoubleWeighted (void *idata, long length, double *odata, int samp_bit, double weight)
 
long spConvertBitToDouble (void *idata, long length, double *odata, int samp_bit, double max)
 

Detailed Description

Macro Definition Documentation

◆ spStrCaseEq

#define spStrCaseEq ( s1,
s2 )   ((s1 != NULL) && (s2 != NULL) && (spStrCaseCmp((s1), (s2)) == 0) ? 1 : 0)

Compares two strings ignoring case.

◆ spStrNCaseEq

#define spStrNCaseEq ( s1,
s2,
n )   ((s1 != NULL) && (s2 != NULL) && (spStrNCaseCmp((s1), (s2), n) == 0) ? 1 : 0)

Compares two strings until n ignoring case.

◆ spStrVCaseEq

#define spStrVCaseEq ( s1,
s2 )   ((s1 != NULL) && (s2 != NULL) && (spStrNCaseCmp((s1), (s2), (int)strlen(s2)) == 0) ? 1 : 0)

Compares two strings until one string ends ignoring case.

◆ strcaseeq

#define strcaseeq ( s1,
s2 )   spStrCaseEq(s1, s2)

Compares two strings ignoring case (abbreviated version).

◆ strncaseeq

#define strncaseeq ( s1,
s2,
n )   spStrNCaseEq(s1, s2, n)

Compares two strings until n ignoring case (abbreviated version).

◆ strvcaseeq

#define strvcaseeq ( s1,
s2 )   spStrVCaseEq(s1, s2)

Compares two strings until one string ends ignoring case (abbreviated version).

◆ strwhite

#define strwhite ( string)    spStrWhite(string)

Checks whether the string consists of white characters only (abbreviated version).

Enumeration Type Documentation

◆ spFileKind

enum spFileKind

Indicates the file kind for applications to deal with documents.

Enumerator
SP_FILE_KIND_UNKNOWN 

Unknown files.

SP_FILE_KIND_DOCUMENT 

General documents.

SP_FILE_KIND_SOURCE 

Source files.

SP_FILE_KIND_CONFIG 

Configure files.

SP_FILE_KIND_INCLUDE 

Include files.

SP_FILE_KIND_PICTURE 

Pictures and images.

SP_FILE_KIND_FIGURE 

Figures.

SP_FILE_KIND_MUSIC 

MIDI files and music files.

SP_FILE_KIND_SOUND 

Other sound files.

SP_FILE_KIND_MOVIE 

Movie files.

SP_FILE_KIND_APPLICATION 

Applications.

SP_FILE_KIND_LIBRARY 

Library files.

SP_FILE_KIND_ARCHIVE 

Archive files.

SP_FILE_KIND_URI 

URI links.

Function Documentation

◆ spSetWarningFlag()

void spSetWarningFlag ( int flag)
extern

Sets a flag to determine whether warning messages are displayed.

◆ spWarning()

void spWarning ( const char * format,
... )
extern

Displays a warning message to stderr.

◆ spSetMessageFlag()

void spSetMessageFlag ( int flag)
extern

Sets a flag to determine whether normal messages are displayed.

◆ spMessage()

void spMessage ( const char * format,
... )
extern

Displays a normal message to stderr.

◆ spError()

void spError ( int status,
const char * format,
... )
extern

Displays an error message to stderr, and then terminates the current program.

Examples
spcat.c.

◆ spProgError()

void spProgError ( const char * func_name,
const char * format,
... )
extern

Displays an error message and the name of the function causing the error to stderr, and then terminates the current program.

◆ spSetDebugStdout()

void spSetDebugStdout ( int flag)
extern

Sets a flag to determine whether the desitination of debug messages is stdout or stderr.

◆ spSetDebugLevel()

void spSetDebugLevel ( int level)
extern

Sets a debug level.

Examples
dirtest.c, and openlib.c.

◆ spGetDebugLevel()

int spGetDebugLevel ( void )
extern

Gets the current debug level.

◆ spDebug()

void spDebug ( int level,
const char * func_name,
const char * format,
... )
extern

Displays a debug message.

Examples
pstest.c.

◆ spSleep()

void spSleep ( int sec)
extern

Suspends the execution of the current program for the specified interval in seconds.

◆ spMSleep()

void spMSleep ( int msec)
extern

Suspends the execution of the current program for the specified interval in milliseconds.

◆ spGetProcessId()

long spGetProcessId ( void )
extern

Gets the unique ID for the current process.

Examples
dirtest.c.

◆ spExecBrowser()

spBool spExecBrowser ( const char * base_url,
const char * sub_url,
spBool local_path )
extern

Opens the URL with a web browser.

Parameters
[in]base_urlThe main part of URL including scheme, host, etc. This can be a local path (file or directory). In this case, local_path must be SP_TRUE.
[in]sub_urlThe optional path following the main part. This part must be used if base_url is a local path and the URL includes '#' such as 'index.html#foo'.
[in]local_pathSP_TRUE if base_url is a local path.
Return values
SP_TRUESuccess
SP_FALSEFailure
Examples
dirtest.c.

◆ spStrCaseCmp()

int spStrCaseCmp ( const char * s1,
const char * s2 )
extern

Compares the two strings ignoring the case of the characters.

◆ spStrNCaseCmp()

int spStrNCaseCmp ( const char * s1,
const char * s2,
int n )
extern

Compares the two strings ignoring the case of the characters.

◆ spStrWhite()

int spStrWhite ( const char * string)
extern

Checks whether the string consists of white characters only.

◆ spSkipWhite()

char * spSkipWhite ( const char * string)
extern

Skips white characters in the string.

◆ xspStrCat()

char * xspStrCat ( const char * orig,
const char * src )
extern

Gets the memory-allocated string which is generated by concatenating src contents into the end of orig .

◆ spStrCat()

char * spStrCat ( char * dest,
int destsize,
const char * src )
extern

Concatenates src contents into the end of dest. The resultant contents of dest is always terminated with '\0' regardless of src 's length.

◆ spStrCopy()

char * spStrCopy ( char * dest,
int destsize,
const char * src )
extern

Copies the contents of src to the address of dest . The resultant contents of dest is always terminated with '\0' regardless of src 's length.

◆ spGetSuffix()

char * spGetSuffix ( const char * name)
extern

Searches the suffix (extension) from the string specified by name and returns the beginning address of the suffix which includes dot such as ".wav".

◆ spEqSuffix()

int spEqSuffix ( const char * file1,
const char * file2 )
extern

Checks whether two strings have the same suffix.

◆ spRemoveNSuffix()

spBool spRemoveNSuffix ( char * path,
char * removed_suffix,
int suffixsize )
extern

Removes the suffix in the string and copies the removed suffix to the address specifed by removed_suffix assuming the buffer size of removed_suffix is suffixsize . removed_suffix can be NULL.

◆ spRemoveSuffix()

spBool spRemoveSuffix ( char * path,
char * removed_suffix )
extern

Removes the suffix in the string and copies the removed suffix to the address specifed by removed_suffix.

◆ spReplaceNSuffix()

spBool spReplaceNSuffix ( char * path,
int pathsize,
const char * suffix )
extern

Replaces a suffix of the string of path with another one specified by suffix assuming the buffer size of path is pathsize . If the string of path doesn't have a suffix, a new suffix will be appended.

◆ spReplaceSuffix()

spBool spReplaceSuffix ( char * path,
const char * suffix )
extern

Replaces a suffix of the string of path with another one specified by suffix . If the string of path doesn't have a suffix, a new suffix will be appended.

◆ spConvertToEscapedString()

int spConvertToEscapedString ( char * escaped,
int bufsize,
const char * string,
const char * charlist )
extern

Prepends the escape character '\' to a character specified by charlist .

Parameters
[in]escapedThe output null-terminated string.
[in]bufsizeThe buffer size of escaped .
[in]stringThe input null-terminated string.
[in]charlistThe list of the target characters.
Returns
The number of insertions of '\' for success, or -1 for failure.

◆ spConvertFromEscapedString()

int spConvertFromEscapedString ( char * string,
int bufsize,
const char * escaped,
const char * charlist )
extern

Deletes the escape character '\' before a character specified by charlist from the input string.

Parameters
[in]stringThe output null-terminated string.
[in]bufsizeThe buffer size of string .
[in]escapedThe input null-terminated string including escape characters.
[in]charlistThe list of the target characters. If charlist is NULL, all escapes by '\' will be deleted.
Returns
The number of deletions of '\' for success, or -1 for failure.

◆ spOpenFile()

FILE * spOpenFile ( const char * path,
const char * mode )
extern

Opens the file whose name is path with the mode specified by mode .

◆ spCloseFile()

int spCloseFile ( FILE * stream)
extern

Closes the stream opened by spOpenFile() .

◆ spSeekFile()

int spSeekFile ( FILE * stream,
spFileOffset offset,
int origin )
extern

Moves the file pointer to the specified location.

◆ spSeekFile64()

int spSeekFile64 ( FILE * stream,
spLong64 offset,
int origin )
extern

Moves the file pointer to the specified location.

◆ spTellFile()

spFileOffset spTellFile ( FILE * stream)
extern

Gets the current position of the file pointer.

◆ spGetFileInfo()

spBool spGetFileInfo ( const char * path,
spBool * dir_flag,
spFileOffset * size )
extern

Gets the information of the path.

◆ spExists()

spBool spExists ( const char * path)
extern

Checks whether the file or directory exists.

◆ spIsExist()

spBool spIsExist ( const char * path)
extern

Checks whether the file or directory exists.

◆ spIsFile()

spBool spIsFile ( const char * path)
extern

Checks whether the path represents a file.

◆ spIsDir()

spBool spIsDir ( const char * path)
extern

Checks whether the path represents a directory.

◆ spCreateDir()

spBool spCreateDir ( const char * path,
unsigned short mode )
extern

Creates a directory.

◆ spCreateDirRecursive()

spBool spCreateDirRecursive ( const char * path,
unsigned short mode )
extern

Creates a directory recursively.

◆ spRemoveDir()

spBool spRemoveDir ( const char * path)
extern

Removes a directory.

◆ spRemoveFile()

spBool spRemoveFile ( const char * path)
extern

Removes a file.

◆ spRenameFile()

spBool spRenameFile ( const char * oldpath,
const char * newpath )
extern

Renames a file or directory.

◆ spAddDirSeparator()

spBool spAddDirSeparator ( char * dir)
extern

Adds a character for directory separator to the path.

◆ spRemoveDirSeparator()

spBool spRemoveDirSeparator ( char * dir)
extern

Removes a character for directory separator from the path.

◆ spIsExactName()

spBool spIsExactName ( const char * name)
extern

Checks whether the name is an exact path name.

◆ xspGetExactName()

char * xspGetExactName ( const char * name)
extern

Gets the exact path.

Examples
dirtest.c.

◆ spGetBaseName()

char * spGetBaseName ( const char * name)
extern

Strips a directory path from the specified path. Note that the argument name is not modified by this function call.

◆ xspGetBaseName()

char * xspGetBaseName ( const char * name)
extern

Strips a directory path from the specified path.

◆ spGetDirName()

char * spGetDirName ( char * filename)
extern

Extract a directory path from the specified path. Note that the argument filename is modified by this function call.

◆ xspGetDirName()

char * xspGetDirName ( const char * filename)
extern

Extract a directory path from the specified path.

◆ xspGetReadablePath()

char * xspGetReadablePath ( const char * real_path)
extern

Gets a path for the use of display from the real path.

◆ xspGetRealPath()

char * xspGetRealPath ( const char * readable_path)
extern

Gets a real path from the path for the use of display.

◆ xspCutPathList()

char * xspCutPathList ( const char * pathlist,
int col )
extern

Extracts a path from the list of paths.

◆ xspAppendPathList()

char * xspAppendPathList ( const char * pathlist,
const char * new_list )
extern

Appends a new path list to the tail of the current path list.

◆ xspPrependPathList()

char * xspPrependPathList ( const char * pathlist,
const char * new_list )
extern

Prepends a new path list to the head of the current path list.

◆ spGetCurrentDir()

const char * spGetCurrentDir ( void )
extern

Gets the current directory.

◆ xspGetCurrentDir()

char * xspGetCurrentDir ( void )
extern

Gets the current directory.

Examples
dirtest.c.

◆ spGetHomeDir()

const char * spGetHomeDir ( void )
extern

Gets the home directory.

◆ xspGetHomeDir()

char * xspGetHomeDir ( void )
extern

Gets the home directory.

Examples
dirtest.c.

◆ spGetTempDir()

const char * spGetTempDir ( void )
extern

Gets the temporal directory.

◆ xspGetTempDir()

char * xspGetTempDir ( void )
extern

Gets the temporal directory.

Examples
dirtest.c.

◆ spSetApplicationId()

spBool spSetApplicationId ( const char * id)
extern

Sets the application ID. This ID can includes the company ID and the version ID by using the character '/' as a separator.

Examples
dirtest.c.

◆ spGetCompanyId()

const char * spGetCompanyId ( void )
extern

Gets the company ID from the ID specified by spSetApplicationId() .

◆ spGetApplicationId()

const char * spGetApplicationId ( void )
extern

Gets the application ID from the ID specified by spSetApplicationId() .

◆ spGetVersionId()

const char * spGetVersionId ( void )
extern

Gets the version ID from the ID specified by spSetApplicationId() .

◆ spCreateApplicationDir()

const char * spCreateApplicationDir ( spBool * id_depend,
spBool * version_depend )
extern

Creates the application directory which corresponds to the ID specified by spSetApplicationId() .

Examples
dirtest.c.

◆ spGetApplicationDir()

const char * spGetApplicationDir ( spBool * version_depend)
extern

Gets the application directory. If spCreateApplicationDir() has not been called yet, this function creates a new application directory.

Examples
dirtest.c.

◆ xspGetApplicationDir()

char * xspGetApplicationDir ( spBool * version_depend)
extern

Gets the application directory. If spCreateApplicationDir() has not been called yet, this function creates a new application directory.

◆ spGetApplicationTempDir()

const char * spGetApplicationTempDir ( void )
extern

Gets the temporal directory for the current application.

Examples
dirtest.c.

◆ xspGetApplicationTempDir()

char * xspGetApplicationTempDir ( void )
extern

Gets the temporal directory for the current application.

◆ spSetApplicationTempDir()

spBool spSetApplicationTempDir ( const char * dir)
extern

Sets the temporal directory for the current application.

◆ xspGetDocumentDir()

char * xspGetDocumentDir ( spFileKind file_kind)
extern

Gets the special directory for a kind of files.

Examples
dirtest.c.

◆ spRound()

double spRound ( double x)
extern

Rounds to the nearest integer.

Examples
pstest.c.

◆ spFix()

double spFix ( double x)
extern

Rounds toward zero.

◆ spFrac()

double spFrac ( double x)
extern

Gets the fractional part of x with the same sign.

◆ spRem()

double spRem ( double x,
double y )
extern

Calculates remainder after division.

◆ spFactorial()

long spFactorial ( int n)
extern

Calculates the factorial.

◆ spNFtos()

void spNFtos ( char * buf,
int bufsize,
double x )
extern

Converts the floating point value to a null-terminated string.

◆ spFtos()

void spFtos ( char * buf,
double x )
extern

Converts the floating point value to a null-terminated string.

◆ spNextPow2()

long spNextPow2 ( long n)
extern

Calculates the exponent for the next power of 2.

◆ spGetBitByte()

int spGetBitByte ( int samp_bit,
spBool * float_flag )
extern

Gets a size in bytes for the specified bit format.

◆ spGetBitNormalizeFactor()

double spGetBitNormalizeFactor ( int samp_bit)
extern

Gets a weighting factor to normalize the specified bit format.

◆ spConvertDoubleToBitWeighted()

long spConvertDoubleToBitWeighted ( double * idata,
long length,
void * odata,
int samp_bit,
double weight )
extern

Converts a buffer of double type into a buffer of the specified bit format.

◆ spConvertDoubleToBit()

long spConvertDoubleToBit ( double * idata,
long length,
void * odata,
int samp_bit,
double max )
extern

Converts a buffer of double type into a buffer of the specified bit format.

◆ spConvertDoubleToClippedBitWeighted()

long spConvertDoubleToClippedBitWeighted ( double * idata,
long length,
void * odata,
int samp_bit,
double weight )
extern

Converts a buffer of double type into a buffer of the specified bit format with hard clipping.

◆ spConvertDoubleToClippedBit()

long spConvertDoubleToClippedBit ( double * idata,
long length,
void * odata,
int samp_bit,
double max )
extern

Converts a buffer of double type into a buffer of the specified bit format with hard clipping.

◆ spConvertBitToDoubleWeighted()

long spConvertBitToDoubleWeighted ( void * idata,
long length,
double * odata,
int samp_bit,
double weight )
extern

Converts a buffer of the specified bit format into a buffer of double type.

◆ spConvertBitToDouble()

long spConvertBitToDouble ( void * idata,
long length,
double * odata,
int samp_bit,
double max )
extern

Converts a buffer of the specified bit format into a buffer of double type.