From: Adam Dickmeiss Date: Thu, 2 Feb 2006 11:33:46 +0000 (+0000) Subject: Changed from 'class' to 'struct' in a few forward declarations X-Git-Tag: YP2.0.0.3~2 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=357884a3c428262e37911c9429dc122fb0243bcd;p=metaproxy-moved-to-github.git Changed from 'class' to 'struct' in a few forward declarations due to MS VS warnings. In HTTP file filter, avoid using stat. --- diff --git a/src/filter_http_file.cpp b/src/filter_http_file.cpp index d83af33..7ca4062 100644 --- a/src/filter_http_file.cpp +++ b/src/filter_http_file.cpp @@ -1,4 +1,4 @@ -/* $Id: filter_http_file.cpp,v 1.2 2006-01-25 11:28:23 adam Exp $ +/* $Id: filter_http_file.cpp,v 1.3 2006-02-02 11:33:46 adam Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -115,39 +115,36 @@ void yf::HttpFile::Rep::fetch_file(yp2::Session &session, Z_HTTP_Request *req, std::string &fname, yp2::Package &package) { - struct stat sbuf; yp2::odr o; - if (stat(fname.c_str(), &sbuf)) - { - Z_GDU *gdu = o.create_HTTP_Response(session, req, 404); - package.response() = gdu; - return; - } - if ((sbuf.st_mode & S_IFMT) != S_IFREG) + FILE *f = fopen(fname.c_str(), "rb"); + if (!f) { Z_GDU *gdu = o.create_HTTP_Response(session, req, 404); package.response() = gdu; return; } - if (sbuf.st_size > (off_t) 1000000) + if (fseek(f, 0L, SEEK_END) == -1) { + fclose(f); Z_GDU *gdu = o.create_HTTP_Response(session, req, 404); package.response() = gdu; return; } - - FILE *f = fopen(fname.c_str(), "rb"); - if (!f) + long sz = ftell(f); + if (sz > 1000000L) { + fclose(f); Z_GDU *gdu = o.create_HTTP_Response(session, req, 404); package.response() = gdu; return; } + rewind(f); + Z_GDU *gdu = o.create_HTTP_Response(session, req, 200); Z_HTTP_Response *hres = gdu->u.HTTP_Response; - hres->content_len = sbuf.st_size; + hres->content_len = sz; hres->content_buf = (char*) odr_malloc(o, hres->content_len); fread(hres->content_buf, 1, hres->content_len, f); diff --git a/src/filter_http_file.hpp b/src/filter_http_file.hpp index 7dd6282..43dc9b9 100644 --- a/src/filter_http_file.hpp +++ b/src/filter_http_file.hpp @@ -1,4 +1,4 @@ -/* $Id: filter_http_file.hpp,v 1.2 2006-01-25 11:28:23 adam Exp $ +/* $Id: filter_http_file.hpp,v 1.3 2006-02-02 11:33:46 adam Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -15,7 +15,7 @@ namespace yp2 { namespace filter { class HttpFile : public Base { class Rep; - class Area; + struct Area; class Mime; boost::scoped_ptr m_p; public: diff --git a/src/filter_multi.cpp b/src/filter_multi.cpp index 53bf19c..b412bb4 100644 --- a/src/filter_multi.cpp +++ b/src/filter_multi.cpp @@ -1,4 +1,4 @@ -/* $Id: filter_multi.cpp,v 1.13 2006-02-02 10:25:13 adam Exp $ +/* $Id: filter_multi.cpp,v 1.14 2006-02-02 11:33:46 adam Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -92,7 +92,7 @@ namespace yp2 { }; class Multi::Rep { friend class Multi; - friend class Frontend; + friend struct Frontend; FrontendPtr get_frontend(Package &package); void release_frontend(Package &package); diff --git a/src/filter_multi.hpp b/src/filter_multi.hpp index 4f6376a..db54055 100644 --- a/src/filter_multi.hpp +++ b/src/filter_multi.hpp @@ -1,4 +1,4 @@ -/* $Id: filter_multi.hpp,v 1.3 2006-01-18 14:10:47 adam Exp $ +/* $Id: filter_multi.hpp,v 1.4 2006-02-02 11:33:46 adam Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -19,12 +19,12 @@ namespace yp2 { namespace filter { class Multi : public Base { class Rep; - class Frontend; - class Map; - class FrontendSet; - class Backend; - class BackendSet; - class ScanTermInfo; + struct Frontend; + struct Map; + struct FrontendSet; + struct Backend; + struct BackendSet; + struct ScanTermInfo; typedef std::list ScanTermInfoList; typedef boost::shared_ptr BackendPtr; typedef boost::shared_ptr FrontendPtr; diff --git a/src/filter_virt_db.cpp b/src/filter_virt_db.cpp index c427deb..7947c6b 100644 --- a/src/filter_virt_db.cpp +++ b/src/filter_virt_db.cpp @@ -1,4 +1,4 @@ -/* $Id: filter_virt_db.cpp,v 1.34 2006-02-02 10:25:13 adam Exp $ +/* $Id: filter_virt_db.cpp,v 1.35 2006-02-02 11:33:46 adam Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -81,7 +81,7 @@ namespace yp2 { }; class Virt_db::Rep { friend class Virt_db; - friend class Frontend; + friend struct Frontend; FrontendPtr get_frontend(Package &package); void release_frontend(Package &package); @@ -336,9 +336,9 @@ void yf::Virt_db::Frontend::search(Package &package, Z_APDU *apdu_req) std::list::const_iterator t_it = b->m_targets.begin(); if (t_it != b->m_targets.end()) { - if (!yp2::util::set_databases_from_zurl(odr, *t_it, + yp2::util::set_databases_from_zurl(odr, *t_it, &req->num_databaseNames, - &req->databaseNames)); + &req->databaseNames); } *req->replaceIndicator = 1; @@ -552,9 +552,9 @@ void yf::Virt_db::Frontend::scan(Package &package, Z_APDU *apdu_req) std::list::const_iterator t_it = b->m_targets.begin(); if (t_it != b->m_targets.end()) { - if (!yp2::util::set_databases_from_zurl(odr, *t_it, + yp2::util::set_databases_from_zurl(odr, *t_it, &req->num_databaseNames, - &req->databaseNames)); + &req->databaseNames); } scan_package.request() = yazpp_1::GDU(apdu_req); diff --git a/src/filter_virt_db.hpp b/src/filter_virt_db.hpp index e16fc34..0ae5b26 100644 --- a/src/filter_virt_db.hpp +++ b/src/filter_virt_db.hpp @@ -1,4 +1,4 @@ -/* $Id: filter_virt_db.hpp,v 1.13 2006-01-16 15:51:56 adam Exp $ +/* $Id: filter_virt_db.hpp,v 1.14 2006-02-02 11:33:46 adam Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -18,10 +18,10 @@ namespace yp2 { namespace filter { class Virt_db : public Base { class Rep; - class Frontend; - class Map; - class Set; - class Backend; + struct Frontend; + struct Map; + struct Set; + struct Backend; typedef boost::shared_ptr BackendPtr; typedef boost::shared_ptr FrontendPtr; public: