Index: /testjes/curl1.cpp
===================================================================
--- /testjes/curl1.cpp	(revision 10)
+++ /testjes/curl1.cpp	(revision 10)
@@ -0,0 +1,42 @@
+// http://curl.haxx.se/libcurl/c/libcurl-tutorial.html
+#include <iostream>
+#include <curl/curl.h>
+
+size_t write_data(void *buffer, size_t size, size_t nmemb, void *userp)
+{
+  int written = fwrite(buffer, size, nmemb, (FILE *)userp);
+  return written;
+}
+int main()
+{
+  static const char *headerfilename = "head.out";
+  FILE *headerfile;
+  static const char *bodyfilename = "body.out";
+  FILE *bodyfile;
+  curl_global_init(CURL_GLOBAL_ALL);
+  CURL *c = curl_easy_init();
+  curl_easy_setopt(c,CURLOPT_URL,"http://localhost:5050/cgi-bin/prenv/aap/noot");
+  curl_easy_setopt(c, CURLOPT_NOPROGRESS, 1L);
+  curl_easy_setopt(c, CURLOPT_WRITEFUNCTION, write_data);
+  headerfile = fopen(headerfilename,"w");
+  if (headerfile == NULL) {
+    curl_easy_cleanup(c);
+    return -1;
+  }
+  bodyfile = fopen(bodyfilename,"w");
+  if (bodyfile == NULL) {
+    curl_easy_cleanup(c);
+    return -1;
+  }
+  curl_easy_setopt(c, CURLOPT_WRITEHEADER, headerfile);
+  curl_easy_setopt(c, CURLOPT_WRITEDATA, bodyfile);
+
+  int rc = curl_easy_perform(c);
+  std::cout << "rc from perform: " << rc << std::endl;
+  fclose(headerfile);
+  fclose(bodyfile);
+ 
+  /* cleanup curl stuff */ 
+  curl_easy_cleanup(c);
+
+}
Index: /testjes/curl2.cpp
===================================================================
--- /testjes/curl2.cpp	(revision 10)
+++ /testjes/curl2.cpp	(revision 10)
@@ -0,0 +1,44 @@
+// http://curl.haxx.se/libcurl/c/libcurl-tutorial.html
+#include <iostream>
+#include <curl/curl.h>
+
+size_t write_data(char *buffer, size_t size, size_t nmemb, std::string *userp)
+{
+  std::cerr << "write_data called\n";
+  std::string s;
+  size_t l = size*nmemb;
+  s.resize(l+1);
+  for (unsigned int i=0; i<l; i++)
+    s[i] = ((char*)buffer)[i];
+  s[l] = '\0';
+  std::cerr << s << std::endl;
+  for (size_t i=0; i<l; i++)
+  {
+    (*userp).push_back(buffer[i]);
+  }
+
+  return l;
+}
+int main()
+{
+  curl_global_init(CURL_GLOBAL_ALL);
+  CURL *c = curl_easy_init();
+  curl_easy_setopt(c,CURLOPT_URL,"http://localhost:5050/cgi-bin/prenv/aap/noot");
+  std::string header;
+  std::string body;
+  std::string *h = &header;
+  std::string *b = &body;
+  curl_easy_setopt(c, CURLOPT_NOPROGRESS, 1L);
+  curl_easy_setopt(c, CURLOPT_WRITEFUNCTION, write_data);
+  curl_easy_setopt(c, CURLOPT_WRITEHEADER, &header);
+  curl_easy_setopt(c, CURLOPT_WRITEDATA, &body);
+
+  int rc = curl_easy_perform(c);
+  std::cout << "rc from perform: " << rc << std::endl;
+  std::cout << header;
+  std::cout << body;
+ 
+  /* cleanup curl stuff */ 
+  curl_easy_cleanup(c);
+
+}
Index: /testjes/curlescapetest.cpp
===================================================================
--- /testjes/curlescapetest.cpp	(revision 10)
+++ /testjes/curlescapetest.cpp	(revision 10)
@@ -0,0 +1,19 @@
+#include <iostream>
+#include <curl/curl.h>
+#include <string>
+int main()
+{
+  std::string a;
+  a = "abc/d";
+  CURL *b;
+  b = curl_easy_init();
+  char *c;
+  int l=0;
+  c=curl_easy_escape(b,a.c_str(),l);
+  std::cout << "c:" << c << std::endl;
+  char *d;
+  d=curl_easy_unescape(b,c,0,&l);
+  std::cout << "d:" << d << std::endl;
+  return 0;
+
+}
Index: /testjes/getl.cpp
===================================================================
--- /testjes/getl.cpp	(revision 10)
+++ /testjes/getl.cpp	(revision 10)
@@ -0,0 +1,20 @@
+#include <iostream>
+#include <fstream>
+#include "../trunk/utils.h"
+int main()
+{
+  std::string a;
+  std::ifstream f;
+  unsigned int x= (unsigned) -1;
+  std::cout << x << std::endl;
+  f.open("prut");
+  getline(f,a);
+  std::cout << a << a.size() << " " << a.length()<< std::endl;
+  for(int i=0; i<a.size() ; i++)
+  {
+    std::cout << i<<":"<<a[i] << " " << (unsigned) (a[i]&255) << std::endl;
+  }
+  std::string h = strtohex(a);
+  std::cout << "'" <<h<<"'" << std::endl;
+  return 0;
+}
Index: /testjes/mysqltest.cpp
===================================================================
--- /testjes/mysqltest.cpp	(revision 10)
+++ /testjes/mysqltest.cpp	(revision 10)
@@ -0,0 +1,78 @@
+// http://dev.mysql.com/doc/refman/5.5/en/connector-cpp-examples-complete-example-2.html
+// g++ -Wall -g twee.cpp -lmysqlcppconn
+#include <stdlib.h>
+#include <iostream>
+
+/*
+  Include directly the different
+  headers from cppconn/ and mysql_driver.h + mysql_util.h
+  (and mysql_connection.h). This will reduce your build time!
+*/
+#include "mysql_connection.h"
+
+#include <cppconn/driver.h>
+#include <cppconn/exception.h>
+#include <cppconn/resultset.h>
+#include <cppconn/statement.h>
+#include <cppconn/prepared_statement.h>
+
+using namespace std;
+
+int main(void)
+{
+cout << endl;
+cout << "Let's have MySQL count from 10 to 1..." << endl;
+
+try {
+  sql::Driver *driver;
+  sql::Connection *con;
+  sql::Statement *stmt;
+  sql::ResultSet *res;
+  sql::PreparedStatement *pstmt;
+
+  /* Create a connection */
+  driver = get_driver_instance();
+  con = driver->connect("tcp://127.0.0.1:3307", "stopos", "x");
+  /* Connect to the MySQL test database */
+  con->setSchema("stopos");
+
+  stmt = con->createStatement();
+  stmt->execute("DROP TABLE IF EXISTS test");
+  stmt->execute("CREATE TABLE test(id INT)");
+  delete stmt;
+
+  /* '?' is the supported placeholder syntax */
+  pstmt = con->prepareStatement("INSERT INTO test(id) VALUES (?)");
+  for (int i = 1; i <= 10; i++) {
+    pstmt->setInt(1, i);
+    pstmt->executeUpdate();
+  }
+  delete pstmt;
+
+  /* Select in ascending order */
+  pstmt = con->prepareStatement("SELECT id FROM test ORDER BY id ASC");
+  res = pstmt->executeQuery();
+
+  /* Fetch in reverse = descending order! */
+  res->afterLast();
+  while (res->previous())
+    cout << "\t... MySQL counts: " << res->getInt("id") << endl;
+  delete res;
+
+  delete pstmt;
+  delete con;
+
+} catch (sql::SQLException &e) {
+  cout << "# ERR: SQLException in " << __FILE__;
+  cout << "(" << __FUNCTION__ << ") on line "
+     << __LINE__ << endl;
+  cout << "# ERR: " << e.what();
+  cout << " (MySQL error code: " << e.getErrorCode();
+  cout << ", SQLState: " << e.getSQLState() <<
+     " )" << endl;
+}
+
+cout << endl;
+
+return EXIT_SUCCESS;
+}
Index: /testjes/mysqltest1.cpp
===================================================================
--- /testjes/mysqltest1.cpp	(revision 10)
+++ /testjes/mysqltest1.cpp	(revision 10)
@@ -0,0 +1,102 @@
+// http://dev.mysql.com/doc/refman/5.5/en/connector-cpp-examples-complete-example-2.html
+// g++ -Wall -g twee.cpp -lmysqlcppconn
+#include <stdlib.h>
+#include <iostream>
+
+/*
+  Include directly the different
+  headers from cppconn/ and mysql_driver.h + mysql_util.h
+  (and mysql_connection.h). This will reduce your build time!
+*/
+#include "mysql_connection.h"
+
+#include <cppconn/driver.h>
+#include <cppconn/exception.h>
+#include <cppconn/resultset.h>
+#include <cppconn/statement.h>
+#include <cppconn/prepared_statement.h>
+
+using namespace std;
+
+int main(void)
+{
+cout << endl;
+
+try {
+  sql::Driver *driver;
+  sql::Connection *con;
+  sql::Statement *stmt;
+  sql::ResultSet *res;
+  sql::PreparedStatement *pstmt;
+
+  /* Create a connection */
+  driver = get_driver_instance();
+  con = driver->connect("tcp://127.0.0.1:3307", "stopos", "x");
+  /* Connect to the MySQL test database */
+  con->setSchema("stopos");
+
+  stmt = con->createStatement();
+  stmt->execute("DROP TABLE IF EXISTS test");
+  stmt->execute("CREATE TABLE test(pkey varchar(20),primary key(pkey),"
+    "index(pkey),data varchar(1024))");
+
+  stmt->execute("replace test values('3','wassenaar')");
+  stmt->execute("replace test values('2','den haag')");
+  stmt->execute("replace test values('1','bodegraven')");
+  stmt->execute("replace test values('1','bodegraven')");
+
+  res = stmt->executeQuery("select data from test where pkey='3'");
+  res->beforeFirst();
+  if (res->next())
+    cout << "[" <<res->getString("data")<<"]" <<  endl;
+  else
+    cout << "NOT FOUND\n";
+  res = stmt->executeQuery("select data from test where pkey='30'");
+  res->beforeFirst();
+  if (res->next())
+    cout << "[" <<res->getString("data")<<"]" <<  endl;
+  else
+    cout << "NOT FOUND\n";
+  bool rc;
+  rc = stmt->execute("delete from test where pkey ='1'");
+  cout << "rc:" << rc << endl;
+  rc = stmt->execute("delete from test where pkey ='11'");
+  cout << "rc:" << rc << endl;
+  cout << "Testing count:\n";
+  res = stmt->executeQuery("select count(*) as count "
+                           "from information_schema.tables "
+			   "where table_schema = 'stopos' "
+			   "and table_name = 'test'");
+  res->beforeFirst();
+  if (res->next())
+    cout << "table [" <<res->getString("count")<<"] found" <<  endl;
+  else
+    cout << "table NOT FOUND\n";
+  res = stmt->executeQuery("select count(*) as count "
+                           "from information_schema.tables "
+			   "where table_schema = 'stopos' "
+			   "and table_name = 'tost'");
+  res->beforeFirst();
+  if (res->next())
+    cout << "table [" <<res->getInt("count")<<"] found" <<  endl;
+  else
+    cout << "table NOT FOUND\n";
+
+  delete res;
+  delete stmt;
+  delete con;
+
+} catch (sql::SQLException &e) {
+  cout << "# ERR: SQLException in " << __FILE__;
+  cout << "(" << __FUNCTION__ << ") on line "
+     << __LINE__ << endl;
+  cout << "# ERR: " << e.what();
+  cout << " (MySQL error code: " << e.getErrorCode();
+  cout << ", SQLState: " << e.getSQLState() <<
+     " )" << endl;
+}
+
+cout << endl;
+
+return EXIT_SUCCESS;
+}
Index: /testjes/numtostest.cpp
===================================================================
--- /testjes/numtostest.cpp	(revision 10)
+++ /testjes/numtostest.cpp	(revision 10)
@@ -0,0 +1,11 @@
+#include <iostream>
+#include "../trunk/utils.h"
+
+int main()
+{
+  unsigned long long n =678;
+  std::cout << NumberToString(n) << std::endl;
+  double x=355.0/113.0;
+  std::cout << NumberToString(x) << std::endl;
+  std::cout << StringToNumber<double>("77.123") << std::endl;
+}
Index: /testjes/prut
===================================================================
--- /testjes/prut	(revision 10)
+++ /testjes/prut	(revision 10)
@@ -0,0 +1,2 @@
+                 on the standard output.  These are the strings that are  sub-
+猴子
Index: /testjes/ranpw.cpp
===================================================================
--- /testjes/ranpw.cpp	(revision 10)
+++ /testjes/ranpw.cpp	(revision 10)
@@ -0,0 +1,28 @@
+#include <iostream>
+#include <stdlib.h>
+#include <algorithm>
+#include <sys/time.h>
+void gen_random(std::string &s, const int len) {
+ timeval t1;
+ gettimeofday(&t1, NULL);
+ std::srand(t1.tv_usec * t1.tv_sec);
+ static const char alphanum[] =
+   "0123456789"
+   "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+   "abcdefghijklmnopqrstuvwxyz";
+
+  s.resize(len);
+  for (int i = 0; i < len; ++i) {
+      s[i] = alphanum[std::rand() % (sizeof(alphanum) - 1)];
+  }
+}
+int main()
+{
+  std::string s;
+  for (int i=0; i<6; i++)
+  {
+    gen_random(s,8);
+    std::cout << s << " ";
+  }
+  std::cout << std::endl;
+}
Index: /testjes/stringstream.cpp
===================================================================
--- /testjes/stringstream.cpp	(revision 10)
+++ /testjes/stringstream.cpp	(revision 10)
@@ -0,0 +1,15 @@
+#include <iostream>
+#include <string>
+#include <sstream>
+#include <iomanip>
+
+int main()
+{
+  std::ostringstream s;
+  int x=3;
+
+  s << std::setfill('0');
+  s << std::setw(8) << x;
+  std::cout << s.str() << std::endl;
+  return 0;
+}
Index: /testjes/strn.cpp
===================================================================
--- /testjes/strn.cpp	(revision 10)
+++ /testjes/strn.cpp	(revision 10)
@@ -0,0 +1,11 @@
+#include <iostream>
+#include "../trunk/utils.h"
+int main()
+{
+  std::string a;
+  a="123:8827";
+  int ia = StringToNumber<int>(a);
+  std::cout << a << std::endl;
+  std::cout << ia << std::endl;
+  return 0;
+}
Index: /testjes/testc.cpp
===================================================================
--- /testjes/testc.cpp	(revision 10)
+++ /testjes/testc.cpp	(revision 10)
@@ -0,0 +1,15 @@
+#include <iostream>
+#include <wutils.h>
+// g++ testc.cpp -I ../trunk ../trunk/libwutils.a
+int main()
+{
+  std::string s ="aap noor mies";
+  std::string c,d;
+
+  c = compress_string(s);
+  d = decompress_string(c);
+
+  std::cout << s << std::endl;
+  std::cout << d << std::endl;
+  return 0;
+}
Index: /testjes/testcompressie.cpp
===================================================================
--- /testjes/testcompressie.cpp	(revision 10)
+++ /testjes/testcompressie.cpp	(revision 10)
@@ -0,0 +1,133 @@
+#include <string>
+#include <stdexcept>
+#include <iostream>
+#include <iomanip>
+#include <sstream>
+
+#include <string.h>
+
+#include <zlib.h>
+
+/** Compress a STL string using zlib with given compression level and return
+  * the binary data. */
+std::string compress_string(const std::string& str,
+                            int compressionlevel = Z_BEST_COMPRESSION)
+{
+    z_stream zs;                        // z_stream is zlib's control structure
+    memset(&zs, 0, sizeof(zs));
+
+    if (deflateInit(&zs, compressionlevel) != Z_OK)
+        throw(std::runtime_error("deflateInit failed while compressing."));
+
+    zs.next_in = (Bytef*)str.data();
+    zs.avail_in = str.size();           // set the z_stream's input
+
+    int ret;
+    char outbuffer[32768];
+    std::string outstring;
+
+    // retrieve the compressed bytes blockwise
+    do {
+        zs.next_out = reinterpret_cast<Bytef*>(outbuffer);
+        zs.avail_out = sizeof(outbuffer);
+
+        ret = deflate(&zs, Z_FINISH);
+
+        if (outstring.size() < zs.total_out) {
+            // append the block to the output string
+            outstring.append(outbuffer,
+                             zs.total_out - outstring.size());
+        }
+    } while (ret == Z_OK);
+
+    deflateEnd(&zs);
+
+    if (ret != Z_STREAM_END) {          // an error occurred that was not EOF
+        std::ostringstream oss;
+        oss << "Exception during zlib compression: (" << ret << ") " << zs.msg;
+        throw(std::runtime_error(oss.str()));
+    }
+
+    return outstring;
+}
+
+/** Decompress an STL string using zlib and return the original data. */
+std::string decompress_string(const std::string& str)
+{
+    z_stream zs;                        // z_stream is zlib's control structure
+    memset(&zs, 0, sizeof(zs));
+
+    if (inflateInit(&zs) != Z_OK)
+        throw(std::runtime_error("inflateInit failed while decompressing."));
+
+    zs.next_in = (Bytef*)str.data();
+    zs.avail_in = str.size();
+
+    int ret;
+    char outbuffer[32768];
+    std::string outstring;
+
+    // get the decompressed bytes blockwise using repeated calls to inflate
+    do {
+        zs.next_out = reinterpret_cast<Bytef*>(outbuffer);
+        zs.avail_out = sizeof(outbuffer);
+
+        ret = inflate(&zs, 0);
+
+        if (outstring.size() < zs.total_out) {
+            outstring.append(outbuffer,
+                             zs.total_out - outstring.size());
+        }
+
+    } while (ret == Z_OK);
+
+    inflateEnd(&zs);
+
+    if (ret != Z_STREAM_END) {          // an error occurred that was not EOF
+        std::ostringstream oss;
+        oss << "Exception during zlib decompression: (" << ret << ") "
+            << zs.msg;
+        throw(std::runtime_error(oss.str()));
+    }
+
+    return outstring;
+}
+
+/** Small dumb tool (de)compressing cin to cout. It holds all input in memory,
+  * so don't use it for huge files. */
+int main(int argc, char* argv[])
+{
+    std::string allinput;
+
+    while (std::cin.good())     // read all input from cin
+    {
+        char inbuffer[32768];
+        std::cin.read(inbuffer, sizeof(inbuffer));
+        allinput.append(inbuffer, std::cin.gcount());
+    }
+
+    if (argc >= 2 && strcmp(argv[1], "-d") == 0)
+    {
+        std::string cstr = decompress_string( allinput );
+
+        std::cerr << "Inflated data: "
+                  << allinput.size() << " -> " << cstr.size()
+                  << " (" << std::setprecision(1) << std::fixed
+                  << ( ((float)cstr.size() / (float)allinput.size() - 1.0) * 100.0 )
+                  << "% increase).\n";
+
+        std::cout << cstr;
+    }
+    else
+    {
+        std::string cstr = compress_string( allinput );
+
+        std::cerr << "Deflated data: "
+                  << allinput.size() << " -> " << cstr.size()
+                  << " (" << std::setprecision(1) << std::fixed
+                  << ( (1.0 - (float)cstr.size() / (float)allinput.size()) * 100.0)
+                  << "% saved).\n";
+
+        std::cout << cstr;
+    }
+}
Index: /testjes/testdirent.cpp
===================================================================
--- /testjes/testdirent.cpp	(revision 10)
+++ /testjes/testdirent.cpp	(revision 10)
@@ -0,0 +1,30 @@
+#include <iostream>
+#include <list>
+#include <stdio.h>
+#include <errno.h>
+#include <dirent.h>
+int main()
+{
+  DIR *dir;
+  struct dirent *ent;
+  if ((dir = opendir (".")) != NULL) {
+    std::list <std::string> v;
+    while ((ent = readdir (dir)) != NULL) {
+      v.push_back(ent->d_name);
+    }
+    closedir (dir);
+    v.sort();
+    std::string a;
+    for (std::list<std::string>::iterator it=v.begin(); it != v.end(); ++it)
+    {
+      if ((*it).size() >=1 && (*it)[0] != '.')
+	a += *it + " ";
+    }
+    std::cout << a << std::endl;
+  } else {
+    /* could not open directory */
+    perror ("");
+    return 1;
+  }
+  return 0;
+}
Index: /testjes/testdirlock.cpp
===================================================================
--- /testjes/testdirlock.cpp	(revision 10)
+++ /testjes/testdirlock.cpp	(revision 10)
@@ -0,0 +1,37 @@
+#include <iostream>
+#include <unistd.h>
+#include <fcntl.h>
+#include <stdio.h>
+
+int main()
+{
+  int f;
+  f = open(".",O_RDWR);
+  if (f < 0)
+  {
+    perror("open error:");
+    return 1;
+  }
+  int rc;
+  struct flock lock;
+  lock.l_type = F_RDLCK|F_WRLCK;
+  lock.l_whence = SEEK_SET;
+  lock.l_start  = 0;
+  lock.l_len    = 0;
+
+  std::cout << "getting lock ... \n";
+  rc = fcntl(f,F_SETLKW,&lock);
+
+  std::cout << " got it, sleeping\n";
+  sleep(5);
+  lock.l_type = F_UNLCK;
+  lock.l_whence = SEEK_SET;
+  lock.l_start  = 0;
+  lock.l_len    = 0;
+  rc  = fcntl(f,F_SETLKW,&lock);
+
+  sleep(5);
+  std::cout << "done\n";
+
+  return 0;
+}
Index: /testjes/testfastgci.cpp
===================================================================
--- /testjes/testfastgci.cpp	(revision 10)
+++ /testjes/testfastgci.cpp	(revision 10)
@@ -0,0 +1,19 @@
+#include <fcgi_stdio.h>
+#include <iostream>
+#include "wutils.h"
+// g++ testfastgci.cpp -I../trunk ../trunk/libwutils.a -lfcgi
+int main(void)
+{
+  int count = 0;
+  while(FCGI_Accept() >= 0) 
+  {
+    printf("Content-type: text/html\r\n");
+    printf("\r\n");
+    printf("Hello world!<br>\r\n");
+    printf("REquest number %d.<br>\r\n", count++);
+    std::string s = envtostr("QUERY_STRING");
+    printf("query string: %s \n",s.c_str());
+
+  }
+return 0;
+}
Index: /testjes/testgci.cpp
===================================================================
--- /testjes/testgci.cpp	(revision 10)
+++ /testjes/testgci.cpp	(revision 10)
@@ -0,0 +1,17 @@
+#include <stdio.h>
+#include "wutils.h"
+// g++ testgci.cpp -I../trunk ../trunk/libwutils.a 
+int main(void)
+{
+  int count = 0;
+  {
+    printf("Content-type: text/html\r\n");
+    printf("\r\n");
+    printf("Hello world!<br>\r\n");
+    printf("REquest number %d.<br>\r\n", count++);
+    std::string s = envtostr("QUERY_STRING");
+    printf("query string: %s \n",s.c_str());
+
+  }
+return 0;
+}
Index: /testjes/testgdbm.cpp
===================================================================
--- /testjes/testgdbm.cpp	(revision 10)
+++ /testjes/testgdbm.cpp	(revision 10)
@@ -0,0 +1,45 @@
+#include <iostream>
+#include <string>
+#include <stdlib.h>
+#include <unistd.h>
+#include <gdbm.h>
+
+// g++ testgdbm.cpp -lgdbm
+
+// test if locking works
+// run one instance, then start another instance
+//
+int main()
+{
+  GDBM_FILE dbf=0;
+  do
+  {
+    dbf=gdbm_open((char*)"/tmp/testdb_gdbm",0,GDBM_WRCREAT|GDBM_SYNC,0666,0);
+    if (dbf == 0)
+      usleep(1000);
+  }
+  while (dbf == 0);
+  std::cout << "geopend ..." << std::endl;
+  //sleep(15);
+  //return 0;
+  int w=10;
+  datum key,content;
+  key.dptr = (char*)&w;
+  key.dsize = sizeof(w);
+  content.dptr = (char*)&w;
+  content.dsize = sizeof(w);
+  for (int i=0; i<3000000; i++)
+  {
+    int rc = gdbm_store(dbf,key,content,GDBM_REPLACE);
+    if (rc !=0)
+    {
+      std::cout << "rc: " << rc << std::endl;
+      goto einde;
+    }
+  }
+  std::cout << "gestored ..." << std::endl;
+einde:
+  if (dbf != 0)
+    gdbm_close(dbf);
+  return 0;
+}
Index: /testjes/testgetfile.cpp
===================================================================
--- /testjes/testgetfile.cpp	(revision 10)
+++ /testjes/testgetfile.cpp	(revision 10)
@@ -0,0 +1,14 @@
+// g++ prog.cpp -I ../trunk ../trunk/utils.o
+#include <iostream>
+#include "../trunk/wutils.h"
+int main()
+{
+  std::string f = "/home/willem/.bashrc";
+  std::string a;
+  int rc = get_file_contents(a,f);
+  std::cout << "rc:"<<rc<<std::endl;
+  std::cout << a<<std::endl;
+
+
+  return 0;
+}
Index: /testjes/testgetopt.cpp
===================================================================
--- /testjes/testgetopt.cpp	(revision 10)
+++ /testjes/testgetopt.cpp	(revision 10)
@@ -0,0 +1,57 @@
+#include <iostream>
+#include <getopt.h>
+int main(int argc, char*argv[])
+{
+  std::string programname = "prog";
+  static struct option long_options[] =
+    {
+      {"help",     0, 0, 'h'},
+      {"pool",     1, 0, 'p'},
+      {"version",  0, 0, 'v'},
+      {"multi",    0, 0, 'm'},
+      {"file",     1, 0, 'f'},
+      {0,          0, 0, 0}
+    };
+
+  while (1)
+  {
+    int c = getopt_long(argc,argv,"-hp:vmf:",long_options,0);
+    if (c == -1)
+    {
+      if (optind < argc)  // unexpected extra argument
+      {
+	std::cerr << programname << ": Unexpected argument:" << argv[optind] << std::endl;
+	return 1;
+      }
+      break;
+    }
+    if ( c == '?' || c == ':' )
+    {
+      std::cerr << "Invalid parameter, try "<< argv[0]<<" --help " <<std::endl;
+      return 1;
+    }
+    switch(c)
+    {
+      case 'h': 
+		std::cerr << (char)c << ":" << std::endl;
+		break;
+      case 'p': 
+		std::cerr << (char)c << ":" << optarg << std::endl;
+		break;
+      case 'f': 
+		std::cerr << (char)c << ":" << optarg << std::endl;
+		break;
+      case 'v': 
+		std::cerr << (char)c << ":" << std::endl;
+		break;
+      case 'm':
+		std::cerr << (char)c << ":" << std::endl;
+		break;
+      case 1:
+		std::cerr << c << ":" << optarg << std::endl;
+		break;
+    }
+
+  }
+  return 0;
+}
Index: /testjes/testhex.cpp
===================================================================
--- /testjes/testhex.cpp	(revision 10)
+++ /testjes/testhex.cpp	(revision 10)
@@ -0,0 +1,32 @@
+// g++ testhex.cpp ../trunk/wutils.cpp -I ../trunk
+#include <iostream>
+#include "wutils.h"
+void doit1(std::string a)
+{
+  std::cout << "zstrtohex '"<<a<<"' ->'"<<zstrtohex(a)<<"'"<<std::endl;
+  std::cout << " strtohex '"<<a<<"' ->'"<< strtohex(a)<<"'"<<std::endl;
+}
+void doit2(std::string a)
+{
+  std::cout << "zhextostr '"<<a<<"' ->'"<<zhextostr(a)<<"'"<<std::endl;
+  std::cout << " hextostr '"<<a<<"' ->'"<< hextostr(a)<<"'"<<std::endl;
+}
+int main()
+{
+  doit1("stopos");
+  doit1("");
+  doit1("   zz  ");
+
+  doit2(ZBEGIN_+"616170"+ZEND_);
+  doit2(ZBEGIN_+"616170"+ZEND_+"31");
+  doit2(ZBEGIN_+ZEND_);
+  doit2(ZBEGIN_+"31");
+  doit2("615170");
+
+  doit1("gdbm");
+  doit1("willem.qR7w3XQp");
+  doit1("mypool");
+  doit1("add");
+  doit1("no");
+  doit1("1 2 3");
+}
Index: /testjes/testlock.cpp
===================================================================
--- /testjes/testlock.cpp	(revision 10)
+++ /testjes/testlock.cpp	(revision 10)
@@ -0,0 +1,38 @@
+#include <iostream>
+#include <unistd.h>
+#include <fcntl.h>
+#include <stdio.h>
+
+int main()
+{
+  int f;
+  std::string fname = "/tmp/testdb_flat";
+  f = open(fname.c_str(),O_CREAT|O_RDWR,0600);
+  if (f < 0)
+  {
+    perror("open error:");
+    return 1;
+  }
+  int rc;
+  struct flock lock;
+  lock.l_type = F_RDLCK|F_WRLCK;
+  lock.l_whence = SEEK_SET;
+  lock.l_start  = 0;
+  lock.l_len    = 0;
+
+  std::cout << "getting lock ... \n";
+  rc = fcntl(f,F_SETLKW,&lock);
+
+  std::cout << " got it, sleeping\n";
+  sleep(15);
+  std::cout << " releasing lock\n";
+  lock.l_type = F_UNLCK;
+  lock.l_whence = SEEK_SET;
+  lock.l_start  = 0;
+  lock.l_len    = 0;
+  rc  = fcntl(f,F_SETLKW,&lock);
+
+  std::cout << "done\n";
+
+  return 0;
+}
Index: /testjes/testmkdir.cpp
===================================================================
--- /testjes/testmkdir.cpp	(revision 10)
+++ /testjes/testmkdir.cpp	(revision 10)
@@ -0,0 +1,20 @@
+// g++ testmkdir.cpp ../trunk/wutils.cpp -I ../trunk
+#include <wutils.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <iostream>
+void doit(std::string d,mode_t mode)
+{
+  std::cout << d << " " << mode << " " <<mkdir_p(d,mode) << std::endl;
+}
+int main()
+{
+  int rc;
+  doit("aap",0700);
+  doit("aap/noot/",0700);
+  doit("/tmp/aan/noot/",0700);
+  doit("/tmp/aap/mies",0700);
+  doit ("",0700);
+  doit ("/",0700);
+  return 0;
+}
Index: /testjes/teststopos_key.cpp
===================================================================
--- /testjes/teststopos_key.cpp	(revision 10)
+++ /testjes/teststopos_key.cpp	(revision 10)
@@ -0,0 +1,27 @@
+#include <iostream>
+#include "stopos_key.h"
+// g++ teststopos_key.cpp ../trunk.stopos_key.cpp -I ../trunk
+
+void doit(int n)
+{
+  stopos_key b;
+  b.set(n);
+  std::cout << n << " " << b.str() << std::endl;
+}
+int main()
+{
+
+  stopos_key a;
+  std::cout << a.str() << std::endl;
+  std::cout << stopos_key().str() << std::endl;
+
+  std::string s;
+  s = a.str();
+  s[0] = '2';
+  std::cout<<a.str()<<":"<<s<<std::endl;
+
+  for (int i=0; i<1000; i++)
+    doit(i);
+
+  return 0;
+}
Index: /testjes/testwrequest.cpp
===================================================================
--- /testjes/testwrequest.cpp	(revision 10)
+++ /testjes/testwrequest.cpp	(revision 10)
@@ -0,0 +1,25 @@
+// vertalen met g++ -g -Wall testwrequest.cpp  -I../trunk ../trunk/wrequest.o ../trunk/wutils.o -lcurl
+#include <iostream>
+#include <wrequest.h>
+
+int main()
+{
+  std::cout << "start test ...\n";
+  wrequest w;
+  w.set_serverurl("http://localhost:5050/cgi-bin/pranv/");
+  w.set_protocol("1");
+  w.set_whoami("willem");
+  w.set_command("hopla");
+  w.set_value("   een //  ////value  ");
+
+  std::string body,header;
+  int rc;
+  rc = w.send_message(body,header);
+
+  std::cout << "rc:" << rc << std::endl;
+  std::cout << "header:" <<std::endl <<header << std::endl;
+  std::cout << "body:" <<std::endl <<body << std::endl;
+
+  std::cout << "all is well that ends well\n";
+  return 0;
+}
Index: /testjes/timefcgi
===================================================================
--- /testjes/timefcgi	(revision 10)
+++ /testjes/timefcgi	(revision 10)
@@ -0,0 +1,22 @@
+#!/bin/bash
+n=1000
+doitfast()
+{
+  for i in `seq $n` ; do
+    curl localhost:8080/cgi-bin/test1.$m?aap-noot-mies-wim  >/dev/null 2>&1
+  done
+}
+
+doit()
+{
+  for i in `seq $n` ; do
+    curl localhost:8080   > /dev/null 2>&1
+  done
+}
+
+time doit
+
+m=fcgi
+time doitfast
+m=cgi
+time doitfast
Index: /testjes/trimtest.cpp
===================================================================
--- /testjes/trimtest.cpp	(revision 10)
+++ /testjes/trimtest.cpp	(revision 10)
@@ -0,0 +1,22 @@
+// g++ -I ../trunk
+#include <iostream>
+#include <string>
+#include <wutils.h>
+void doit(std::string a)
+{
+  std::cout << "["<<a<<"] -> ["<<trim_left(a)<<"]"<<std::endl;
+  std::cout << "["<<a<<"] -> ["<<trim_right(a)<<"]"<<std::endl;
+  std::cout << "["<<a<<"] -> ["<<trim(a)<<"]"<<std::endl;
+}
+int main()
+{
+  doit("aap");
+
+  doit("    aap");
+  doit("   aap   ");
+  doit("aap   ");
+  doit("    ");
+  doit("");
+
+}
+
