00001 #ifndef __J2K__JString_Function_HPP__
00002 #define __J2K__JString_Function_HPP__
00003
00004 #include <stdio.h>
00005 #include <string.h>
00006 #include <time.h>
00007 #include <ctype.h>
00008
00009 #if defined(__sun) || defined(__SUN__) || defined( linux )
00010
00011 char* strrev( const char* s ) {
00012 if ( s == NULL || *s == '\0' ) return NULL;
00013
00014 size_t len = strlen( s );
00015 size_t i = 0;
00016 size_t j = len;
00017
00018 char* s2 = new char[ len+1 ];
00019
00020 while( i <= len ) {
00021 s2[j] = s[i];
00022 i++;
00023 j--;
00024 }
00025
00026 return s2;
00027 }
00028
00029 char* strupr( const char* s ) {
00030 if ( s == NULL || *s == '\0' ) return NULL;
00031
00032 size_t i = 0;
00033 char* s2 = new char[ strlen(s) + 1 ];
00034
00035 while( s[i] != '\0' ) {
00036 s2[i] = (char)toupper( (int)s[i] );
00037 i++;
00038 }
00039 }
00040
00041 char* strlwr( const char* s ) {
00042 if ( s == NULL || *s == '\0' ) return NULL;
00043
00044 char* s2 = new char[ strlen(s) + 1 ];
00045 size_t i = 0;
00046 while( s[i] != '\0' ) {
00047 s2[i] = (char)tolower( (int)s[i] );
00048 i++;
00049 }
00050 }
00051
00052 char* _strdate( const char* ) {
00053 printf("_strdate() function doesn't exist.");
00054 abort();
00055 }
00056
00057 char* _strtime( const char* ) {
00058 time_t tloc;
00059 time( &tloc );
00060 return asctime( localtime( &tloc ) );
00061 }
00062
00063 char* strnset( const char*, char, size_t ) {
00064 printf("strnset() function doesn't exist.");
00065 abort();
00066 }
00067
00068 #endif
00069
00070 #endif