HTTP Parser and message builder / objects in plain C Snapshot
charclass.h
Go to the documentation of this file.
00001 #ifndef __CHARCLASS_H_
00002 #define __CHARCLASS_H_
00003 
00004 #include <cutils/base.h>
00005 
00006 
00007 M_INLINE int is_digit( int8_t ch )
00008 {
00009   return (ch >= '0' && ch <= '9');
00010 }
00011 
00012 M_INLINE int is_upper_case( int8_t ch )
00013 {
00014   return (ch >= 'A' && ch <= 'Z');
00015 }
00016 
00017 M_INLINE int is_hex( int8_t ch ) 
00018 {
00019   return is_digit(ch) || (ch >= 'a' && ch <='f') || (ch >='A' && ch <= 'F');
00020 }
00021 
00022 
00023 M_INLINE int is_hex_ext( int8_t ch ) 
00024 {
00025   if (is_digit(ch)) {
00026     return ch - '0';
00027   }
00028   if ( ch >= 'a' && ch <='f') { 
00029     return ch - 'a';
00030   }
00031   if ( ch >='A' && ch <= 'F') {
00032     return ch - 'A';
00033   }
00034   return 0;
00035 }
00036 
00037 M_INLINE int is_alpha( int8_t ch )
00038 {
00039   return (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z');
00040 }
00041 
00042 M_INLINE int is_alphanum( int8_t ch )
00043 {
00044   return is_alpha( ch ) || is_digit( ch );
00045 }
00046 
00047 
00048 
00049 
00050 #endif
00051 
00052 
00053