diff options
-rw-r--r-- | include/Main.h | 1 | ||||
-rw-r--r-- | include/gettext.h | 2 | ||||
-rw-r--r-- | lib/Action.cc | 1 | ||||
-rw-r--r-- | lib/Buffer.cc | 1 | ||||
-rw-r--r-- | lib/Confirm.cc | 1 | ||||
-rw-r--r-- | lib/CopyJob.cc | 2 | ||||
-rw-r--r-- | lib/Form.cc | 1 | ||||
-rw-r--r-- | lib/GMPString.cc | 1 | ||||
-rw-r--r-- | lib/Handle.cc | 26 | ||||
-rw-r--r-- | lib/HttpServ.cc | 15 | ||||
-rw-r--r-- | lib/IRC.cc | 1 | ||||
-rw-r--r-- | lib/Input.cc | 35 | ||||
-rw-r--r-- | lib/Main.cc | 5 | ||||
-rw-r--r-- | lib/OutPipe.cc | 2 | ||||
-rw-r--r-- | lib/String.cc | 11 | ||||
-rw-r--r-- | lib/checkargs.c | 166 | ||||
-rw-r--r-- | po/POTFILES.in | 13 | ||||
-rw-r--r-- | po/fr.po | 22 |
18 files changed, 151 insertions, 155 deletions
diff --git a/include/Main.h b/include/Main.h index 6d4ac9c..0e3885a 100644 --- a/include/Main.h +++ b/include/Main.h @@ -25,6 +25,7 @@ class Main : public Base { #define CODE_ENDS }; \ int main(int argc, char ** argv) { \ int r; \ + setlocale(LC_ALL, ""); \ Appli * Application = new Appli(); \ r = Main::truemain(Application, argc, argv, environ); \ delete Application; \ diff --git a/include/gettext.h b/include/gettext.h index ab2d962..248bf2e 100644 --- a/include/gettext.h +++ b/include/gettext.h @@ -66,7 +66,7 @@ initializer for static 'char[]' or 'const char[]' variables. */ #define gettext_noop(String) String -#define _(Text) gettext (Text) +#define _(Text) dgettext ("Baltisot", Text) #define N_(Text) Text #endif /* _LIBGETTEXT_H */ diff --git a/lib/Action.cc b/lib/Action.cc index e5825b9..1b560ff 100644 --- a/lib/Action.cc +++ b/lib/Action.cc @@ -4,6 +4,7 @@ #include "BString.h" #include "Action.h" #include "HttpServ.h" +#include "gettext.h" Action * Action::start = 0; diff --git a/lib/Buffer.cc b/lib/Buffer.cc index db8b3ee..6dcfa6e 100644 --- a/lib/Buffer.cc +++ b/lib/Buffer.cc @@ -4,6 +4,7 @@ #endif #include "Buffer.h" #include "generic.h" +#include "gettext.h" Buffer::Buffer() : Handle(-1), buffer(0), zero(0), realsiz(0), bufsiz(0), ptr(0) { } diff --git a/lib/Confirm.cc b/lib/Confirm.cc index 18e56e6..64a623f 100644 --- a/lib/Confirm.cc +++ b/lib/Confirm.cc @@ -5,6 +5,7 @@ #include "Confirm.h" #include "Buffer.h" #include "CopyJob.h" +#include "gettext.h" Confirm::Confirm(const String & t, const String & m, const String & U, Action * y, Action * n) : Action(U), tit(t), msg(m), NYes(y), NNo(n) { } diff --git a/lib/CopyJob.cc b/lib/CopyJob.cc index 2554654..fc2a0ca 100644 --- a/lib/CopyJob.cc +++ b/lib/CopyJob.cc @@ -1,8 +1,8 @@ #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include "gettext.h" #include "CopyJob.h" +#include "gettext.h" CopyJob::CopyJob(Handle * as, Handle * ad, ssize_t asiz, bool ads, bool add, int ashape) : s(as), d(ad), ds(ads), dd(add), siz(asiz), cursiz(0), r(0), w(0), tw(0), shape(ashape) { struct timezone tz; diff --git a/lib/Form.cc b/lib/Form.cc index fedfc3e..e0e5073 100644 --- a/lib/Form.cc +++ b/lib/Form.cc @@ -5,6 +5,7 @@ #include "HttpServ.h" #include "Buffer.h" #include "CopyJob.h" +#include "gettext.h" Form::Form(const String & titre, const String & url, const String & inv, String * names, String * invs, String * defaults, String ** lists, String ** descs, int nb, Action * na) : diff --git a/lib/GMPString.cc b/lib/GMPString.cc index 5b2d1c6..ee4debb 100644 --- a/lib/GMPString.cc +++ b/lib/GMPString.cc @@ -4,6 +4,7 @@ #ifdef HAVE_GMP #include <gmpxx.h> #include "GMPString.h" +#include "gettext.h" GMPString::GMPString(const GMPString & s) : str(s.str) { } diff --git a/lib/Handle.cc b/lib/Handle.cc index 255eacd..de4114e 100644 --- a/lib/Handle.cc +++ b/lib/Handle.cc @@ -40,7 +40,7 @@ enum { Handle::Handle(const Handle & nh) : itell(0), h(nh.h >= 0 ? dup(nh.h) : nh.h), closed(nh.closed), nonblock(nh.closed), zfile(0), z(0) { #ifdef DEBUG - std::cerr << "Duplication of handle " << nh.h << " to " << h << std::endl; + std::cerr << _("Duplication of handle ") << nh.h << _(" to ") << h << std::endl; #endif if ((h >= 0) && (nh.z)) { SetZ(nh.z); @@ -49,7 +49,7 @@ Handle::Handle(const Handle & nh) : itell(0), h(nh.h >= 0 ? dup(nh.h) : nh.h), c Handle::~Handle() { #ifdef DEBUG - std::cerr << "Destroying handle " << h << std::endl; + std::cerr << _("Destroying handle ") << h << std::endl; #endif close(); } @@ -57,7 +57,7 @@ Handle::~Handle() { Handle::Handle(int nh) : h(nh), closed(false), nonblock(false), zfile(0), z(0) { #ifdef DEBUG - std::cerr << "Initialising handle " << h << std::endl; + std::cerr << _("Initialising handle ") << h << std::endl; #endif } @@ -92,7 +92,7 @@ ssize_t Handle::write(const void *cbuf, size_t count) throw (GeneralException) { full = true; if (nonblock) { #ifdef DEBUG - std::cerr << "write: throwing IOAgain for handle " << GetName() << std::endl; + std::cerr << _("write: throwing IOAgain for handle ") << GetName() << std::endl; #endif throw IOAgain(); } else { @@ -121,7 +121,7 @@ ssize_t Handle::read(void *buf, size_t count) throw (GeneralException) { ssize_t r; #ifdef FULLDEBUG - std::cerr << "read: reading " << count << " bytes from handle " << GetHandle() << std::endl; + std::cerr << _("read: reading ") << count << _(" bytes from handle ") << GetHandle() << std::endl; #endif errno = 0; @@ -131,7 +131,7 @@ ssize_t Handle::read(void *buf, size_t count) throw (GeneralException) { // problème lié au fait qu'il n'y a plus d'octets. if (nonblock) { #ifdef DEBUG - std::cerr << "read: throwing IOAgain for handle " << GetName() << std::endl; + std::cerr << _("read: throwing IOAgain for handle ") << GetName() << std::endl; #endif throw IOAgain(); } @@ -223,11 +223,11 @@ void Handle::close() throw (GeneralException) { } } else if (z) { #ifdef DEBUG - std::cerr << "Performing gzclose on handle " << h << std::endl; + std::cerr << _("Performing gzclose on handle ") << h << std::endl; #endif int err = gzclose(zfile); #ifdef DEBUG - std::cerr << "gzclose returned " << err << std::endl; + std::cerr << _("gzclose returned ") << err << std::endl; #endif if (err) { if (err == Z_ERRNO) { @@ -286,7 +286,7 @@ void Handle::SetZ(int az) throw (GeneralException) { } if (az >= 10) { #ifdef DEBUG - std::cerr << "Setting up zstream using inflate/deflate...\n"; + std::cerr << _("Setting up zstream using inflate/deflate...\n"); #endif int err; zstrm.zalloc = Z_NULL; @@ -318,7 +318,7 @@ void Handle::SetZ(int az) throw (GeneralException) { format[index++] = (char) (az + '0'); format[index] = 0; #ifdef FULLDEBUG - std::cerr << "Performing gzdopen on handle " << h << " with mode \"" << format << "\"\n"; + std::cerr << _("Performing gzdopen on handle ") << h << _(" with mode \"") << format << "\"\n"; #endif if (!(zfile = gzdopen(h, format))) { throw GeneralException(_("Was not able to gzdopen.")); @@ -331,7 +331,7 @@ ssize_t Handle::uwrite(const void * buf, size_t count) throw (GeneralException) if (z >= 10) { } else if (z) { #ifdef FULLDEBUG - std::cerr << "Performing gzwrite of " << count << " byte for handle " << h << std::endl; + std::cerr << _("Performing gzwrite of ") << count << _(" byte(s) for handle ") << h << std::endl; #endif #ifdef HAVE_WD_ZLIB int err = gzwrite(zfile, buf, count); @@ -358,7 +358,7 @@ ssize_t Handle::uread(void * buf, size_t count) { if (z >= 10) { } if (z) { #ifdef DEBUG - std::cerr << "Performing gzread of " << count << " byte for handle " << h << std::endl; + std::cerr << _("Performing gzread of ") << count << _(" byte(s) for handle ") << h << std::endl; #endif int err = gzread(zfile, buf, count); if (err == -1) { @@ -393,7 +393,7 @@ off_t Handle::seek(off_t offset, int whence) throw(GeneralException) { if (z) { return itell = gzseek(zfile, offset, whence); } else { - throw IOGeneral("Handle " + GetName() + " can't seek"); + throw IOGeneral(_("Handle ") + GetName() + _(" can't seek")); } } diff --git a/lib/HttpServ.cc b/lib/HttpServ.cc index 2c79de7..a4101a7 100644 --- a/lib/HttpServ.cc +++ b/lib/HttpServ.cc @@ -8,6 +8,7 @@ #include "ReadJob.h" #include "CopyJob.h" #include "Task.h" +#include "gettext.h" String endhl = "\r\n", endnl = "\n"; @@ -44,7 +45,7 @@ ProcessRequest::ProcessRequest(Action * ap, const Socket & as, const String & an } String ProcessRequest::GetName() { - return "Processing HTTP request"; + return _("Processing HTTP request"); } int ProcessRequest::Do() throw(GeneralException) { @@ -138,7 +139,7 @@ int ProcessRequest::Do() throw(GeneralException) { if (domain == "/bin") bad = false; if (domain == "/") bad = false; if (bad) { - std::cerr << "Error: bad domain.\n"; + std::cerr << _("Error: bad domain.\n"); } } else { // L'url sans domaine ni fichier est valide. (cela arrive sur certains navigateurs...) @@ -172,11 +173,11 @@ int ProcessRequest::Do() throw(GeneralException) { SendHeads(&b, GetMime(file), String("Accept-Ranges: bytes") + endhl + "Content-Length: " + (unsigned long long int) i->GetSize() + endhl, i->GetModif()); i->SetNonBlock(); a = new CopyJob(i, &s); - std::cerr << "File found, dumping.\n"; + std::cerr << _("File found, dumping.\n"); } catch (IOGeneral e) { ShowError(&b); - std::cerr << "File not found, error showed.\n"; + std::cerr << _("File not found, error showed.\n"); } } } @@ -276,7 +277,7 @@ bool ProcessRequest::ParseUri(String & file, String & domain, String & gvars, Ha ssize_t sppos; *s >> t; - std::cerr << "Read Request (1): " << t << std::endl; + std::cerr << _("Read Request (1): ") << t << std::endl; int IPos = t.strchr('?'); @@ -437,13 +438,13 @@ HttpServ::HttpServ(Action * ap, int port, const String & nname) throw (GeneralEx r = Listener.SetLocal("", port); if (!r) { - throw GeneralException("Initialisation of the Mini HTTP-Server failed: can't bind"); + throw GeneralException(_("Initialisation of the Mini HTTP-Server failed: can't bind")); } r = Listener.Listen(); if (!r) { - throw GeneralException("Initialisation of the Mini HTTP-Server failed: can't listen"); + throw GeneralException(_("Initialisation of the Mini HTTP-Server failed: can't listen")); } Listener.SetNonBlock(); @@ -4,6 +4,7 @@ #include "BString.h" #include "IRC.h" #include "HttpServ.h" +#include "gettext.h" ircmsg_t ircmsgs[MSG_COUNT] = diff --git a/lib/Input.cc b/lib/Input.cc index 9697913..8ce13cf 100644 --- a/lib/Input.cc +++ b/lib/Input.cc @@ -70,7 +70,7 @@ Input::Input(const String & no) throw (GeneralException) : n(no) { #ifdef DEBUG - fprintf(stderr, "Opening file %s, Input at %p\n", no.to_charp(), this); + fprintf(stderr, _("Opening file %s, Input at %p\n"), no.to_charp(), this); #endif if (GetHandle() < 0) { @@ -91,7 +91,7 @@ Input::Input(const String & no) throw (GeneralException) : } } else { #ifdef DEBUG - std::cerr << "Opening file in archive, position " << results.ptr << std::endl; + std::cerr << _("Opening file in archive, position ") << results.ptr << std::endl; #endif size = results.size; seek(results.ptr, SEEK_SET); @@ -151,14 +151,14 @@ off_t Input::seek(off_t offset, int whence) throw (GeneralException) { int Input::wrapopen(const String & fname, openresults_t * results) { #ifdef DEBUG - std::cerr << "Wrap-opening " << fname << std::endl; + std::cerr << _("Wrap-opening ") << fname << std::endl; #endif if (fname[0] != '/') { bool t; t = Archive::inarchive(fname); if (t) { #ifdef DEBUG - std::cerr << "Trying to open the file in archive, since it seems to be here\n"; + std::cerr << _("Trying to open the file in archive, since it seems to be here\n"); #endif return Archive::open(fname, results); } @@ -200,7 +200,7 @@ Archive::Archive(const String & fname, int atype) throw (GeneralException) : case ARCHIVE_BUILTIN: archive.read(buffer, 4); if (*((Uint32 *)buffer) != BUILTIN_SIG) - throw GeneralException("Archive: not in built-in format."); + throw GeneralException(_("Archive: not in built-in format.")); while (p) { archive.read(buffer, 1); len = *buffer; @@ -211,7 +211,7 @@ Archive::Archive(const String & fname, int atype) throw (GeneralException) : size = archive.readU32(); archive.read(buffer, 1); #ifdef DEBUG - std::cerr << "Adding file `" << ifname << "' to node `" << p->name << "'\n"; + std::cerr << _("Adding file `") << ifname << _("' to node `") << p->name << "'\n"; #endif t = new FileTree(ifname, size, buffer[0], p); if (buffer[0]) @@ -223,7 +223,7 @@ Archive::Archive(const String & fname, int atype) throw (GeneralException) : filetree.compute_ptrs(archive.tell()); break; default: - throw GeneralException("Archive: unsupported archive format."); + throw GeneralException(_("Archive: unsupported archive format.")); } next = header; @@ -247,11 +247,11 @@ bool Archive::inarchive(const String & fname) { Archive * p; for (p = header; p; p = p->next) { #ifdef DEBUG - std::cerr << "Looking for file `" << fname << "' in archive " << p->name << std::endl; + std::cerr << _("Looking for file `") << fname << _("' in archive ") << p->name << std::endl; #endif if (p->inarchivein(fname)) { #ifdef DEBUG - std::cerr << "File `" << fname << "' found in archive " << p->name << std::endl; + std::cerr << _("File `") << fname << _("' found in archive ") << p->name << std::endl; #endif return true; } @@ -268,7 +268,7 @@ int Archive::open(const String & fname, Input::openresults_t * results) throw (G if (t) return p->openin(fname, results); } - throw IOGeneral("File `" + fname + "' not found in archive collection."); + throw IOGeneral(_("File `") + fname + _("' not found in archive collection.")); } bool Archive::inarchivein(const String & fname) { @@ -287,8 +287,7 @@ bool Archive::inarchivein(const String & fname) { name = ""; } #ifdef DEBUG - std::cerr << "inarchivein: reste = `" << reste << "' - name = `" << name << "'\n"; - std::cerr << "Checking against node `" << p->name << "'\n"; + std::cerr << _("Checking against node `") << p->name << "'\n"; #endif while (p) { if (p->name == reste) { @@ -332,10 +331,10 @@ int Archive::openin(const String & fname, Input::openresults_t * results) throw } if (!p) - throw IOGeneral("File `" + fname + "' not in archive " + this->name); + throw IOGeneral(_("File `") + fname + _("' not in archive ") + this->name); if (p->Child()) - throw IOGeneral("File `" + fname + "' in archive " + this->name + " is a directory - can't open."); + throw IOGeneral(_("File `") + fname + _("' in archive ") + this->name + _(" is a directory - can't open.")); results->name = p->name; results->ptr = p->ptr; @@ -354,7 +353,7 @@ Archive::FileTree::FileTree(const String & fname, size_t fsize, int ftype, Archi prev = p; } else { #ifdef DEBUG - std::cerr << "Adding `" << fname << "' as first child of node `" << father->name << "'\n"; + std::cerr << _("Adding `") << fname << _("' as first child of node `") << father->name << "'\n"; #endif father->child = this; } @@ -386,11 +385,11 @@ int Archive::FileTree::compute_ptrs(size_t cptr) { ptr = cptr; #ifdef DEBUG - std::cerr << "Computed pointer for `" << name << "' = " << ptr << std::endl; + std::cerr << _("Computed pointer for `") << name << "' = " << ptr << std::endl; if (child) - std::cerr << "Node has child\n"; + std::cerr << _("Node has child\n"); else - std::cerr << "Node is " << size << " bytes large.\n"; + std::cerr << _("Node is ") << size << _(" bytes large.\n"); #endif if (child) { diff --git a/lib/Main.cc b/lib/Main.cc index 5571689..992f73c 100644 --- a/lib/Main.cc +++ b/lib/Main.cc @@ -3,6 +3,7 @@ #endif #include "Main.h" #include "generic.h" +#include "gettext.h" Main::Main() : setted(false) {} @@ -29,11 +30,11 @@ int Main::truemain(Main * Application, int argc, char ** argv, char ** enve) { r = e.GetCode(); } catch (GeneralException e) { - Base::printm(M_ERROR, "The application caused an exception: %s\n", e.GetMsg()); + Base::printm(M_ERROR, _("The application caused an exception: %s\n"), e.GetMsg()); return -1; } catch (...) { - Base::printm(M_ERROR, "The application caused an unknow exception\n"); + Base::printm(M_ERROR, _("The application caused an unknow exception\n")); return -1; } return r; diff --git a/lib/OutPipe.cc b/lib/OutPipe.cc index a5404d6..c8d979c 100644 --- a/lib/OutPipe.cc +++ b/lib/OutPipe.cc @@ -37,5 +37,5 @@ bool OutPipe::CanRead() { } String OutPipe::GetName() { - return (String("Output pipe to stdin (") + (hooked ? "" : _("not ")) + _("hooked)")); + return (String(_("Output pipe to stdin (")) + (hooked ? "" : _("not ")) + _("hooked)")); } diff --git a/lib/String.cc b/lib/String.cc index 22a9efb..53ecb83 100644 --- a/lib/String.cc +++ b/lib/String.cc @@ -10,6 +10,7 @@ #endif #include "BString.h" #include "Exceptions.h" +#include "gettext.h" char ** gruikptr; @@ -22,13 +23,13 @@ char String::t[BUFSIZ + 1]; String::String(const String & s) : str(Base::strdup(s.str)), siz(s.siz) { #ifdef DEBUG - fprintf(stderr, "Duplicating string `%s', from %p to %p, from this %p to this %p\n", str, s.str, str, s, this); + fprintf(stderr, _("Duplicating string `%s', from %p to %p, from this %p to this %p\n"), str, s.str, str, s, this); #endif } String::String(char c) : siz(1) { #ifdef DEBUG - fprintf(stderr, "Creating a string with `%c' at %p, this = %p\n", c, str, this); + fprintf(stderr, _("Creating a string with `%c' at %p, this = %p\n"), c, str, this); #endif #ifndef HAVE_ASPRINTF char * t = (char *) malloc(2); @@ -44,13 +45,13 @@ String::String(const char * s) : str(Base::strdup(s)), siz(::strlen(str)) { gruikptr = &str; } #ifdef DEBUG - fprintf(stderr, "Creating a string with `%s' at %p from %p, this = %p\n", str, str, s, this); + fprintf(stderr, _("Creating a string with `%s' at %p from %p, this = %p\n"), str, str, s, this); #endif } String::String(int hs, char * s) : str(Base::strdup(s ? s : "")), siz(hs) { #ifdef DEBUG - fprintf(stderr, "Fast-Creating a string with `%s' at %p from %p, this = %p\n", str, str, s, this); + fprintf(stderr, _("Fast-Creating a string with `%s' at %p from %p, this = %p\n"), str, str, s, this); #endif } @@ -111,7 +112,7 @@ String::String(double d) { String::~String() { #ifdef DEBUG - fprintf(stderr, "Destroying string @ %p, freeing %p.\n", this, str); + fprintf(stderr, _("Destroying string @ %p, freeing %p.\n"), this, str); #endif free(str); } diff --git a/lib/checkargs.c b/lib/checkargs.c index e1c97be..4fee446 100644 --- a/lib/checkargs.c +++ b/lib/checkargs.c @@ -1,85 +1,85 @@ -/* datedif - calculates the difference in days between two dates
- * Copyright (C) 2000 Micael Widell contact: xeniac@linux.nu
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
+/* datedif - calculates the difference in days between two dates + * Copyright (C) 2000 Micael Widell contact: xeniac@linux.nu + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + #include <stdlib.h> #include <string.h> -
-int isDateArgument(char* dateString) {
-
- const int MONTHS[] = {31,0,31,30,31,30,31,31,30,31,30,31};
- int i, day, month, year;
- char buffer[5];
-
- /* 'today' is a valid date */
- if (strcmp(dateString, "today") == 0)
- return 1;
-
- /* Numeric dates must be eight characters long */
- if (8 != strlen(dateString))
- return 0;
-
- /* Check that the date is entirely formed of numbers */
- for (i = 0; i < 8; i++) {
- if (dateString[i] < '0' || dateString[i] > '9')
- return 0;
- }
-
- /* Check that the date exists */
- memset(buffer, 0, 5);
- strncpy(buffer, dateString + 6, 2);
- day = atoi(buffer);
- strncpy(buffer, dateString + 4, 2);
- month = atoi(buffer);
- month -= 1;
- strncpy(buffer, dateString, 4);
- year = atoi(buffer);
-
- /* Validate month */
- if (month < 0 || month > 11)
- return 0;
-
- /* Validating dates is simple when the date does not fall into February */
- if (1 != month) {
- if (day < 1 || day > MONTHS[month])
- return 0;
- } else {
- int feb = 28;
-
- /* Februarys are a bit tougher issue */
- if (0 == year % 4) {
- if (0 == year % 100) {
- if (0 == year % 400) {
- feb = 29;
- } else {
- feb = 28;
- }
- } else {
- feb = 29;
- }
- }
- if (day < 1 || day > feb)
- return 0;
- }
-
- /* Avoid user from using dates before 16000301, since those will result in
- incorrect output */
- if(16000301 > atoi(dateString))
- return 0;
-
- return 1;
-}
+ +int isDateArgument(char* dateString) { + + const int MONTHS[] = {31,0,31,30,31,30,31,31,30,31,30,31}; + int i, day, month, year; + char buffer[5]; + + /* 'today' is a valid date */ + if (strcmp(dateString, "today") == 0) + return 1; + + /* Numeric dates must be eight characters long */ + if (8 != strlen(dateString)) + return 0; + + /* Check that the date is entirely formed of numbers */ + for (i = 0; i < 8; i++) { + if (dateString[i] < '0' || dateString[i] > '9') + return 0; + } + + /* Check that the date exists */ + memset(buffer, 0, 5); + strncpy(buffer, dateString + 6, 2); + day = atoi(buffer); + strncpy(buffer, dateString + 4, 2); + month = atoi(buffer); + month -= 1; + strncpy(buffer, dateString, 4); + year = atoi(buffer); + + /* Validate month */ + if (month < 0 || month > 11) + return 0; + + /* Validating dates is simple when the date does not fall into February */ + if (1 != month) { + if (day < 1 || day > MONTHS[month]) + return 0; + } else { + int feb = 28; + + /* Februarys are a bit tougher issue */ + if (0 == year % 4) { + if (0 == year % 100) { + if (0 == year % 400) { + feb = 29; + } else { + feb = 28; + } + } else { + feb = 29; + } + } + if (day < 1 || day > feb) + return 0; + } + + /* Avoid user from using dates before 16000301, since those will result in + incorrect output */ + if(16000301 > atoi(dateString)) + return 0; + + return 1; +} diff --git a/po/POTFILES.in b/po/POTFILES.in index 1cf525b..39f43a0 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -4,12 +4,17 @@ lib/Confirm.cc lib/CopyJob.cc lib/Exceptions.cc lib/Form.cc +lib/GMPString.cc lib/Handle.cc lib/HttpServ.cc lib/IRC.cc +lib/Image.cc +lib/InPipe.cc lib/Input.cc +lib/Main.cc lib/Menu.cc lib/Message.cc +lib/OutPipe.cc lib/Output.cc lib/ReadJob.cc lib/Regex.cc @@ -19,9 +24,5 @@ lib/Table.cc lib/Task.cc lib/TaskMan.cc lib/Variables.cc -lib/checkargs.c -lib/datecalc.c -lib/InPipe.cc -lib/OutPipe.cc -src/Main.cc -src/misc.cc +lib/fileutils.cc +lib/generic.cc @@ -27,14 +27,12 @@ msgid "Generating a General Exception error: '" msgstr "Génération d'une Exception Générale: '" #: lib/Exceptions.cc:38 -#, fuzzy, c-format msgid "Failed allocating %ld bytes." -msgstr "N'a pu allouer %u octets." +msgstr "N'a pu allouer %ld octets." #: lib/Exceptions.cc:43 -#, fuzzy, c-format msgid "An error has occured while %s %ld bytes on %s: %s" -msgstr "Une erreur est survenue en %s %u octets depuis %s: %s" +msgstr "Une erreur est survenue en %s %lu octets depuis %s: %s" #: lib/Exceptions.cc:43 msgid "writing" @@ -46,7 +44,7 @@ msgstr "lisant" #: lib/Exceptions.cc:52 msgid "No more bytes for reading or writing." -msgstr "Plus d'octets à lire ou écrire" +msgstr "Plus d'octets à lire ou écrire." #: lib/Exceptions.cc:58 msgid "Switching task in a non-tasked environnement" @@ -166,7 +164,7 @@ msgstr " invalide." #: lib/TaskMan.cc:414 msgid "TaskMan: internal error (task not found) -- SHOULD NOT HAPPEN!!" -msgstr "" +msgstr "TaskMan: erreur interne (tâche non trouvée) - NE DEVRAIT PAS ARRIVER!!" #: lib/InPipe.cc:32 msgid "Input pipe from stdout (" @@ -179,15 +177,3 @@ msgstr "non " #: lib/InPipe.cc:32 lib/OutPipe.cc:32 msgid "hooked)" msgstr "détourné)" - -#~ msgid "Exitting with code " -#~ msgstr "Sortie avec le code " - -#~ msgid "Error seeking file " -#~ msgstr "Erreur en avançant dans le fichier" - -#~ msgid ": " -#~ msgstr ": " - -#~ msgid ": the position does not match" -#~ msgstr ": la position ne correspond pas" |