BOOTSTRAP (kutils) functions
LIBRARY ROUTINE
kchar_replace - replace a character with another through a string
LIBRARY CALL
char *kchar_replace(
const char *istr,
int scan_char,
int replace_char,
char *ostr)
INPUT
- istr - The string to be changed.
- scan_char - The scan character to be replaced.
- replace_char - The character which replaces the scan
character.
OUTPUT
- ostr - The string that holds the converted string.
If it's NULL, the routine allocates the space
necessary to hold the result.
RETURN VALUE
The converted string 'ostr' if it is not NULL, or a pointer
to the resulting allocated string if it is NULL. NULL is
returned on an error, or if 'istr' is NULL.
DESCRIPTION
This function performs a global change of character on
the input string. It returns a string where every
occurrence of the scan character is replaced with the
replacement character. If 'ostr' is sent in as NULL,
the result will be allocated with kmalloc() for you.
If 'ostr' is non-NULL, the result will be stored
in 'ostr'. Note that if 'ostr' is non-NULL, it must
point at a memory buffer with a sufficient amount of
storage space before this routine is called.
Note that if 'ostr' is non-NULL, the calling routine
must ensure that 'ostr' points to a memory buffer
large enough to hold the copied string and terminating
null character. If the buffer is not large enough,
memory will be overwritten resulting in unpredicable
program failure.
ADDITIONAL INFORMATION
none
EXAMPLES
For example, if we call:
new_string = kchar_replace("Many fishes", 'f', 'w', NULL);
the result will be:
new_string = "Many wishes".
SIDE EFFECTS
Allocates the space for the output string if 'ostr' is NULL
RESTRICTIONS
none
MODIFICATION
none
FILES
$BOOTSTRAP/objects/library/kutils/src/strings.c
SEE ALSO
kutils(3)
COPYRIGHT
Copyright (C) 1993 - 1997, Khoral Research, Inc. ("KRI") All rights reserved.