Skip to content
Permalink
Browse files

Modernise and fix build warnings

  • Loading branch information...
sconemad committed Sep 11, 2019
1 parent 5e9c639 commit aec08c0b27a2cdc80e1e7efa236e802fa308f314
@@ -90,7 +90,7 @@ std::string AuthRealmDB::lookup_hash(const std::string& username)
{
if (!m_db) return "";

std::auto_ptr<scx::DbQuery> query(m_db->object()->new_query(
std::unique_ptr<scx::DbQuery> query(m_db->object()->new_query(
"SELECT id,password FROM user WHERE username = ?"));

scx::ScriptList::Ref args(new scx::ScriptList());
@@ -120,7 +120,7 @@ bool AuthRealmDB::update_hash(const std::string& username,
{
if (!m_db) return 0;

std::auto_ptr<scx::DbQuery> query(m_db->object()->new_query(
std::unique_ptr<scx::DbQuery> query(m_db->object()->new_query(
"UPDATE user SET password = ? WHERE username = ?"));

scx::ScriptList::Ref args(new scx::ScriptList());
@@ -134,7 +134,7 @@ scx::ScriptRef* AuthRealmDB::lookup_data(const std::string& username)
{
if (!m_db) return 0;

std::auto_ptr<scx::DbQuery> query(m_db->object()->new_query(
std::unique_ptr<scx::DbQuery> query(m_db->object()->new_query(
"SELECT id FROM user WHERE username = ?"));

scx::ScriptList::Ref args(new scx::ScriptList());
@@ -164,7 +164,7 @@ bool AuthRealmDB::add_user(const std::string& username,
{
if (!m_db) return false;

std::auto_ptr<scx::DbQuery> query(m_db->object()->new_query(
std::unique_ptr<scx::DbQuery> query(m_db->object()->new_query(
"SELECT id FROM user WHERE username = ?"));

scx::ScriptList::Ref args(new scx::ScriptList());
@@ -175,7 +175,7 @@ bool AuthRealmDB::add_user(const std::string& username,

//XXX what about if someone else add the username in between these calls?

std::auto_ptr<scx::DbQuery> query2(m_db->object()->new_query(
std::unique_ptr<scx::DbQuery> query2(m_db->object()->new_query(
"INSERT INTO user (username,password) VALUES (?,?)"));

args.object()->give(scx::ScriptString::new_ref(hash));
@@ -190,7 +190,7 @@ bool AuthRealmDB::remove_user(const std::string& username)
{
if (!m_db) return false;

std::auto_ptr<scx::DbQuery> query(m_db->object()->new_query(
std::unique_ptr<scx::DbQuery> query(m_db->object()->new_query(
"DELETE FROM user WHERE username = ?"));

scx::ScriptList::Ref args(new scx::ScriptList());
@@ -620,6 +620,7 @@ scx::Condition ResponseStream::mimeheader_end()
scx::Kernel::get()->connect(file);
}
}
return scx::Ok;
}

};
@@ -28,6 +28,8 @@ Free Software Foundation, Inc.,
#include <sconex/ScriptTypes.h>
#include <sconex/Log.h>

#define MAGICKCORE_HDRI_ENABLE 0
#define MAGICKCORE_QUANTUM_DEPTH 16
#include <Magick++.h>
using namespace Magick;

@@ -65,7 +65,7 @@ class LocationModule : public scx::Module {
std::string m_host;
std::string m_port;

std::auto_ptr<gpsmm> m_interface;
std::unique_ptr<gpsmm> m_interface;

const int m_timeout_us;
};
@@ -45,6 +45,7 @@ void RSSFeed_ErrorHandler(void* vcx,const char* str,...)
// xmlParserCtxt* cx = (xmlParserCtxt*)vcx;
// Feed* feed = (Feed*)cx->_private;
RSSFeed_DEBUG_LOG("Feed error: " << msg);
std::ignore = msg;
}

//=========================================================================
@@ -32,7 +32,7 @@ Free Software Foundation, Inc.,
#include <sconex/ScriptTypes.h>
#include <sconex/Database.h>
#include <sconex/Log.h>
#include <memory> // Using auto_ptr
#include <memory> // Using unique_ptr
namespace scs {

// Uncomment to enable debug logging
@@ -141,7 +141,7 @@ Article::Ref* Profile::lookup_article(int id)
locker.unlock();

// Look for article in database
std::auto_ptr<scx::DbQuery> query(m_db->object()->new_query(
std::unique_ptr<scx::DbQuery> query(m_db->object()->new_query(
"SELECT path,parent FROM article WHERE id = ?"));

std::string link;
@@ -205,7 +205,7 @@ Article::Ref* Profile::lookup_article(const std::string& href,
locker.unlock();

// Look for article in database
std::auto_ptr<scx::DbQuery> query(m_db->object()->new_query(
std::unique_ptr<scx::DbQuery> query(m_db->object()->new_query(
"SELECT id FROM article WHERE parent = ? AND path = ?"));

std::string key = href;
@@ -300,7 +300,7 @@ Article::Ref* Profile::create_article(int pid,
return 0;
}

std::auto_ptr<scx::DbQuery> query(m_db->object()->new_query(
std::unique_ptr<scx::DbQuery> query(m_db->object()->new_query(
"INSERT INTO article (parent,path) VALUES (?,?)"));

scx::ScriptList::Ref args(new scx::ScriptList());
@@ -355,7 +355,7 @@ bool Profile::remove_article(int id)
return false;
}

std::auto_ptr<scx::DbQuery> query(m_db->object()->new_query(
std::unique_ptr<scx::DbQuery> query(m_db->object()->new_query(
"DELETE FROM article WHERE id = ?"));

scx::ScriptList::Ref args(new scx::ScriptList());
@@ -428,7 +428,7 @@ bool Profile::rename_article(int id,

if (new_parent) {
// Update parent id field
std::auto_ptr<scx::DbQuery> query(m_db->object()->new_query(
std::unique_ptr<scx::DbQuery> query(m_db->object()->new_query(
"UPDATE article SET parent = ? WHERE id = ?"));
scx::ScriptList::Ref args(new scx::ScriptList());
args.object()->give(scx::ScriptInt::new_ref(new_pid));
@@ -441,7 +441,7 @@ bool Profile::rename_article(int id,

if (!new_name.empty()) {
// Update path field
std::auto_ptr<scx::DbQuery> query(m_db->object()->new_query(
std::unique_ptr<scx::DbQuery> query(m_db->object()->new_query(
"UPDATE article SET path = ? WHERE id = ?"));
scx::ScriptList::Ref args(new scx::ScriptList());
args.object()->give(scx::ScriptString::new_ref(new_name));
@@ -689,7 +689,7 @@ bool Profile::set_meta(int id,
const std::string& property,
scx::ScriptRef* value)
{
std::auto_ptr<scx::DbQuery> query(m_db->object()->new_query(
std::unique_ptr<scx::DbQuery> query(m_db->object()->new_query(
"UPDATE article set "+property+" = ? WHERE id = ?"));

scx::ScriptList::Ref args(new scx::ScriptList());
@@ -708,7 +708,7 @@ bool Profile::set_meta(int id,
scx::ScriptRef* Profile::get_meta(int id,
const std::string& property) const
{
std::auto_ptr<scx::DbQuery> query(m_db->object()->new_query(
std::unique_ptr<scx::DbQuery> query(m_db->object()->new_query(
"SELECT "+property+" FROM article WHERE id = ?"));

scx::ScriptList::Ref args(new scx::ScriptList());
@@ -63,14 +63,14 @@ Database::~Database()
//=========================================================================
bool Database::simple_query(const std::string& query)
{
std::auto_ptr<DbQuery> q(new_query(query));
std::unique_ptr<DbQuery> q(new_query(query));
return q->exec(0);
}

//=========================================================================
int Database::simple_query_num(const std::string& query)
{
std::auto_ptr<DbQuery> q(new_query(query));
std::unique_ptr<DbQuery> q(new_query(query));
if (!q->exec(0)) return -1;
if (!q->next_result()) return -1;
ScriptRef* row_ref = q->result_list();
@@ -191,7 +191,7 @@ ScriptRef* DbProxy::script_op(const ScriptAuth& auth,
return new ScriptMethodRef(ref,name);
}

std::auto_ptr<DbQuery> query(m_db.object()->new_query(
std::unique_ptr<DbQuery> query(m_db.object()->new_query(
"SELECT "+name+" FROM "+m_table+" WHERE "+m_key_field+" = ?"));

ScriptList::Ref args(new ScriptList());
@@ -227,7 +227,7 @@ ScriptRef* DbProxy::script_method(const ScriptAuth& auth,

const ScriptRef* value = get_method_arg_ref(args,1,"value");

std::auto_ptr<DbQuery> query(m_db.object()->new_query(
std::unique_ptr<DbQuery> query(m_db.object()->new_query(
"UPDATE "+m_table+" SET "+s_name+" = ? WHERE "+m_key_field+" = ?"));

ScriptList::Ref args(new ScriptList());
@@ -232,8 +232,7 @@ SocketAddress* DatagramSocket::peek_address()
struct sockaddr* sa_local = (struct sockaddr*)sa_local_buffer;

char buffer[1];
int na=0;
na = recvfrom(m_socket,(char*)buffer,0,MSG_PEEK,sa_local,&sa_size);
recvfrom(m_socket,(char*)buffer,0,MSG_PEEK,sa_local,&sa_size);

sa->set_sockaddr(sa_local);
delete [] sa_local_buffer;
@@ -68,10 +68,9 @@ bool FileDir::next()
}

if (m_state == 1) {
struct dirent dent;
struct dirent* dret = 0;
if (0 == readdir_r(m_dir,&dent,&dret) && dret) {
m_current_name = dent.d_name;
struct dirent* dent = readdir(m_dir);
if (dent) {
m_current_name = dent->d_name;
m_current_stat = FileStat(path());
return true;
}
@@ -948,12 +948,12 @@ ScriptRef* ScriptList::script_method(const ScriptAuth& auth,

const ScriptNum* a_offs = get_method_arg<ScriptNum>(args,0,"offset");
int offset = a_offs ? a_offs->get_int() : 0;
if (offset < 0 || offset > m_list.size())
if (offset < 0 || offset > (int)m_list.size())
return ScriptError::new_ref("ScriptList::splice() Offset out of range");

const ScriptNum* a_len = get_method_arg<ScriptNum>(args,1,"length");
int length= a_len ? a_len->get_int() : (m_list.size() - offset);
if (length < 0 || offset + length > m_list.size())
if (length < 0 || offset + length > (int)m_list.size())
return ScriptError::new_ref("ScriptList::splice() Length out of range");

ScriptList* removed = new ScriptList();

0 comments on commit aec08c0

Please sign in to comment.
You can’t perform that action at this time.