Next: Known Problems
Up: The UUDeview Decoding Library
Previous: Version 3
Replacement functions
This section is a short reference for the replacement functions from
the fptools library. Some of them may be useful in the
application code as well. Most of these functions are pretty standard
in modern systems, but there's also a few from the author's
imagination. Each of the functions is tagged with information why this
replacement exists:
- ``nonstandard'' (ns): this function is available on some systems, but
not on others. Functions with this tag could be safely replaced with a
native implementation.
- ``feature'' (f): the replacement adds some functionality with
respect to the ``original''.
- ``author''(a): just a function the author considered useful.
- void _FP_free (void *)
- (f)
ANSI C guarantees that free() can be safely called with a
NULL argument, but some old systems dump core. This
replacement just ignores a NULL pointer and passes anything
else to the original free().
- char *_FP_strdup (char *ptr)
- (ns)
Allocates new storage for the string ptr and copies the
string including the final nullbyte to the new location (thus
``duplicating'' the string). Returns NULL if the
malloc() call fails.
- char *_FP_strncpy (char *dest, char *src, int count)
- (f)
Copies text from the src area to the dest area,
until either a nullbyte has been copied or count bytes have
been copied. Differs from the original in that if src is
longer than count bytes, then only count-1 bytes are
copied, and the destination area is properly terminated with a
nullbyte.
- void *_FP_memdup (void *ptr, int count)
- (a)
Allocates a new area of count bytes, which are then copied
from the ptr area.
- int _FP_stricmp (char *str1, char *str2)
- (ns)
Case-insensitive equivalent of strcmp.
- int _FP_strnicmp (char *str1, char *str2, int count)
- (ns)
Case-insensitive equivalent of strncmp.
- char *_FP_strrchr (char *string, int chr)
- (ns)
Similar to strchr, but returns a pointer to the last
occurrence of the character chr in string.
- char *_FP_strstr (char *str1, char *str2)
- (ns)
Returns a pointer to the first occurrence of str2 in
str1 or NULL if the second string does not appear
within the first.
- char *_FP_strrstr (char *str1, char *str2)
- (ns)
Similar to strstr, but returns a pointer to the last
occurrence of str2 in str1.
- char *_FP_stristr (char *str1, char *str2)
- (a)
Case-insensitive equivalent of strstr.
- char *_FP_strirstr (char *str1, char *str2)
- (a)
Case-insensitive equivalent of strrstr.
- char *_FP_stoupper (char *string)
- (a)
Converts all alphabetic characters in string to uppercase.
- char *_FP_stolower (char *string)
- (a)
Converts all alphabetic characters in string to lowercase.
- int _FP_strmatch (char *str, char *pat)
- (a)
Performs glob-style pattern matching. pat is a string
containing regular characters and the two wildcards '?'
(question mark) and '*'. The question mark matches any single
character, the '*' matches any zero or more characters. If
str is matched by pat, the function returns 1,
otherwise 0.
- char *_FP_fgets (char *buf, int max, FILE *file)
- (f)
Extends the standard fgets(); this replacement is able to
handle line terminators from various systems. DOS text files have
their lines terminated by CRLF, Unix files by LF only and Mac files by
CR only. This function reads a line and replaces whatever line
terminator present with a single LF.
- char *_FP_strpbrk (char *str, char *accept)
- (ns)
Locates the first occurrence in the string str of any of
the characters in accept.
- char *_FP_strtok (char *str, char *del)
- (ns)
Considers the string str to be a sequence of tokens separated
by one or more of the delimiter characters given in del. Upon
first call with str!=NULL, returns the first token. Later
calls with str==NULL return the following tokens. Returns
NULL if no more tokens are found.
- char *_FP_cutdir (char *str)
- (a)
Returns the filename part of str, meaning everything after
the last slash or backslash in the string. Now replaced with the
concept of the filename filter.
- char *_FP_strerror (int errcode)
- (ns)
A rather dumb replacement of the original one, which transforms error
codes from errno into a human-readable error message. This
function should only be used if no native implementation
exists; it just returns a string with the numerical error number.
- char *_FP_tempnam (char *dir, char *pfx)
- (ns)
The original is supposed to return a unique filename. The temporary
file should be stored in dir and have a prefix of
pfx. This replacement, too, should only be used if no native
implementation exists. It just returns a temporary filename created by
the standard tmpnam(), which not necessarily resides in a
proper TEMP directory. The value returned by this function is
an allocated memory area which must later be freed by calling
free.
Next: Known Problems
Up: The UUDeview Decoding Library
Previous: Version 3
Debian/Alpha Build Daemon
2002-04-14