summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2011-10-27 12:13:03 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2011-10-27 12:13:03 +0200
commit408e980a83437ed621fa99ae0cd8d2bc6579f5ba (patch)
tree7f73587d84487f989bca966a22fc1c85c3f8397b /lib
parent7d8e6af2df12442c1c133956b3acf3fdbc496423 (diff)
Fix warnings and error (due to bitrot)master-old
Diffstat (limited to 'lib')
-rw-r--r--lib/Makefile.am2
-rw-r--r--lib/aa_socket.cc2
-rw-r--r--lib/aa_socket.h2
-rw-r--r--lib/configuration.cc12
-rw-r--r--lib/configuration.h12
-rw-r--r--lib/file.cc2
-rw-r--r--lib/file.h2
-rw-r--r--lib/info.cc5
-rw-r--r--lib/info.h8
-rw-r--r--lib/info_simple.cc6
-rw-r--r--lib/info_simple.h6
-rw-r--r--lib/liblua_wrapper.cc10
-rw-r--r--lib/liblua_wrapper.h10
-rw-r--r--lib/socket.cc4
-rw-r--r--lib/tcp_socket.cc4
-rw-r--r--lib/udp_socket.cc4
16 files changed, 52 insertions, 39 deletions
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 4e2b923..59561fc 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -1,6 +1,8 @@
AM_CXXFLAGS :=
lib_LTLIBRARIES = libmiav.la
+libmiav_la_LIBADD = $(LUA_LIBS)
+libmiav_la_CFLAGS = $(LUA_CFLAGS)
libmiav_la_SOURCES = \
aa_socket.cc \
diff --git a/lib/aa_socket.cc b/lib/aa_socket.cc
index 28ecead..d287789 100644
--- a/lib/aa_socket.cc
+++ b/lib/aa_socket.cc
@@ -13,6 +13,8 @@ using namespace std;
#include <sys/types.h>
#include <sys/socket.h>
+#include <stdio.h>
+#include <string.h>
#include <errno.h>
#include <netinet/in.h>
diff --git a/lib/aa_socket.h b/lib/aa_socket.h
index 0d02723..4ad4f48 100644
--- a/lib/aa_socket.h
+++ b/lib/aa_socket.h
@@ -11,7 +11,7 @@
* Exceptions
*/
struct Network_error {
- Network_error(char *event, char *err) {
+ Network_error(const char *event, char *err) {
error = std::string(err) + " - in " + std::string(event);
}
std::string error;
diff --git a/lib/configuration.cc b/lib/configuration.cc
index 64153d9..7605403 100644
--- a/lib/configuration.cc
+++ b/lib/configuration.cc
@@ -32,7 +32,7 @@ const char preload[] =
"c = 42\n"
"d = \"42\"\n";
-Configuration::Configuration(char *configfile)
+Configuration::Configuration(const char *configfile)
{
// Preload default values.
lua.loadBuffer((char*)preload);
@@ -45,7 +45,7 @@ Configuration::~Configuration()
{
}
-int Configuration::get(char *node, std::string *retval)
+int Configuration::get(const char *node, std::string *retval)
{
try {
*retval = lua.getString(node);
@@ -55,7 +55,7 @@ int Configuration::get(char *node, std::string *retval)
return 0;
}
-int Configuration::get(char *node, std::vector<std::string> *retval)
+int Configuration::get(const char *node, std::vector<std::string> *retval)
{/*
try {
*retval = lua.getString(node);
@@ -67,7 +67,7 @@ int Configuration::get(char *node, std::vector<std::string> *retval)
return 1;
}
-int Configuration::get(char *node, double *retval)
+int Configuration::get(const char *node, double *retval)
{
try {
*retval = lua.getReal(node);
@@ -77,7 +77,7 @@ int Configuration::get(char *node, double *retval)
return 0;
}
-int Configuration::get(char *node, int *retval)
+int Configuration::get(const char *node, int *retval)
{
try {
*retval = lua.getInteger(node);
@@ -87,7 +87,7 @@ int Configuration::get(char *node, int *retval)
return 0;
}
-int Configuration::get(char *node, bool *retval)
+int Configuration::get(const char *node, bool *retval)
{
try {
*retval = lua.getBoolean(node);
diff --git a/lib/configuration.h b/lib/configuration.h
index fba4c01..18e9bc2 100644
--- a/lib/configuration.h
+++ b/lib/configuration.h
@@ -34,14 +34,14 @@
class Configuration {
public:
- Configuration(char *configfile);
+ Configuration(const char *configfile);
~Configuration();
- int get(char *node, std::string *retval);
- int get(char *node, std::vector<std::string> *retval);
- int get(char *node, double *retval);
- int get(char *node, int *retval);
- int get(char *node, bool *retval);
+ int get(const char *node, std::string *retval);
+ int get(const char *node, std::vector<std::string> *retval);
+ int get(const char *node, double *retval);
+ int get(const char *node, int *retval);
+ int get(const char *node, bool *retval);
private:
LibLUAWrapper lua;
diff --git a/lib/file.cc b/lib/file.cc
index bba2f5b..d238c4a 100644
--- a/lib/file.cc
+++ b/lib/file.cc
@@ -43,7 +43,7 @@
#include <stdlib.h>
-File::File(char *fn, char* ext)
+File::File(const char *fn, const char* ext)
{
char path[256];
diff --git a/lib/file.h b/lib/file.h
index 8b241b4..37a2998 100644
--- a/lib/file.h
+++ b/lib/file.h
@@ -39,7 +39,7 @@
class File {
public:
- File(char *filename, char* ext);
+ File(const char *filename, const char* ext);
~File();
int Write(void* data, int size);
diff --git a/lib/info.cc b/lib/info.cc
index 86e4cc4..6d381a3 100644
--- a/lib/info.cc
+++ b/lib/info.cc
@@ -29,11 +29,14 @@
#include <time.h>
#include <stdarg.h>
+#include <stdio.h>
+#include <string.h>
+
Info::Info() {
pthread_mutex_init (&mutex, NULL);
}
-void Info::log(char *fmt, ...)
+void Info::log(const char *fmt, ...)
{
// const time_t t;
FILE *fp;
diff --git a/lib/info.h b/lib/info.h
index b499421..aec643a 100644
--- a/lib/info.h
+++ b/lib/info.h
@@ -41,10 +41,10 @@ public:
Info();
virtual ~Info() {}
- virtual void error(char* fmt, ...) = 0;
- virtual void warn(char* fmt, ...) = 0;
- virtual void info(char* fmt, ...) = 0;
- void log(char* fmt, ...);
+ virtual void error(const char* fmt, ...) = 0;
+ virtual void warn(const char* fmt, ...) = 0;
+ virtual void info(const char* fmt, ...) = 0;
+ void log(const char* fmt, ...);
protected:
// MiavConfig *config;
diff --git a/lib/info_simple.cc b/lib/info_simple.cc
index a3db393..9c78ae8 100644
--- a/lib/info_simple.cc
+++ b/lib/info_simple.cc
@@ -39,7 +39,7 @@ InfoSimple::~InfoSimple()
pthread_mutex_destroy(&mutex);
}
-void InfoSimple::error(char *fmt, ...)
+void InfoSimple::error(const char *fmt, ...)
{
char buf[1024];
@@ -57,7 +57,7 @@ void InfoSimple::error(char *fmt, ...)
fprintf(stderr, "Error: %s\n", buf);
}
-void InfoSimple::warn(char *fmt, ...)
+void InfoSimple::warn(const char *fmt, ...)
{
char buf[1024];
@@ -75,7 +75,7 @@ void InfoSimple::warn(char *fmt, ...)
fprintf(stderr, "Warning: %s\n", buf);
}
-void InfoSimple::info(char *fmt, ...)
+void InfoSimple::info(const char *fmt, ...)
{
char buf[1024];
diff --git a/lib/info_simple.h b/lib/info_simple.h
index 302a371..0dfbe0c 100644
--- a/lib/info_simple.h
+++ b/lib/info_simple.h
@@ -35,9 +35,9 @@ public:
InfoSimple();
~InfoSimple();
- void error(char* fmt, ...);
- void warn(char* fmt, ...);
- void info(char* fmt, ...);
+ void error(const char* fmt, ...);
+ void warn(const char* fmt, ...);
+ void info(const char* fmt, ...);
private:
};
diff --git a/lib/liblua_wrapper.cc b/lib/liblua_wrapper.cc
index 9e06be9..80a05d6 100644
--- a/lib/liblua_wrapper.cc
+++ b/lib/liblua_wrapper.cc
@@ -39,7 +39,7 @@ LibLUAWrapper::~LibLUAWrapper()
lua_close(L);
}
-int LibLUAWrapper::loadFile(char *fname)
+int LibLUAWrapper::loadFile(const char *fname)
{
int s;
@@ -112,7 +112,7 @@ int LibLUAWrapper::loadBuffer(char *buffer)
return 0;
}
-int LibLUAWrapper::getInteger(char *name)
+int LibLUAWrapper::getInteger(const char *name)
{
lua_getfield(L, LUA_GLOBALSINDEX, name);
@@ -125,7 +125,7 @@ int LibLUAWrapper::getInteger(char *name)
return val;
}
-double LibLUAWrapper::getReal(char *name)
+double LibLUAWrapper::getReal(const char *name)
{
lua_getfield(L, LUA_GLOBALSINDEX, name);
@@ -138,7 +138,7 @@ double LibLUAWrapper::getReal(char *name)
return val;
}
-bool LibLUAWrapper::getBoolean(char *name)
+bool LibLUAWrapper::getBoolean(const char *name)
{
lua_getfield(L, LUA_GLOBALSINDEX, name);
@@ -151,7 +151,7 @@ bool LibLUAWrapper::getBoolean(char *name)
return val;
}
-std::string LibLUAWrapper::getString(char *name)
+std::string LibLUAWrapper::getString(const char *name)
{
lua_getfield(L, LUA_GLOBALSINDEX, name);
diff --git a/lib/liblua_wrapper.h b/lib/liblua_wrapper.h
index 30371fe..f83760f 100644
--- a/lib/liblua_wrapper.h
+++ b/lib/liblua_wrapper.h
@@ -40,7 +40,7 @@ public:
* loadFile reads, parses and runs a lue file.
* @return 0 on success 1 on error
*/
- int loadFile(char *fname);
+ int loadFile(const char *fname);
/**
* loadBuffer parses a buffer containing lue code,
@@ -49,10 +49,10 @@ public:
*/
int loadBuffer(char *buffer);
- double getReal(char *name);
- int getInteger(char *name);
- bool getBoolean(char *name);
- std::string getString(char *name);
+ double getReal(const char *name);
+ int getInteger(const char *name);
+ bool getBoolean(const char *name);
+ std::string getString(const char *name);
std::string error();
diff --git a/lib/socket.cc b/lib/socket.cc
index 37e985a..db0cb41 100644
--- a/lib/socket.cc
+++ b/lib/socket.cc
@@ -36,6 +36,8 @@
#include <netinet/in.h>
#include <arpa/inet.h>
+#include <string.h>
+
Socket::Socket(int port, std::string addr)
{
this->prt = port;
@@ -105,7 +107,7 @@ int Socket::connect()
// }
struct sockaddr_in socketaddr;
- memset((char *) &socketaddr, sizeof(socketaddr), 0);
+ memset((char *) &socketaddr, 0, sizeof(socketaddr));
socketaddr.sin_family = AF_INET;
socketaddr.sin_port = htons(prt);
socketaddr.sin_addr.s_addr = inet_addr(ip);
diff --git a/lib/tcp_socket.cc b/lib/tcp_socket.cc
index 8468df9..7f2b3d9 100644
--- a/lib/tcp_socket.cc
+++ b/lib/tcp_socket.cc
@@ -46,6 +46,8 @@
#include <netinet/in.h>
#include <arpa/inet.h>
+#include <string.h>
+
TCPSocket::TCPSocket(int port, std::string addr) : Socket(port, addr)
{
sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
@@ -66,7 +68,7 @@ int TCPSocket::listen(TCPSocket *s)
if(!connected) {
struct sockaddr_in socketaddr;
- memset((char *) &socketaddr, sizeof(socketaddr), 0);
+ memset((char *) &socketaddr, 0, sizeof(socketaddr));
socketaddr.sin_family = AF_INET;
socketaddr.sin_port = htons(prt);
socketaddr.sin_addr.s_addr = htonl(INADDR_ANY);
diff --git a/lib/udp_socket.cc b/lib/udp_socket.cc
index 9668cc6..b265c43 100644
--- a/lib/udp_socket.cc
+++ b/lib/udp_socket.cc
@@ -41,6 +41,8 @@
#include <netinet/in.h>
#include <arpa/inet.h>
+#include <string.h>
+
#include "info.h"
UDPSocket::UDPSocket(int port, std::string addr) : Socket(port, addr)
@@ -54,7 +56,7 @@ int UDPSocket::write(void *buf, int size)
int n;
if(!connected) {
- memset((char *) &sa, sizeof(sa), 0);
+ memset((char *) &sa, 0, sizeof(sa));
sa.sin_family = AF_INET;
sa.sin_port = htons(prt);
if (inet_aton(addr.c_str(), &sa.sin_addr)==0) {