00001
00002
00003
00004
00005
00006
00007
00008 #include "ODBCConnHandle.h"
00009
00010 ODBCConnHandle::ODBCConnHandle(){
00011 Reset();
00012 }
00013
00014 ODBCConnHandle::ODBCConnHandle(Connection *inconn, char *hostname){
00015 Reset();
00016 conn=inconn;
00017 strncpy(servername, hostname, 128);
00018 }
00019
00020 ODBCConnHandle::~ODBCConnHandle(){
00021 Disconnect();
00022 delete conn;
00023 }
00024
00025 void ODBCConnHandle::Reset(){
00026 tapect=0;
00027 conn=0;
00028 if(!tapelist.empty()){
00029 printf("WARNING:\tODBCConnHandle::Reset: we're reseting a non-empty handle?\n");
00030 }
00031 tapelist.clear();
00032 memset(servername, 0, 128);
00033 }
00034
00035 int ODBCConnHandle::CheckName(char *hostname){
00036 return strcmp(servername, hostname);
00037 }
00038
00039 void ODBCConnHandle::DisconnectTape(ODBCTapeStream *ts){
00040 if(tapelist.empty()) return;
00041 tapelist.remove(ts);
00042 int tapelistsize=(int)(tapelist.size());
00043 if(tapelistsize > tapect)
00044 printf("WARNING:\tODBCConnHandle::DisconnectTape: we disconnected a tape and ended up with more tapes than we started with?\n");
00045 tapect=tapelistsize;
00046 }
00047
00048 void ODBCConnHandle::Disconnect(){
00049 while(!tapelist.empty()){
00050 tapelist.front()->HardClose();
00051 tapelist.pop_front();
00052 }
00053 }
00054
00055 int ODBCConnHandle::RegisterStream(ODBCTapeStream *ts){
00056 tapelist.push_back(ts);
00057 ++tapect;
00058 return 1;
00059 }
00060
00061