Subversion Repositories Projects

Rev

Rev 211 | Rev 230 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
11 dhylands 1
/****************************************************************************
2
*
3
*   Copyright (c) 2006 Dave Hylands     <dhylands@gmail.com>
4
*
5
*   This program is free software; you can redistribute it and/or modify
6
*   it under the terms of the GNU General Public License version 2 as
7
*   published by the Free Software Foundation.
8
*
9
*   Alternatively, this software may be distributed under the terms of BSD
10
*   license.
11
*
12
*   See README and COPYING for more details.
13
*
14
****************************************************************************/
15
/**
16
*
17
*  @file    Str.h
18
*
19
*  @brief   String Manipulation routines.
20
*
21
*  Definitions for a variety of string manipulation routine. These routines
22
*  are all bounded, to ensure that memory overwrites don't occur.
23
*
24
****************************************************************************/
25
/**
26
*  @defgroup   Str   String Manipulation
27
*
28
*  @brief   Provides a variety of string manipulation routines.
29
*/
30
 
31
// ---- Include Files -------------------------------------------------------
32
 
33
#if !defined( STR_H )
34
#define STR_H                 ///< Include Guard
35
 
36
#include <stddef.h>
37
#include <stdarg.h>
38
 
211 dhylands 39
#if defined( __cplusplus )
40
extern "C" {
41
#endif
42
 
11 dhylands 43
/**
44
 * @addtogroup Str
45
 * @{
46
 */
47
 
48
// ---- Constants and Types -------------------------------------------------
49
 
50
/**
51
 * Pointer to a function which outputs a single character. This function
52
 * is called by the strXPrintf()/vStrXPrintf() functions to output a
53
 * character.
54
 */
55
 
56
typedef int (*StrXPrintfFunc)( void *outParm, int ch );
57
 
58
/**
59
 * Maintains data used by StrTok
60
 */
61
 
62
// ---- Variable Externs ----------------------------------------------------
63
// ---- Function Prototypes -------------------------------------------------
64
 
65
char *StrMaxCpy( char *dst, const char *src, size_t maxLen );
66
char *StrMaxCat( char *dst, const char *src, size_t maxLen );
67
 
68
#if defined( AVR )
69
 
213 dhylands 70
#include <avr/pgmspace-fix.h>
11 dhylands 71
 
72
int StrPrintf_P( char *outStr, int maxLen, const prog_char *fmt, ... );
73
int vStrPrintf_P( char *outStr, int maxLen, const prog_char *fmt, va_list args );
74
 
75
int StrXPrintf_P( StrXPrintfFunc func, void *userParm, const prog_char *fmt, ... );
76
int vStrXPrintf_P( StrXPrintfFunc func, void *userParm, const prog_char *fmt, va_list args );
77
 
78
#define StrPrintf(  outStr, maxLen, fmt, args... )      StrPrintf_P(  outStr, maxLen, PSTR( fmt ), ## args )
79
#define vStrPrintf( outStr, maxLen, fmt, args )         vStrPrintf_P( outStr, maxLen, PSTR( fmt ), args )
80
 
81
#define StrXPrintf(  func, userParm, fmt, args... )     StrXPrintf_P(  func, userParm, PSTR( fmt ), ## args )
82
#define vStrXPrintf( func, userParm, fmt, args )        vStrXPrintf_P( func, userParm, PSTR( fmt ), args )
83
 
84
#else
85
 
86
int StrPrintf( char *outStr, int maxLen, const char *fmt, ... );
87
int vStrPrintf( char *outStr, int maxLen, const char *fmt, va_list args );
88
 
89
int StrXPrintf( StrXPrintfFunc func, void *userParm, const char *fmt, ... );
90
int vStrXPrintf( StrXPrintfFunc func, void *userParm, const char *fmt, va_list args );
91
 
92
#endif
93
 
211 dhylands 94
#if defined( __cplusplus )
95
}
96
#endif
97
 
11 dhylands 98
#endif // STR_H
99