aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/optparser.cpp62
-rw-r--r--src/optparser.h1
-rw-r--r--src/string.cpp34
-rw-r--r--src/string.h45
-rw-r--r--src/tests/archive.cpp27
-rw-r--r--src/tests/archive2.cpp102
-rw-r--r--src/tests/atom.cpp32
-rw-r--r--src/tests/buffer.cpp45
-rw-r--r--src/tests/cache.cpp260
-rw-r--r--src/tests/conduit.cpp56
-rw-r--r--src/tests/console.cpp43
-rw-r--r--src/tests/cryptpass.cpp25
-rw-r--r--src/tests/csv.cpp50
-rw-r--r--src/tests/daysinmonth.cpp23
-rw-r--r--src/tests/fastcgi.cpp90
-rw-r--r--src/tests/formula.cpp56
-rw-r--r--src/tests/fstratsptr.cpp53
-rw-r--r--src/tests/fstrstd.cpp16
-rw-r--r--src/tests/hash.cpp31
-rw-r--r--src/tests/hash2.cpp35
-rw-r--r--src/tests/heap.cpp120
-rw-r--r--src/tests/itoheap.cpp70
-rw-r--r--src/tests/itoqueue1.cpp115
-rw-r--r--src/tests/itoqueue2.cpp87
-rw-r--r--src/tests/itoserver.cpp80
-rw-r--r--src/tests/list.cpp77
-rw-r--r--src/tests/list2.cpp26
-rw-r--r--src/tests/listsort.cpp79
-rw-r--r--src/tests/logger.cpp37
-rw-r--r--src/tests/md5.cpp34
-rw-r--r--src/tests/minicron.cpp63
-rw-r--r--src/tests/mmparse.cpp22
-rw-r--r--src/tests/multiserver.cpp76
-rw-r--r--src/tests/procs.cpp37
-rw-r--r--src/tests/queuebuf.cpp66
-rw-r--r--src/tests/regex.cpp38
-rw-r--r--src/tests/ringbuffer.cpp38
-rw-r--r--src/tests/rot13.cpp91
-rw-r--r--src/tests/serverticks.cpp69
-rw-r--r--src/tests/sha1.cpp39
-rw-r--r--src/tests/sharedcore.cpp98
-rw-r--r--src/tests/signals.cpp131
-rw-r--r--src/tests/size.cpp20
-rw-r--r--src/tests/socketblock.cpp56
-rw-r--r--src/tests/socketbreak.cpp35
-rw-r--r--src/tests/speed.cpp58
-rw-r--r--src/tests/stdstream.cpp39
-rw-r--r--src/tests/streamstack.cpp100
-rw-r--r--src/tests/string.cpp154
-rw-r--r--src/tests/stringspeed.cpp122
-rw-r--r--src/tests/tcpsocket.cpp73
-rw-r--r--src/tests/telnetsrv.cpp92
-rw-r--r--src/tests/tracer.cpp36
-rw-r--r--src/tests/udpsocket.cpp86
-rw-r--r--src/tests/url.cpp42
-rw-r--r--src/tests/variant.cpp52
-rw-r--r--src/unit/string.unit159
-rw-r--r--test.taf1381
58 files changed, 1648 insertions, 3436 deletions
diff --git a/src/optparser.cpp b/src/optparser.cpp
index bab93d0..74aba3e 100644
--- a/src/optparser.cpp
+++ b/src/optparser.cpp
@@ -167,6 +167,68 @@ void Bu::OptParser::parse( int argc, char **argv )
167 } 167 }
168} 168}
169 169
170void Bu::OptParser::parse( const Bu::String &sLine )
171{
172 Bu::String sCmd = sLine.clone();
173 int iParams = 0;
174 bool bInGap = true;
175 bool bInQuote = false;
176 for( Bu::String::iterator i = sCmd.begin(); i; i++ )
177 {
178 if( bInQuote == false && (*i == ' ' || *i == '\t') )
179 {
180 if( bInGap == false )
181 {
182 bInGap = true;
183 }
184 }
185 else if( *i == '"' )
186 {
187 bInQuote = !bInQuote;
188 }
189 else
190 {
191 if( bInGap )
192 {
193 iParams++;
194 bInGap = false;
195 }
196 }
197 }
198
199 bInQuote = false;
200 bInGap = true;
201 char **asParam = new char*[iParams];
202 iParams = 0;
203 for( char *i = sCmd.getStr(); *i; i++ )
204 {
205 if( bInQuote == false && (*i == ' ' || *i == '\t') )
206 {
207 if( bInGap == false )
208 {
209 bInGap = true;
210 *i = '\0';
211 }
212 }
213 else if( *i == '"' )
214 {
215 bInQuote = !bInQuote;
216 }
217 else
218 {
219 if( bInGap )
220 {
221 asParam[iParams++] = i;
222 bInGap = false;
223 }
224 }
225 }
226
227 parse( iParams, asParam );
228
229 delete[] asParam;
230}
231
170void Bu::OptParser::addOption( const Option &opt ) 232void Bu::OptParser::addOption( const Option &opt )
171{ 233{
172 lOption.append( opt ); 234 lOption.append( opt );
diff --git a/src/optparser.h b/src/optparser.h
index 2033850..f2fe531 100644
--- a/src/optparser.h
+++ b/src/optparser.h
@@ -133,6 +133,7 @@ namespace Bu
133 virtual ~OptParser(); 133 virtual ~OptParser();
134 134
135 void parse( int argc, char **argv ); 135 void parse( int argc, char **argv );
136 void parse( const Bu::String &sLine );
136 137
137 void addOption( const Option &opt ); 138 void addOption( const Option &opt );
138 139
diff --git a/src/string.cpp b/src/string.cpp
index 5834da1..edc45f9 100644
--- a/src/string.cpp
+++ b/src/string.cpp
@@ -443,7 +443,7 @@ Bu::String Bu::String::replace( const Bu::String &fnd,
443 const_iterator o = begin(); 443 const_iterator o = begin();
444 while( true ) 444 while( true )
445 { 445 {
446 const_iterator i = o.find( fnd ); 446 const_iterator i = o.find( fnd, fnd.getSize() );
447 if( !i ) 447 if( !i )
448 { 448 {
449 out.append( o ); 449 out.append( o );
@@ -994,7 +994,7 @@ Bu::String::const_iterator Bu::String::find( const String &rStr,
994 if( !iStart ) iStart = begin(); 994 if( !iStart ) iStart = begin();
995 for( ; iStart; iStart++ ) 995 for( ; iStart; iStart++ )
996 { 996 {
997 if( iStart.compare( rStr, rStr.getSize() ) ) 997 if( iStart.compare( rStr ) )
998 return iStart; 998 return iStart;
999 } 999 }
1000 return end(); 1000 return end();
@@ -1133,6 +1133,36 @@ void Bu::String::trimBack( long iAmnt )
1133 core->nLength -= iAmnt; 1133 core->nLength -= iAmnt;
1134} 1134}
1135 1135
1136Bu::String Bu::String::trimWhitespace() const
1137{
1138 if( core->nLength == 0 )
1139 return "";
1140 const_iterator i = begin();
1141 for( ; i && (*i == ' ' || *i == '\t' || *i == '\n' || *i == '\r'); i++ ) { }
1142 if( !i )
1143 return "";
1144
1145 const_iterator e = i;
1146 for( ; e; e++ )
1147 {
1148 if( *e == ' ' || *e == '\t' || *e == '\n' || *e == '\r' )
1149 {
1150 const_iterator t = e;
1151 for( ; t && (*t == ' ' || *t == '\t' || *t == '\n' || *t == '\r'); t++ ) { }
1152 if( t )
1153 {
1154 e = t;
1155 }
1156 else
1157 {
1158 break;
1159 }
1160 }
1161 }
1162
1163 return Bu::String( i, e );
1164}
1165
1136Bu::String::iterator Bu::String::begin() 1166Bu::String::iterator Bu::String::begin()
1137{ 1167{
1138 if( core->nLength == 0 ) 1168 if( core->nLength == 0 )
diff --git a/src/string.h b/src/string.h
index 3ac161b..2874e37 100644
--- a/src/string.h
+++ b/src/string.h
@@ -117,6 +117,13 @@ namespace Bu
117 iPos = i.iPos; 117 iPos = i.iPos;
118 return *this; 118 return *this;
119 } 119 }
120
121 const_iterator &operator=( const iterator &i )
122 {
123 pChunk = i.pChunk;
124 iPos = i.iPos;
125 return *this;
126 }
120 127
121 const_iterator &operator++() 128 const_iterator &operator++()
122 { 129 {
@@ -203,7 +210,8 @@ namespace Bu
203 if( *a != *b ) 210 if( *a != *b )
204 return false; 211 return false;
205 } 212 }
206 213 if( (bool)a != (bool)b )
214 return false;
207 return true; 215 return true;
208 } 216 }
209 217
@@ -213,14 +221,11 @@ namespace Bu
213 const_iterator b = c; 221 const_iterator b = c;
214 if( a == b ) 222 if( a == b )
215 return true; 223 return true;
216 int j; 224 for(int j = 0; j < nLen; a++, b++, j++ )
217 for( j = 0; a && b && j < nLen; a++, b++, j++ )
218 { 225 {
219 if( *a != *b ) 226 if( !a || !b || *a != *b )
220 return false; 227 return false;
221 } 228 }
222 if( j < nLen )
223 return false;
224 return true; 229 return true;
225 } 230 }
226 231
@@ -256,7 +261,7 @@ namespace Bu
256 bool compare( const String &s ) const 261 bool compare( const String &s ) const
257 { 262 {
258 if( !pChunk ) return false; 263 if( !pChunk ) return false;
259 return compare( s.begin(), s.getSize() ); 264 return compare( s.begin() );
260 } 265 }
261 266
262 bool compare( const String &s, int nLen ) const 267 bool compare( const String &s, int nLen ) const
@@ -442,10 +447,10 @@ namespace Bu
442 return pChunk != NULL; 447 return pChunk != NULL;
443 } 448 }
444 449
445 bool compare( const iterator &c ) const 450 bool compare( const const_iterator &c ) const
446 { 451 {
447 iterator a = *this; 452 const_iterator a( *this );
448 iterator b = c; 453 const_iterator b = c;
449 if( a == b ) 454 if( a == b )
450 return true; 455 return true;
451 for(; a && b; a++, b++ ) 456 for(; a && b; a++, b++ )
@@ -453,23 +458,22 @@ namespace Bu
453 if( *a != *b ) 458 if( *a != *b )
454 return false; 459 return false;
455 } 460 }
461 if( (bool)a != (bool)b )
462 return false;
456 return true; 463 return true;
457 } 464 }
458 465
459 bool compare( const iterator &c, int nLen ) const 466 bool compare( const const_iterator &c, int nLen ) const
460 { 467 {
461 iterator a = *this; 468 const_iterator a( *this );
462 iterator b = c; 469 const_iterator b = c;
463 if( a == b ) 470 if( a == b )
464 return true; 471 return true;
465 int j; 472 for(int j = 0; j < nLen; a++, b++, j++ )
466 for( j = 0; a && b && j < nLen; a++, b++, j++ )
467 { 473 {
468 if( *a != *b ) 474 if( !a || !b || *a != *b )
469 return false; 475 return false;
470 } 476 }
471 if( j < nLen )
472 return false;
473 return true; 477 return true;
474 } 478 }
475 479
@@ -505,7 +509,7 @@ namespace Bu
505 bool compare( const String &s ) const 509 bool compare( const String &s ) const
506 { 510 {
507 if( !pChunk ) return false; 511 if( !pChunk ) return false;
508 return compare( s.begin(), s.getSize() ); 512 return compare( s.begin() );
509 } 513 }
510 514
511 bool compare( const String &s, int nLen ) const 515 bool compare( const String &s, int nLen ) const
@@ -924,8 +928,9 @@ namespace Bu
924 */ 928 */
925 void trimFront( long nAmnt ); 929 void trimFront( long nAmnt );
926 930
927 // void trimBack( char c );
928 void trimBack( long iAmnt ); 931 void trimBack( long iAmnt );
932
933 Bu::String trimWhitespace() const;
929 934
930 iterator begin(); 935 iterator begin();
931 936
diff --git a/src/tests/archive.cpp b/src/tests/archive.cpp
deleted file mode 100644
index c905007..0000000
--- a/src/tests/archive.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include "bu/archive.h"
9#include "bu/file.h"
10#include "bu/string.h"
11
12using namespace Bu;
13
14int main()
15{
16 File f("test.dat", File::WriteNew );
17 Archive ar( f, Archive::save );
18
19 Bu::String s("Hello there");
20 ar << s;
21
22 ar.setProp("hi", 45 );
23 printf("Hi: %d", ar.getProp<int>("hi") );
24
25 return 0;
26}
27
diff --git a/src/tests/archive2.cpp b/src/tests/archive2.cpp
deleted file mode 100644
index e8d3360..0000000
--- a/src/tests/archive2.cpp
+++ /dev/null
@@ -1,102 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include "bu/archive.h"
9#include "bu/archival.h"
10#include "bu/file.h"
11
12int giId = 0;
13
14class A : public Bu::Archival
15{
16public:
17 A() :
18 iId( giId++ )
19 {
20 }
21
22 virtual ~A()
23 {
24 }
25
26 virtual void archive( Bu::ArchiveBase &ar )
27 {
28 ar && iId;
29 }
30
31 int iId;
32};
33
34class B : public Bu::Archival
35{
36public:
37 B() :
38 iId( giId++ ),
39 a1( new A ),
40 a2( new A )
41 {
42 }
43
44 virtual ~B()
45 {
46 delete a1;
47 delete a2;
48 }
49
50 virtual void archive( Bu::ArchiveBase &ar )
51 {
52 //ar && iId && a1 && a2;
53 ar << iId << a1 << a2;
54 }
55
56 int iId;
57 A *a1, *a2;
58};
59
60class C : public Bu::Archival
61{
62public:
63 C() :
64 iId( giId++ ),
65 a( new A ),
66 b( new B )
67 {
68 }
69
70 virtual ~C()
71 {
72 delete a;
73 delete b;
74 }
75
76 virtual void archive( Bu::ArchiveBase &ar )
77 {
78 //ar && iId && a && b;
79 ar << iId;
80 ar << a << b;
81 }
82
83 int iId;
84 A *a;
85 B *b;
86};
87
88void write()
89{
90 C *c = new C;
91
92 Bu::File f( "test.archive", Bu::File::Write );
93 Bu::Archive ar( f, Bu::Archive::save );
94 ar << c;
95}
96
97int main()
98{
99 write();
100
101}
102
diff --git a/src/tests/atom.cpp b/src/tests/atom.cpp
deleted file mode 100644
index 7808282..0000000
--- a/src/tests/atom.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include "bu/atom.h"
9#include <stdio.h>
10#include <stdlib.h>
11
12typedef struct bob
13{
14 int a, b;
15} bob;
16int main()
17{
18 Bu::Atom<int> aInt;
19 Bu::Atom<const char *> aStr;
20 Bu::Atom<bob> aBob;
21
22 aBob = bob();
23 aBob->a = 5;
24
25 aStr.set("Hey there, dude");
26 aInt.set( 55 );
27 int me = aInt;
28 aInt = 12;
29 printf("%d, %d\n", aInt.get(), me );
30 printf("%s\n", aStr.get() );
31}
32
diff --git a/src/tests/buffer.cpp b/src/tests/buffer.cpp
deleted file mode 100644
index f3f6f41..0000000
--- a/src/tests/buffer.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include "bu/membuf.h"
9#include "bu/buffer.h"
10#include "bu/file.h"
11
12using namespace Bu;
13
14int main( int argc, char *argv[] )
15{
16 argc--,argv++;
17 if( argc == 0 )
18 {
19 MemBuf mOut;
20 Buffer bOut( mOut, 10 );
21
22 for( int j = 0; j < 4; j++ )
23 bOut.write("hi ", 3 );
24
25 printf("Preflush: \"%s\"\n", mOut.getString().getStr() );
26 bOut.flush();
27
28 printf("Final: \"%s\"\n", mOut.getString().getStr() );
29 }
30 else
31 {
32 File fIn( *argv, File::Read );
33 Buffer bIn( fIn, 10 );
34
35 char buf[5];
36 for( int j = 0; j < 5; j++ )
37 {
38 buf[bIn.read( buf, 4 )] = '\0';
39 printf("Four chars: \"%s\"\n", buf );
40 }
41 }
42
43 return 0;
44}
45
diff --git a/src/tests/cache.cpp b/src/tests/cache.cpp
deleted file mode 100644
index e9dbd86..0000000
--- a/src/tests/cache.cpp
+++ /dev/null
@@ -1,260 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include <stdio.h>
9#include <stdlib.h>
10#include <sys/stat.h>
11#include <sys/types.h>
12#include <errno.h>
13#include <unistd.h>
14
15#include "bu/cache.h"
16#include "bu/file.h"
17#include "bu/string.h"
18#include "bu/cachecalc.h"
19
20class Bob
21{
22public:
23 Bob()
24 {
25 TRACE();
26 }
27
28 Bob( int i ) :
29 iInt( i )
30 {
31 TRACE( i );
32 }
33
34 virtual ~Bob()
35 {
36 TRACE();
37 }
38
39 void setInt( int i )
40 {
41 TRACE( i );
42 iInt = i;
43 }
44
45 long getKey() const
46 {
47 TRACE( i );
48 return iInt;
49 }
50
51 int getInt()
52 {
53 return iInt;
54 }
55
56 int iInt;
57};
58
59namespace Bu {
60 template<>
61 void __tracer_format<Bob*>( Bob* const &c )
62 {
63 printf("%08X=%d", (uint32_t)c, c->getInt() );
64 }
65}
66
67class BobStore : public Bu::CacheStore<long, Bob>
68{
69public:
70 BobStore() :
71 cLastId( 0 )
72 {
73 TRACE();
74 if( access( "bobcache/last", R_OK|W_OK ) )
75 {
76 mkdir("bobcache", 0755 );
77 Bu::File f("bobcache/last", Bu::File::Write|Bu::File::Create );
78 f.write("0", 1);
79 printf("Initializing cache: %s\n", strerror( errno ) );
80 }
81 else
82 {
83 cLastId = readNum("bobcache/last");
84 }
85 }
86
87 ~BobStore()
88 {
89 TRACE();
90 writeNum("bobcache/last", cLastId );
91 }
92
93 long readNum( const Bu::String &sFile )
94 {
95 TRACE( sFile );
96 Bu::File f( sFile, Bu::File::Read );
97 char buf[80];
98 buf[f.read( buf, 80 )] = '\0';
99 return strtol( buf, NULL, 0 );
100 }
101
102 void writeNum( const Bu::String &sFile, long num )
103 {
104 TRACE( sFile, num );
105 Bu::File f( sFile,
106 Bu::File::Write|Bu::File::Create|Bu::File::Truncate
107 );
108 f.write( Bu::String("%1").arg( num ) );
109 }
110
111 virtual void sync( Bob *, const long & )
112 {
113 }
114
115 virtual void sync()
116 {
117 }
118
119 virtual bool has( const long & )
120 {
121 return true;
122 }
123
124 virtual Bob *load( const long &key )
125 {
126 TRACE( key );
127 Bu::String sDest = Bu::String("bobcache/%1").arg( key );
128 return new Bob( readNum( sDest ) );
129 }
130
131 virtual void unload( Bob *pObj, const long &key )
132 {
133 TRACE( pObj, key );
134 Bu::String sDest = Bu::String("bobcache/%1").arg( key );
135 writeNum( sDest, pObj->getInt() );
136 delete pObj;
137 }
138
139 virtual long create( Bob *rSrc )
140 {
141 TRACE( rSrc );
142 long id = ++cLastId;
143 Bu::String sDest = Bu::String("bobcache/%1").arg( id );
144 writeNum( sDest, rSrc->getInt() );
145 return id;
146 }
147
148 virtual void destroy( Bob *pObj, const long &key )
149 {
150 TRACE( pObj, key );
151 Bu::String sDest = Bu::String("bobcache/%1").arg( key );
152 if( !access( sDest.getStr(), F_OK ) )
153 unlink( sDest.getStr() );
154 delete pObj;
155 }
156
157 virtual void destroy( const long &key )
158 {
159 TRACE( pObj, key );
160 Bu::String sDest = Bu::String("bobcache/%1").arg( key );
161 if( !access( sDest.getStr(), F_OK ) )
162 unlink( sDest.getStr() );
163 }
164
165private:
166 long cLastId;
167};
168
169class BobCalc : public Bu::CacheCalc<long, Bob>
170{
171public:
172 BobCalc()
173 {
174 }
175
176 virtual ~BobCalc()
177 {
178 }
179
180 virtual void onLoad( Bob *, const long & )
181 {
182 }
183
184 virtual void onUnload( Bob *, const long & )
185 {
186 }
187
188 virtual void onDestroy( Bob *, const long & )
189 {
190 }
191
192 virtual void onDestroy( const long & )
193 {
194 }
195
196 virtual bool shouldSync( Bob *, const long &, time_t )
197 {
198 return false;
199 }
200
201private:
202
203};
204
205int main( int argc, char *argv[] )
206{
207 TRACE( argc, argv );
208 typedef Bu::Cache<long, Bob> BobCache;
209 typedef BobCache::Ptr BobPtr;
210
211 if( argc < 3 )
212 {
213 printf("Try: %s [crudl] [<id/value>]\n\n", argv[0] );
214 return 0;
215 }
216
217 BobCache cBob( new BobCalc(), new BobStore() );
218 switch( argv[1][0] )
219 {
220 case 'c':
221 {
222 BobCache::Ptr pBob = cBob.insert(
223 new Bob( strtol( argv[2], NULL, 0 ) )
224 );
225 printf("Key = %ld\n", pBob.getKey() );
226 }
227 return 0;
228
229 case 'r':
230 {
231 BobCache::Ptr pBob = cBob.get( strtol( argv[2], NULL, 0 ) );
232 printf("Value = %d\n", pBob->getInt() );
233 }
234 return 0;
235
236 case 'u':
237 {
238 BobCache::Ptr pBob = cBob.get( strtol( argv[2], NULL, 0 ) );
239 pBob->setInt( strtol( argv[3], NULL, 0 ) );
240 }
241 return 0;
242
243 case 'd':
244 {
245 cBob.erase( strtol( argv[2], NULL, 0 ) );
246 }
247 return 0;
248
249 case 'l':
250 {
251 BobCache::Ptr pBob = cBob.getLazy( strtol( argv[2], NULL, 0 ) );
252 printf("isBound: %s\n", pBob.isBound()?"yes":"no");
253 printf("Value = %d\n", pBob->getInt() );
254 printf("isBound: %s\n", pBob.isBound()?"yes":"no");
255 }
256 return 0;
257 }
258
259}
260
diff --git a/src/tests/conduit.cpp b/src/tests/conduit.cpp
deleted file mode 100644
index d8d9e03..0000000
--- a/src/tests/conduit.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
1#include "bu/conduit.h"
2#include "bu/sio.h"
3#include "bu/ito.h"
4
5using namespace Bu;
6
7class Reader : public Bu::Ito
8{
9public:
10 Reader( Bu::Conduit &rCond ) :
11 rCond( rCond )
12 {
13 }
14
15 virtual ~Reader()
16 {
17 }
18
19protected:
20 virtual void run()
21 {
22 while( rCond.isOpen() )
23 {
24 char buf[1025];
25
26 sio << "Reading..." << sio.flush;
27 Bu::size iRead = rCond.read( buf, 1024 );
28 buf[iRead] = '\0';
29 sio << "got " << iRead << " >" << buf << "<" << sio.nl;
30 }
31
32 sio << "Conduit closed, exting thread." << sio.nl;
33 }
34
35private:
36 Bu::Conduit &rCond;
37};
38
39int main()
40{
41 Conduit c;
42 Reader r( c );
43 r.start();
44
45 sleep( 3 );
46 c.write("Hi there", 8 );
47 sleep( 3 );
48 c.write("Goodbye, soon.", 14 );
49 sleep( 3 );
50 c.write("...NOW!", 9 );
51 c.close();
52 sleep( 3 );
53
54 return 0;
55}
56
diff --git a/src/tests/console.cpp b/src/tests/console.cpp
deleted file mode 100644
index 670ff5b..0000000
--- a/src/tests/console.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include <bu/sio.h>
9using namespace Bu;
10
11#include <iostream>
12using namespace std;
13
14typedef struct Counter
15{
16 Counter() : i( 0 )
17 {
18 }
19
20 int get()
21 {
22 i++;
23 return i-1;
24 }
25
26 int i;
27} Counter;
28
29template<typename a>
30void runtest( a &out )
31{
32 Counter c;
33 out << c.get() << ", " << c.get() << ", " << c.get() << ", " << c.get() << ", " << c.get() << "\n";
34}
35
36int main()
37{
38 runtest( cout );
39 runtest( sio );
40
41 return 0;
42}
43
diff --git a/src/tests/cryptpass.cpp b/src/tests/cryptpass.cpp
deleted file mode 100644
index d272344..0000000
--- a/src/tests/cryptpass.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include "bu/crypt.h"
9#include "bu/sio.h"
10
11using namespace Bu;
12
13int main( int argc, char *argv[] )
14{
15 if( argc == 1 )
16 sio << "Syntax: " << argv[0] << " <password> [salt]" << sio.nl
17 << sio.nl;
18 else if( argc == 2 )
19 sio << "Crypt1: >> " << cryptPass( argv[1] ) << " <<" << sio.nl;
20 else
21 sio << "Crypt2: >> " << cryptPass( argv[1], argv[2] ) << " <<" << sio.nl;
22
23 return 0;
24}
25
diff --git a/src/tests/csv.cpp b/src/tests/csv.cpp
deleted file mode 100644
index 850fda8..0000000
--- a/src/tests/csv.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include "bu/optparser.h"
9#include "bu/file.h"
10#include "bu/newline.h"
11#include "bu/csvreader.h"
12#include "bu/buffer.h"
13#include "bu/sio.h"
14
15using namespace Bu;
16
17class Options : public OptParser
18{
19public:
20 Options( int argc, char *argv[] )
21 {
22 addOption( slot( this, &Options::onRead ), 'r', "read",
23 "Read and display a csv file." );
24
25 addHelpOption();
26
27 parse( argc, argv );
28 }
29
30 int onRead( StrArray aArgs )
31 {
32 File fIn( aArgs[1], File::Read );
33 NewLine nlIn( fIn );
34 Buffer bIn( nlIn );
35 CsvReader rCsv( bIn );
36 while( !fIn.isEos() )
37 {
38 sio << rCsv.readLine() << sio.nl;
39 }
40 sio << sio.nl;
41 return 1;
42 }
43};
44
45int main( int argc, char *argv[] )
46{
47 Options opts( argc, argv );
48 return 0;
49}
50
diff --git a/src/tests/daysinmonth.cpp b/src/tests/daysinmonth.cpp
deleted file mode 100644
index 1e78eb3..0000000
--- a/src/tests/daysinmonth.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include "bu/sio.h"
9#include "bu/util.h"
10
11using namespace Bu;
12
13int main()
14{
15 for( int j = 0; j < 12; j++ )
16 {
17 sio << "2012-" << j << " = "
18 << getDaysInMonth( j, 2012 ) << sio.nl;
19 }
20
21 return 0;
22}
23
diff --git a/src/tests/fastcgi.cpp b/src/tests/fastcgi.cpp
deleted file mode 100644
index 7447a6f..0000000
--- a/src/tests/fastcgi.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include "bu/fastcgi.h"
9
10#include <unistd.h>
11
12class Cgi : public Bu::FastCgi
13{
14public:
15 Cgi() :
16 Bu::FastCgi::FastCgi()
17 {
18 }
19
20 Cgi( int iPort ) :
21 Bu::FastCgi::FastCgi( iPort )
22 {
23 }
24
25 virtual ~Cgi()
26 {
27 }
28
29 virtual int onRequest( const StrHash &hParams,
30 const Bu::String &sStdIn, Bu::Stream &sStdOut,
31 Bu::Stream &/*sStdErr*/ )
32 {
33 Bu::String sOut("Content-Type: text/html\r\n\r\n");
34 sOut += "<html><body><h1>Environment:</h1><ul>";
35 for( StrHash::const_iterator i = hParams.begin(); i; i++ )
36 {
37 sOut += "<li>" + i.getKey() + " = " +
38 i.getValue() + "</li>";
39 }
40 sOut += "</ul>";
41 char buf[2048];
42 sOut += "<h1>Cwd:</h1><ul><li>";
43 sOut += getcwd( buf, 2048 );
44 sOut += "</li></ul>";
45 sOut += "<h1>Stdin:</h1>";
46 sOut += Bu::String("%1 bytes<pre>").arg( sStdIn.getSize() );
47 Bu::String sL, sR;
48 for( Bu::String::const_iterator i = sStdIn.begin();
49 i; i++ )
50 {
51 sL += Bu::String("%1").arg(
52 (unsigned int)((unsigned char)*i), Bu::Fmt::hex().width(2).fill('0') );
53 if( *i < 27 )
54 sR += ". ";
55 else
56 sR += Bu::String("&#%1; ").arg(
57 (unsigned int)((unsigned char)*i) );
58 if( sL.getSize()/3 == 8 )
59 {
60 sOut += sL + " | " + sR + "\n";
61 sL = sR = "";
62 }
63 }
64 if( sL != "" )
65 {
66 while( sL.getSize()/3 < 8 )
67 sL += " ";
68 sOut += sL + " | " + sR + "\n";
69 }
70 sOut += "</pre><hr/><pre>";
71 sOut += sStdIn;
72 sOut += "</pre>";
73 sOut += "<form method=\"post\" enctype=\"multipart/form-data\"><textarea name=\"bob\"></textarea><br /><input type=\"file\" name=\"somefile\" /><br /><input type=\"submit\" name=\"yeah\" value=\"try it\" /></form>";
74 sOut += "</body></html>";
75
76 sStdOut.write( sOut );
77
78 return 0;
79 }
80};
81
82int main()
83{
84 Cgi c( 8789 );
85
86 c.run();
87
88 return 0;
89}
90
diff --git a/src/tests/formula.cpp b/src/tests/formula.cpp
deleted file mode 100644
index a90ddaf..0000000
--- a/src/tests/formula.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include "bu/formula.h"
9#include <math.h>
10
11int main( int argc, char *argv[] )
12{
13 if( argc < 2 )
14 {
15 printf("usage: %s <formula>\n", argv[0] );
16 return -1;
17 }
18 Bu::Formula<uint32_t> uForm;
19 Bu::Formula<double> dForm;
20
21 class DblCeilFunc : public Bu::Formula<double>::Func
22 {
23 public:
24 virtual double operator()( double x )
25 {
26 return ceil( x );
27 }
28 };
29
30 dForm.hFunc.insert( "ceil", new DblCeilFunc() );
31
32 class IntCeilFunc : public Bu::Formula<uint32_t>::Func
33 {
34 public:
35 virtual uint32_t operator()( uint32_t x )
36 {
37 return x;
38 }
39 };
40
41 uForm.hFunc.insert( "ceil", new IntCeilFunc() );
42
43 uForm.hVars.insert("x", 10 );
44 dForm.hVars.insert("x", 10.00 );
45 uForm.hVars.insert("y", 10 );
46 dForm.hVars.insert("y", 10.00 );
47
48 for( int j = 1; j < argc; j++ )
49 {
50 printf("u: %s = %u\n", argv[j], uForm.run( argv[j] ) );
51 printf("d: %s = %f\n", argv[j], dForm.run( argv[j] ) );
52 }
53
54 return 0;
55}
56
diff --git a/src/tests/fstratsptr.cpp b/src/tests/fstratsptr.cpp
deleted file mode 100644
index 5053dd1..0000000
--- a/src/tests/fstratsptr.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include "bu/string.h"
9#include "bu/atom.h"
10#include "bu/sptr.h"
11
12class Person
13{
14public:
15 Person(){};
16 virtual ~Person(){};
17
18 Bu::Atom<Bu::String> sFirstName;
19 Bu::Atom<Bu::String> sLastName;
20};
21
22typedef Bu::SPtr<Person> PersonPtr;
23
24void Swap(PersonPtr one, PersonPtr two)
25{
26 PersonPtr three(new Person);
27 three->sFirstName = one->sFirstName;
28 three->sLastName = two->sLastName;
29
30 printf(
31 "%s %s\n",
32 three->sFirstName->getStr(),
33 three->sLastName->getStr() );
34}
35
36int main()
37{
38/* PersonPtr one(new Person);
39 PersonPtr two(new Person);
40 one->sFirstName = "Bob";
41 one->sLastName = "Smith";
42 two->sFirstName = "Fred";
43 two->sLastName = "Carpenter";
44
45 Swap(one, two);
46*/
47
48 Bu::Atom<Bu::String> sOne, sTwo;
49 sOne = "Hello";
50 sTwo = sOne;
51
52 return 0;
53}
diff --git a/src/tests/fstrstd.cpp b/src/tests/fstrstd.cpp
deleted file mode 100644
index b2fed8a..0000000
--- a/src/tests/fstrstd.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include <iostream>
9#include "bu/string.h"
10
11int main()
12{
13 Bu::String s("Hey there, dude.\n");
14
15// std::cout << s << 5;
16}
diff --git a/src/tests/hash.cpp b/src/tests/hash.cpp
deleted file mode 100644
index 7cefb79..0000000
--- a/src/tests/hash.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include "bu/hash.h"
9#include "bu/sptr.h"
10
11typedef struct Bob
12{
13 int nID;
14} Bob;
15
16int main()
17{
18 Bu::Hash<int, Bu::SPtr<const Bob> > lb;
19 for( int j = 0; j < 10; j++ )
20 {
21 Bob *b = new Bob;
22 b->nID = j;
23 lb.insert( j, b );
24 }
25
26 for( int j = 0; j < 10; j++ )
27 {
28 printf("%d\n", lb[j].getValue()->nID );
29 }
30}
31
diff --git a/src/tests/hash2.cpp b/src/tests/hash2.cpp
deleted file mode 100644
index 55bb4c9..0000000
--- a/src/tests/hash2.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include <bu/string.h>
9#include <bu/hash.h>
10
11int main()
12{
13 Bu::Hash<Bu::String, int> hCmd;
14
15 hCmd.insert("help", 5 );
16 hCmd.insert("exit", 5 );
17 hCmd.insert("getkey", 5 );
18 hCmd.insert("setcrypt", 5 );
19 hCmd.insert("user", 5 );
20 hCmd.insert("pass", 5 );
21 hCmd.erase("getkey");
22 hCmd.erase("setcrypt");
23 hCmd.insert("user", 5 );
24 hCmd.insert("pass", 5 );
25 hCmd.erase("pass");
26 hCmd.erase("user");
27 hCmd.insert("acl", 5 );
28 hCmd.insert("owner", 5 );
29 hCmd.insert("operator", 5 );
30 hCmd.insert("admin", 5 );
31 hCmd.insert("monitor", 5 );
32 hCmd.insert("shutdown", 5 );
33
34 return 0;
35}
diff --git a/src/tests/heap.cpp b/src/tests/heap.cpp
deleted file mode 100644
index 520a57f..0000000
--- a/src/tests/heap.cpp
+++ /dev/null
@@ -1,120 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include <stdlib.h>
9#include <stdio.h>
10
11#include "bu/formatter.h"
12#include "bu/heap.h"
13#include "bu/string.h"
14#include "bu/file.h"
15
16typedef struct num
17{
18 num( int iNum, int iOrder ) : iNum( iNum ), iOrder( iOrder )
19 {
20 }
21
22 num( const num &src ) : iNum( src.iNum ), iOrder( src.iOrder )
23 {
24 }
25
26 int iNum;
27 int iOrder;
28
29 bool operator<( const num &oth ) const
30 {
31 if( iNum == oth.iNum )
32 return iOrder < oth.iOrder;
33 return iNum < oth.iNum;
34 }
35 bool operator>( const num &oth ) const
36 {
37 return iNum > oth.iNum;
38 }
39} num;
40
41void printHeap( Bu::Heap<Bu::String> &h, int j )
42{
43// return;
44 Bu::String sFName = Bu::String("graph-step-%1.dot").arg( j, Bu::Fmt().width(2).fill('0') );
45 Bu::File fOut( sFName, Bu::File::WriteNew );
46 Bu::Formatter f( fOut );
47 f << "Graph step: " << j << ", total size: " << h.getSize() << f.nl;
48 for( Bu::Heap<Bu::String>::iterator i = h.begin(); i; i++ )
49 {
50 f << *i << f.nl;
51 }
52 f << f.nl;
53}
54
55int main()
56{
57 /*
58 Bu::Heap<num> hNum;
59
60 for( int j = 0; j < 30; j++ )
61 {
62 int r = rand()%10;
63 printf("Pushing: %d, top: ", r );
64 hNum.enqueue( num( r, j ) );
65 printf("%d\n", hNum.peek().iNum );
66 }
67
68 while( !hNum.isEmpty() )
69 {
70 printf("(%d:%d) ", hNum.peek().iOrder, hNum.peek().iNum );
71 hNum.dequeue();
72 }
73 printf("\n");
74*/
75 Bu::Heap<Bu::String> hStr;
76 int j = 0;
77
78 hStr.enqueue("George");
79 printHeap( hStr, j++ );
80 hStr.enqueue("George");
81 printHeap( hStr, j++ );
82 hStr.enqueue("Sam");
83 printHeap( hStr, j++ );
84 hStr.enqueue("Abby");
85 printHeap( hStr, j++ );
86 hStr.enqueue("Zorro");
87 printHeap( hStr, j++ );
88 hStr.enqueue("Brianna");
89 printHeap( hStr, j++ );
90 hStr.enqueue("Kate");
91 printHeap( hStr, j++ );
92 hStr.enqueue("Soggy");
93 printHeap( hStr, j++ );
94
95 while( !hStr.isEmpty() )
96 {
97 printf("\"%s\" ", hStr.dequeue().getStr() );
98 printHeap( hStr, j++ );
99 }
100 printf("\n");
101
102 Bu::List<Bu::String> lStr;
103
104 lStr.insertSorted("George");
105 lStr.insertSorted("George");
106 lStr.insertSorted("Sam");
107 lStr.insertSorted("Abby");
108 lStr.insertSorted("Zorro");
109 lStr.insertSorted("Brianna");
110 lStr.insertSorted("Kate");
111 lStr.insertSorted("Soggy");
112 for( Bu::List<Bu::String>::iterator i = lStr.begin(); i; i++ )
113 {
114 printf("\"%s\" ", (*i).getStr() );
115 }
116 printf("\n");
117
118 return 0;
119}
120
diff --git a/src/tests/itoheap.cpp b/src/tests/itoheap.cpp
deleted file mode 100644
index ec06b90..0000000
--- a/src/tests/itoheap.cpp
+++ /dev/null
@@ -1,70 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include <stdio.h>
9#include <stdlib.h>
10#include <unistd.h>
11
12#include "bu/itoheap.h"
13#include "bu/ito.h"
14
15class Consumer : public Bu::Ito
16{
17public:
18 Consumer()
19 {
20 }
21
22 virtual ~Consumer()
23 {
24 }
25
26 void run()
27 {
28 for( int j = 0; j < 10; j++ )
29 {
30 printf("Trying to read [%d].\n", j );
31
32 try
33 {
34 int iNum = hInt.dequeue( 0, 500000 );
35 printf("Read %d\n", iNum );
36 }
37 catch( Bu::HeapException &e )
38 {
39 printf("Nothing yet...\n");
40 }
41 }
42 }
43
44 Bu::ItoHeap<int> hInt;
45};
46
47
48int main()
49{
50 Consumer c;
51
52 for( int j = 0; j < 3; j++ )
53 {
54 int iNum = rand()%10;
55 printf("Enqueuing %d.\n", iNum );
56 c.hInt.enqueue( iNum );
57 }
58
59 printf("Sarting consumer.\n");
60 c.start();
61
62 for( int j = 0; j < 5; j++ )
63 {
64 sleep( 1 );
65 int iNum = rand()%10;
66 printf("Enqueuing %d.\n", iNum );
67 c.hInt.enqueue( iNum );
68 }
69}
70
diff --git a/src/tests/itoqueue1.cpp b/src/tests/itoqueue1.cpp
deleted file mode 100644
index 27cb93c..0000000
--- a/src/tests/itoqueue1.cpp
+++ /dev/null
@@ -1,115 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include <string>
9#include "bu/ito.h"
10#include "bu/itoqueue.h"
11#include <stdlib.h>
12#include <stdio.h>
13
14class Reader : public Bu::Ito
15{
16public:
17 Reader( Bu::ItoQueue<std::string *> &q, int id ) :
18 q( q ),
19 id( id )
20 {
21 }
22
23 void run()
24 {
25 for( int i = 0; i < 10; i++ )
26 {
27 std::string *pStr = q.dequeue( true );
28 if( pStr == NULL )
29 {
30 printf("Null received...\n");
31 }
32 else
33 {
34 printf("[%d] read: %s\n", id, pStr->c_str() );
35 delete pStr;
36 }
37 usleep( (int)(((double)rand())/((double)RAND_MAX)*2000000.0) );
38 }
39 }
40
41private:
42 Bu::ItoQueue<std::string *> &q;
43 int id;
44};
45
46class Writer : public Bu::Ito
47{
48public:
49 Writer( Bu::ItoQueue<std::string *> &q, int id, const char *strbase ) :
50 q( q ),
51 strbase( strbase ),
52 id( id )
53 {
54 }
55
56 void run()
57 {
58 for( int i = 0; i < 11; i++ )
59 {
60 usleep( (int)(((double)rand())/((double)RAND_MAX)*2000000.0) );
61 q.enqueue( new std::string( strbase ) );
62 printf("[%d] write: %s\n", id, strbase );
63 }
64 }
65
66private:
67 Bu::ItoQueue<std::string *> &q;
68 const char *strbase;
69 int id;
70};
71
72int main()
73{
74 Writer *wr[5];
75 Reader *rd[5];
76 const char bob[][7]={
77 {"Test 1"},
78 {"Test 2"},
79 {"Test 3"},
80 {"Test 4"},
81 {"Test 5"}
82 };
83
84 Bu::ItoQueue<std::string *> q;
85
86 for( int j = 0; j < 5; j++ )
87 {
88 wr[j] = new Writer( q, j, bob[j] );
89 rd[j] = new Reader( q, j );
90 }
91
92 for( int j = 0; j < 5; j++ )
93 {
94 rd[j]->start();
95 }
96
97 for( int j = 0; j < 5; j++ )
98 {
99 wr[j]->start();
100 }
101
102 for( int j = 0; j < 5; j++ )
103 {
104 rd[j]->join();
105 }
106
107 for( int j = 0; j < 5; j++ )
108 {
109 delete wr[j];
110 delete rd[j];
111 }
112
113 return 0;
114}
115
diff --git a/src/tests/itoqueue2.cpp b/src/tests/itoqueue2.cpp
deleted file mode 100644
index 10bc566..0000000
--- a/src/tests/itoqueue2.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include <string>
9#include "bu/ito.h"
10#include "bu/itoqueue.h"
11#include <errno.h>
12#include <stdio.h>
13
14class Reader : public Bu::Ito
15{
16public:
17 Reader( Bu::ItoQueue<std::string *> &q, int id ) :
18 q( q ),
19 id( id )
20 {
21 }
22
23 void run()
24 {
25 for( int i = 0; i < 10; i++ )
26 {
27 std::string *pStr = q.dequeue( 0, 500000 );
28 if( pStr == NULL )
29 {
30 printf("Null received...\n");
31 i--;
32 }
33 else
34 {
35 printf("[%d] read: %s\n", id, pStr->c_str() );
36 delete pStr;
37 }
38 }
39 }
40
41private:
42 Bu::ItoQueue<std::string *> &q;
43 int id;
44};
45
46class Writer : public Bu::Ito
47{
48public:
49 Writer( Bu::ItoQueue<std::string *> &q, int id, const char *strbase ) :
50 q( q ),
51 strbase( strbase ),
52 id( id )
53 {
54 }
55
56 void run()
57 {
58 for( int i = 0; i < 11; i++ )
59 {
60 sleep( 2 );
61 printf("[%d] write: %s\n", id, strbase );
62 q.enqueue( new std::string( strbase ) );
63 }
64 }
65
66private:
67 Bu::ItoQueue<std::string *> &q;
68 const char *strbase;
69 int id;
70};
71
72int main()
73{
74 printf("ETIMEDOUT: %d\n", ETIMEDOUT );
75 Bu::ItoQueue<std::string *> q;
76 Writer wr( q, 0, "writer" );
77 Reader rd( q, 0 );
78
79 rd.start();
80 wr.start();
81
82 rd.join();
83 wr.join();
84
85 return 0;
86}
87
diff --git a/src/tests/itoserver.cpp b/src/tests/itoserver.cpp
deleted file mode 100644
index 48ef527..0000000
--- a/src/tests/itoserver.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include "bu/itoserver.h"
9#include "bu/protocol.h"
10#include "bu/client.h"
11
12#define BU_TRACE
13#include "bu/trace.h"
14
15class ProtocolEcho : public Bu::Protocol
16{
17public:
18 ProtocolEcho()
19 {
20 TRACE();
21 }
22 virtual ~ProtocolEcho()
23 {
24 TRACE();
25 }
26
27 virtual void onNewConnection( Bu::Client * )
28 {
29 TRACE();
30 // Huh...
31 }
32
33 virtual void onNewData( Bu::Client *pClient )
34 {
35 TRACE();
36 char buf[1024];
37 while( pClient->hasInput() )
38 {
39 int iAmnt = pClient->read( buf, 1024 );
40 pClient->write( buf, iAmnt );
41 }
42 }
43};
44
45class TestServer : public Bu::ItoServer
46{
47public:
48 TestServer()
49 {
50 TRACE();
51 }
52 virtual ~TestServer()
53 {
54 TRACE();
55 }
56
57 virtual void onNewConnection( Bu::Client *pClient, int )
58 {
59 TRACE();
60 pClient->setProtocol( new ProtocolEcho() );
61 }
62
63 virtual void onClosedConnection( Bu::Client *pClient )
64 {
65 TRACE();
66 delete pClient->getProtocol();
67 }
68};
69
70int main()
71{
72 TRACE();
73
74 TestServer ts;
75
76 ts.addPort( 5555 );
77 ts.start();
78 ts.join();
79}
80
diff --git a/src/tests/list.cpp b/src/tests/list.cpp
deleted file mode 100644
index aa3d32d..0000000
--- a/src/tests/list.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include "bu/list.h"
9#include <list>
10
11typedef struct Bob
12{
13 int nID;
14} Bob;
15
16int main()
17{
18 Bu::List<int> l;
19
20 l.append( 0 );
21
22 for( int j = 3; j <= 21; j += 3 )
23 {
24 l.append( j );
25 l.prepend( -j );
26 }
27
28 {
29 Bu::List<int>::iterator i = l.begin();
30 Bu::List<int>::iterator j = i;
31 int a, b;
32 a = *j;
33 printf("end: %s\n", (j != l.end())?"no":"yes");
34 j--;
35 printf("end: %s\n", (j != l.end())?"no":"yes");
36 j++;
37 printf("end: %s\n", (j != l.end())?"no":"yes");
38 i = j;
39 b = *i;
40 printf("%d -> %d\n", a, b );
41 }
42
43 for( Bu::List<int>::iterator i = l.begin(); i != l.end(); i++ )
44 {
45 printf("%d ", *i );
46 }
47 printf("\n");
48 for( Bu::List<int>::iterator i = l.begin(); i != l.end(); i++ )
49 {
50 Bu::List<int>::iterator j = i; j--;
51 l.erase( i );
52 i = j;
53 if( i != l.end() )
54 printf("!%d ", *i );
55 }
56
57 printf("\n\n");
58
59 Bu::List<Bob> lb;
60 for( int j = 0; j < 10; j++ )
61 {
62 Bob b;
63 b.nID = j;
64 lb.append( b );
65 }
66
67 const Bu::List<Bob> rb = lb;
68
69 for( Bu::List<Bob>::const_iterator i = rb.begin(); i != rb.end(); i++ )
70 {
71 //i->nID += 2;
72 //(*i).nID = 4;
73 printf("%d ", i->nID );
74 }
75 printf("\n\n");
76}
77
diff --git a/src/tests/list2.cpp b/src/tests/list2.cpp
deleted file mode 100644
index 567370e..0000000
--- a/src/tests/list2.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include <bu/list.h>
9#include <bu/sio.h>
10
11using namespace Bu;
12
13int main()
14{
15 List<int64_t> lInt;
16
17 lInt.append( 512 );
18 lInt.append( 1024 );
19 lInt.append( 4096 );
20 lInt.append( 12 );
21 lInt.erase( 12 );
22 lInt.append( 12 );
23 lInt.erase( 12 );
24 lInt.append( 12 );
25}
26
diff --git a/src/tests/listsort.cpp b/src/tests/listsort.cpp
deleted file mode 100644
index 4873a05..0000000
--- a/src/tests/listsort.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include <bu/list.h>
9#include <bu/sio.h>
10#include <bu/string.h>
11
12using namespace Bu;
13
14int main()
15{
16 /*
17 List<int> il;
18 il.append( 5 );
19 il.append( 12 );
20 il.append( 0 );
21 il.append( 7 );
22 il.append( 3 );
23 il.append( 5 );
24 Bu::__basicLTCmp<int> cmp;
25 il.sortI( cmp );
26 */
27
28 String a("Soggy"), b("Sam");
29
30 if( a < b )
31 {
32 sio << "Bad" << sio.nl;
33 }
34 else
35 {
36 sio << "Good" << sio.nl;
37 }
38
39 typedef List<String> StrList;
40
41 StrList lNames;
42
43 lNames.append("George");
44 lNames.append("Sam");
45 lNames.append("Abby");
46 lNames.append("Zorro");
47 lNames.append("Brianna");
48 lNames.append("Kate");
49 lNames.append("Soggy");
50
51 sio << "Names: " << lNames << sio.nl;
52 lNames.sort();
53
54 sio << "Names: " << lNames << sio.nl;
55
56 StrList lNames2;
57
58 lNames2.insertSorted("George");
59 lNames2.insertSorted("Sam");
60 lNames2.insertSorted("Abby");
61 lNames2.insertSorted("Zorro");
62 lNames2.insertSorted("Brianna");
63 lNames2.insertSorted("Kate");
64 lNames2.insertSorted("Soggy");
65
66 sio << "Names: " << lNames2 << sio.nl;
67
68 if( lNames == lNames2 )
69 {
70 sio << "They're the same." << sio.nl;
71 }
72 else
73 {
74 sio << "They're different." << sio.nl;
75 }
76
77 return 0;
78}
79
diff --git a/src/tests/logger.cpp b/src/tests/logger.cpp
deleted file mode 100644
index e97193c..0000000
--- a/src/tests/logger.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include "bu/logger.h"
9#include <errno.h>
10#include <stdlib.h>
11
12class Thing
13{
14 public:
15 Thing()
16 {
17 lineLog( 2, "Want a thing?");
18 }
19
20 void go( int )
21 {
22 lineLog( 1, "GO!!!!");
23 }
24};
25
26int main()
27{
28 setLogLevel( 4 );
29 setLogFormat("%L: %y-%02m-%02d %h:%02M:%02s %f:%l:%F: %t");
30 lineLog( 5, "Hey, error: %s", strerror( errno ) );
31
32 logHexDump( 5, "This is a test of the hex-dump facility", 16, "Random stuff");
33
34 Thing gh;
35 gh.go( 6 );
36}
37
diff --git a/src/tests/md5.cpp b/src/tests/md5.cpp
deleted file mode 100644
index a32f669..0000000
--- a/src/tests/md5.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include "bu/sio.h"
9#include "bu/file.h"
10#include "bu/md5.h"
11
12using Bu::sio;
13
14int main( int argc, char *argv[] )
15{
16 argv++, argc--;
17 for(; *argv; argv++ )
18 {
19 Bu::File fIn( *argv, Bu::File::Read );
20 Bu::Md5 m;
21
22 char buf[100000];
23 for(;;)
24 {
25 int iRead = fIn.read( buf, 100000 );
26 m.addData( buf, iRead );
27 if( iRead < 100000 )
28 break;
29 }
30
31 sio << m.getHexResult() << " *" << *argv << sio.nl;
32 }
33}
34
diff --git a/src/tests/minicron.cpp b/src/tests/minicron.cpp
deleted file mode 100644
index aed63e2..0000000
--- a/src/tests/minicron.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include "bu/minicron.h"
9#include "bu/sio.h"
10
11#include <unistd.h>
12
13using namespace Bu;
14
15Bu::MiniCron mCron;
16
17void job0( Bu::MiniCron::Job &job )
18{
19 sio << time( NULL ) << ": job0( id = " << job.getId() << ", count = "
20 << job.getRunCount() << ")" << sio.nl;
21}
22
23void job1( Bu::MiniCron::Job &job )
24{
25 sio << time( NULL ) << ": job1( id = " << job.getId() << ", count = "
26 << job.getRunCount() << ")" << sio.nl;
27 mCron.removeJob( 4 );
28}
29
30void job2( Bu::MiniCron::Job &job )
31{
32 sio << time( NULL ) << ": job2( id = " << job.getId() << ", count = "
33 << job.getRunCount() << ")" << sio.nl;
34}
35
36void job3( Bu::MiniCron::Job &job )
37{
38 sio << time( NULL ) << ": job3( id = " << job.getId() << ", count = "
39 << job.getRunCount() << ")" << sio.nl;
40}
41
42int main()
43{
44 mCron.addJob(
45 "job0", slot( &job0 ), MiniCron::TimerInterval( time(NULL)+3, 5 ) );
46 mCron.addJob(
47 "job1", slot( &job1 ), MiniCron::TimerInterval( time(NULL)+10, 8 ) );
48 mCron.addJob(
49 "job2", slot( &job2 ), MiniCron::TimerBasic("weekly wed 17") );
50 mCron.addJob(
51 "job3", slot( &job3 ), MiniCron::TimerInterval( time(NULL)+1, 2 ) );
52
53 sio << time( NULL ) << ": Program started." << sio.nl;
54
55 for(;;)
56 {
57 usleep( 50000 );
58 mCron.poll();
59 }
60
61 return 0;
62}
63
diff --git a/src/tests/mmparse.cpp b/src/tests/mmparse.cpp
deleted file mode 100644
index c1ce862..0000000
--- a/src/tests/mmparse.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include "bu/minimacro.h"
9#include "bu/string.h"
10
11int main()
12{
13 Bu::MiniMacro mm;
14
15 mm.addVar("name", "Mike");
16 mm.addVar("age", "no");
17
18 printf("%s\n", mm.parse("Hey there {=name:toupper():tolower()}, how are you?").getStr() );
19
20 return 0;
21}
22
diff --git a/src/tests/multiserver.cpp b/src/tests/multiserver.cpp
deleted file mode 100644
index 12f4681..0000000
--- a/src/tests/multiserver.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include "bu/multiserver.h"
9#include "bu/protocol.h"
10#include "bu/client.h"
11
12class ProtocolRaw : public Bu::Protocol
13{
14public:
15 virtual void onNewConnection( Bu::Client *pClient )
16 {
17 pClient->write("Raw echo\n");
18 }
19
20 virtual void onNewData( Bu::Client *pClient )
21 {
22 char buf[1024];
23 while( pClient->hasInput() )
24 {
25 int iAmnt = pClient->read( buf, 1024 );
26 pClient->write( buf, iAmnt );
27 }
28 }
29};
30
31class ProtocolRot13 : public Bu::Protocol
32{
33public:
34 virtual void onNewConnection( Bu::Client *pClient )
35 {
36 pClient->write("Rot13 echo\n");
37 }
38
39 virtual void onNewData( Bu::Client *pClient )
40 {
41 while( pClient->hasInput() )
42 {
43 char sTmp[1024];
44 int iAmnt = pClient->read( sTmp, 1024 );
45 for( int j = 0; j < iAmnt; j++ )
46 {
47 if( sTmp[j] >= 'a' && sTmp[j] <= 'z' )
48 {
49 sTmp[j] = ((sTmp[j]-'a'+13)%26) + 'a';
50 }
51 else if( sTmp[j] >= 'A' && sTmp[j] <= 'Z' )
52 {
53 sTmp[j] = ((sTmp[j]-'A'+13)%26) + 'A';
54 }
55 }
56 pClient->write( sTmp, iAmnt );
57 }
58 }
59};
60
61int main()
62{
63 Bu::MultiServer msMain;
64
65 msMain.addProtocol( Bu::genProtocol<ProtocolRaw>, 5550 );
66 msMain.addProtocol( Bu::genProtocol<ProtocolRot13>, 5551 );
67 msMain.setTimeout( 5, 0 );
68
69 for(;;)
70 {
71 msMain.scan();
72 }
73
74 return 0;
75}
76
diff --git a/src/tests/procs.cpp b/src/tests/procs.cpp
deleted file mode 100644
index 94d2cc5..0000000
--- a/src/tests/procs.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include "bu/process.h"
9
10#include <stdio.h>
11
12int main()
13{
14 Bu::Process p( Bu::Process::Both, "/bin/bash", "/bin/bash", "-c", "echo Hello 1>&2; echo StdOut; sleep 1; echo Yup; echo Yup 1>&2", NULL );
15
16 char buf[1000];
17 while( !p.isEos() )
18 {
19 bool out, err;
20 p.select( out, err );
21 if( out )
22 {
23 int iSize = p.read( buf, 1000 );
24 printf("::read=%d::\n", iSize );
25 fwrite( buf, iSize, 1, stdout );
26 }
27 if( err )
28 {
29 int iSize = p.readErr( buf, 1000 );
30 printf("::readErr=%d::\n", iSize );
31 fwrite( buf, iSize, 1, stdout );
32 }
33 }
34
35 return 0;
36}
37
diff --git a/src/tests/queuebuf.cpp b/src/tests/queuebuf.cpp
deleted file mode 100644
index f872738..0000000
--- a/src/tests/queuebuf.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include <bu/queuebuf.h>
9#include <bu/sio.h>
10
11using namespace Bu;
12
13int main()
14{
15 static const char *src = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789%#";
16 QueueBuf qb;
17
18 for( int j = 0; j < 8; j++ )
19 {
20 qb.write( src, 60 );
21 }
22
23 char buf[11], bufp[11];
24 while( !qb.isEos() )
25 {
26 int iAmntPeek = qb.peek( bufp, 9 );
27 int iAmntRead = qb.read( buf, 9 );
28 if( iAmntPeek != iAmntRead )
29 sio << "Differ: " << iAmntPeek << " vs " << iAmntRead << sio.nl;
30 buf[iAmntRead] = '\0';
31 bufp[iAmntPeek] = '\0';
32 if( memcmp( buf, bufp, iAmntPeek ) )
33 {
34 sio << "Buffers differ" << sio.nl
35 << " " << buf << sio.nl
36 << " " << bufp << sio.nl;
37 }
38 else
39 sio << "Read: >>" << buf << "<<" << sio.nl;
40 }
41
42 sio << sio.nl << sio.nl << sio.nl << "Seek test:" << sio.nl << sio.nl;
43
44 for( int j = 0; j < 5; j++ )
45 {
46 qb.write( src, 25 );
47 qb.write( src+10, 25 );
48 }
49
50 char bufa[26];
51 char bufb[26];
52 ::memcpy( bufb, src+10, 15 );
53 ::memcpy( bufb+15, src+10, 10 );
54 bufb[25] = '\0';
55 sio << "Comparing to '" << bufb << "'" << sio.nl;
56 qb.seek( 10 );
57 while( !qb.isEos() )
58 {
59 bufa[qb.read( bufa, 25 )] = '\0';
60 qb.seek( 25 );
61 if( memcmp( bufa, bufb, 25 ) )
62 sio << "Differ?" << sio.nl;
63 sio << "=== '" << bufa << "' == '" << bufb << "'" << sio.nl;
64 }
65}
66
diff --git a/src/tests/regex.cpp b/src/tests/regex.cpp
deleted file mode 100644
index 376fbb2..0000000
--- a/src/tests/regex.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include <bu/regex.h>
9#include <stdio.h>
10
11int main( int argc, char *argv[] )
12{
13 if( argc < 3 )
14 {
15 printf("No... %s <regex> <string>\n\n", argv[0] );
16 return 0;
17 }
18
19 Bu::RegEx re( argv[1] );
20
21 printf("Regex: %s\n", argv[1] );
22 printf("Match: %s\n", argv[2] );
23
24 if( re.execute( argv[2] ) )
25 {
26 for( int j = 0; j < re.getNumSubStrings(); j++ )
27 {
28 printf("SubStr %d: %s\n", j, re.getSubString( j ).getStr() );
29 }
30 }
31 else
32 {
33 printf("Regex did not match.\n");
34 }
35
36 return 0;
37}
38
diff --git a/src/tests/ringbuffer.cpp b/src/tests/ringbuffer.cpp
deleted file mode 100644
index da5126c..0000000
--- a/src/tests/ringbuffer.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include "bu/ringbuffer.h"
9#include <stdlib.h>
10#include <stdint.h>
11#include <stdio.h>
12
13int main()
14{
15 Bu::RingBuffer<uint32_t> ibuf( 10 );
16
17 for( int k = 0; k < 2; k++ )
18 {
19 int j = 1;
20 for(; j < 7; j++ )
21 {
22 ibuf.enqueue( j );
23 }
24
25 for(; j < 20; j++ )
26 {
27 ibuf.enqueue( j );
28 printf("- %d\n", ibuf.dequeue() );
29 }
30
31 for(;;)
32 {
33 if( ibuf.isEmpty() ) break;
34 printf(". %d\n", ibuf.dequeue() );
35 }
36 }
37}
38
diff --git a/src/tests/rot13.cpp b/src/tests/rot13.cpp
deleted file mode 100644
index 1530af3..0000000
--- a/src/tests/rot13.cpp
+++ /dev/null
@@ -1,91 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include "bu/protocol.h"
9#include "bu/multiserver.h"
10#include "bu/client.h"
11#include "bu/filter.h"
12
13using namespace Bu;
14
15class Rot13Filter : public Filter
16{
17public:
18 Rot13Filter( Stream &next ) :
19 Filter( next )
20 {
21 }
22
23 virtual ~Rot13Filter()
24 {
25 }
26
27 virtual void start()
28 {
29 }
30
31 virtual Bu::size stop()
32 {
33 return 0;
34 }
35
36 virtual Bu::size read( void *pBuf, Bu::size nBytes )
37 {
38 return rNext.read( pBuf, nBytes );
39 }
40
41 virtual Bu::size write( const void *pBuf, Bu::size nBytes )
42 {
43 const char *cBuf = (const char *)pBuf;
44 char *buf = new char[nBytes];
45 for( Bu::size j = 0; j < nBytes; j++ )
46 {
47 if( cBuf[j] >= 'a' && cBuf[j] <= 'z' )
48 buf[j] = (cBuf[j]-'a'+13)%26+'a';
49 else if( cBuf[j] >= 'A' && cBuf[j] <= 'Z' )
50 buf[j] = (cBuf[j]-'A'+13)%26+'A';
51 else
52 buf[j] = cBuf[j];
53 }
54 rNext.write( buf, nBytes );
55 delete[] buf;
56 return nBytes;
57 }
58};
59
60class Rot13Protocol : public Protocol
61{
62public:
63 void onNewConnection( Bu::Client *pClient )
64 {
65 pClient->pushFilter<Rot13Filter>();
66 }
67
68 void onNewData( Bu::Client *pClient )
69 {
70 char buf[1024];
71 while( pClient->hasInput() )
72 {
73 int iAmnt = pClient->read( buf, 1024 );
74 pClient->write( buf, iAmnt );
75 }
76 }
77};
78
79int main()
80{
81 MultiServer xSrv;
82
83 xSrv.setTimeout( 5 );
84 xSrv.addProtocol( genProtocol<Rot13Protocol>, 9999 );
85
86 for(;;)
87 xSrv.scan();
88
89 return 0;
90}
91
diff --git a/src/tests/serverticks.cpp b/src/tests/serverticks.cpp
deleted file mode 100644
index 3872a16..0000000
--- a/src/tests/serverticks.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include "bu/server.h"
9#include "bu/client.h"
10#include "bu/protocol.h"
11#include <unistd.h>
12
13class TickProtocol : public Bu::Protocol
14{
15public:
16 TickProtocol()
17 {
18 }
19
20 virtual ~TickProtocol()
21 {
22 }
23
24 virtual void onTick( Bu::Client *pClient )
25 {
26 printf("tick!\n");
27 pClient->write("tick!\n");
28 }
29};
30
31class TickServer : public Bu::Server
32{
33public:
34 TickServer()
35 {
36 }
37
38 virtual ~TickServer()
39 {
40 }
41
42 virtual void onNewConnection( Bu::Client *pClient, int )
43 {
44 pClient->setProtocol( new TickProtocol() );
45 }
46
47 virtual void onClosedConnection( Bu::Client *pClient )
48 {
49 delete pClient->getProtocol();
50 }
51};
52
53int main( int , char *[] )
54{
55 TickServer ts;
56
57 ts.setTimeout( 1, 0 );
58 ts.setAutoTick();
59 ts.addPort( 5555 );
60
61 for(;;)
62 {
63 ts.scan();
64 sleep( 1 );
65 }
66
67 return 0;
68}
69
diff --git a/src/tests/sha1.cpp b/src/tests/sha1.cpp
deleted file mode 100644
index ac795e7..0000000
--- a/src/tests/sha1.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include "bu/sio.h"
9#include "bu/file.h"
10#include "bu/sha1.h"
11
12using namespace Bu;
13
14int main( int argc, char *argv[] )
15{
16 argv++, argc--;
17 for(; *argv; argv++ )
18 {
19 Bu::File fIn( *argv, Bu::File::Read );
20 Bu::Sha1 m;
21
22 char buf[100000];
23 for(;;)
24 {
25 int iRead = fIn.read( buf, 100000 );
26 m.addData( buf, iRead );
27 if( iRead < 100000 )
28 break;
29 }
30
31 Bu::String sRes = m.getResult();
32 for( Bu::String::iterator i = sRes.begin(); i; i++ )
33 {
34 sio << Fmt::hex(2,false) << (int)(unsigned char)(*i);
35 }
36 sio << " *" << *argv << sio.nl;
37 }
38}
39
diff --git a/src/tests/sharedcore.cpp b/src/tests/sharedcore.cpp
deleted file mode 100644
index c68f07b..0000000
--- a/src/tests/sharedcore.cpp
+++ /dev/null
@@ -1,98 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include "bu/sharedcore.h"
9#include "bu/sio.h"
10
11using namespace Bu;
12
13struct ShintCore
14{
15 int val;
16};
17class Shint : public Bu::SharedCore<Shint, struct ShintCore>
18{
19public:
20 Shint()
21 {
22 core->val = 0;
23 }
24
25 Shint( int val )
26 {
27 core->val = val;
28 }
29
30 int getVal() const
31 {
32 return core->val;
33 }
34
35 void setValBad( int val )
36 {
37 core->val = val;
38 }
39
40 void setVal( int val )
41 {
42 _hardCopy();
43 core->val = val;
44 }
45
46 bool operator==( const Shint &rhs )
47 {
48 if( core == rhs.core )
49 {
50 sio << "Same pointer (" << Fmt::ptr() << core << ")" << sio.nl;
51 return true;
52 }
53 if( core->val == rhs.core->val )
54 {
55 sio << "Same value " << core->val << " ("
56 << Fmt::ptr() << core << " vs "
57 << Fmt::ptr() << rhs.core << ")"
58 << sio.nl;
59 return true;
60 }
61 sio << "Different" << sio.nl;
62 return false;
63 }
64};
65
66#define line( x ) sio << __FILE__ ": " << __LINE__ << ": " << #x << sio.nl; x
67
68int main()
69{
70 line( Shint a; )
71 line( Shint b( 5 ); )
72
73 line( a == b; )
74
75 line( b = a; )
76 line( a == b; )
77
78 line( b.setValBad( 12 ); )
79 sio << a.getVal() << " != " << b.getVal() << sio.nl;
80 line( a == b; )
81
82 line( a.setVal( 3 ); )
83 sio << a.getVal() << " != " << b.getVal() << sio.nl;
84 line( a == b; )
85
86 line( a.setVal( b.getVal() ); )
87 line( a == b; )
88
89 {
90 Shint c( b );
91 Shint d( c );
92 sio << c.getVal();
93 d.setVal( 43 );
94 }
95
96 sio << b.getVal();
97}
98
diff --git a/src/tests/signals.cpp b/src/tests/signals.cpp
deleted file mode 100644
index 14bbc9c..0000000
--- a/src/tests/signals.cpp
+++ /dev/null
@@ -1,131 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include <bu/signals.h>
9#include <bu/sio.h>
10
11using namespace Bu;
12
13class Thing
14{
15public:
16 Thing() :
17 iState( 82731 )
18 {
19 }
20
21 virtual ~Thing()
22 {
23 }
24
25 void fnc0()
26 {
27 sio << iState << ": void fnc0()" << sio.nl;
28 }
29
30 void fnc1( int a )
31 {
32 sio << iState << ": void fnc1( " << a << " )" << sio.nl;
33 }
34
35 void fnc2( int a, Bu::String b )
36 {
37 sio << iState << ": void fnc2( " << a << ", \"" << b << "\" )" << sio.nl;
38 }
39
40 void fnc3( int a, Bu::String b, double c )
41 {
42 sio << iState << ": void fnc3( " << a << ", \"" << b << "\", " << c << " )" << sio.nl;
43 }
44
45 void fnc4( int a, Bu::String b, double c, char d )
46 {
47 sio << iState << ": void fnc4( " << a << ", \"" << b << "\", " << c << ", '" << d << "' )" << sio.nl;
48 }
49
50 void fnc5( int a, Bu::String b, double c, char d, long e )
51 {
52 sio << iState << ": void fnc5( " << a << ", \"" << b << "\", " << c << ", '" << d << "', " << e << " )" << sio.nl;
53 }
54
55private:
56 int iState;
57};
58
59void pfnc0()
60{
61 sio << ": void pfnc0()" << sio.nl;
62}
63
64void pfnc1( int a )
65{
66 sio << ": void pfnc1( " << a << " )" << sio.nl;
67}
68
69void pfnc2( int a, Bu::String b )
70{
71 sio << ": void pfnc2( " << a << ", \"" << b << "\" )" << sio.nl;
72}
73
74void pfnc3( int a, Bu::String b, double c )
75{
76 sio << ": void pfnc3( " << a << ", \"" << b << "\", " << c << " )" << sio.nl;
77}
78
79void pfnc4( int a, Bu::String b, double c, char d )
80{
81 sio << ": void pfnc4( " << a << ", \"" << b << "\", " << c << ", '" << d << "' )" << sio.nl;
82}
83
84void pfnc5( int a, Bu::String b, double c, char d, long e )
85{
86 sio << ": void pfnc5( " << a << ", \"" << b << "\", " << c << ", '" << d << "', " << e << " )" << sio.nl;
87}
88
89void callit( Signal0<void> sig )
90{
91 sig();
92}
93
94int main()
95{
96 Thing t;
97
98 Signal0<void> cb0( slot( &t, &Thing::fnc0 ) );
99 cb0();
100 cb0 = slot( &pfnc0 );
101 cb0();
102
103 Signal1<void, int> cb1( slot( &t, &Thing::fnc1 ) );
104 cb1( 5 );
105 cb1 = slot( &pfnc1 );
106 cb1( 5 );
107
108 Signal2<void, int, Bu::String> cb2( slot( &t, &Thing::fnc2 ) );
109 cb2( 5, "Hi there" );
110 cb2 = slot( &pfnc2 );
111 cb2( 5, "Hi there" );
112
113 Signal3<void, int, Bu::String, double> cb3( slot( &t, &Thing::fnc3 ) );
114 cb3( 5, "Hi there", 12.85 );
115 cb3 = slot( &pfnc3 );
116 cb3( 5, "Hi there", 12.85 );
117
118 Signal4<void, int, Bu::String, double, char> cb4( slot( &t, &Thing::fnc4 ) );
119 cb4( 5, "Hi there", 12.85, 'z' );
120 cb4 = slot( &pfnc4 );
121 cb4( 5, "Hi there", 12.85, 'z' );
122
123 Signal5<void, int, Bu::String, double, char, long> cb5( slot( &t, &Thing::fnc5 ) );
124 cb5( 5, "Hi there", 12.85, 'z', 849 );
125 cb5 = slot( &pfnc5 );
126 cb5( 5, "Hi there", 12.85, 'z', 849 );
127
128// Signal1<int, int> cb1( slot( &t, &Thing::fnc1 ) );
129// sio << "Result: " << cb1( 5 ) << sio.nl;
130}
131
diff --git a/src/tests/size.cpp b/src/tests/size.cpp
deleted file mode 100644
index dfad16f..0000000
--- a/src/tests/size.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include "bu/hash.h"
9#include "bu/string.h"
10
11#define pSize( t ) printf("%15s: %db\n", #t, sizeof( t ) );
12
13int main()
14{
15 typedef Bu::Hash<char, char> charcharHash;
16 typedef Bu::Hash<Bu::String, Bu::String> strstrHash;
17 pSize( Bu::String );
18 pSize( charcharHash );
19 pSize( strstrHash );
20}
diff --git a/src/tests/socketblock.cpp b/src/tests/socketblock.cpp
deleted file mode 100644
index e36bb33..0000000
--- a/src/tests/socketblock.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include "bu/ito.h"
9#include "bu/tcpsocket.h"
10#include "bu/tcpserversocket.h"
11#include <stdio.h>
12#include <unistd.h>
13
14class TstServer : public Bu::Ito
15{
16public:
17 TstServer() :
18 s( 55678 )
19 {
20 }
21
22 virtual void run()
23 {
24 Bu::TcpSocket c = s.accept( 45, 0 );
25 printf("TstServer: Accetped connection.\n"); fflush( stdout );
26
27 sleep( 1 );
28 printf("TstServer: Trying to read 10 bytes...\n"); fflush( stdout );
29
30 char buf[10];
31 size_t nRead = c.read( buf, 10 );
32 printf("TstServer: Got %d bytes...\n", nRead ); fflush( stdout );
33
34 printf("TstServer: Closing connection...\n"); fflush( stdout );
35 c.close();
36 }
37
38 Bu::TcpServerSocket s;
39};
40
41int main()
42{
43 TstServer ts;
44
45 ts.start();
46
47 printf("main: Connecting to server.\n"); fflush( stdout );
48 Bu::TcpSocket s( "localhost", 55678 );
49
50 printf("main: Sending 4 bytes.\n"); fflush( stdout );
51 s.write( "aoeu", 4 );
52
53 printf("main: Sleeping 10 seconds for good measure.\n"); fflush( stdout );
54 sleep( 10 );
55}
56
diff --git a/src/tests/socketbreak.cpp b/src/tests/socketbreak.cpp
deleted file mode 100644
index d58ebcf..0000000
--- a/src/tests/socketbreak.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include "bu/tcpserversocket.h"
9#include "bu/tcpsocket.h"
10#include <unistd.h>
11
12int main()
13{
14 Bu::TcpServerSocket sSrv( 9987 );
15
16 Bu::TcpSocket sSend("localhost", 9987 );
17
18 Bu::TcpSocket sRecv( sSrv.accept() );
19
20 printf("Connected sockets.\n");
21
22 sleep( 1 );
23 printf("Closing sRecv.\n");
24 sRecv.close();
25 sleep( 1 );
26
27 char buf[3];
28 printf("About to write.\n");
29 printf("write: %lld\n", sSend.write("hi", 2 ) );
30 printf("About to read.\n");
31 printf("read: %lld\n", sSend.read( buf, 2 ) );
32
33 return 0;
34}
35
diff --git a/src/tests/speed.cpp b/src/tests/speed.cpp
deleted file mode 100644
index 2fa29aa..0000000
--- a/src/tests/speed.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include "bu/string.h"
9#include <sys/time.h>
10
11template<typename a>
12struct tstCopy
13{
14 tstCopy( const a &src ) :
15 src( src )
16 {
17 }
18
19 void operator()()
20 {
21 a tmp = src;
22 }
23
24 a src;
25};
26
27template<typename f>
28double runTest( f fnc )
29{
30 struct timeval tStart, tEnd;
31 int j = 0;
32 gettimeofday( &tStart, NULL );
33 for(; j < 500000; j++ )
34 fnc();
35 gettimeofday( &tEnd, NULL );
36
37 return (double)(tEnd.tv_sec-tStart.tv_sec)+
38 (double)(tEnd.tv_usec-tStart.tv_usec)/1000000.0;
39}
40
41template<typename tst>
42void fullTest( tst t )
43{
44 double dTotal;
45 int iCount = 10;
46 for( int j = 0; j < iCount; j++ )
47 dTotal += runTest( t );
48 printf("Average time: %f\n", dTotal/iCount );
49}
50
51int main()
52{
53 Bu::String str;
54 for( int j = 0; j < 500; j++ )
55 str.append("Hey, this is a test string. It will be reapeated many, many times. How's that?");
56 fullTest( tstCopy<Bu::String>( str ) );
57}
58
diff --git a/src/tests/stdstream.cpp b/src/tests/stdstream.cpp
deleted file mode 100644
index 95df42e..0000000
--- a/src/tests/stdstream.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include "bu/sio.h"
9
10using Bu::sio;
11using Bu::Fmt;
12
13int main()
14{
15 sio << "Hello there" << sio.nl;
16
17 sio << "sizeof(Fmt) = " << sizeof(Fmt) << sio.nl;
18
19 sio << -123 << ", " << 0 << ", " << 123 << sio.nl;
20
21 sio << "+----------+" << sio.nl;
22 sio << "|" << Fmt( 10, 10, Fmt::Center ) << "Test" << "|" << sio.nl;
23 sio << "+----------+" << sio.nl;
24 sio << "|" << Fmt( 10, 10, Fmt::Left ) << 123 << "|" << sio.nl;
25 sio << "|" << Fmt( 10, 10, Fmt::Center ) << 123 << "|" << sio.nl;
26 sio << "|" << Fmt( 10, 10, Fmt::Right ) << 123 << "|" << sio.nl;
27 sio << "+----------+" << sio.nl;
28
29 sio << Fmt(10,Fmt::Left) << "Hexcode:" << Fmt::ptr() << (void*)(&sio) << sio.nl;
30
31 sio << 0.123 << sio.nl;
32 sio << true << " and then " << false << sio.nl;
33
34 for( int j = 2; j <= 36; j++ )
35 sio << "radix(" << j << ") = " << Fmt().radix( j ).width( 8 ).align( Fmt::Right ) << 255 << sio.nl;
36
37 return 0;
38}
39
diff --git a/src/tests/streamstack.cpp b/src/tests/streamstack.cpp
deleted file mode 100644
index 4a0e128..0000000
--- a/src/tests/streamstack.cpp
+++ /dev/null
@@ -1,100 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include "bu/streamstack.h"
9
10#include "bu/file.h"
11#include "bu/base64.h"
12#include "bu/bzip2.h"
13
14#include "bu/sio.h"
15
16#include <time.h>
17
18using namespace Bu;
19
20class DoStuff
21{
22public:
23 DoStuff( Bu::Stream &rStream ) :
24 rStream( rStream )
25 {
26 }
27
28 virtual ~DoStuff()
29 {
30 }
31
32 void write()
33 {
34 Bu::String s;
35 time_t tNow = time( NULL );
36 s = ctime( &tNow );
37 long lSize = s.getSize()-1;
38 rStream.write( &lSize, sizeof(long) );
39 rStream.write( s.getStr(), lSize );
40 }
41
42 void read()
43 {
44 Bu::String s;
45 long lSize;
46 rStream.read( &lSize, sizeof(long) );
47 s.setSize( lSize );
48 rStream.read( s.getStr(), lSize );
49 sio << "Read str(" << lSize << ") = '" << s << "'" << sio.nl;
50 }
51
52private:
53 Bu::Stream &rStream;
54};
55
56int main()
57{
58 Bu::StreamStack ss;
59
60 DoStuff ds( ss );
61
62 try
63 {
64 ds.write();
65 sio << "This shouldn't have worked." << sio.nl;
66 }
67 catch( Bu::ExceptionBase &e )
68 {
69 sio << "Got exception, this is good: " << e.what() << sio.nl;
70 }
71
72 ss.setStream( new Bu::File("Hello.test", Bu::File::WriteNew ) );
73
74 ds.write();
75
76 ss.pushFilter<Bu::Base64>();
77
78 ds.write();
79
80 ss.pushFilter<Bu::BZip2>();
81
82 ds.write();
83
84 ss.clear();
85
86 ss.setStream( new Bu::File("Hello.test", Bu::File::Read ) );
87
88 ds.read();
89
90 ss.pushFilter<Bu::Base64>();
91
92 ds.read();
93
94 ss.pushFilter<Bu::BZip2>();
95
96 ds.read();
97
98 return 0;
99}
100
diff --git a/src/tests/string.cpp b/src/tests/string.cpp
deleted file mode 100644
index b37460e..0000000
--- a/src/tests/string.cpp
+++ /dev/null
@@ -1,154 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include "bu/hash.h"
9#include "bu/string.h"
10#include <sys/time.h>
11#include <string>
12
13#ifndef WIN32
14inline double getTime()
15{
16 struct timeval tv;
17 gettimeofday( &tv, NULL );
18 return ((double)tv.tv_sec) + ((double)tv.tv_usec/1000000.0);
19}
20#else
21#include "windows.h"
22#include "winbase.h"
23inline double getTime()
24{
25 uint32_t t = (uint32_t) GetTickCount();
26 return (double) t / 1000.0;
27}
28#endif
29
30Bu::String genThing()
31{
32 Bu::String bob;
33 bob.append("ab ");
34 bob += "cd ";
35 bob += "efg";
36
37 printf("---bob------\n%08tX: %s\n", (ptrdiff_t)bob.getStr(),
38 bob.getStr() );
39 return bob;
40}
41
42void thing( Bu::String str )
43{
44 printf("Hey: %s\n", str.getStr() );
45}
46
47void copyfunc( std::string temp )
48{
49 temp += "Hi";
50}
51
52void copyfunc( Bu::String temp )
53{
54 temp += "Hi";
55}
56
57void doTimings()
58{
59 Bu::String fs1, fs2;
60 std::string ss1, ss2;
61 double dStart, dEnd, tfs1, tfs2, tfs3, tss1, tss2, tss3;
62 int nChars = 50000000, nChunks=50000, nCopies=500000000, nChunkSize=1024*4;
63 char *buf = new char[nChunkSize];
64 memset( buf, '!', nChunkSize );
65
66 printf("Timing Bu::String single chars...\n");
67 dStart = getTime();
68 for( int j = 0; j < nChars; j++ ) fs1 += (char)('a'+(j%26));
69 fs1.getStr();
70 dEnd = getTime();
71 tfs1 = dEnd-dStart;
72
73 printf("Timing std::string single chars...\n");
74 dStart = getTime();
75 for( int j = 0; j < nChars; j++ ) ss1 += (char)('a'+(j%26));
76 ss1.c_str();
77 dEnd = getTime();
78 tss1 = dEnd-dStart;
79
80 printf("Timing Bu::String %d char chunks...\n", nChunkSize);
81 dStart = getTime();
82 for( int j = 0; j < nChunks; j++ ) fs2.append(buf, nChunkSize);
83 fs2.getStr();
84 dEnd = getTime();
85 tfs2 = dEnd-dStart;
86
87 printf("Timing std::string %d char chunks...\n", nChunkSize);
88 dStart = getTime();
89 for( int j = 0; j < nChunks; j++ ) ss2.append(buf, nChunkSize);
90 ss2.c_str();
91 dEnd = getTime();
92 tss2 = dEnd-dStart;
93
94 fs2 = "Hello there.";
95 ss2 = "Hello there.";
96 printf("Timing Bu::String copies...\n");
97 dStart = getTime();
98 for( int j = 0; j < nCopies; j++ ) Bu::String stmp = fs2;
99 dEnd = getTime();
100 tfs3 = dEnd-dStart;
101
102 printf("Timing std::string copies...\n");
103 dStart = getTime();
104 for( int j = 0; j < nCopies; j++ ) std::string stpm = ss2;
105 dEnd = getTime();
106 tss3 = dEnd-dStart;
107
108 printf(
109 "Results: singles: chunks: copies:\n"
110 "Bu::String %15.2f/s %15.2f/s %15.2f/s\n"
111 "std::string %15.2f/s %15.2f/s %15.2f/s\n",
112 nChars/tfs1, nChunks/tfs2, nCopies/tfs3,
113 nChars/tss1, nChunks/tss2, nCopies/tss3 );
114
115 delete[] buf;
116}
117
118#define pem printf("---------\n%08tX: %s\n%08tX: %s\n", (ptrdiff_t)str.getConstStr(), str.getConstStr(), (ptrdiff_t)str2.getConstStr(), str2.getConstStr() );
119int main( )
120{
121// Bu::String fs1;
122// for( int j = 0; j < 500000; j++ ) fs1 += (char)('a'+(j%26));
123// return 0;
124
125 Bu::String str("th");
126
127 str.prepend("Hello ");
128 str.append("ere.");
129
130 Bu::String str2( str );
131 pem;
132 str += " What's up?";
133 pem;
134 str2 += " How are you?";
135 pem;
136 str = str2;
137 pem;
138
139 str2 = genThing();
140 pem;
141
142 str = str2;
143 pem;
144
145 thing( str2 );
146 thing("test.");
147
148 printf("%d == %d\n", Bu::__calcHashCode( str ), Bu::__calcHashCode( str.getStr() ) );
149
150 doTimings();
151
152 return 0;
153}
154
diff --git a/src/tests/stringspeed.cpp b/src/tests/stringspeed.cpp
deleted file mode 100644
index 5636de7..0000000
--- a/src/tests/stringspeed.cpp
+++ /dev/null
@@ -1,122 +0,0 @@
1#include <bu/string.h>
2
3#include <sys/time.h>
4#include <stdio.h>
5
6void timeit( void (*func)(), const char *sName, int iIter )
7{
8 struct timeval ts, te;
9
10 gettimeofday( &ts, NULL );
11 for( int j = 0; j < iIter; j++ )
12 {
13 func();
14 }
15 gettimeofday( &te, NULL );
16
17 double dTotal = (double)(te.tv_sec-ts.tv_sec) + (double)(te.tv_usec-ts.tv_usec)/1000000.0;
18 printf("%10s: %f spi (%f total)\n", sName, dTotal/iIter, dTotal );
19}
20
21void append1()
22{
23 Bu::String sTmp;
24 for( int c = 0; c < 5000; c++ )
25 {
26 sTmp += (char)(c%256);
27 }
28}
29
30void append2()
31{
32 Bu::String sTmp;
33 for( int c = 0; c < 5000; c++ )
34 {
35 sTmp.append( (char)(c%256) );
36 }
37}
38
39void append3()
40{
41 Bu::String sTmp;
42 for( int c = 0; c < 5000; c++ )
43 {
44 sTmp += "Test";
45 }
46}
47
48void append4()
49{
50 Bu::String sTmp;
51 for( int c = 0; c < 5000; c++ )
52 {
53 sTmp.append("Test");
54 }
55}
56
57void append5()
58{
59 Bu::String sTmp, sAdd("Test");
60 for( int c = 0; c < 5000; c++ )
61 {
62 sTmp += sAdd;
63 }
64}
65
66void append6()
67{
68 Bu::String sTmp, sAdd("Test");
69 for( int c = 0; c < 5000; c++ )
70 {
71 sTmp.append( sAdd );
72 }
73}
74
75void prepend1()
76{
77 Bu::String sTmp;
78 for( int c = 0; c < 5000; c++ )
79 {
80 sTmp.prepend('c');
81 }
82}
83
84void copy1()
85{
86 Bu::String sSrc;
87 for( int c = 0; c < 1000; c++ )
88 {
89 sSrc += (char)(c%256);
90 Bu::String sTmp = sSrc;
91 sTmp.append( '-' );
92 }
93}
94
95void copy2()
96{
97 Bu::String sSrc;
98 for( int c = 0; c < 1000; c++ )
99 {
100 sSrc += (char)(c%256);
101 Bu::String sTmp = sSrc;
102 }
103}
104
105void replace1()
106{
107 Bu::String s("Hey, this is a replacement test, what do you thing of it?");
108 s.replace("e", "X").replace("a", "X").replace("what","XXX");
109}
110
111int main()
112{
113 timeit( append1, "Append1", 5000 );
114 timeit( append2, "Append2", 5000 );
115 timeit( append3, "Append3", 2000 );
116 timeit( append4, "Append4", 2000 );
117 timeit( append4, "Prepend1", 2000 );
118 timeit( copy1, "Copy1", 2000 );
119 timeit( copy2, "Copy2", 2000 );
120 timeit( replace1, "Replace1", 10000 );
121}
122
diff --git a/src/tests/tcpsocket.cpp b/src/tests/tcpsocket.cpp
deleted file mode 100644
index 89c015c..0000000
--- a/src/tests/tcpsocket.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include <bu/tcpsocket.h>
9#include <bu/sio.h>
10
11#include <sys/time.h>
12#include <time.h>
13
14using namespace Bu;
15
16bool isUp()
17{
18 try
19 {
20 TcpSocket s("xagasoft.com", 9898, 1 );
21
22 char buf[5];
23 buf[s.read(buf, 2, 1, 0)] = '\0';
24
25 if( !strcmp( buf, "hi" ) )
26 return true;
27 else
28 return false;
29 }
30 catch(...)
31 {
32 return false;
33 }
34}
35
36int main()
37{
38 uint32_t uUp = 0;
39 uint32_t uDown = 0;
40 uint32_t uTotal = 0;
41 struct timeval tv;
42
43 for(;;)
44 {
45 gettimeofday( &tv, NULL );
46 time_t goal = ((tv.tv_sec/5)+1)*5;
47 tv.tv_sec = goal-tv.tv_sec;
48 tv.tv_usec = 0-tv.tv_usec;
49 if( tv.tv_usec < 0 )
50 {
51 tv.tv_sec--;
52 tv.tv_usec = 1000000+tv.tv_usec;
53 }
54 select( 0, NULL, NULL, NULL, &tv );
55 gettimeofday( &tv, NULL );
56 if( isUp() )
57 {
58 uUp++;
59 sio << "status: up ";
60 }
61 else
62 {
63 uDown++;
64 sio << "status: down ";
65 }
66 uTotal++;
67
68 sio << "(up=" << (uUp*5) << "s, down=" << (uDown*5) << ") up for "
69 << uUp*100/uTotal << "% of " << uTotal*5 << "s" << sio.nl
70 << sio.flush;
71 }
72}
73
diff --git a/src/tests/telnetsrv.cpp b/src/tests/telnetsrv.cpp
deleted file mode 100644
index aac6b39..0000000
--- a/src/tests/telnetsrv.cpp
+++ /dev/null
@@ -1,92 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include "bu/server.h"
9#include "bu/protocoltelnet.h"
10#include "bu/client.h"
11
12class MyTelnet : public Bu::ProtocolTelnet
13{
14public:
15 MyTelnet()
16 {
17 }
18
19 virtual ~MyTelnet()
20 {
21 }
22
23 virtual void onNewConnection( Bu::Client *pClient )
24 {
25 Bu::ProtocolTelnet::onNewConnection( pClient );
26
27 //oNAWS.remoteSet();
28 oEcho.localSet();
29 oSuppressGA.remoteSet( true );
30 oSuppressGA.localSet( true );
31 setCanonical();
32 }
33
34 virtual void onSubNAWS( uint16_t iWidth, uint16_t iHeight )
35 {
36 printf("New dim = (%dx%d)\n", iWidth, iHeight );
37 }
38
39 virtual void gotLine( Bu::String &sLine )
40 {
41 printf("Line: \"%s\"\n", sLine.getStr() );
42 write("\n\r", 2 );
43 }
44
45private:
46
47};
48
49class TelServer : public Bu::Server
50{
51public:
52 TelServer()
53 {
54 }
55
56 virtual ~TelServer()
57 {
58 }
59
60 virtual void onNewConnection( Bu::Client *pClient, int )
61 {
62 printf("New connection.\n");
63
64 pClient->setProtocol( new MyTelnet() );
65 }
66
67 virtual void onClosedConnection( Bu::Client *pClient )
68 {
69 printf("Lost connection.\n");
70
71 delete pClient->getProtocol();
72 }
73
74private:
75
76};
77
78int main()
79{
80 TelServer ts;
81
82 ts.addPort( 4000 );
83 ts.setTimeout( 0, 5000 );
84
85 printf("Initializing server on port: 4000\n");
86
87 for(;;)
88 {
89 ts.scan();
90 }
91}
92
diff --git a/src/tests/tracer.cpp b/src/tests/tracer.cpp
deleted file mode 100644
index 703fa1a..0000000
--- a/src/tests/tracer.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8
9#define BU_TRACE
10#include "bu/trace.h"
11
12void doThing3( int x, const char *bob, void *p )
13{
14 TRACE( x, bob, p );
15}
16
17void doThing2( int x, const char *bob )
18{
19 TRACE( x, bob );
20}
21
22void doThing( int8_t x )
23{
24 TRACE( x );
25}
26
27int main( int argc, char *argv[] )
28{
29 TRACE( argc, argv );
30 doThing( 54 );
31 doThing2( 128, "Hello" );
32 doThing3( 266, "Goodbye", argv );
33
34 return 0;
35}
36
diff --git a/src/tests/udpsocket.cpp b/src/tests/udpsocket.cpp
deleted file mode 100644
index 2a74acf..0000000
--- a/src/tests/udpsocket.cpp
+++ /dev/null
@@ -1,86 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include "bu/udpsocket.h"
9#include "bu/sio.h"
10
11#include <errno.h>
12#include <arpa/inet.h>
13#include <sys/socket.h>
14#include <netinet/in.h>
15#include <sys/utsname.h>
16
17using namespace Bu;
18
19int main( int argc, char *argv[] )
20{
21 sio << Fmt::hex(8) << INADDR_ANY << sio.nl << Fmt::hex(8) << inet_addr("0.0.0.0") << sio.nl;
22 if( argc == 1 )
23 {
24 sio << "Options are 'l' for listening and 'b' for broadcasting."
25 << sio.nl;
26 }
27 else if( argv[1][0] == 'l' )
28 {
29 sio << "Listening..." << sio.nl;
30 Bu::UdpSocket udp( "0.0.0.0", 6688, UdpSocket::Read|UdpSocket::Broadcast );
31
32 for(;;)
33 {
34 char buf[1501];
35 int iRead = udp.read( buf, 1500 );
36 if( iRead >= 0 )
37 {
38 buf[iRead] = '\0';
39 sio << "Read(" << iRead << "): '" << buf << "'" << sio.nl;
40 }
41 else
42 {
43 sio << "Got " << iRead << ": " << strerror( errno ) << sio.nl;
44 }
45 }
46 }
47 else if( argv[1][0] == 'L' )
48 {
49 sio << "Listening..." << sio.nl;
50 Bu::UdpSocket udp( "0.0.0.0", 6688, UdpSocket::Read|UdpSocket::Broadcast );
51
52 for(;;)
53 {
54 char buf[1501];
55 Bu::UdpSocket::addr aHost;
56 int iPort;
57 int iRead = udp.read( buf, 1500, aHost, iPort );
58 if( iRead >= 0 )
59 {
60 buf[iRead] = '\0';
61 sio << "Read(" << iRead << ") from " << Bu::UdpSocket::addrToStr( aHost ) << ":" << iPort << ": '" << buf << "'" << sio.nl;
62 }
63 }
64 }
65 else if( argv[1][0] == 'b' )
66 {
67 sio << "Broadcasting..." << sio.nl;
68 Bu::UdpSocket udp("255.255.255.255", 6688,
69 UdpSocket::Write|UdpSocket::Broadcast );
70
71 for(;;)
72 {
73 int iWrote = udp.write("hello", 5 );
74 sio << "Wrote(" << iWrote << "): " << strerror( errno ) << sio.nl;
75 usleep( 250000 );
76 }
77 }
78 else
79 {
80 sio << "Options are 'l' for listening and 'b' for broadcasting."
81 << sio.nl;
82 }
83
84 return 0;
85}
86
diff --git a/src/tests/url.cpp b/src/tests/url.cpp
deleted file mode 100644
index a381cbe..0000000
--- a/src/tests/url.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include "bu/url.h"
9
10#include <stdio.h>
11
12int main( int argc, char *argv[] )
13{
14 for( argc--, argv++; argc >= 0; argc--, argv++ )
15 {
16 printf("encodede: %s\n", Bu::Url::encode( *argv ).getStr() );
17 printf("decodede: %s\n", Bu::Url::decode( *argv ).getStr() );
18 Bu::Url u( *argv );
19
20 printf("Protocol: %s\n", u.getProtocol().getStr() );
21 printf("User: %s\n", u.getUser().getStr() );
22 printf("Pass: %s\n", u.getPass().getStr() );
23 printf("Host: %s\n", u.getHost().getStr() );
24 printf("Path: %s\n", u.getPath().getStr() );
25 try
26 {
27 printf("Port: %d\n", u.getPort() );
28 } catch( Bu::ExceptionBase &e )
29 {
30 printf("Port: not set.\n");
31 }
32 printf("Parameters:\n");
33 for( Bu::Url::ParamList::const_iterator i = u.getParamBegin(); i; i++ )
34 {
35 printf(" \"%s\" = \"%s\"\n",
36 (*i).sName.getStr(), (*i).sValue.getStr()
37 );
38 }
39 }
40
41 return 0;
42}
diff --git a/src/tests/variant.cpp b/src/tests/variant.cpp
deleted file mode 100644
index 68dec4f..0000000
--- a/src/tests/variant.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include <bu/sio.h>
9#include <bu/variant.h>
10#include <bu/list.h>
11
12using namespace Bu;
13
14Variant getThing( int i )
15{
16 Variant v;
17 switch( i )
18 {
19 case 0:
20 v = 45;
21 break;
22
23 case 1:
24 v = true;
25 break;
26
27 case 2:
28 v = List<int>(5).append(10).append(15);
29 break;
30 }
31
32 return v;
33}
34
35int main()
36{
37 Variant a;
38 Variant b;
39 Variant c;
40
41 a = getThing( 0 );
42 b = getThing( 1 );
43 c = getThing( 2 );
44
45 sio << "a = " << a << " or " << (int)a << sio.nl
46 << "b = " << b << " or " << b.toString() << sio.nl
47 << "c = " << c << " or " << c.toString() << sio.nl
48 << sio.nl;
49
50 return 0;
51}
52
diff --git a/src/unit/string.unit b/src/unit/string.unit
index 4911597..5298f8a 100644
--- a/src/unit/string.unit
+++ b/src/unit/string.unit
@@ -174,7 +174,7 @@ suite String
174 unitTest( a == b ); 174 unitTest( a == b );
175 } 175 }
176 176
177 test iterator2 177 test iteratorCompare1
178 { 178 {
179 Bu::String a("This is a test."); 179 Bu::String a("This is a test.");
180 Bu::String b("--This is a test."); 180 Bu::String b("--This is a test.");
@@ -185,9 +185,12 @@ suite String
185 bi++; bi++; 185 bi++; bi++;
186 unitTest( ai.compare( bi ) == true ); 186 unitTest( ai.compare( bi ) == true );
187 unitTest( bi.compare( ai ) == true ); 187 unitTest( bi.compare( ai ) == true );
188 b += "hi";
189 unitTest( ai.compare( bi ) == false );
190 unitTest( bi.compare( ai ) == false );
188 } 191 }
189 192
190 test iterator3 193 test iteratorCompare2
191 { 194 {
192 Bu::String a("1234honour"); 195 Bu::String a("1234honour");
193 Bu::String b("--1234ueje"); 196 Bu::String b("--1234ueje");
@@ -200,19 +203,33 @@ suite String
200 unitTest( bi.compare( ai, 4 ) == true ); 203 unitTest( bi.compare( ai, 4 ) == true );
201 unitTest( ai.compare( bi, 5 ) == false ); 204 unitTest( ai.compare( bi, 5 ) == false );
202 unitTest( bi.compare( ai, 5 ) == false ); 205 unitTest( bi.compare( ai, 5 ) == false );
203 206
207 a = "fell";
208 b = "-felloo";
209 ai = a.begin();
210 bi = b.begin()+1;
211 unitTest( ai.compare( bi, 4 ) == true );
212 ai++;
213 bi++;
214 unitTest( ai.compare( bi, 4 ) == false );
204 } 215 }
205 216
206 test iterator4 217 test iteratorCompare3
207 { 218 {
208 Bu::String a("1234aoeu"); 219 Bu::String a("1234aoeu");
209 Bu::String::iterator ai = a.begin(); 220 Bu::String::iterator ai = a.begin();
210 unitTest( ai.compare("1234") == false ); 221 unitTest( ai.compare("1234") == false );
211 unitTest( ai.compare("1234aoeu") == true ); 222 unitTest( ai.compare("1234aoeu") == true );
212 unitTest( ai.compare("1234aoeuee") == false ); 223 unitTest( ai.compare("1234aoeuee") == false );
224 ai += 4;
225 unitTest( ai.compare("aoeu") == true );
226 unitTest( ai.compare("aoeubo") == false );
227 unitTest( ai.compare("aoe") == false );
228 unitTest( ai.compare("wrong") == false );
229 unitTest( ai.compare("boeu") == false );
213 } 230 }
214 231
215 test iterator5 232 test iteratorCompare4
216 { 233 {
217 Bu::String a("1234aoeu"); 234 Bu::String a("1234aoeu");
218 Bu::String::iterator ai = a.begin(); 235 Bu::String::iterator ai = a.begin();
@@ -221,7 +238,119 @@ suite String
221 unitTest( ai.compare("1234aoeuee", 10) == false ); 238 unitTest( ai.compare("1234aoeuee", 10) == false );
222 } 239 }
223 240
224 test iterator6 241 test iteratorCompare5
242 {
243 Bu::String a("1234aoeu");
244 Bu::String b("34ao");
245 Bu::String::iterator ai = a.begin();
246 unitTest( ai.compare( b ) == false );
247 ai += 2;
248 unitTest( ai.compare( b ) == false );
249 b = "oeu";
250 ai += 3;
251 unitTest( ai.compare( b ) == true );
252 b += "boo";
253 unitTest( ai.compare( b ) == false );
254 }
255
256 test iteratorCompare6
257 {
258 Bu::String a("1234aoeu");
259 Bu::String::iterator ai = a.begin();
260 unitTest( ai.compare( Bu::String("1234"), 4) == true );
261 unitTest( ai.compare( Bu::String("1234aoeu"), 8) == true );
262 unitTest( ai.compare( Bu::String("1234aoeuee"), 10) == false );
263 }
264
265 test const_iteratorCompare1
266 {
267 Bu::String a("This is a test.");
268 Bu::String b("--This is a test.");
269 Bu::String::const_iterator ai = a.begin();
270 Bu::String::const_iterator bi = b.begin();
271 unitTest( ai.compare( bi ) == false );
272 unitTest( bi.compare( ai ) == false );
273 bi++; bi++;
274 unitTest( ai.compare( bi ) == true );
275 unitTest( bi.compare( ai ) == true );
276 b += "hi";
277 unitTest( ai.compare( bi ) == false );
278 unitTest( bi.compare( ai ) == false );
279 }
280
281 test const_iteratorCompare2
282 {
283 Bu::String a("1234honour");
284 Bu::String b("--1234ueje");
285 Bu::String::const_iterator ai = a.begin();
286 Bu::String::const_iterator bi = b.begin();
287 unitTest( ai.compare( bi, 4 ) == false );
288 unitTest( bi.compare( ai, 4 ) == false );
289 bi++; bi++;
290 unitTest( ai.compare( bi, 4 ) == true );
291 unitTest( bi.compare( ai, 4 ) == true );
292 unitTest( ai.compare( bi, 5 ) == false );
293 unitTest( bi.compare( ai, 5 ) == false );
294
295 a = "fell";
296 b = "-felloo";
297 ai = a.begin();
298 bi = b.begin()+1;
299 unitTest( ai.compare( bi, 4 ) == true );
300 ai++;
301 bi++;
302 unitTest( ai.compare( bi, 4 ) == false );
303 }
304
305 test const_iteratorCompare3
306 {
307 Bu::String a("1234aoeu");
308 Bu::String::const_iterator ai = a.begin();
309 unitTest( ai.compare("1234") == false );
310 unitTest( ai.compare("1234aoeu") == true );
311 unitTest( ai.compare("1234aoeuee") == false );
312 ai += 4;
313 unitTest( ai.compare("aoeu") == true );
314 unitTest( ai.compare("aoeubo") == false );
315 unitTest( ai.compare("aoe") == false );
316 unitTest( ai.compare("wrong") == false );
317 unitTest( ai.compare("boeu") == false );
318 }
319
320 test const_iteratorCompare4
321 {
322 Bu::String a("1234aoeu");
323 Bu::String::const_iterator ai = a.begin();
324 unitTest( ai.compare("1234", 4) == true );
325 unitTest( ai.compare("1234aoeu", 8) == true );
326 unitTest( ai.compare("1234aoeuee", 10) == false );
327 }
328
329 test const_iteratorCompare5
330 {
331 Bu::String a("1234aoeu");
332 Bu::String b("34ao");
333 Bu::String::const_iterator ai = a.begin();
334 unitTest( ai.compare( b ) == false );
335 ai += 2;
336 unitTest( ai.compare( b ) == false );
337 b = "oeu";
338 ai += 3;
339 unitTest( ai.compare( b ) == true );
340 b += "boo";
341 unitTest( ai.compare( b ) == false );
342 }
343
344 test const_iteratorCompare6
345 {
346 Bu::String a("1234aoeu");
347 Bu::String::const_iterator ai = a.begin();
348 unitTest( ai.compare( Bu::String("1234"), 4) == true );
349 unitTest( ai.compare( Bu::String("1234aoeu"), 8) == true );
350 unitTest( ai.compare( Bu::String("1234aoeuee"), 10) == false );
351 }
352
353 test iteratorAppend1
225 { 354 {
226 Bu::String a("just ->this part"); 355 Bu::String a("just ->this part");
227 Bu::String b; 356 Bu::String b;
@@ -247,7 +376,7 @@ suite String
247 unitTest( c == b ); 376 unitTest( c == b );
248 } 377 }
249 378
250 test iterator7 379 test iteratorAppend2
251 { 380 {
252 Bu::String a("just [this] part"); 381 Bu::String a("just [this] part");
253 Bu::String b; 382 Bu::String b;
@@ -428,6 +557,22 @@ suite String
428 unitTest( s1.toLower() == "hello there, how are you doing?" ); 557 unitTest( s1.toLower() == "hello there, how are you doing?" );
429 unitTest( s1 == "HeLlO ThErE, HoW ArE YoU DoInG?" ); 558 unitTest( s1 == "HeLlO ThErE, HoW ArE YoU DoInG?" );
430 } 559 }
560
561 test trimWhitespace1
562 {
563 unitTest( Bu::String("Hello there").trimWhitespace()
564 == "Hello there" );
565 unitTest( Bu::String(" \t\r\r\nHello there").trimWhitespace()
566 == "Hello there" );
567 unitTest( Bu::String("Hello there \r\n\n\t\t ").trimWhitespace()
568 == "Hello there" );
569 unitTest( Bu::String(" \tHello there\r\n \t").trimWhitespace()
570 == "Hello there" );
571 unitTest( Bu::String(" \t\t\r\n").trimWhitespace() == "" );
572 unitTest( Bu::String().trimWhitespace() == "" );
573 unitTest( Bu::String(" \tHello \t\t\r\nthere\r\n \t").trimWhitespace()
574 == "Hello \t\t\r\nthere" );
575 }
431} 576}
432// 03F09CA4F58AC8CA0E80F0D9D409D0A60700A192270004BC3A99E91D0001034F544603362E35013103313130019CA4F58AC8CA0E0002830800002C4200008AC200EBF7D9D4090127BB010000E3 577// 03F09CA4F58AC8CA0E80F0D9D409D0A60700A192270004BC3A99E91D0001034F544603362E35013103313130019CA4F58AC8CA0E0002830800002C4200008AC200EBF7D9D4090127BB010000E3
433// 578//
diff --git a/test.taf b/test.taf
index cc45a4b..5bd8c48 100644
--- a/test.taf
+++ b/test.taf
@@ -1,6 +1,1377 @@
1{"test": 1{"newVTR":
2 {repo: 2 //FONT DEFINITIONS
3 url = "http://svn.xagasoft.com/libbu++" 3 "basefontsize"="6pt"
4 name = libbu++ 4 {"font":
5 } 5 "name"="form_info"
6 "face"="Times New Roman"
7 "face"="Times"
8 "face"="serif"
9 "size"="{=basefontsize}"
10 }
11 {"font":
12 "name"="big_form_info"
13 "face"="Times New Roman"
14 "face"="Times"
15 "face"="serif"
16 "size"="{=basefontsize}+2pt"
17 "style"="bold"
18 }
19 {"font":
20 "name"="main_title"
21 "face"="Times New Roman"
22 "face"="Times"
23 "face"="serif"
24 "size"="{=basefontsize}+3.5pt"
25 "style"="bold"
26 }
27 {"font":
28 "name"="plain_title"
29 "face"="Times New Roman"
30 "face"="Times"
31 "face"="serif"
32 "size"="{=basefontsize}+3.5pt"
33 }
34 {"font":
35 "name"="italic_title"
36 "face"="Times New Roman"
37 "face"="Times"
38 "face"="serif"
39 "size"="{=basefontsize}+2pt"
40 "style"="italic"
41 }
42 {"font":
43 "name"="small_title"
44 "face"="Times New Roman"
45 "face"="Times"
46 "face"="serif"
47 "size"="{=basefontsize}-2pt"
48 }
49 {"font":
50 "name"="main_font"
51 "face"="Times New Roman"
52 "face"="Times"
53 "face"="serif"
54 "size"="{=basefontsize}"
55 "style"="bold"
56 }
57 {"font":
58 "name"="main_font_plain"
59 "face"="Times New Roman"
60 "face"="Times"
61 "face"="serif"
62 "size"="{=basefontsize}"
63 }
64 {"font":
65 "name"="big_font_bold"
66 "face"="Times New Roman"
67 "face"="Times"
68 "face"="serif"
69 "size"="{=basefontsize}+3.5pt"
70 "style"="bold"
71 }
72 {"font":
73 "name"="fill_in"
74 "face"="Courier New"
75 "face"="monospace"
76 "size"="{=basefontsize}+4pt"
77 "style"="bold"
78 }
79 {"font":
80 "name"="fill_in_med"
81 "face"="Courier New"
82 "face"="monospace"
83 "size"="{=basefontsize}+1pt"
84 "style"="bold"
85 }
86 {"font":
87 "name"="fill_in_sm"
88 "face"="Courier New"
89 "face"="monospace"
90 "size"="{=basefontsize}-0pt"
91 "style"="bold"
92 }
93 //DEFAULTS
94 {"default":
95 {"text":
96 "font"="main_font"
97 "alignment"="top"
98 }
99 }
100 //THE ACTUAL PAGE
101 {"page":
102 "name"="vtr_page"
103 "width"="8.5in"
104 "height"="11in"
105 "padding-left"=".3125in"
106 "padding-right"=".25in"
107 "padding-top"=".125in"
108 "padding-bottom"=".125in"
109 //FORM TITLE
110 {"box":
111 "name"="doc_header"
112 "width"="100%"
113 "height"=".3in"
114 {"text":
115 "string"="FISHING VESSEL TRIP REPORT"
116 "top"=".06in"
117 "font"="main_title"
118 "left"="2.8in"
119 }
120 }
121 //DID NOT FISH BOX
122 {"box":
123 "name"="did_not_fish"
124 "top"="doc_header::bottom"
125 "width"="3.2in"
126 "height"=".85in"
127 "thickness"="1pt"
128 "style"="solid"
129 {"text":
130 "top"="5pt"
131 "left"="1in"
132 "string"="DID NOT FISH"
133 "font"="plain_title"
134 }
135 {"box":
136 "name"="dnf_start"
137 "top"=".3in"
138 "width"="1.6in"
139 {"text":
140 "string"="Start Date"
141 "left"=".6in"
142 }
143 {"text":
144 "top"="14pt"
145 "left"=".35in"
146 "string"="______/______/______"
147 }
148 {"text":
149 "top"="24pt"
150 "left"=".35in"
151 "string"=" MM DD YY"
152 }
153 }
154 {"box":
155 "left"="dnf_start::right"
156 "top"=".3in"
157 {"text":
158 "string"="End Date"
159 "left"=".6in"
160 }
161 {"text":
162 "top"="14pt"
163 "left"=".35in"
164 "string"="______/______/______"
165 }
166 {"text":
167 "top"="24pt"
168 "left"=".35in"
169 "string"=" MM DD YY"
170 }
171 }
172 }
173 //FORM INFO (NUMBERS AND PERMIT, ETC)
174 {"box":
175 "name"="form_info"
176 "top"="doc_header::bottom"
177 "left"="did_not_fish::right"
178 "height"=".85in"
179 {"text":
180 "string"="NOAA Form No. 88-30"
181 "left"="3.6in"
182 "font"="form_info"
183 }
184 {"text":
185 "string"="OMB No. 0648-0212"
186 "top"="10pt"
187 "left"="3.71in"
188 "font"="form_info"
189 }
190 {"text":
191 "string"="Expires 1/31/2013"
192 "top"="20pt"
193 "left"="3.83in"
194 "font"="form_info"
195 }
196 {"text":
197 "top"=".6in"
198 "left"=".2in"
199 "src"="page_num"
200 "font"="main_title"
201 }
202 {"box":
203 "name"="permit"
204 "top"=".4in"
205 "left"="1.6in"
206 "width"="1in"
207 {"text":
208 "top"="5pt"
209 "string"="__________"
210 "font"="big_font_bold"
211 }
212 {"text":
213 "top"="19pt"
214 "string"=" PERMIT"
215 "font"="big_form_info"
216 }
217 //VESSEL PERMIT
218 {"text":
219 "top"="4pt"
220 "string"="FIXME"
221 "font"="fill_in"
222 "src"="rpt_permit"
223 }
224 }
225 {"box":
226 "name"="permit_year"
227 "top"=".4in"
228 "left"="permit::right"
229 "width"=".5in"
230 {"text":
231 "top"="5pt"
232 "string"="____"
233 "font"="big_font_bold"
234 }
235 {"text":
236 "top"="19pt"
237 "string"=" YY"
238 "font"="big_form_info"
239 }
240 //YEAR
241 {"text":
242 "top"="4pt"
243 "string"="FIXME"
244 "font"="fill_in"
245 "src"="rpt_year"
246 }
247 }
248 {"box":
249 "name"="permit_month"
250 "top"=".4in"
251 "left"="permit_year::right"
252 "width"=".5in"
253 {"text":
254 "top"="5pt"
255 "string"="____"
256 "font"="big_font_bold"
257 }
258 {"text":
259 "top"="19pt"
260 "string"=" MM"
261 "font"="big_form_info"
262 }
263 //MONTH
264 {"text":
265 "top"="4pt"
266 "string"="FIXME"
267 "font"="fill_in"
268 "src"="rpt_month"
269 }
270 }
271 {"box":
272 "name"="permit_day"
273 "top"=".4in"
274 "left"="permit_month::right"
275 "width"=".5in"
276 {"text":
277 "top"="5pt"
278 "string"="____"
279 "font"="big_font_bold"
280 }
281 {"text":
282 "top"="19pt"
283 "string"=" DD"
284 "font"="big_form_info"
285 }
286 //DAY
287 {"text":
288 "top"="4pt"
289 "string"="FIXME"
290 "font"="fill_in"
291 "src"="rpt_day"
292 }
293 }
294 {"box":
295 "name"="permit_hour"
296 "top"=".4in"
297 "left"="permit_day::right"
298 "width"=".5in"
299 {"text":
300 "top"="5pt"
301 "string"="____"
302 "font"="big_font_bold"
303 }
304 {"text":
305 "top"="19pt"
306 "string"=" HH"
307 "font"="big_form_info"
308 }
309 //HOUR
310 {"text":
311 "top"="4pt"
312 "string"="FIXME"
313 "font"="fill_in"
314 "src"="rpt_hour"
315 }
316 }
317 }
318 //HEADER LINE ONE
319 {"box":
320 "src"="trip_info"
321 "name"="header_line_1"
322 "top"="form_info::bottom+.2in"
323 "height"=".55in"
324 {"box":
325 "name"="vessel_name"
326 "width"="3in"
327 "thickness"="1pt"
328 "style"="solid"
329 {"text":
330 "top"="2pt"
331 "left"="5pt"
332 "string"="1. Vessel Name"
333 }
334 //VESSEL NAME
335 {"text":
336 "top"="16pt"
337 "left"=".2in"
338 "src"="vessel_name"
339 "font"="fill_in"
340 }
341 }
342 {"box":
343 "name"="doc_reg"
344 "left"="vessel_name::right"
345 "width"="2.5in"
346 "thickness"="1pt"
347 "style"="solid"
348 {"text":
349 "top"="2pt"
350 "left"="5pt"
351 "string"="2. USCG Documentation or State Registration"
352 }
353 //DOC REG
354 {"text":
355 "top"="16pt"
356 "left"=".2in"
357 "src"="doc_reg"
358 "font"="fill_in"
359 }
360 }
361 {"box":
362 "name"="permit"
363 "left"="doc_reg::right"
364 "thickness"="1pt"
365 "style"="solid"
366 {"text":
367 "top"="2pt"
368 "left"="5pt"
369 "string"="3. NMFS Vessel Permit Number"
370 }
371 //VESSEL PERMIT
372 {"text":
373 "top"="16pt"
374 "left"=".2in"
375 "src"="vessel_permit"
376 "font"="fill_in"
377 }
378 }
379 }
380 //HEADER LINE TWO
381 {"box":
382 "name"="header_line_2"
383 "top"="header_line_1::bottom"
384 "height"=".65in"
385 {"box":
386 "name"="date_sailed"
387 "width"="4in"
388 "thickness"="1pt"
389 "style"="solid"
390 {"text":
391 "top"="2pt"
392 "left"="5pt"
393 "string"="4. Date and Time Sailed"
394 }
395 {"text":
396 "top"=".36in"
397 "left"="5pt"
398 "string"="Date: ________/________/________"
399 "font"="main_font_plain"
400 }
401 //SAILED MM
402 {"text":
403 "top"=".28in"
404 "left"=".4in"
405 "string"="FIXME"
406 "font"="fill_in"
407 "src"="sailed_month"
408 }
409 //SAILED DD
410 {"text":
411 "top"=".28in"
412 "left"=".9in"
413 "string"="FIXME"
414 "font"="fill_in"
415 "src"="sailed_day"
416 }
417 //SAILED YY
418 {"text":
419 "top"=".28in"
420 "left"="1.4in"
421 "string"="FIXME"
422 "font"="fill_in"
423 "src"="sailed_year"
424 }
425 {"text":
426 "top"=".38in+8pt"
427 "left"="5pt+.4in"
428 "string"="MM DD YY"
429 "font"="main_font_plain"
430 }
431 {"text":
432 "top"=".36in"
433 "left"="2in+5pt"
434 "string"="Military Time: ________ : ________"
435 "font"="main_font_plain"
436 }
437 //SAILED TIME HH
438 {"text":
439 "top"=".28in"
440 "left"="2.9in"
441 "string"="FIXME"
442 "font"="fill_in"
443 "src"="sailed_hour"
444 }
445 //SAILED TIME MM
446 {"text":
447 "top"=".28in"
448 "left"="3.4in"
449 "string"="FIXME"
450 "font"="fill_in"
451 "src"="sailed_min"
452 }
453 {"text":
454 "top"=".38in+8pt"
455 "left"="2.4in+7pt+.4in"
456 "string"="HH MM"
457 "font"="main_font_plain"
458 }
459 }
460 {"box":
461 "name"="date_landed"
462 "left"="date_sailed::right"
463 "thickness"="1pt"
464 "style"="solid"
465 {"text":
466 "top"="2pt"
467 "left"="5pt"
468 "string"="5. Date and Time Landed"
469 }
470 {"text":
471 "top"=".36in"
472 "left"="5pt"
473 "string"="Date: ________/________/________"
474 "font"="main_font_plain"
475 }
476 //LANDED MM
477 {"text":
478 "top"=".28in"
479 "left"=".4in"
480 "string"="FIXME"
481 "font"="fill_in"
482 "src"="landed_month"
483 }
484 //LANDED DD
485 {"text":
486 "top"=".28in"
487 "left"=".9in"
488 "string"="FIXME"
489 "font"="fill_in"
490 "src"="landed_day"
491 }
492 //LANDED YY
493 {"text":
494 "top"=".28in"
495 "left"="1.4in"
496 "string"="FIXME"
497 "font"="fill_in"
498 "src"="landed_year"
499 }
500 {"text":
501 "top"=".38in+8pt"
502 "left"="5pt+.4in"
503 "string"="MM DD YY"
504 "font"="main_font_plain"
505 }
506 {"text":
507 "top"=".36in"
508 "left"="2in+5pt"
509 "string"="Military Time: ________ : ________"
510 "font"="main_font_plain"
511 }
512 //LANDED TIME HH
513 {"text":
514 "top"=".28in"
515 "left"="2.9in"
516 "string"="FIXME"
517 "font"="fill_in"
518 "src"="landed_hour"
519 }
520 //LANDED TIME MM
521 {"text":
522 "top"=".28in"
523 "left"="3.4in"
524 "string"="FIXME"
525 "font"="fill_in"
526 "src"="landed_min"
527 }
528 {"text":
529 "top"=".38in+8pt"
530 "left"="2.4in+7pt+.4in"
531 "string"="HH MM"
532 "font"="main_font_plain"
533 }
534 }
535 }
536 //HEADER LINE THREE
537 {"box":
538 "src"="trip_info"
539 "name"="header_line_3"
540 "top"="header_line_2::bottom"
541 "height"=".65in"
542 "thickness"="1pt"
543 "style"="solid"
544 {"text":
545 "top"="2pt"
546 "left"="5pt"
547 "string"="6. Trip Type - check one box and record the number of crew including the captain. Party/Charter must also include the number of anglers."
548 }
549 //COMERCIAL
550 {"box":
551 "name"="commercial"
552 "top"="14pt"
553 "left"="7pt"
554 "width"="2.2in"
555 {"box":
556 "name"="commercial_check"
557 "top"=".12in"
558 "height"=".2in"
559 "width"=".3in"
560 "thickness"="1pt"
561 "style"="solid"
562 //COMM CHECK
563 {"text":
564 "top"="1pt"
565 "left"=".1in"
566 "src"="tt_commercial"
567 "font"="fill_in"
568 }
569 }
570 {"text":
571 "top"="commercial_check::top+2pt"
572 "left"="commercial_check::right+2pt"
573 "string"="Commercial: # of Crew ________"
574 "font"="main_font_plain"
575 }
576 //COMM CrewNum
577 {"text":
578 "top"="commercial_check::top-3pt"
579 "left"="commercial_check::right+1.2in"
580 "src"="crew_no"
581 "font"="fill_in"
582 }
583 }
584 //RSAEFP
585 {"box":
586 "name"="rsaefp"
587 "top"="14pt"
588 "left"="commercial::right"
589 "width"="2.1in"
590 {"box":
591 "name"="rsaefp_check"
592 "top"=".12in"
593 "height"=".2in"
594 "width"=".3in"
595 "thickness"="1pt"
596 "style"="solid"
597 //rsaefp CHECK
598 {"text":
599 "top"="1pt"
600 "left"=".1in"
601 "string"=""
602 "font"="fill_in"
603 }
604 }
605 {"text":
606 "top"="rsaefp_check::top+2pt"
607 "left"="rsaefp_check::right+2pt"
608 "string"="RSA/EFP: # of Crew ________"
609 "font"="main_font_plain"
610 }
611 //RSAEFP CrewNum
612 {"text":
613 "top"="rsaefp_check::top-3pt"
614 "left"="rsaefp_check::right+1.1in"
615 "string"=""
616 // src="crew_no"
617 "font"="fill_in"
618 }
619 }
620 //PARTY
621 {"box":
622 "name"="party"
623 "top"="14pt"
624 "left"="rsaefp::right"
625 "width"="1.8in"
626 {"box":
627 "name"="party_check"
628 "top"=".12in"
629 "height"=".2in"
630 "width"=".3in"
631 "thickness"="1pt"
632 "style"="solid"
633 //party CHECK
634 {"text":
635 "top"="1pt"
636 "left"=".1in"
637 "src"="tt_party"
638 "font"="fill_in"
639 }
640 }
641 {"text":
642 "top"="party_check::top+2pt"
643 "left"="party_check::right+2pt"
644 "string"="Party:"
645 "font"="main_font_plain"
646 }
647 {"text":
648 "top"="5pt"
649 "left"="party_check::right+.3in"
650 "string"="# of Crew ______"
651 "font"="main_font_plain"
652 }
653 //Party CrewNum
654 {"text":
655 "top"="-1pt"
656 "left"="party_check::right+.9in"
657 "string"=""
658 // src="crew_no"
659 "font"="fill_in"
660 }
661 {"text":
662 "top"=".25in"
663 "left"="party_check::right+.3in"
664 "string"="# of Anglers ______"
665 "font"="main_font_plain"
666 }
667 //Party Anglers
668 {"text":
669 "top"=".24in-3pt"
670 "left"="party_check::right+.9in"
671 "string"=""
672 // src="angler_no"
673 "font"="fill_in"
674 }
675 }
676 //CHARTER
677 {"box":
678 "name"="charter"
679 "top"="14pt"
680 "left"="party::right"
681 //width=2.2in
682 {"box":
683 "name"="charter_check"
684 "top"=".12in"
685 "height"=".2in"
686 "width"=".3in"
687 "thickness"="1pt"
688 "style"="solid"
689 //charter CHECK
690 {"text":
691 "top"="1pt"
692 "left"=".1in"
693 "src"="tt_charter"
694 "font"="fill_in"
695 }
696 }
697 {"text":
698 "top"="charter_check::top+2pt"
699 "left"="charter_check::right+2pt"
700 "string"="Charter:"
701 "font"="main_font_plain"
702 }
703 {"text":
704 "top"="5pt"
705 "left"="charter_check::right+.3in"
706 "string"="# of Crew ______"
707 "font"="main_font_plain"
708 }
709 //Party CrewNum
710 {"text":
711 "top"="-1pt"
712 "left"="charter_check::right+.9in"
713 "string"=""
714 // src="crew_no"
715 "font"="fill_in"
716 }
717 {"text":
718 "top"=".25in"
719 "left"="charter_check::right+.3in"
720 "string"="# of Anglers ______"
721 "font"="main_font_plain"
722 }
723 //Party Anglers
724 {"text":
725 "top"=".24in-3pt"
726 "left"="charter_check::right+.9in"
727 "string"=""
728 // src="angler_no"
729 "font"="fill_in"
730 }
731 }
732 }
733 //INSTRUCTIONS
734 {"box":
735 "name"="instructions"
736 "top"="header_line_3::bottom"
737 "height"=".5in"
738 {"text":
739 "top"=".15in"
740 "left"=".1in"
741 "string"="COMPLETE A NEW FORM FOR EACH DIFFERENT CHART AREA, GEAR TYPE OR MESH/RING SIZE USED ON A TRIP."
742 "font"="italic_title"
743 }
744 }
745 //DATA_LINE_1
746 {"box":
747 "src"="setup_info"
748 "name"="data_line_1"
749 "top"="instructions::bottom"
750 "height"=".55in"
751 {"box":
752 "name"="gear_code"
753 "width"="1.3in"
754 "thickness"="1pt"
755 "style"="solid"
756 {"text":
757 "top"="2pt"
758 "left"="5pt"
759 "string"="7. Gear Code"
760 }
761 //GEAR CODE
762 {"text":
763 "top"="16pt"
764 "left"=".2in"
765 "src"="gear"
766 "font"="fill_in"
767 }
768 }
769 {"box":
770 "name"="meshring_size"
771 "left"="gear_code::right"
772 "width"="1.25in"
773 "thickness"="1pt"
774 "style"="solid"
775 {"text":
776 "top"="2pt"
777 "left"="5pt"
778 "string"="8. Mesh/Ring Size"
779 }
780 //MESHRING SIZE
781 {"text":
782 "top"="16pt"
783 "left"=".2in"
784 "src"="mesh_ring_size"
785 "font"="fill_in"
786 }
787 }
788 {"box":
789 "name"="quantity"
790 "left"="meshring_size::right"
791 "width"="1.25in"
792 "thickness"="1pt"
793 "style"="solid"
794 {"text":
795 "top"="2pt"
796 "left"="5pt"
797 "string"="9. Gear Quantity"
798 }
799 //GEAR QUANTITY
800 {"text":
801 "top"="16pt"
802 "left"=".2in"
803 "src"="gear_num"
804 "font"="fill_in"
805 }
806 }
807 {"box":
808 "name"="size"
809 "left"="quantity::right"
810 "width"="1.25in"
811 "thickness"="1pt"
812 "style"="solid"
813 {"text":
814 "top"="2pt"
815 "left"="5pt"
816 "string"="10. Gear Size"
817 }
818 //GEAR SIZE
819 {"text":
820 "top"="16pt"
821 "left"=".2in"
822 "src"="gear_size"
823 "font"="fill_in"
824 }
825 }
826 {"box":
827 "name"="depth"
828 "left"="size::right"
829 "width"="1.5in"
830 "thickness"="1pt"
831 "style"="solid"
832 {"text":
833 "top"="2pt"
834 "left"="5pt"
835 "string"="11. Fishing Depth (Fathoms)"
836 }
837 //FISHING DEPTH
838 {"text":
839 "top"="16pt"
840 "left"=".2in"
841 "src"="depth"
842 "font"="fill_in"
843 }
844 }
845 {"box":
846 "name"="hauls"
847 "left"="depth::right"
848 "thickness"="1pt"
849 "style"="solid"
850 {"text":
851 "top"="2pt"
852 "left"="5pt"
853 "string"="12. Number of Hauls"
854 }
855 //HAUL NO
856 {"text":
857 "top"="16pt"
858 "left"=".2in"
859 "src"="haul_no"
860 "font"="fill_in"
861 }
862 }
863 }
864 //DATA_LINE_2
865 {"box":
866 "src"="setup_info"
867 "name"="data_line_2"
868 "top"="data_line_1::bottom"
869 "height"=".55in"
870 {"box":
871 "name"="chart_area"
872 "width"="1.2in"
873 "thickness"="1pt"
874 "style"="solid"
875 {"text":
876 "top"="2pt"
877 "left"="5pt"
878 "string"="13. Chart Area"
879 }
880 //CHART AREA
881 {"text":
882 "top"="16pt"
883 "left"=".2in"
884 "src"="chart_area"
885 "font"="fill_in"
886 }
887 }
888 {"box":
889 "name"="latitude"
890 "left"="chart_area::right"
891 "width"="2.2in"
892 "thickness"="1pt"
893 "style"="solid"
894 {"text":
895 "top"="2pt"
896 "left"="5pt"
897 "string"="14. Latitude"
898 }
899 {"text":
900 "top"=".25in"
901 "left"=".4in"
902 "string"="_____________:_____________"
903 "font"="main_font_plain"
904 }
905 //LAT DEG
906 {"text":
907 "top"="12pt"
908 "left"=".6in"
909 "string"="FIXME"
910 "font"="fill_in"
911 "src"="lat_hour"
912 }
913 //LAT MIN
914 {"text":
915 "top"="12pt"
916 "left"="1.4in"
917 "string"="FIXME"
918 "font"="fill_in"
919 "src"="lat_min"
920 }
921 {"text":
922 "top"=".25in+10pt"
923 "left"=".5in"
924 "string"="DEGREES MINUTES"
925 "font"="main_font_plain"
926 }
927 }
928 {"box":
929 "name"="longitude"
930 "left"="latitude::right"
931 "width"="2.2in"
932 "thickness"="1pt"
933 "style"="solid"
934 {"text":
935 "top"="2pt"
936 "left"="5pt"
937 "string"="15. Longitude"
938 }
939 {"text":
940 "top"=".25in"
941 "left"=".4in"
942 "string"="_____________:_____________"
943 "font"="main_font_plain"
944 }
945 //LON DEG
946 {"text":
947 "top"="12pt"
948 "left"=".6in"
949 "string"="FIXME"
950 "font"="fill_in"
951 "src"="lon_hour"
952 }
953 //LON MIN
954 {"text":
955 "top"="12pt"
956 "left"="1.4in"
957 "string"="FIXME"
958 "font"="fill_in"
959 "src"="lon_min"
960 }
961 {"text":
962 "top"=".25in+10pt"
963 "left"=".5in"
964 "string"="DEGREES MINUTES"
965 "font"="main_font_plain"
966 }
967 }
968 {"box":
969 "name"="towsoak_time"
970 "left"="longitude::right"
971 "thickness"="1pt"
972 "style"="solid"
973 {"text":
974 "top"="2pt"
975 "left"="5pt"
976 "string"="16. Tow / Soak Time"
977 }
978 {"text":
979 "top"=".25in"
980 "left"=".4in"
981 "string"="_____________:_____________"
982 "font"="main_font_plain"
983 }
984 //SOAK HR
985 {"text":
986 "top"="12pt"
987 "left"=".6in"
988 "src"="tow_soak_time_hrs"
989 "font"="fill_in"
990 }
991 //SOAK MIN
992 {"text":
993 "top"="12pt"
994 "left"="1.4in"
995 "src"="tow_soak_time_mins"
996 "font"="fill_in"
997 }
998 {"text":
999 "top"=".25in+10pt"
1000 "left"=".5in"
1001 "string"="HOURS MINUTES"
1002 "font"="main_font_plain"
1003 }
1004 }
1005 }
1006 //DATA_LINE_3
1007 {"box":
1008 "name"="data_line_3"
1009 "top"="data_line_2::bottom"
1010 "height"=".4in"
1011 {"box":
1012 "name"="species"
1013 "width"=".9in"
1014 "thickness"="1pt"
1015 "style"="solid"
1016 {"text":
1017 "top"="2pt"
1018 "left"=".45in"
1019 "string"="17."
1020 }
1021 {"text":
1022 "top"="11pt"
1023 "left"="15pt"
1024 "string"="Species Code"
1025 }
1026 }
1027 {"box":
1028 "name"="kept"
1029 "left"="species::right"
1030 "width"=".9in"
1031 "thickness"="1pt"
1032 "style"="solid"
1033 {"text":
1034 "top"="2pt"
1035 "left"=".45in"
1036 "string"="18."
1037 }
1038 {"text":
1039 "top"="11pt"
1040 "left"=".3in"
1041 "string"="Kept"
1042 }
1043 }
1044 {"box":
1045 "name"="discarded"
1046 "left"="kept::right"
1047 "width"=".9in"
1048 "thickness"="1pt"
1049 "style"="solid"
1050 {"text":
1051 "top"="2pt"
1052 "left"="5pt"
1053 "string"="19. Discarded"
1054 }
1055 }
1056 {"box":
1057 "name"="dealer_permit"
1058 "left"="discarded::right"
1059 "width"=".7in"
1060 "thickness"="1pt"
1061 "style"="solid"
1062 {"text":
1063 "top"="2pt"
1064 "left"="8pt"
1065 "string"="20. Dealer"
1066 }
1067 {"text":
1068 "top"="10pt"
1069 "left"="12pt"
1070 "string"="Permit"
1071 }
1072 {"text":
1073 "top"="18pt"
1074 "left"="10pt"
1075 "string"="Number"
1076 }
1077 }
1078 {"box":
1079 "name"="dealer_name"
1080 "left"="dealer_permit::right"
1081 "width"="1.8in"
1082 "thickness"="1pt"
1083 "style"="solid"
1084 {"text":
1085 "top"="2pt"
1086 "left"=".7in"
1087 "string"="21."
1088 }
1089 {"text":
1090 "top"="11pt"
1091 "left"=".5in"
1092 "string"="Dealer Name"
1093 }
1094 }
1095 {"box":
1096 "name"="date_sold"
1097 "left"="dealer_name::right"
1098 "width"=".75in"
1099 "thickness"="1pt"
1100 "style"="solid"
1101 {"text":
1102 "top"="2pt"
1103 "left"=".3in"
1104 "string"="22."
1105 }
1106 {"text":
1107 "top"="10pt"
1108 "left"="10pt"
1109 "string"="Date Sold"
1110 }
1111 {"text":
1112 "top"="18pt"
1113 "left"="7pt"
1114 "string"="MM/DD/YY"
1115 }
1116 }
1117 {"box":
1118 "name"="offload_port"
1119 "left"="date_sold::right"
1120 "thickness"="1pt"
1121 "style"="solid"
1122 {"text":
1123 "top"="1pt"
1124 "left"="5pt"
1125 "string"="23. Offloading Port for each species"
1126 }
1127 {"line":
1128 "top"="11pt"
1129 "bottom"="11pt"
1130 "thickness"="1pt"
1131 "style"="solid"
1132 }
1133 {"text":
1134 "top"="12pt"
1135 "left"=".6in"
1136 "string"="City"
1137 }
1138 {"line":
1139 "top"="11pt"
1140 "left"="1.5in"
1141 "right"="1.5in"
1142 }
1143 {"text":
1144 "top"="12pt"
1145 "left"="1.6in"
1146 "string"="State"
1147 }
1148 }
1149 }
1150 //DATA_GRID
1151 {"box":
1152 "name"="data_grid"
1153 "top"="data_line_3::bottom"
1154 "height"="4.25in"
1155 "src"="setup_info"
1156 {"box":
1157 "src"="catch_data"
1158 "repeat"="tile-ttb-ltr"
1159 "height"=".3in"
1160 {"box":
1161 "name"="data_species"
1162 "width"=".9in"
1163 "thickness"="1pt"
1164 "style"="solid"
1165 //SPECIES
1166 {"text":
1167 "top"="2pt"
1168 "left"=".1in"
1169 "src"="species_code"
1170 "font"="fill_in"
1171 }
1172 }
1173 {"box":
1174 "name"="data_kept"
1175 "left"="data_species::right"
1176 "width"=".9in"
1177 "thickness"="1pt"
1178 "style"="solid"
1179 //KEPT
1180 {"text":
1181 "top"="2pt"
1182 "left"=".1in"
1183 "src"="kept_pounds"
1184 "font"="fill_in"
1185 }
1186 }
1187 {"box":
1188 "name"="data_discarded"
1189 "left"="data_kept::right"
1190 "width"=".9in"
1191 "thickness"="1pt"
1192 "style"="solid"
1193 //DISC
1194 {"text":
1195 "top"="2pt"
1196 "left"=".1in"
1197 "src"="disc_pounds"
1198 "font"="fill_in"
1199 }
1200 }
1201 {"box":
1202 "name"="data_dealer_permit"
1203 "left"="data_discarded::right"
1204 "width"=".7in"
1205 "thickness"="1pt"
1206 "style"="solid"
1207 //DEALER_NUM
1208 {"text":
1209 "top"="5pt"
1210 "left"="5pt"
1211 "src"="dealer_no"
1212 "font"="fill_in_med"
1213 }
1214 }
1215 {"box":
1216 "name"="data_dealer_name"
1217 "left"="data_dealer_permit::right"
1218 "width"="1.8in"
1219 "thickness"="1pt"
1220 "style"="solid"
1221 //DEALER NAME
1222 {"text":
1223 "top"="1pt"
1224 "left"="5pt"
1225 "src"="dealer_name"
1226 "font"="fill_in_sm"
1227 }
1228 }
1229 {"box":
1230 "name"="data_date_sold"
1231 "left"="data_dealer_name::right"
1232 "width"=".75in"
1233 "thickness"="1pt"
1234 "style"="solid"
1235 //DATE SOLD
1236 {"text":
1237 "top"="5pt"
1238 "left"="2pt"
1239 "src"="date_sold"
1240 "font"="fill_in_med"
1241 }
1242 }
1243 {"box":
1244 "name"="data_port_city"
1245 "left"="data_date_sold::right"
1246 "width"="1.5in"
1247 "thickness"="1pt"
1248 "style"="solid"
1249 //PORT CITY
1250 {"text":
1251 "top"="5pt"
1252 "left"="5pt"
1253 "src"="port_city"
1254 "font"="fill_in_med"
1255 }
1256 }
1257 {"box":
1258 "name"="data_port_state"
1259 "left"="data_port_city::right"
1260 "thickness"="1pt"
1261 "style"="solid"
1262 //PORT STATE
1263 {"text":
1264 "top"="2pt"
1265 "left"=".1in"
1266 "src"="port_state"
1267 "font"="fill_in"
1268 }
1269 }
1270 }
1271 }
1272 //WARNING
1273 {"box":
1274 "name"="warning"
1275 "top"="data_grid::bottom"
1276 "height"="14pt"
1277 {"text":
1278 "top"="2pt"
1279 "left"=".5in"
1280 "string"="I certify that the information provided on this form is true, complete and correct to the best of my knowledge, and made in good faith. Making a false statement on this form is punishable by law (18 U.S.C. 1001)."
1281 "font"="small_title"
1282 }
1283 }
1284 //SIGN
1285 {"box":
1286 "name"="sign"
1287 "top"="warning::bottom"
1288 "height"=".5in"
1289 "src"="sign_info"
1290 {"box":
1291 "name"="op_permit"
1292 "width"="1.8in"
1293 "thickness"="1pt"
1294 "style"="solid"
1295 {"text":
1296 "top"="2pt"
1297 "left"="5pt"
1298 "string"="24. Operator Permit Number"
1299 }
1300 //OP PERMIT
1301 {"text":
1302 "top"="16pt"
1303 "left"=".1in"
1304 "string"="FIXME"
1305 "font"="fill_in"
1306 "src"="operator_permit"
1307 }
1308 }
1309 {"box":
1310 "name"="op_name"
1311 "left"="op_permit::right"
1312 "width"="2.4in"
1313 "thickness"="1pt"
1314 "style"="solid"
1315 {"text":
1316 "top"="2pt"
1317 "left"="5pt"
1318 "string"="25. Operator Name"
1319 }
1320 //OP PERMIT
1321 {"text":
1322 "top"="16pt"
1323 "left"=".1in"
1324 "string"="FIXME"
1325 "font"="fill_in"
1326 "src"="operator_name"
1327 }
1328 }
1329 {"box":
1330 "name"="op_sig"
1331 "left"="op_name::right"
1332 "width"="2.4in"
1333 "thickness"="1pt"
1334 "style"="solid"
1335 {"text":
1336 "top"="2pt"
1337 "left"="5pt"
1338 "string"="26. Operator Signature"
1339 }
1340 }
1341 {"box":
1342 "name"="op_date"
1343 "left"="op_sig::right"
1344 "thickness"="1pt"
1345 "style"="solid"
1346 {"text":
1347 "top"="2pt"
1348 "left"="5pt"
1349 "string"="27. Date Signed"
1350 }
1351 {"text":
1352 "top"="10pt"
1353 "left"=".4in"
1354 "string"="MM/DD/YY"
1355 }
1356 //DATE SIGNED
1357 {"text":
1358 "top"="20pt"
1359 "left"=".1in"
1360 "src"="sig_date"
1361 "font"="fill_in"
1362 }
1363 }
1364 }
1365 //BOTTOM
1366 {"box":
1367 "name"="bottom"
1368 "top"="sign::bottom"
1369 {"text":
1370 "top"=".3in"
1371 "left"="3.5in"
1372 "string"="NMFS COPY"
1373 "font"="main_title"
1374 }
1375 }
1376 }
6} 1377}