summaryrefslogtreecommitdiff
path: root/generic
diff options
context:
space:
mode:
Diffstat (limited to 'generic')
-rw-r--r--generic/Handle.cpp8
-rwxr-xr-xgeneric/Makefile5
-rw-r--r--generic/Output.cpp4
-rw-r--r--generic/String.cpp25
4 files changed, 37 insertions, 5 deletions
diff --git a/generic/Handle.cpp b/generic/Handle.cpp
index 6d02381..44b01de 100644
--- a/generic/Handle.cpp
+++ b/generic/Handle.cpp
@@ -289,3 +289,11 @@ ssize_t Handle::uread(void * buf, size_t count) {
off_t Handle::tell() {
return itell;
}
+
+bool Handle::CanSeek() {
+ return 0;
+}
+
+off_t Handle::seek(off_t, int) throw(GeneralException) {
+ throw IOGeneral("Handle " + GetName() + " can't seek");
+}
diff --git a/generic/Makefile b/generic/Makefile
index 99a9631..4ca5e32 100755
--- a/generic/Makefile
+++ b/generic/Makefile
@@ -2,11 +2,12 @@
CPPFLAGS=-Wall -g -O3 -mcpu=i686 -pedantic -pedantic-errors -I../includes -DPARANOID_SEEK -DHAVE_ZLIB
CXX=g++
+CC=gcc
-OBJECTS = Buffer.o Exceptions.o Handle.o Image.o Input.o Output.o generic.o String.o
+OBJECTS = Buffer.o Exceptions.o Handle.o Image.o Input.o Output.o generic.o String.o checkargs.o datecalc.o
TARGET = generic.a
-all: ${TARGET}
+all: ${TARGET} Makefile
generic.a: ${OBJECTS}
ar -r generic.a ${OBJECTS}
diff --git a/generic/Output.cpp b/generic/Output.cpp
index 72d00cf..e136524 100644
--- a/generic/Output.cpp
+++ b/generic/Output.cpp
@@ -13,8 +13,8 @@
#define _(x) x
#endif
-Output::Output(String no, int trunc) throw (GeneralException) :
- Handle(no.strlen() ? open(no.to_charp(), O_WRONLY | O_CREAT | (trunc ? O_TRUNC : O_APPEND), 00666) : dup(1)),
+Output::Output(String no, int create, int trunc) throw (GeneralException) :
+ Handle(no.strlen() ? open(no.to_charp(), O_WRONLY | (O_CREAT * (create ? 1 : 0)) | (trunc ? O_TRUNC : O_APPEND), 00666) : dup(1)),
n(no) {
if (GetHandle() < 0) {
throw IOGeneral(String(_("Error opening file ")) + no + _(" for writing: ") + strerror(errno));
diff --git a/generic/String.cpp b/generic/String.cpp
index 49b4e4d..0f4da24 100644
--- a/generic/String.cpp
+++ b/generic/String.cpp
@@ -23,7 +23,19 @@ String::String(char c) : siz(1) {
str = t;
}
-String::String(const char * s) : str(s ? Base::strdup(s) : Base::strdup("")) {
+String::String(const char * s, ...) : str(s ? Base::strdup(s) : Base::strdup("")) {
+ va_list ap;
+
+ if (!s)
+ return;
+
+/* This causes a warning: cannot pass objects of type `const String' through `...'
+ but it is not really a problem. */
+ va_start(ap, s);
+ vsnprintf(t, BUFSIZ, s, ap);
+ free(str);
+ str = Base::strdup(t);
+ va_end(ap);
siz = ::strlen(str);
}
@@ -78,6 +90,13 @@ String::~String() {
const char * String::set(const char * s, ...) {
va_list ap;
+ if (!s) {
+ free(str);
+ str = Base::strdup("");
+ t[0] = 0;
+ return t;
+ }
+
/* This causes a warning: cannot pass objects of type `const String' through `...'
but it is not really a problem. */
va_start(ap, s);
@@ -354,3 +373,7 @@ bool String::is_time(void) const {
return (extract(p + 1).to_int() < 60) ? true : false;
}
+
+String operator+(const char * a, const String & b) {
+ return String(a) + b;
+}