1 // Z39.50 Connection class
10 connection::connection() {
11 ZOOM_options o = ZOOM_options_create();
12 c = ZOOM_connection_create(o);
15 void connection::connect(const std::string &hostname, int portnum) {
16 const char *line_printer_size_hostname = hostname.c_str();
17 //###cerr << "opening " << hostname << ":" << portnum << "\n";
18 ZOOM_connection_connect(c, line_printer_size_hostname, portnum);
19 //###cerr << "opened\n";
22 const char *errmsg; // unused: carries same info as `errcode'
24 if ((errcode = ZOOM_connection_error(c, &errmsg, &addinfo)) != 0) {
25 //###cerr << "oops: no connect, errcode=" << errcode << "\n";
26 throw bib1Exception(errcode, addinfo);
30 connection::connection(const std::string &hostname, int portnum) {
31 ZOOM_options o = ZOOM_options_create();
32 c = ZOOM_connection_create(o);
33 connect(hostname, portnum);
36 std::string connection::option(const std::string &key) const {
37 const char* val = ZOOM_connection_option_get(c, key.c_str());
38 return (val) ? val : std::string();
41 bool connection::option(const std::string &key, const std::string &val) {
42 // No way to tell whether ZOOM_connection_option_set() accepts key
43 ZOOM_connection_option_set(c, key.c_str(), val.c_str());
47 connection::~connection() {
48 ZOOM_connection_destroy(c);
54 * c-file-style: "Stroustrup"
55 * indent-tabs-mode: nil
57 * vim: shiftwidth=4 tabstop=8 expandtab