Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

gdp / ep / ep_string.h @ master

History | View | Annotate | Download (4.53 KB)

1
/* vim: set ai sw=8 sts=8 ts=8 :*/
2

    
3
/***********************************************************************
4
**  ----- BEGIN LICENSE BLOCK -----
5
**        LIBEP: Enhanced Portability Library (Reduced Edition)
6
**
7
**        Copyright (c) 2008-2019, Eric P. Allman.  All rights reserved.
8
**        Copyright (c) 2015-2019, Regents of the University of California.
9
**        All rights reserved.
10
**
11
**        Permission is hereby granted, without written agreement and without
12
**        license or royalty fees, to use, copy, modify, and distribute this
13
**        software and its documentation for any purpose, provided that the above
14
**        copyright notice and the following two paragraphs appear in all copies
15
**        of this software.
16
**
17
**        IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
18
**        SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST
19
**        PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
20
**        EVEN IF REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
21
**
22
**        REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
23
**        LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24
**        FOR A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION,
25
**        IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO
26
**        OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
27
**        OR MODIFICATIONS.
28
**  ----- END LICENSE BLOCK -----
29
***********************************************************************/
30

    
31
#ifndef _EP_STRING_H_
32
#define _EP_STRING_H_
33
#include <ep/ep.h>
34
__BEGIN_DECLS
35

    
36
#include <string.h>
37

    
38
// these really don't belong here -- maybe ep_video.h
39

    
40
// video sequences for terminals
41
extern struct epVidSequences
42
{
43
        const char        *vidnorm;        // set video to normal
44
        const char        *vidbold;        // set video to bold
45
        const char        *vidfaint;        // set video to faint
46
        const char        *vidstout;        // set video to "standout"
47
        const char        *viduline;        // set video to underline
48
        const char        *vidblink;        // set video to blink
49
        const char        *vidinv;        // set video to invert
50
        const char        *vidfgblack;        // set foreground black
51
        const char        *vidfgred;        // set foreground red
52
        const char        *vidfggreen;        // set foreground green
53
        const char        *vidfgyellow;        // set foreground yellow
54
        const char        *vidfgblue;        // set foreground blue
55
        const char        *vidfgmagenta;        // set foreground magenta
56
        const char        *vidfgcyan;        // set foreground cyan
57
        const char        *vidfgwhite;        // set foreground white
58
        const char        *vidbgblack;        // set background black
59
        const char        *vidbgred;        // set background red
60
        const char        *vidbggreen;        // set background green
61
        const char        *vidbgyellow;        // set background yellow
62
        const char        *vidbgblue;        // set background blue
63
        const char        *vidbgmagenta;        // set background magenta
64
        const char        *vidbgcyan;        // set background cyan
65
        const char        *vidbgwhite;        // set background white
66
} *EpVid;
67

    
68
// target video treatment, corresponding to above
69
//  (currently used only in ep_st_printf for %#c and %#s printing)
70
#define EP_VID_NORM        0
71
#define EP_VID_BOLD        0x00000001
72
#define EP_VID_FAINT        0x00000002
73
#define EP_VID_STOUT        0x00000004
74
#define EP_VID_ULINE        0x00000008
75
#define EP_VID_BLINK        0x00000010
76
#define EP_VID_INV        0x00000020
77

    
78
extern EP_STAT        ep_str_vid_set(const char *);
79

    
80

    
81
// character sequences (e.g., ASCII, ISO-8859-1, UTF-8)
82
extern struct epCharSequences
83
{
84
        const char        *lquote;        // left quote or '<<' character
85
        const char        *rquote;        // right quote or '>>' character
86
        const char        *copyright;        // copyright symbol
87
        const char        *degree;        // degree symbol
88
        const char        *micro;                // micro symbol
89
        const char        *plusminus;        // +/- symbol
90
        const char        *times;                // times symbol
91
        const char        *divide;        // divide symbol
92
        const char        *null;                // null symbol
93
        const char        *notequal;        // not equal symbol
94
        const char        *unprintable;        // non-printable character
95
        const char        *paragraph;        // paragraph symbol
96
        const char        *section;        // section symbol
97
        const char        *notsign;        // "not" symbol
98
        const char        *infinity;        // infinity symbol
99
} *EpChar;
100

    
101
extern EP_STAT        ep_str_char_set(const char *);
102

    
103
// function to adjust alternate printing
104
extern uint32_t        (*EpStPrintfAltprFunc)(int *, char *, char *);
105

    
106

    
107
#ifndef EP_OSCF_HAS_STRLCPY
108
# define EP_OSCF_HAS_STRLCPY        1
109
#endif
110

    
111
#if !EP_OSCF_HAS_STRLCPY
112
extern size_t        strlcpy(char *dst, const char *src, size_t n);
113
extern size_t        strlcat(char *dst, const char *src, size_t n);
114
#endif
115

    
116
#define ep_str_lcpy(dst, src, siz)        strlcpy(dst, src, siz)
117
#define ep_str_lcat(dst, src, siz)        strlcat(dst, src, siz)
118
#define ep_str_casecmp(s1, s2)                strcasecmp(s1, s2)
119
#define ep_str_ncasecmp(s1, s2, l)        strncasecmp(s1, s2, l)
120

    
121
extern size_t        ep_str_lcpyn(char *dst, size_t siz, ...);
122
extern size_t        ep_str_lcatn(char *dst, size_t siz, ...);
123

    
124
__END_DECLS
125
#endif /* _EP_STRING_H_ */