#ifndef INCLUDED_str
#define INCLUDED_str

#ifndef INCLUDED_string
#include <string.h>
#define INCLUDED_string
#endif

//fix Test

inline int
substr( char *source, char *dst, int pos, int len )     //fix ???
  {
    char  *str = source + pos;

    if( pos > (int)strlen( source ) )  return 0;
    while( len-- ) *dst++ =*str++;
    *dst++ = '\0';
    return 1;  
  }

inline void 
get_substr (const char *source, char *dst, int pos, int len)
{
    const char  *str = source + pos;

    #ifndef NDEBUG
    if( (pos+len) > (int)strlen (source))
        throw "Out of range.\n"
              "C_str.h\n"
              "get_substr( char *source, char *dst, int pos, int len )\n";
    #endif

    while (len--) *dst++ = *str++;
    *dst++ = '\0';
}

inline void 
set_substr (char *dst, const char *source, int pos, int len)
{
    char  *str = dst + pos;

    #ifndef NDEBUG
    if( (pos+len) > (int)strlen (dst))
        throw "Out of range.\n"
              "C_str.h\n"
              "set_substr( char *source, char *dst, int pos, int len )\n";
    #endif

//fix ???    int l = strlen( source );
//    if( l < len )  len = l;
    while (len--) *str++ = *source++;
    //*str++ = '\0';
}

#endif//INCLUDED_str
