1 // Z39.50 Connection class
7 connection::connection() {
8 ZOOM_options o = ZOOM_options_create();
9 c = ZOOM_connection_create(o);
12 void connection::connect(const std::string &hostname, int portnum) {
13 const char *line_printer_size_hostname = hostname.c_str();
14 //###cerr << "opening " << hostname << ":" << portnum << "\n";
15 ZOOM_connection_connect(c, line_printer_size_hostname, portnum);
16 //###cerr << "opened\n";
19 const char *errmsg; // unused: carries same info as `errcode'
21 if ((errcode = ZOOM_connection_error(c, &errmsg, &addinfo)) != 0) {
22 //###cerr << "oops: no connect, errcode=" << errcode << "\n";
23 throw bib1Exception(errcode, addinfo);
27 connection::connection(const std::string &hostname, int portnum) {
28 ZOOM_options o = ZOOM_options_create();
29 c = ZOOM_connection_create(o);
30 connect(hostname, portnum);
33 std::string connection::option(const std::string &key) const {
34 const char* val = ZOOM_connection_option_get(c, key.c_str());
35 return (val) ? val : std::string();
38 bool connection::option(const std::string &key, const std::string &val) {
39 // No way to tell whether ZOOM_connection_option_set() accepts key
40 ZOOM_connection_option_set(c, key.c_str(), val.c_str());
44 connection::~connection() {
45 ZOOM_connection_destroy(c);
51 * c-file-style: "Stroustrup"
52 * indent-tabs-mode: nil
54 * vim: shiftwidth=4 tabstop=8 expandtab