Subversion Repositories Projects

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
212 dhylands 1
/****************************************************************************
2
*
3
*     Copyright (c) 2003 Dave Hylands
4
*           All Rights Reserved
5
*
6
*       Permission is granted to any individual or institution to use, copy, or
7
*       redistribute this software so long as it is not sold for profit, and that
8
*       this copyright notice is retained.
9
*
10
****************************************************************************/
11
/**
12
*
13
*  @file    StrMaxCat.cpp
14
*
15
*  @brief   Implements StrMaxCat, a bounded string concatenation routine.
16
*
17
****************************************************************************/
18
 
19
/* ---- Include Files ---------------------------------------------------- */
20
 
21
#include "Str.h"
22
#include <string.h>
23
 
24
/* ---- Public Variables ------------------------------------------------- */
25
/* ---- Private Constants and Types -------------------------------------- */
26
/* ---- Private Variables ------------------------------------------------ */
27
/* ---- Private Function Prototypes -------------------------------------- */
28
/* ---- Functions -------------------------------------------------------- */
29
 
30
/**
31
 * @addtogroup Str
32
 * @{
33
 */
34
 
35
/***************************************************************************/
36
/**
37
*  Concatenates source to the destination, but makes sure that the
38
*  destination string (including terminating null), doesn't exceed maxLen.
39
*
40
*  @param   dst      (mod) String to concatnate onto.
41
*  @param   src      (in)  String to being added to the end of @a dst.
42
*  @param   maxLen   (in)  Maximum length that @a dst is allowed to be.
43
*
44
*  @return  A pointer to the destination string.
45
*/
46
 
47
char *StrMaxCat( char *dst, const char *src, size_t maxLen )
48
{
49
        size_t  dstLen = strlen( dst );
50
 
51
        if ( dstLen < maxLen )
52
        {
53
                StrMaxCpy( &dst[ dstLen ], src, maxLen - dstLen );
54
        }
55
 
56
        return dst;
57
 
58
} /* StrMaxCat */
59
 
60
/** @} */
61