aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorFritz Elfert <felfert@to.com>2002-07-14 19:08:08 +0000
committerFritz Elfert <felfert@to.com>2002-07-14 19:08:08 +0000
commit28e01b8c6a137a9e98d95689be3d3d72be18d9d7 (patch)
treef011d3dba1f05cc8c08b582ba4b9568d3dfc94af /lib
parent838b2558b635d0ec27785e1280904fdea61bc935 (diff)
downloadplptools-28e01b8c6a137a9e98d95689be3d3d72be18d9d7.tar.gz
plptools-28e01b8c6a137a9e98d95689be3d3d72be18d9d7.tar.bz2
plptools-28e01b8c6a137a9e98d95689be3d3d72be18d9d7.zip
- Non-KDE stuff now builds correctly with gcc3
Diffstat (limited to 'lib')
-rw-r--r--lib/Enum.h2
-rw-r--r--lib/bufferstore.h5
-rw-r--r--lib/log.cc12
-rw-r--r--lib/log.h52
-rw-r--r--lib/plpdirent.h2
-rw-r--r--lib/ppsocket.cc2
-rw-r--r--lib/psiprocess.h9
-rw-r--r--lib/rpcs.h4
-rw-r--r--lib/rpcs16.cc2
-rw-r--r--lib/rpcs16.h2
-rw-r--r--lib/rpcs32.cc2
-rw-r--r--lib/rpcs32.h2
12 files changed, 77 insertions, 19 deletions
diff --git a/lib/Enum.h b/lib/Enum.h
index df91aa3..ba410f9 100644
--- a/lib/Enum.h
+++ b/lib/Enum.h
@@ -312,7 +312,7 @@ name(#EnumName),defaultValue(initWith)
* Writes enumeration's string representation.
*/
template <typename E>
-inline std::ostream& operator << (ostream& out, const Enum<E> &e) {
+inline std::ostream& operator << (std::ostream& out, const Enum<E> &e) {
return out << _(e.toString().c_str());
}
diff --git a/lib/bufferstore.h b/lib/bufferstore.h
index 5a1d8bf..0e951b8 100644
--- a/lib/bufferstore.h
+++ b/lib/bufferstore.h
@@ -25,8 +25,7 @@
#define _BUFFERSTORE_H_
#include <sys/types.h>
-
-class ostream;
+#include <stream.h>
/**
* A generic container for an array of bytes.
@@ -130,7 +129,7 @@ public:
*
* @returns The stream.
*/
- friend ostream &operator<<(ostream &, const bufferStore &);
+ friend class std::ostream &operator<<(std::ostream &, const bufferStore &);
/**
* Tests if the bufferStore is empty.
diff --git a/lib/log.cc b/lib/log.cc
index 48b07d8..321de6a 100644
--- a/lib/log.cc
+++ b/lib/log.cc
@@ -22,18 +22,24 @@
*
*/
#include "log.h"
+#include <unistd.h>
-logbuf::logbuf(int _level) {
+logbuf::logbuf(int level, int fd) {
ptr = buf;
len = 0;
- level = _level;
+ _on = true;
+ _level = level;
+ _fd = fd;
}
int logbuf::overflow(int c) {
if (c == '\n') {
*ptr++ = '\n';
*ptr = '\0';
- syslog(level, buf);
+ if (_on)
+ syslog(_level, buf);
+ else if (_fd != -1)
+ write(_fd, buf, len + 1);
ptr = buf;
len = 0;
return 0;
diff --git a/lib/log.h b/lib/log.h
index 9067ae1..9f629e1 100644
--- a/lib/log.h
+++ b/lib/log.h
@@ -38,13 +38,18 @@
*
* <PRE>
* openlog("myDaemon", LOG_CONS|LOG_PID, LOG_DAEMON);
- * logbuf ebuf(LOG_ERR);
+ * logbuf ebuf(LOG_ERR, 2);
* ostream lerr(&ebuf);
*
* ... some code ...
*
* lerr << "Whoops, got an error" << endl;
* </PRE>
+ *
+ * The second optional argument of the constructor can be used
+ * to switch the output destination between syslog and some
+ * file. If it is omitted or set to -1, logging can be switched on
+ * or off. The initial state is on.
*/
class logbuf : public streambuf {
public:
@@ -54,8 +59,38 @@ public:
*
* @param level The log level for this instance.
* see syslog(3) for symbolic names to use.
+ * @param fd An optional file descriptor to use
+ * if switched off.
+ */
+ logbuf(int level, int fd = -1);
+
+ /**
+ * Switches loggin on or off.
+ *
+ * @param on The desired state.
*/
- logbuf(int level);
+ void setOn(bool on) { _on = on; }
+
+ /**
+ * Modifies the loglevel of this instance.
+ *
+ * @param level The new loglevel.
+ */
+ void setLevel(int level) { _level = level; }
+
+ /**
+ * Retrieve the current state.
+ *
+ * @returns The current state.
+ */
+ bool on() { return _on; }
+
+ /**
+ * Retrieves the current loglevel.
+ *
+ * @returns The current loglevel.
+ */
+ int level() { return _level; }
/**
* Called by the associated
@@ -81,7 +116,18 @@ private:
/**
* The log level to use with syslog.
*/
- int level;
+ int _level;
+
+ /**
+ * File descriptor to use when switched off.
+ * If this is -1, don't output anything.
+ */
+ int _fd;
+
+ /**
+ * Log flag.
+ */
+ bool _on;
/**
* The internal buffer for holding
diff --git a/lib/plpdirent.h b/lib/plpdirent.h
index 1c5e8ab..5eeced7 100644
--- a/lib/plpdirent.h
+++ b/lib/plpdirent.h
@@ -266,7 +266,7 @@ public:
*
* @param ret The string is returned here.
*/
- void getDriveAttribute(string &ret);
+ void getDriveAttribute(std::string &ret);
/**
* Retrieve the attributes of the media.
diff --git a/lib/ppsocket.cc b/lib/ppsocket.cc
index 8940148..757c2a4 100644
--- a/lib/ppsocket.cc
+++ b/lib/ppsocket.cc
@@ -45,6 +45,8 @@
#define INVALID_SOCKET -1
#define SOCKET_ERROR -1
+using namespace std;
+
ppsocket::ppsocket(const ppsocket & another)
{
m_Socket = another.m_Socket;
diff --git a/lib/psiprocess.h b/lib/psiprocess.h
index 24d47eb..3e76d8e 100644
--- a/lib/psiprocess.h
+++ b/lib/psiprocess.h
@@ -24,6 +24,7 @@
#define _PSIPROCESS_H_
#include <string>
+#include <stream.h>
class rpcs;
@@ -104,16 +105,16 @@ public:
* The output is in human readable similar to the
* output of a "ls" command.
*/
- friend ostream &operator<<(ostream &o, const PsiProcess &p);
+ friend class std::ostream &operator<<(std::ostream &o, const PsiProcess &p);
private:
friend class rpcs;
- void setArgs(string _args);
+ void setArgs(std::string _args);
int pid;
- string name;
- string args;
+ std::string name;
+ std::string args;
bool s5mx;
};
diff --git a/lib/rpcs.h b/lib/rpcs.h
index 2cb276a..5834afa 100644
--- a/lib/rpcs.h
+++ b/lib/rpcs.h
@@ -33,7 +33,7 @@ class ppsocket;
class bufferStore;
class bufferArray;
-typedef vector<PsiProcess> processList;
+typedef std::vector<PsiProcess> processList;
/**
* Remote procedure call services via PLP
@@ -340,7 +340,7 @@ public:
*
* @return Psion error code. 0 = Ok.
*/
- virtual Enum<rfsv::errs> getCmdLine(const char *process, string &ret) = 0;
+ virtual Enum<rfsv::errs> getCmdLine(const char *process, std::string &ret) = 0;
/**
* Retrieve general Information about the connected
diff --git a/lib/rpcs16.cc b/lib/rpcs16.cc
index ce13b4d..3a2b59a 100644
--- a/lib/rpcs16.cc
+++ b/lib/rpcs16.cc
@@ -38,6 +38,8 @@
#include "bufferarray.h"
#include "ppsocket.h"
+using namespace std;
+
rpcs16::rpcs16(ppsocket * _skt)
{
skt = _skt;
diff --git a/lib/rpcs16.h b/lib/rpcs16.h
index 58ca05b..0489d87 100644
--- a/lib/rpcs16.h
+++ b/lib/rpcs16.h
@@ -41,7 +41,7 @@ class rpcs16 : public rpcs {
friend class rpcsfactory;
public:
- Enum<rfsv::errs> getCmdLine(const char *, string &);
+ Enum<rfsv::errs> getCmdLine(const char *, std::string &);
private:
rpcs16(ppsocket *);
diff --git a/lib/rpcs32.cc b/lib/rpcs32.cc
index b1cbe49..b8874f1 100644
--- a/lib/rpcs32.cc
+++ b/lib/rpcs32.cc
@@ -37,6 +37,8 @@
#include "bufferarray.h"
#include "ppsocket.h"
+using namespace std;
+
rpcs32::rpcs32(ppsocket * _skt)
{
skt = _skt;
diff --git a/lib/rpcs32.h b/lib/rpcs32.h
index 9089b66..4f02a2d 100644
--- a/lib/rpcs32.h
+++ b/lib/rpcs32.h
@@ -40,7 +40,7 @@ class rpcs32 : public rpcs {
friend class rpcsfactory;
public:
- Enum<rfsv::errs> getCmdLine(const char *, string &);
+ Enum<rfsv::errs> getCmdLine(const char *, std::string &);
Enum<rfsv::errs> getMachineInfo(machineInfo &);
Enum<rfsv::errs> configRead(u_int32_t, bufferStore &);
Enum<rfsv::errs> configWrite(bufferStore);