~noskcaj/ubuntu/saucy/sflphone/merge-1.2.3-2

« back to all changes in this revision

Viewing changes to daemon/libs/pjproject/pjlib/include/pj/ctype.h

  • Committer: Jackson Doak
  • Date: 2013-07-10 21:04:46 UTC
  • mfrom: (20.1.3 sid)
  • Revision ID: noskcaj@ubuntu.com-20130710210446-y8f587vza807icr9
Properly merged from upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: ctype.h 3553 2011-05-05 06:14:19Z nanang $ */
2
 
/* 
3
 
 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
4
 
 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
5
 
 *
6
 
 * This program is free software; you can redistribute it and/or modify
7
 
 * it under the terms of the GNU General Public License as published by
8
 
 * the Free Software Foundation; either version 2 of the License, or
9
 
 * (at your option) any later version.
10
 
 *
11
 
 * This program is distributed in the hope that it will be useful,
12
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
 * GNU General Public License for more details.
15
 
 *
16
 
 * You should have received a copy of the GNU General Public License
17
 
 * along with this program; if not, write to the Free Software
18
 
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
19
 
 */
20
 
#ifndef __PJ_CTYPE_H__
21
 
#define __PJ_CTYPE_H__
22
 
 
23
 
/**
24
 
 * @file ctype.h
25
 
 * @brief C type helper macros.
26
 
 */
27
 
 
28
 
#include <pj/types.h>
29
 
#include <pj/compat/ctype.h>
30
 
 
31
 
PJ_BEGIN_DECL
32
 
 
33
 
/**
34
 
 * @defgroup pj_ctype ctype - Character Type
35
 
 * @ingroup PJ_MISC
36
 
 * @{
37
 
 *
38
 
 * This module contains several inline functions/macros for testing or
39
 
 * manipulating character types. It is provided in PJLIB because PJLIB
40
 
 * must not depend to LIBC.
41
 
 */
42
 
 
43
 
/** 
44
 
 * Returns a non-zero value if either isalpha or isdigit is true for c.
45
 
 * @param c     The integer character to test.
46
 
 * @return      Non-zero value if either isalpha or isdigit is true for c.
47
 
 */
48
 
PJ_INLINE(int) pj_isalnum(unsigned char c) { return isalnum(c); }
49
 
 
50
 
/** 
51
 
 * Returns a non-zero value if c is a particular representation of an 
52
 
 * alphabetic character.
53
 
 * @param c     The integer character to test.
54
 
 * @return      Non-zero value if c is a particular representation of an 
55
 
 *              alphabetic character.
56
 
 */
57
 
PJ_INLINE(int) pj_isalpha(unsigned char c) { return isalpha(c); }
58
 
 
59
 
/** 
60
 
 * Returns a non-zero value if c is a particular representation of an 
61
 
 * ASCII character.
62
 
 * @param c     The integer character to test.
63
 
 * @return      Non-zero value if c is a particular representation of 
64
 
 *              an ASCII character.
65
 
 */
66
 
PJ_INLINE(int) pj_isascii(unsigned char c) { return c<128; }
67
 
 
68
 
/** 
69
 
 * Returns a non-zero value if c is a particular representation of 
70
 
 * a decimal-digit character.
71
 
 * @param c     The integer character to test.
72
 
 * @return      Non-zero value if c is a particular representation of 
73
 
 *              a decimal-digit character.
74
 
 */
75
 
PJ_INLINE(int) pj_isdigit(unsigned char c) { return isdigit(c); }
76
 
 
77
 
/** 
78
 
 * Returns a non-zero value if c is a particular representation of 
79
 
 * a space character (0x09 - 0x0D or 0x20).
80
 
 * @param c     The integer character to test.
81
 
 * @return      Non-zero value if c is a particular representation of 
82
 
 *              a space character (0x09 - 0x0D or 0x20).
83
 
 */
84
 
PJ_INLINE(int) pj_isspace(unsigned char c) { return isspace(c); }
85
 
 
86
 
/** 
87
 
 * Returns a non-zero value if c is a particular representation of 
88
 
 * a lowercase character.
89
 
 * @param c     The integer character to test.
90
 
 * @return      Non-zero value if c is a particular representation of 
91
 
 *              a lowercase character.
92
 
 */
93
 
PJ_INLINE(int) pj_islower(unsigned char c) { return islower(c); }
94
 
 
95
 
 
96
 
/** 
97
 
 * Returns a non-zero value if c is a particular representation of 
98
 
 * a uppercase character.
99
 
 * @param c     The integer character to test.
100
 
 * @return      Non-zero value if c is a particular representation of 
101
 
 *              a uppercase character.
102
 
 */
103
 
PJ_INLINE(int) pj_isupper(unsigned char c) { return isupper(c); }
104
 
 
105
 
/**
106
 
 * Returns a non-zero value if c is a either a space (' ') or horizontal
107
 
 * tab ('\\t') character.
108
 
 * @param c     The integer character to test.
109
 
 * @return      Non-zero value if c is a either a space (' ') or horizontal
110
 
 *              tab ('\\t') character.
111
 
 */
112
 
PJ_INLINE(int) pj_isblank(unsigned char c) { return isblank(c); }
113
 
 
114
 
/**
115
 
 * Converts character to lowercase.
116
 
 * @param c     The integer character to convert.
117
 
 * @return      Lowercase character of c.
118
 
 */
119
 
PJ_INLINE(int) pj_tolower(unsigned char c) { return tolower(c); }
120
 
 
121
 
/**
122
 
 * Converts character to uppercase.
123
 
 * @param c     The integer character to convert.
124
 
 * @return      Uppercase character of c.
125
 
 */
126
 
PJ_INLINE(int) pj_toupper(unsigned char c) { return toupper(c); }
127
 
 
128
 
/**
129
 
 * Returns a non-zero value if c is a particular representation of 
130
 
 * an hexadecimal digit character.
131
 
 * @param c     The integer character to test.
132
 
 * @return      Non-zero value if c is a particular representation of 
133
 
 *              an hexadecimal digit character.
134
 
 */
135
 
PJ_INLINE(int) pj_isxdigit(unsigned char c){ return isxdigit(c); }
136
 
 
137
 
/**
138
 
 * Array of hex digits, in lowerspace.
139
 
 */
140
 
/*extern char pj_hex_digits[];*/
141
 
#define pj_hex_digits   "0123456789abcdef"
142
 
 
143
 
/**
144
 
 * Convert a value to hex representation.
145
 
 * @param value     Integral value to convert.
146
 
 * @param p         Buffer to hold the hex representation, which must be
147
 
 *                  at least two bytes length.
148
 
 */
149
 
PJ_INLINE(void) pj_val_to_hex_digit(unsigned value, char *p)
150
 
{
151
 
    *p++ = pj_hex_digits[ (value & 0xF0) >> 4 ];
152
 
    *p   = pj_hex_digits[ (value & 0x0F) ];
153
 
}
154
 
 
155
 
/**
156
 
 * Convert hex digit c to integral value.
157
 
 * @param c     The hex digit character.
158
 
 * @return      The integral value between 0 and 15.
159
 
 */
160
 
PJ_INLINE(unsigned) pj_hex_digit_to_val(unsigned char c)
161
 
{
162
 
    if (c <= '9')
163
 
        return (c-'0') & 0x0F;
164
 
    else if (c <= 'F')
165
 
        return  (c-'A'+10) & 0x0F;
166
 
    else
167
 
        return (c-'a'+10) & 0x0F;
168
 
}
169
 
 
170
 
/** @} */
171
 
 
172
 
PJ_END_DECL
173
 
 
174
 
#endif  /* __PJ_CTYPE_H__ */
175