Removed prefix Yaz_ from several class - and interface names now
[yazpp-moved-to-github.git] / zoom / zconn.cpp
index 17773c8..4edb20c 100644 (file)
@@ -1,4 +1,4 @@
-// $Header: /home/cvsroot/yaz++/zoom/zconn.cpp,v 1.5 2003-07-02 10:25:13 adam Exp $
+// $Header: /home/cvsroot/yaz++/zoom/zconn.cpp,v 1.8 2005-05-03 16:29:52 mike Exp $
 
 // Z39.50 Connection class
 
@@ -6,11 +6,16 @@
 
 
 namespace ZOOM {
-    connection::connection(const std::string &hostname, int portnum) {
+    connection::connection() {
+       ZOOM_options o = ZOOM_options_create();
+       c = ZOOM_connection_create(o);
+    }
+
+    void connection::connect(const std::string &hostname, int portnum) {
        const char *line_printer_size_hostname = hostname.c_str();
        //###cerr << "opening " << hostname << ":" << portnum << "\n";
-       c = ZOOM_connection_new(line_printer_size_hostname, portnum);
-       //###cerr << "opened, got " << c << "\n";
+       ZOOM_connection_connect(c, line_printer_size_hostname, portnum);
+       //###cerr << "opened\n";
 
        int errcode;
        const char *errmsg;     // unused: carries same info as `errcode'
@@ -21,8 +26,15 @@ namespace ZOOM {
        }
     }
 
+    connection::connection(const std::string &hostname, int portnum) {
+       ZOOM_options o = ZOOM_options_create();
+       c = ZOOM_connection_create(o);
+       connect(hostname, portnum);
+    }
+
     std::string connection::option(const std::string &key) const {
-       return ZOOM_connection_option_get(c, key.c_str());
+       const char* val = ZOOM_connection_option_get(c, key.c_str());
+       return (val) ? val : std::string();
     }
 
     bool connection::option(const std::string &key, const std::string &val) {