/** @file  psString.h
 *
 * -*- mode: C; c-basic-indent: 4; tab-width: 8; indent-tabs-mode: nil -*-
 * vim: set cindent ts=8 sw=4 expandtab:
 *
 *  @brief Contains the declarations of string utility functions
 *
 *  @ingroup SysUtils
 *
 *  String utility functions defined shall provide basic string copying
 *  capabilities.
 *
 *  @author Eric Van Alst, MHPCC
 *
 *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
 *  @date $Date: 2005-09-13 01:09:58 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
 */

#ifndef PS_STRING_H
#define PS_STRING_H

#include <sys/types.h>
#include "psType.h"

/** This macro will convert the argument to a quoted string */
#define PS_STRING(S)  #S

// Doxygen group tags

/** @addtogroup SysUtils
 *  @{
 */

/** Copies the input string
 *
 *  This function shall allocate memory to the length of the input string
 *  plus one and copy the input string to the newly allocated memory.
 *
 *  @return psString:      Copy of input string
 *
 */
psString psStringCopy(
    const char *string                 ///< Input string of characters to copy
);

/** Copies the input string up to the specified number of characters
 *
 *  This function shall allocate memory to the length specified by nChar
 *  plus one and copy the input string to the newly allocated memory.
 *  This function will only copy nChar bytes from the input to new string,
 *  so if the input string is larger than nChar characters the copied
 *  string will be a substring of the input string.  If the input string
 *  is smaller than nChar bytes then the remaining bytes allocated will
 *  be set to NULL.
 *
 *  @return  psString:   Copy of input string
 *
 */

/*@null@*/

psString psStringNCopy(
    const char *string,                ///< Input string of characters to copy
    unsigned int nChar                 ///< Number of bytes to allocate for string copy
);

/** Appends a format onto a string
 *
 * This function shall allocate a new string if dest is NULL.  dest shall be
 * automatically extended to the size of the new string.
 *
 * @return The length of the new string (excluding '\0')
 */

ssize_t psStringAppend(
    char **dest,                        ///< existing string
    const char *format,                 ///< format to append
    ...                                 ///< format arguments
);

/** Prepends a format onto a string
 *
 * This function shall allocate a new string if dest is NULL.  dest shall be
 * automatically extended to the size of the new string.
 *
 * @return The length of the new string (excluding '\0')
 */

ssize_t psStringPrepend(
    char **dest,                        ///< existing string
    const char *format,                 ///< format to append
    ...                                 ///< format arguments
);

/** @} */// Doxygen - End of SystemGroup Functions

#endif // #ifndef PS_STRING_H
