]> err.no Git - sope/blob - sope-core/NGStreams/NGStreams/NGUrlChars.h
Drop apache 1 build-dependency
[sope] / sope-core / NGStreams / NGStreams / NGUrlChars.h
1 /*
2   Copyright (C) 2000-2005 SKYRIX Software AG
3
4   This file is part of SOPE.
5
6   SOPE is free software; you can redistribute it and/or modify it under
7   the terms of the GNU Lesser General Public License as published by the
8   Free Software Foundation; either version 2, or (at your option) any
9   later version.
10
11   SOPE is distributed in the hope that it will be useful, but WITHOUT ANY
12   WARRANTY; without even the implied warranty of MERCHANTABILITY or
13   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
14   License for more details.
15
16   You should have received a copy of the GNU Lesser General Public
17   License along with SOPE; see the file COPYING.  If not, write to the
18   Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19   02111-1307, USA.
20 */
21
22 #ifndef __NGStreams_NGUrlChars_H__
23 #define __NGStreams_NGUrlChars_H__
24
25 static inline BOOL isUrlAlpha(unsigned char _c) {
26   return
27     (((_c >= 'a') && (_c <= 'z')) ||
28      ((_c >= 'A') && (_c <= 'Z')))
29     ? YES : NO;
30 }
31 static inline BOOL isUrlDigit(unsigned char _c) {
32   return ((_c >= '0') && (_c <= '9')) ? YES : NO;
33 }
34 static inline BOOL isUrlSafeChar(unsigned char _c) {
35   switch (_c) {
36     case '$': case '-': case '_': case '@':
37     case '.': case '&': case '+':
38       return YES;
39
40     default:
41       return NO;
42   }
43 }
44 static inline BOOL isUrlExtraChar(unsigned char _c) {
45   switch (_c) {
46     case '!': case '*': case '"': case '\'':
47     case '|': case ',':
48       return YES;
49   }
50   return NO;
51 }
52 static inline BOOL isUrlEscapeChar(unsigned char _c) {
53   return (_c == '%') ? YES : NO;
54 }
55 static inline BOOL isUrlReservedChar(unsigned char _c) {
56   switch (_c) {
57     case '=': case ';': case '/':
58     case '#': case '?': case ':':
59     case ' ':
60       return YES;
61   }
62   return NO;
63 }
64
65 static inline BOOL isUrlXalpha(unsigned char _c) {
66   if (isUrlAlpha(_c))      return YES;
67   if (isUrlDigit(_c))      return YES;
68   if (isUrlSafeChar(_c))   return YES;
69   if (isUrlExtraChar(_c))  return YES;
70   if (isUrlEscapeChar(_c)) return YES;
71   return NO;
72 }
73
74 static inline BOOL isUrlHexChar(unsigned char _c) {
75   if (isUrlDigit(_c))
76     return YES;
77   if ((_c >= 'a') && (_c <= 'f'))
78     return YES;
79   if ((_c >= 'A') && (_c <= 'F'))
80     return YES;
81   return NO;
82 }
83
84 static inline BOOL isUrlAlphaNum(unsigned char _c) {
85   return (isUrlAlpha(_c) || isUrlDigit(_c)) ? YES : NO;
86 }
87
88 #endif /* __NGStreams_NGUrlChars_H__ */