diff --git a/Cache.cpp b/Cache.cpp index fc1ca61..26e5b44 100644 --- a/Cache.cpp +++ b/Cache.cpp @@ -11,7 +11,7 @@ ** Science The University of Illinois at Urbana-Champaign ** http://www.cs.uiuc.edu/homes/kingst/Research.html ** -** Copyright (C) Sam King +** Copyright (C) Sam King and Hui Xue ** ** Permission is hereby granted, free of charge, to any person obtaining a ** copy of this software and associated documentation files (the @@ -91,7 +91,7 @@ MySocket *Cache::getReplySocket(string host, bool isSSL, int serverPort) return replySock; } -//XXX: should check url, method, cookie, possible even port +//XXX: should check url, method, cookie, possible even port, like what we did in Java version CacheEntry *Cache::find(string url, string /*request*/) { map::iterator i = m_store.find(url); if(i == m_store.end()) @@ -107,7 +107,7 @@ void Cache::addToStore(string url, CacheEntry *ent) { static void dbg_print_vector(CacheEntry *ent, string url, int browserId, string msg) { vector v = ent->getReqVec(); - printf("%d: %d %d %d %s: %s\n", browserId, v[0], v[1], v[2], url.c_str(), msg.c_str()); + cache_dbg("%d: %d %d %d %s: %s\n", browserId, v[0], v[1], v[2], url.c_str(), msg.c_str()); } @@ -252,16 +252,16 @@ int Cache::fetch(CacheEntry *ent, string host, bool isSSL, int browserId, MySock delete replySock; return -1; } - printf("%d FETCH CALLED %s, response length: %d\n", browserId, ent->getUrl().c_str(), ent->getResponse().length()); + cache_dbg("%d FETCH CALLED %s, response length: %d\n", browserId, ent->getUrl().c_str(), ent->getResponse().length()); unsigned char buf[1024]; int num_bytes; while((num_bytes = replySock->read(buf, sizeof(buf))) > 0) { - cerr << "read " << num_bytes << " from " << browserId << ent->getUrl().c_str() << endl; + //cerr << "read " << num_bytes << " from " << browserId << ent->getUrl().c_str() << endl; ent->appendResponse((const char *)buf, num_bytes); } dbg_fetch(num_bytes); - printf("%d FETCHED %s, response length: %d\n", browserId, ent->getUrl().c_str(), ent->getResponse().length()); + cache_dbg("%d FETCHED %s, response length: %d\n", browserId, ent->getUrl().c_str(), ent->getResponse().length()); delete replySock; return 0; } @@ -289,7 +289,7 @@ void Cache::getHTTPResponseNoVote(string host, string request, string url, int s MySocket *browserSock, bool isSSL, MySocket *replySock) { if(replySock == NULL) { - cout << "get...NoVote(): replySock is NULL, give browser 404" << endl; + cerr << "get...NoVote(): replySock is NULL, give browser 404" << endl; browserSock->write_bytes(reply404); return; } diff --git a/CacheEntry.cpp b/CacheEntry.cpp index 91a7f27..74f76d8 100644 --- a/CacheEntry.cpp +++ b/CacheEntry.cpp @@ -1,3 +1,47 @@ +/*======================================================== +** University of Illinois/NCSA +** Open Source License +** +** Copyright (C) 2011,The Board of Trustees of the University of +** Illinois. All rights reserved. +** +** Developed by: +** +** Research Group of Professor Sam King in the Department of Computer +** Science The University of Illinois at Urbana-Champaign +** http://www.cs.uiuc.edu/homes/kingst/Research.html +** +** Copyright (C) Hui Xue +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and associated documentation files (the +** Software), to deal with the Software without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Software, and to +** permit persons to whom the Software is furnished to do so, subject to +** the following conditions: +** +** Redistributions of source code must retain the above copyright notice, +** this list of conditions and the following disclaimers. +** +** Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimers in the +** documentation and/or other materials provided with the distribution. +** Neither the names of Sam King or the University of Illinois, +** nor the names of its contributors may be used to endorse or promote +** products derived from this Software without specific prior written +** permission. +** +** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR +** ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. +**========================================================== +*/ + #include "CacheEntry.h" CacheEntry::CacheEntry(int num_browsers, std::string _url, std::string _request) diff --git a/MySocket.cpp b/MySocket.cpp index d438a11..2262044 100644 --- a/MySocket.cpp +++ b/MySocket.cpp @@ -11,7 +11,7 @@ ** Science The University of Illinois at Urbana-Champaign ** http://www.cs.uiuc.edu/homes/kingst/Research.html ** -** Copyright (C) Sam King +** Copyright (C) Sam King and Hui Xue ** ** Permission is hereby granted, free of charge, to any person obtaining a ** copy of this software and associated documentation files (the diff --git a/UI.cpp b/UI.cpp index 59b5f9a..ba1ffaf 100644 --- a/UI.cpp +++ b/UI.cpp @@ -1,3 +1,47 @@ +/*======================================================== +** University of Illinois/NCSA +** Open Source License +** +** Copyright (C) 2011,The Board of Trustees of the University of +** Illinois. All rights reserved. +** +** Developed by: +** +** Research Group of Professor Sam King in the Department of Computer +** Science The University of Illinois at Urbana-Champaign +** http://www.cs.uiuc.edu/homes/kingst/Research.html +** +** Copyright (C) Hui Xue +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and associated documentation files (the +** Software), to deal with the Software without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Software, and to +** permit persons to whom the Software is furnished to do so, subject to +** the following conditions: +** +** Redistributions of source code must retain the above copyright notice, +** this list of conditions and the following disclaimers. +** +** Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimers in the +** documentation and/or other materials provided with the distribution. +** Neither the names of Sam King or the University of Illinois, +** nor the names of its contributors may be used to endorse or promote +** products derived from this Software without specific prior written +** permission. +** +** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR +** ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. +**========================================================== +*/ + #include "UI.h" #include #include "unistd.h" diff --git a/UIQueueEntry.cpp b/UIQueueEntry.cpp index 73c80fd..4e85d65 100644 --- a/UIQueueEntry.cpp +++ b/UIQueueEntry.cpp @@ -1,3 +1,47 @@ +/*======================================================== +** University of Illinois/NCSA +** Open Source License +** +** Copyright (C) 2011,The Board of Trustees of the University of +** Illinois. All rights reserved. +** +** Developed by: +** +** Research Group of Professor Sam King in the Department of Computer +** Science The University of Illinois at Urbana-Champaign +** http://www.cs.uiuc.edu/homes/kingst/Research.html +** +** Copyright (C) Hui Xue +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and associated documentation files (the +** Software), to deal with the Software without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Software, and to +** permit persons to whom the Software is furnished to do so, subject to +** the following conditions: +** +** Redistributions of source code must retain the above copyright notice, +** this list of conditions and the following disclaimers. +** +** Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimers in the +** documentation and/or other materials provided with the distribution. +** Neither the names of Sam King or the University of Illinois, +** nor the names of its contributors may be used to endorse or promote +** products derived from this Software without specific prior written +** permission. +** +** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR +** ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. +**========================================================== +*/ + #include "UIQueueEntry.h" #include "UI.h" diff --git a/dbg.h b/dbg.h index 4516bed..38dfa7e 100644 --- a/dbg.h +++ b/dbg.h @@ -11,7 +11,7 @@ #define ui_dbg(...); -#define cache_dbg(...) do{printf(__VA_ARGS__);}while(0); +//#define cache_dbg(...) do{printf(__VA_ARGS__);}while(0); //#define httpreq_dbg(...) do{printf(__VA_ARGS__);}while(0); diff --git a/main.cpp b/main.cpp index 4c421f9..521e11f 100644 --- a/main.cpp +++ b/main.cpp @@ -11,7 +11,7 @@ ** Science The University of Illinois at Urbana-Champaign ** http://www.cs.uiuc.edu/homes/kingst/Research.html ** -** Copyright (C) Sam King +** Copyright (C) Sam King and Hui Xue ** ** Permission is hereby granted, free of charge, to any person obtaining a ** copy of this software and associated documentation files (the