due to MS VS warnings. In HTTP file filter, avoid using stat.
-/* $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%
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);
-/* $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%
namespace filter {
class HttpFile : public Base {
class Rep;
- class Area;
+ struct Area;
class Mime;
boost::scoped_ptr<Rep> m_p;
public:
-/* $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%
};
class Multi::Rep {
friend class Multi;
- friend class Frontend;
+ friend struct Frontend;
FrontendPtr get_frontend(Package &package);
void release_frontend(Package &package);
-/* $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%
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<ScanTermInfo> ScanTermInfoList;
typedef boost::shared_ptr<Backend> BackendPtr;
typedef boost::shared_ptr<Frontend> FrontendPtr;
-/* $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%
};
class Virt_db::Rep {
friend class Virt_db;
- friend class Frontend;
+ friend struct Frontend;
FrontendPtr get_frontend(Package &package);
void release_frontend(Package &package);
std::list<std::string>::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;
std::list<std::string>::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);
-/* $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%
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<Backend> BackendPtr;
typedef boost::shared_ptr<Frontend> FrontendPtr;
public: