group General Utils

Description

Every now and then we cant have nice data structures, so here are some handy functions to help with dealing with data with existing apis. All the functions require that they return a string that it is free'd using ffree().

group attributes
function ferite_lowercase() - Convert a string to lowercase
function ferite_strip_whitespace() - Create a new string based upon the data with the whitespace removed
function ferite_find_string() - Find a substring within a string and return the first occurance
function ferite_copy_string() - Copy a subsection of a string
function ferite_delete_string() - Cuts out a substring starting at "start" up to but not including "end"
function ferite_insert_string() - Insert a string within another string at a specified position
function ferite_replace_string() - Replace all occurances of a pattern in a string with another
function fstrdup() - Allocate the memory and copy the string

Functions

function ferite_lowercase Click to go up to the list
Convert a string to lowercase
Declaration:
    char *ferite_lowercase( char *str )
Parameters:
    Parameter #1: char *str - The string to convert
Returns:
    A new string that is a lowercase version of the passed string

function ferite_strip_whitespace Click to go up to the list
Create a new string based upon the data with the whitespace removed
Declaration:
    char *ferite_strip_whitespace( char *str )
Description:
This function will remove whitespace but not from within quotes
Parameters:
    Parameter #1: char *str - The string to remove the whitespace from
Returns:
    A new string without whitespace

function ferite_find_string Click to go up to the list
Find a substring within a string and return the first occurance
Declaration:
    int ferite_find_string( char *haystack, char *needle )
Parameters:
    Parameter #1: char *haystack - The string to scan
    Parameter #2: char *needle - The string to look for
Returns:
    The index of the start of the substring or -1 if no string is found

function ferite_copy_string Click to go up to the list
Copy a subsection of a string
Declaration:
    char *ferite_copy_string( char *str, int start, int end )
Parameters:
    Parameter #1: char *str - The string to copy from
    Parameter #2: int start - The start of the subsection
    Parameter #3: int end - The end of the subsection
Returns:
    A string containing the data between the two bounds

function ferite_delete_string Click to go up to the list
Cuts out a substring starting at "start" up to but not including "end"
Declaration:
    char *ferite_delete_string( char *str, int start, int end )
Parameters:
    Parameter #1: int start - The start of the substring
    Parameter #2: int end - The end of the substring
Returns:
    The string without the substring

function ferite_insert_string Click to go up to the list
Insert a string within another string at a specified position
Declaration:
    char *ferite_insert_string( char *str, char *istr, int pos )
Parameters:
    Parameter #1: char *str - The string to insert into
    Parameter #2: char *istr - The string to insert
    Parameter #3: int pos - The position to insert at
Returns:
    A new string

function ferite_replace_string Click to go up to the list
Replace all occurances of a pattern in a string with another
Declaration:
    char *ferite_replace_string( char *str, char *pattern, char *data )
Parameters:
    Parameter #1: char *str - The string to scan
    Parameter #2: char *pattern - The pattern to look for
    Parameter #3: char *datat - The data to replace with
Returns:
    A string that has had the replacements

function fstrdup Click to go up to the list
Allocate the memory and copy the string
Declaration:
    char *fstrdup( char *str )
Parameters:
    Parameter #1: char *str - The string to copy
Returns:
    The copied string

Automatically generated at 8:45pm, Wednesday 08 January 2003 by feritedoc.