00001 #include <j2k/Fred/Standard.hpp>
00002 #include <j2k/Fred/String/Str-fn.hpp>
00003
00004 char s[] = { '0', '1', \
00005 'h', 'e', 'l', 'l', 'o', '.', 'h', 'p', 'p', '\0', \
00006 'o', 'c', 't', 'e', 't', '\0', \
00007 'b', 'l', 'k', 's', 'i', 'z', 'e', '\0', \
00008 '2', '0', '4', '8', '\0', \
00009 'w', 's', 'i', 'z', 'e', '\0', \
00010 '7', '\0', 'f', 'r', '\0'
00011 };
00012
00013 char* scanParam( char* s, size_t* len ) {
00014 size_t l = strlen( s );
00015 char* t = s + l + 1;
00016
00017 cout << '[' << s << "]\t\t";
00018 cout << '[' << l << ']' << endl;
00019
00020 *len = l;
00021
00022 return t;
00023 }
00024
00025
00026 char* array[12];
00027 size_t array_sz;
00028
00029 void testParser() {
00030 size_t l = 1;
00031 char* f = s + 2;
00032 char* p = f;
00033 char* q = p;
00034
00035 int k = 0;
00036 while( l != 0 ) {
00037 q = scanParam( p, &l );
00038 array[ k ] = new char[ l ];
00039 memcpy( array[ k++ ], p, l );
00040 p = q;
00041 }
00042 array_sz = k - 1;
00043 }
00044
00045 int select( char** array, size_t i, size_t max )
00046 {
00047 printf( "[%d, %d]", i, max );
00048
00049 char* s2 = strlwr( array[i] );
00050 char* opt = NULL;
00051
00052 if ( (i+1) <= max ) {
00053 opt = strlwr( array[i+1] );
00054 }
00055
00056 if ( !strcmp( s2, "blksize" ) || !strcmp( s2, "blocksize" ) )
00057 {
00058 long bsize = atol( opt );
00059
00060 printf("BlockSize[%d]", bsize );
00061 return 1;
00062 } else
00063 if ( !strcmp( s2, "timeout" ) )
00064 {
00065 size_t t = atol( opt );
00066
00067 printf("Timeout[%d]", t );
00068 return 1;
00069 } else
00070 if ( !strcmp( s2, "tsize" ) )
00071 {
00072 size_t sz = atol( opt );
00073
00074 printf("FileSize[%d]", sz );
00075 return 1;
00076 } else
00077 if ( !strcmp( s2, "wsize" ) || !strcmp( s2, "windowsize" ) )
00078 {
00079 long wsize = atol( opt );
00080
00081 printf("WindowSize[%d]", wsize );
00082 return 1;
00083 }
00084
00085 if ( i == 0 ) {
00086
00087 printf("Filename[%s]", array[i] );
00088 return 0;
00089 }
00090
00091 if ( i == 1 ) {
00092
00093 printf("Mode[%s]", array[i] );
00094 return 0;
00095 }
00096
00097 return 0;
00098 }
00099
00100 void main() {
00101 testParser();
00102 for( int i = 0; i < array_sz; i++ ) {
00103 printf( "\n\t[%s]%d-%d\n", array[i], i, array_sz );
00104 i += select( array, i, array_sz );
00105 }
00106 }