diff options
41 files changed, 449 insertions, 360 deletions
diff --git a/Makefile.am b/Makefile.am index 1152b4f..9ab1ebf 100644 --- a/Makefile.am +++ b/Makefile.am @@ -22,6 +22,8 @@ maintainer-clean-local: conf/config.guess conf/config.sub conf/install-sh conf/ltconfig \ conf/ltmain.sh conf/missing conf/mkinstalldirs \ etc/*.spec + find . -name "*~" -exec rm -f {} \; + find . -name "\.\#*" -exec rm -f {} \; dist-hook: $(MAKE) TMPDEST=$(distdir)/ kdoc specfile @@ -68,5 +68,17 @@ # define NDEBUG #endif +#ifndef HAVE_BOOL +# ifndef bool +# define bool int +# endif +# ifndef true +# define true 1 +# endif +# ifndef false +# define false 0 +# endif +#endif + #endif /* _CONFIG_H_ */ diff --git a/configure.in b/configure.in index 7157287..b391e48 100644 --- a/configure.in +++ b/configure.in @@ -119,6 +119,9 @@ else AC_DEFINE_UNQUOTED(DONT_UPDATE_MTAB) fi +dnl Check, if compiler knows about bool +AC_CHECK_BOOL + dnl Type of sighandlers AC_TYPE_SIGNAL diff --git a/kde2/kioslave/kio_plp.cpp b/kde2/kioslave/kio_plp.cpp index 8cf76c7..587ef98 100644 --- a/kde2/kioslave/kio_plp.cpp +++ b/kde2/kioslave/kio_plp.cpp @@ -260,27 +260,25 @@ listDir(const KURL& _url) { convertName(path); path += "\\"; - bufferArray files; + PlpDir files; Enum<rfsv::errs> res = plpRfsv->dir(path, files); if (checkForError(res)) return; - totalSize(files.length()); + totalSize(files.size()); UDSEntry entry; - while (!files.empty()) { + for (int i = 0; i < files.size(); i++) { UDSAtom atom; - bufferStore s = files.pop(); - PsiTime *date = (PsiTime *)s.getDWord(0); - long size = s.getDWord(4); - long attr = s.getDWord(8); - entry.clear(); + PlpDirent e = files[i]; + long attr = e.getAttr(); + entry.clear(); atom.m_uds = KIO::UDS_NAME; - atom.m_str = s.getString(12); + atom.m_str = e.getName(); entry.append(atom); if (rom) attr |= rfsv::PSI_A_RDONLY; - completeUDSEntry(entry, attr, size, date); + completeUDSEntry(entry, attr, e.getSize(), e.getPsiTime().getTime()); listEntry(entry, false); } listEntry(entry, true); // ready @@ -364,14 +362,14 @@ stat( const KURL & url) { atom.m_uds = KIO::UDS_NAME; atom.m_str = fileName; entry.append(atom); - completeUDSEntry(entry, attr, size, &time); + completeUDSEntry(entry, attr, size, time.getTime()); statEntry(entry); finished(); } void PLPProtocol:: -completeUDSEntry(UDSEntry& entry, const long attr, const long size, PsiTime *date) { +completeUDSEntry(UDSEntry& entry, const long attr, const long size, const time_t date) { UDSAtom atom; atom.m_uds = KIO::UDS_SIZE; @@ -379,7 +377,7 @@ completeUDSEntry(UDSEntry& entry, const long attr, const long size, PsiTime *dat entry.append(atom); atom.m_uds = KIO::UDS_MODIFICATION_TIME; - atom.m_long = date->getTime(); + atom.m_long = date; entry.append(atom); atom.m_uds = KIO::UDS_ACCESS; @@ -661,8 +659,8 @@ put( const KURL& url, int _mode, bool _overwrite, bool /*_resume*/ ) { void PLPProtocol:: rename(const KURL &src, const KURL &dest, bool _overwrite) { - QString from( QFile::encodeName(src.path())); - QString to( QFile::encodeName(dest.path())); + QString from(QFile::encodeName(src.path())); + QString to(QFile::encodeName(dest.path())); if (checkConnection()) return; diff --git a/kde2/kioslave/kio_plp.h b/kde2/kioslave/kio_plp.h index 4f1bc23..0112801 100644 --- a/kde2/kioslave/kio_plp.h +++ b/kde2/kioslave/kio_plp.h @@ -56,7 +56,7 @@ class PLPProtocol : public KIO::SlaveBase char driveChar(const QString& path); void createVirtualDirEntry(KIO::UDSEntry & entry, bool rdonly); - void completeUDSEntry(KIO::UDSEntry& entry, const long attr, const long size, PsiTime *date); + void completeUDSEntry(KIO::UDSEntry& entry, const long attr, const long size, const time_t date); bool checkForError(Enum<rfsv::errs> res); bool isRomDrive(const QString& path); bool isDrive(const QString& path); diff --git a/lib/Makefile.am b/lib/Makefile.am index af983e3..367fbb7 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -5,10 +5,10 @@ lib_LTLIBRARIES = libplp.la libplp_la_LDFLAGS = --debug -version-info 1:1:0 libplp_la_SOURCES = bufferarray.cc bufferstore.cc iowatch.cc ppsocket.cc \ rfsv16.cc rfsv32.cc rfsvfactory.cc log.cc rfsv.cc rpcs32.cc rpcs16.cc \ - rpcs.cc rpcsfactory.cc psitime.cc Enum.cc -pkginclude_HEADERS = bool.h bufferarray.h bufferstore.h iowatch.h ppsocket.h \ + rpcs.cc rpcsfactory.cc psitime.cc Enum.cc plpdirent.cc +pkginclude_HEADERS = bufferarray.h bufferstore.h iowatch.h ppsocket.h \ rfsv.h rfsv16.h rfsv32.h rfsvfactory.h log.h rpcs32.h rpcs16.h rpcs.h \ - rpcsfactory.h psitime.h Enum.h + rpcsfactory.h psitime.h Enum.h plpdirent.h maintainer-clean-local: rm -f Makefile.in diff --git a/lib/bool.h b/lib/bool.h deleted file mode 100644 index 7525d6c..0000000 --- a/lib/bool.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef _bool_h_ -#define _bool_h_ - -#ifndef __GNUC__ - -#ifndef bool -#define bool int -#endif - -#ifndef true -#define true 1 -#endif - -#ifndef false -#define false 0 -#endif - -#endif - -#endif diff --git a/lib/bufferarray.h b/lib/bufferarray.h index b43dcbd..358d428 100644 --- a/lib/bufferarray.h +++ b/lib/bufferarray.h @@ -1,7 +1,9 @@ #ifndef _bufferarray_h #define _bufferarray_h -#include "bool.h" +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif class bufferStore; /** diff --git a/lib/bufferstore.h b/lib/bufferstore.h index 494d0af..65f6607 100644 --- a/lib/bufferstore.h +++ b/lib/bufferstore.h @@ -1,7 +1,6 @@ #ifndef _bufferstore_h #define _bufferstore_h -#include "bool.h" class ostream; /** @@ -210,7 +209,7 @@ private: }; inline bool bufferStore::empty() const { - return (len-start) == 0; + return (len - start) == 0; } #endif diff --git a/lib/iowatch.cc b/lib/iowatch.cc index df7be8e..e3c86fc 100644 --- a/lib/iowatch.cc +++ b/lib/iowatch.cc @@ -26,7 +26,6 @@ #include <stream.h> #include <memory.h> -#include "bool.h" #include "iowatch.h" IOWatch::IOWatch() { diff --git a/lib/iowatch.h b/lib/iowatch.h index a578e05..12abb1f 100644 --- a/lib/iowatch.h +++ b/lib/iowatch.h @@ -1,8 +1,6 @@ #ifndef _iowatch_h #define _iowatch_h -#include "bool.h" - /** * A simple wrapper for select() * diff --git a/lib/plpdirent.h b/lib/plpdirent.h new file mode 100644 index 0000000..f29cc74 --- /dev/null +++ b/lib/plpdirent.h @@ -0,0 +1,110 @@ +#ifndef _PLP_DIRENT_H_ +#define _PLP_DIRENT_H_ + +#include <string> +#include <psitime.h> +#include <rfsv.h> + +/** + * A class, representing a directory entry of the Psion. + * Objects of this type are used by @ref rfsv::readdir and + * @ref rfsv::dir for returning the entries of a directory. + */ +class PlpDirent { + friend class rfsv32; + friend class rfsv16; + +public: + /** + * Default constructor + */ + PlpDirent() : size(0), attr(0), name(""), time(0L), attrstr("") { }; + + /** + * A copy constructor. + * Mainly used by STL container classes. + * + * @param d The object to be used as initializer. + */ + PlpDirent(const PlpDirent &d); + + /** + * Default destructor. + */ + ~PlpDirent() {}; + + /** + * Retrieves the file size of a directory entry. + * + * @returns The file size in bytes. + */ + long getSize(); + + /** + * Retrieves the file attributes of a directory entry. + * + * @returns The generic attributes ( @ref rfsv:file_attribs ). + */ + long getAttr(); + + /** + * Retrieves the UIDs of a directory entry. + * This method returns always 0 with a Series3. + * + * @param uididx The index of the UID to retrieve (0 .. 2). + * + * @returns The selected UID or 0 if the index is out of range. + */ + long getUID(int uididx); + + /** + * Retrieve the file name of a directory entry. + * + * @returns The name of the file. + */ + const char *getName(); + + /** + * Retrieve the modification time of a directory entry. + * + * @returns A @ref PsiTime object, representing the time. + */ + PsiTime getPsiTime(); + + /** + * Set the file name of a directory entry. + * This is currently used in plpbackup only for + * changing the name to the full path. It does NOT + * change the name of the corresponding file on + * the Psion. + * + * @param str The new name of the file. + */ + void setName(const char *str); + + /** + * Assignment opreator + * Mainly used by STL container classes. + * + * @param e The new value to assign. + * + * @returns The modified object. + */ + PlpDirent &operator=(const PlpDirent &e); + + /** + * Prints the object contents. + * The output is in human readable similar to the + * output of a "ls" command. + */ + friend ostream &operator<<(ostream &o, const PlpDirent &e); + +private: + long size; + long attr; + long uid[3]; + PsiTime time; + string attrstr; + string name; +}; +#endif diff --git a/lib/ppsocket.cc b/lib/ppsocket.cc index 2140cf8..cfaa429 100644 --- a/lib/ppsocket.cc +++ b/lib/ppsocket.cc @@ -35,7 +35,6 @@ #include <netinet/in.h> #include <arpa/inet.h> -#include "bool.h" #include "bufferstore.h" #include "ppsocket.h" diff --git a/lib/ppsocket.h b/lib/ppsocket.h index 3cd288a..f36344c 100644 --- a/lib/ppsocket.h +++ b/lib/ppsocket.h @@ -26,7 +26,6 @@ extern int errno; -#include "bool.h" class bufferStore; class ppsocket diff --git a/lib/psitime.cc b/lib/psitime.cc index 11e16e0..bb4ea78 100644 --- a/lib/psitime.cc +++ b/lib/psitime.cc @@ -43,6 +43,14 @@ PsiTime::PsiTime(struct timeval *_utv = 0L, struct timezone *_utz = 0L) { unix2psi(); } +PsiTime::PsiTime(const PsiTime &t) { + utv = t.utv; + utz = t.utz; + ptv = t.ptv; + ptz = t.ptz; + ptzValid = t.ptzValid; +} + PsiTime::~PsiTime() { } @@ -104,6 +112,15 @@ const unsigned long PsiTime::getPsiTimeHi(void) { return ptv.tv_high; } +PsiTime &PsiTime::operator=(const PsiTime &t) { + utv = t.utv; + utz = t.utz; + ptv = t.ptv; + ptz = t.ptz; + ptzValid = t.ptzValid; + return *this; +} + ostream &operator<<(ostream &s, const PsiTime &t) { const char *fmt = "%c"; char buf[100]; diff --git a/lib/psitime.h b/lib/psitime.h index 9755473..7072711 100644 --- a/lib/psitime.h +++ b/lib/psitime.h @@ -133,6 +133,11 @@ public: PsiTime(void); /** + * A copy-constructor + */ + PsiTime(const PsiTime &t); + + /** * Destroys the instance. */ ~PsiTime(); @@ -231,6 +236,11 @@ public: */ friend ostream &operator<<(ostream &s, const PsiTime &t); + /** + * Assignment operator + */ + PsiTime &operator=(const PsiTime &t); + enum zone { PSI_TZ_NONE = 0, PSI_TZ_EUROPEAN = 1, @@ -1,12 +1,14 @@ #ifndef _rfsv_h_ #define _rfsv_h_ +#include <deque> #include "Enum.h" -#include "psitime.h" +#include "plpdirent.h" #include "bufferstore.h" +typedef deque<class PlpDirent> PlpDir; + class ppsocket; -class bufferArray; const long RFSV_SENDLEN = 2000; @@ -190,8 +192,8 @@ class rfsv { * @param attr The open mode. Use @ref opMode to convert a combination of @ref open_flags * and @ref open_mode to the machine-specific representation. * @param name The name of the file to open. - * @param handle The handle for usage with @ref fread, - * @ref frwrite, @ref fseek @ref fclose is returned here. + * @param handle The handle for usage with @ref fread , + * @ref frwrite , @ref fseek or @ref fclose is returned here. * * @returns A Psion error code (One of enum @ref #errs ). */ @@ -201,8 +203,8 @@ class rfsv { * Creates a unique temporary file. * The file is opened for reading and writing. * - * @param handle The handle for usage with @ref fread, - * @ref frwrite, @ref fseek @ref fclose is returned here. + * @param handle The handle for usage with @ref fread , + * @ref frwrite , @ref fseek or @ref fclose is returned here. * @param name The name of the temporary file is returned here. * * @returns A Psion error code (One of enum @ref #errs ). @@ -215,8 +217,8 @@ class rfsv { * @param attr The open mode. Use @ref opMode to convert a combination of @ref open_flags * and @ref open_mode to the machine-specific representation. * @param name The name of the file to create. - * @param handle The handle for usage with @ref fread, - * @ref frwrite, @ref fseek @ref fclose is returned here. + * @param handle The handle for usage with @ref fread , + * @ref frwrite , @ref fseek or @ref fclose is returned here. * * @returns A Psion error code (One of enum @ref #errs ). */ @@ -228,8 +230,8 @@ class rfsv { * @param attr The open mode. Use @ref opMode to convert a combination of @ref open_flags * and @ref open_mode to the machine-specific representation. * @param name The name of the file to create. - * @param handle The handle for usage with @ref fread, - * @ref frwrite, @ref fseek @ref fclose is returned here. + * @param handle The handle for usage with @ref fread , + * @ref frwrite , @ref fseek or @ref fclose is returned here. * * @returns A Psion error code (One of enum @ref #errs ). */ @@ -237,7 +239,7 @@ class rfsv { /** * Close a file on the Psion whih was previously opened/created by using - * @ref fopen, @ref fcreatefile, @ref freplacefile or @ref mktemp. + * @ref fopen , @ref fcreatefile , @ref freplacefile or @ref mktemp . * * @param handle A valid file handle. */ @@ -247,14 +249,14 @@ class rfsv { * Reads a directory on the Psion. * The returned array of @ref bufferArray contains one @ref bufferStore element * for each directory entry. For a description of the layout of the elements - * in each directory entry, see @ref readdir. + * in each directory entry, see @ref readdir . * * @param name The name of the directory - * @param ret Array of @ref bufferStore containing information for directory entries. + * @param ret An STL deque of @ref PlpDirent entries. * * @returns A Psion error code (One of enum @ref #errs ). */ - virtual Enum<errs> dir(const char * const name, bufferArray &ret) = 0; + virtual Enum<errs> dir(const char * const name, PlpDir &ret) = 0; /** * Retrieves the modification time of a file on the Psion. @@ -473,9 +475,9 @@ class rfsv { * Open a directory for reading with readdir. * * @param attr A combination of PSI_A_.. flags, representing the desired types - * of entries to be returned when calling @ref readdir. + * of entries to be returned when calling @ref readdir . * @param name The name of the directory - * @param handle A handle to be used with @ref readdir and @ref closedir. + * @param handle A handle to be used with @ref readdir and @ref closedir . * * @returns A Psion error code (One of enum @ref #errs ). */ @@ -484,23 +486,14 @@ class rfsv { /** * Read directory entries. * This method reads entries of a directory, previously - * opened with @ref opendir. + * opened with @ref opendir . * - * The entry is returned in the buff parameter as follows: - * <pre> - * offset size value - * 0 4 Pointer to a PsiTime object, representing the file's modification. - * 4 4 Size in bytes. - * 8 4 Attributes. - * 12 ? Zero terminated file name. - * </pre> - * - * @param handle A handle, obtained by calling @see opendir. - * @param buff The entry information is returned here. + * @param handle A handle, obtained by calling @ref opendir . + * @param entry The entry information is returned here. * * @returns A Psion error code (One of enum @ref #errs ). */ - virtual Enum<errs> readdir(rfsvDirhandle &handle, bufferStore &buff) = 0; + virtual Enum<errs> readdir(rfsvDirhandle &handle, PlpDirent &entry) = 0; /** * Close a directory, previously opened with @ref opendir. diff --git a/lib/rfsv16.cc b/lib/rfsv16.cc index fdec2e7..26a153b 100644 --- a/lib/rfsv16.cc +++ b/lib/rfsv16.cc @@ -34,7 +34,6 @@ #include <time.h> #include <string> -#include "bool.h" #include "rfsv16.h" #include "bufferstore.h" #include "ppsocket.h" @@ -181,7 +180,7 @@ closedir(rfsvDirhandle &dH) { } Enum<rfsv::errs> rfsv16:: -readdir(rfsvDirhandle &dH, bufferStore &s) { +readdir(rfsvDirhandle &dH, PlpDirent &e) { Enum<rfsv::errs> res = E_PSI_GEN_NONE; if (dH.b.getLen() < 17) { @@ -198,32 +197,30 @@ readdir(rfsvDirhandle &dH, bufferStore &s) { cerr << "dir: not version 2" << endl; return E_PSI_GEN_FAIL; } - long attr = attr2std((long)dH.b.getWord(2)); - long size = dH.b.getDWord(4); - PsiTime *date = new PsiTime((time_t)dH.b.getDWord(8)); - const char *name = dH.b.getString(16); - - dH.b.discardFirstBytes(17+strlen(name)); - - s.init(); - s.addDWord((unsigned long)date); - s.addDWord(size); - s.addDWord(attr); - s.addStringT(name); + e.attr = attr2std((long)dH.b.getWord(2)); + e.size = dH.b.getDWord(4); + e.time = PsiTime((time_t)dH.b.getDWord(8)); + e.name = dH.b.getString(16); + e.uid[0] = e.uid[1] = e.uid[2] = 0; + e.attrstr = attr2String(e.attr); + + dH.b.discardFirstBytes(17 + e.name.length()); + } return res; } Enum<rfsv::errs> rfsv16:: -dir(const char *name, bufferArray &files) +dir(const char *name, PlpDir &files) { rfsvDirhandle h; + files.clear(); Enum<rfsv::errs> res = opendir(PSI_A_HIDDEN | PSI_A_SYSTEM | PSI_A_DIR, name, h); while (res == E_PSI_GEN_NONE) { - bufferStore b; - res = readdir(h, b); + PlpDirent e; + res = readdir(h, e); if (res == E_PSI_GEN_NONE) - files += b; + files.push_back(e); } closedir(h); if (res == E_PSI_FILE_EOF) diff --git a/lib/rfsv16.h b/lib/rfsv16.h index 852d816..d0eda32 100644 --- a/lib/rfsv16.h +++ b/lib/rfsv16.h @@ -12,7 +12,7 @@ public: Enum<rfsv::errs> fcreatefile(const long, const char * const, long &); Enum<rfsv::errs> freplacefile(const long, const char * const, long &); Enum<rfsv::errs> fclose(const long); - Enum<rfsv::errs> dir(const char * const, bufferArray &); + Enum<rfsv::errs> dir(const char * const, PlpDir &); Enum<rfsv::errs> fgetmtime(const char * const, PsiTime &); Enum<rfsv::errs> fsetmtime(const char * const, const PsiTime); Enum<rfsv::errs> fgetattr(const char * const, long &); @@ -33,7 +33,7 @@ public: Enum<rfsv::errs> rename(const char * const, const char * const); Enum<rfsv::errs> remove(const char * const); Enum<rfsv::errs> opendir(const long, const char * const, rfsvDirhandle &); - Enum<rfsv::errs> readdir(rfsvDirhandle &, bufferStore &); + Enum<rfsv::errs> readdir(rfsvDirhandle &, PlpDirent &); Enum<rfsv::errs> closedir(rfsvDirhandle &); Enum<rfsv::errs> setVolumeName(const char, const char * const); diff --git a/lib/rfsv32.cc b/lib/rfsv32.cc index 5a23c08..8808879 100644 --- a/lib/rfsv32.cc +++ b/lib/rfsv32.cc @@ -25,16 +25,16 @@ #include <stream.h> #include <stdlib.h> -#include <fstream.h> -#include <iomanip.h> +#include <fstream> +#include <iomanip> #include <time.h> -#include <string.h> +#include <string> -#include "bool.h" #include "rfsv32.h" #include "bufferstore.h" #include "ppsocket.h" #include "bufferarray.h" +#include "plpdirent.h" rfsv32::rfsv32(ppsocket * _skt) { @@ -126,7 +126,7 @@ fopendir(const long attr, const char * const name, long &handle) { bufferStore a; char *n = convertSlash(name); - a.addDWord(attr); + a.addDWord(attr | EPOC_ATTR_GETUID); a.addWord(strlen(n)); a.addString(n); free(n); @@ -163,7 +163,7 @@ closedir(rfsvDirhandle &dH) { } Enum<rfsv::errs> rfsv32:: -readdir(rfsvDirhandle &dH, bufferStore &s) { +readdir(rfsvDirhandle &dH, PlpDirent &e) { Enum<rfsv::errs> res = E_PSI_GEN_NONE; if (dH.b.getLen() < 17) { @@ -174,23 +174,21 @@ readdir(rfsvDirhandle &dH, bufferStore &s) { res = getResponse(dH.b); } if ((res == E_PSI_GEN_NONE) && (dH.b.getLen() > 16)) { - long shortLen = dH.b.getDWord(0); - long attributes = attr2std(dH.b.getDWord(4)); - long size = dH.b.getDWord(8); - // long uid1 = dH.b.getDWord(20); - // long uid2 = dH.b.getDWord(24); - // long uid3 = dH.b.getDWord(28); - long longLen = dH.b.getDWord(32); - PsiTime *date = new PsiTime(dH.b.getDWord(16), dH.b.getDWord(12)); - - s.init(); - s.addDWord((unsigned long)date); - s.addDWord(size); - s.addDWord(attributes); + long shortLen = dH.b.getDWord(0); + long longLen = dH.b.getDWord(32); + + e.attr = attr2std(dH.b.getDWord(4)); + e.size = dH.b.getDWord(8); + e.uid[0] = dH.b.getDWord(20); + e.uid[1] = dH.b.getDWord(24); + e.uid[2] = dH.b.getDWord(28); + e.time = PsiTime(dH.b.getDWord(16), dH.b.getDWord(12)); + e.name = ""; + e.attrstr = string(attr2String(e.attr)); + int d = 36; for (int i = 0; i < longLen; i++, d++) - s.addByte(dH.b.getByte(d)); - s.addByte(0); + e.name += dH.b.getByte(d); while (d % 4) d++; d += shortLen; @@ -202,70 +200,21 @@ readdir(rfsvDirhandle &dH, bufferStore &s) { } Enum<rfsv::errs> rfsv32:: -dir(const char *name, bufferArray &files) +dir(const char *name, PlpDir &files) { rfsvDirhandle h; + files.clear(); Enum<rfsv::errs> res = opendir(PSI_A_HIDDEN | PSI_A_SYSTEM | PSI_A_DIR, name, h); while (res == E_PSI_GEN_NONE) { - bufferStore b; - res = readdir(h, b); + PlpDirent e; + res = readdir(h, e); if (res == E_PSI_GEN_NONE) - files += b; + files.push_back(e); } closedir(h); if (res == E_PSI_FILE_EOF) res = E_PSI_GEN_NONE; return res; -#if 0 - long handle; - Enum<rfsv::errs> res = fopendir(EPOC_ATTR_HIDDEN | EPOC_ATTR_SYSTEM | EPOC_ATTR_DIRECTORY, name, handle); - if (res != E_PSI_GEN_NONE) - return res; - - while (1) { - bufferStore a; - a.addDWord(handle); - if (!sendCommand(READ_DIR, a)) - return E_PSI_FILE_DISC; - res = getResponse(a); - if (res != E_PSI_GEN_NONE) - break; - while (a.getLen() > 16) { - long shortLen = a.getDWord(0); - long attributes = attr2std(a.getDWord(4)); - long size = a.getDWord(8); - //unsigned long modLow = a.getDWord(12); - //unsigned long modHi = a.getDWord(16); - // long uid1 = a.getDWord(20); - // long uid2 = a.getDWord(24); - // long uid3 = a.getDWord(28); - long longLen = a.getDWord(32); - - //long date = micro2time(modHi, modLow); - PsiTime *date = new PsiTime(a.getDWord(16), a.getDWord(12)); - - bufferStore s; - s.addDWord((unsigned long)date); - s.addDWord(size); - s.addDWord(attributes); - int d = 36; - for (int i = 0; i < longLen; i++, d++) - s.addByte(a.getByte(d)); - s.addByte(0); - while (d % 4) - d++; - files += s; - d += shortLen; - while (d % 4) - d++; - a.discardFirstBytes(d); - } - } - if (res == E_PSI_FILE_EOF) - res = E_PSI_GEN_NONE; - fclose(handle); - return res; -#endif } long rfsv32:: diff --git a/lib/rfsv32.h b/lib/rfsv32.h index fb4c624..2ef584b 100644 --- a/lib/rfsv32.h +++ b/lib/rfsv32.h @@ -2,13 +2,14 @@ #define _rfsv32_h_ #include "rfsv.h" +#include "plpdirent.h" class rfsv32 : public rfsv { public: rfsv32(ppsocket *); - Enum<rfsv::errs> dir(const char * const, bufferArray &); + Enum<rfsv::errs> dir(const char * const, PlpDir &); Enum<rfsv::errs> dircount(const char * const, long &); Enum<rfsv::errs> copyFromPsion(const char * const, const char * const, void *, cpCallback_t); Enum<rfsv::errs> copyToPsion(const char * const, const char * const, void *, cpCallback_t); @@ -35,7 +36,7 @@ public: Enum<rfsv::errs> devlist(long &); Enum<rfsv::errs> devinfo(const int, long &, long &, long &, long &, char * const); Enum<rfsv::errs> opendir(const long, const char * const, rfsvDirhandle &); - Enum<rfsv::errs> readdir(rfsvDirhandle &, bufferStore &); + Enum<rfsv::errs> readdir(rfsvDirhandle &, PlpDirent &); Enum<rfsv::errs> closedir(rfsvDirhandle &); Enum<rfsv::errs> setVolumeName(const char, const char * const); long opMode(const long); @@ -52,7 +53,8 @@ private: EPOC_ATTR_NORMAL = 0x0080, EPOC_ATTR_TEMPORARY = 0x0100, EPOC_ATTR_COMPRESSED = 0x0800, - EPOC_ATTR_MASK = 0x09f7 /* All of the above */ + EPOC_ATTR_MASK = 0x09f7, /* All of the above */ + EPOC_ATTR_GETUID = 0x10000000 /* Deliver UIDs on dir listing */ }; enum open_mode { diff --git a/lib/rfsvfactory.cc b/lib/rfsvfactory.cc index a0d8480..12bd623 100644 --- a/lib/rfsvfactory.cc +++ b/lib/rfsvfactory.cc @@ -29,7 +29,6 @@ #include <time.h> #include <string.h> -#include "bool.h" #include "rfsv.h" #include "rfsv16.h" #include "rfsv32.h" diff --git a/lib/rpcs.cc b/lib/rpcs.cc index d93fad0..837f235 100644 --- a/lib/rpcs.cc +++ b/lib/rpcs.cc @@ -25,7 +25,6 @@ #include <time.h> #include <string.h> -#include "bool.h" #include "rpcs.h" #include "bufferstore.h" #include "ppsocket.h" diff --git a/lib/rpcs16.cc b/lib/rpcs16.cc index 6e196fc..0a3121b 100644 --- a/lib/rpcs16.cc +++ b/lib/rpcs16.cc @@ -25,7 +25,6 @@ #include <time.h> #include <string.h> -#include "bool.h" #include "rpcs16.h" #include "bufferstore.h" #include "ppsocket.h" diff --git a/lib/rpcs32.cc b/lib/rpcs32.cc index 2175ef0..7a7982f 100644 --- a/lib/rpcs32.cc +++ b/lib/rpcs32.cc @@ -26,7 +26,6 @@ #include <time.h> #include <string.h> -#include "bool.h" #include "rpcs32.h" #include "bufferstore.h" #include "bufferarray.h" diff --git a/lib/rpcsfactory.cc b/lib/rpcsfactory.cc index 869c6c5..091f12a 100644 --- a/lib/rpcsfactory.cc +++ b/lib/rpcsfactory.cc @@ -30,7 +30,6 @@ #include <time.h> #include <string.h> -#include "bool.h" #include "rpcs16.h" #include "rpcs32.h" #include "rpcsfactory.h" diff --git a/ncpd/channel.cc b/ncpd/channel.cc index f52cea1..d708cd9 100644 --- a/ncpd/channel.cc +++ b/ncpd/channel.cc @@ -23,9 +23,11 @@ // e-mail philip.proudman@btinternet.com +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif #include <stream.h> -#include "bool.h" #include "channel.h" #include "ncp.h" diff --git a/ncpd/channel.h b/ncpd/channel.h index 2c06d6d..90f08f6 100644 --- a/ncpd/channel.h +++ b/ncpd/channel.h @@ -25,10 +25,11 @@ #ifndef _channel_h_ #define _channel_h_ +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif #include <stdio.h> -#include "bool.h" - class ncp; class bufferStore; diff --git a/ncpd/link.cc b/ncpd/link.cc index f4f73e4..90a7451 100644 --- a/ncpd/link.cc +++ b/ncpd/link.cc @@ -30,7 +30,6 @@ #include <stdlib.h> #include <stdio.h> -#include "bool.h" #include "link.h" #include "packet.h" #include "bufferstore.h" diff --git a/ncpd/link.h b/ncpd/link.h index 23e2ac5..010100b 100644 --- a/ncpd/link.h +++ b/ncpd/link.h @@ -25,7 +25,9 @@ #ifndef _link_h_ #define _link_h_ -#include "bool.h" +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif #include "bufferstore.h" #include "bufferarray.h" diff --git a/ncpd/ncp.cc b/ncpd/ncp.cc index 1fbd533..8af83d8 100644 --- a/ncpd/ncp.cc +++ b/ncpd/ncp.cc @@ -23,14 +23,13 @@ // e-mail philip.proudman@btinternet.com #ifdef HAVE_CONFIG_H -#include "config.h" +#include <config.h> #endif #include <stream.h> #include <string.h> #include <time.h> -#include "bool.h" #include "ncp.h" #include "linkchan.h" #include "bufferstore.h" @@ -25,7 +25,9 @@ #ifndef _ncp_h_ #define _ncp_h_ -#include "bool.h" +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif #include "bufferstore.h" #include "linkchan.h" class link; diff --git a/ncpd/packet.cc b/ncpd/packet.cc index 5c05849..ebefc0a 100644 --- a/ncpd/packet.cc +++ b/ncpd/packet.cc @@ -23,6 +23,10 @@ // e-mail philip.proudman@btinternet.com +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + #include <stdio.h> #include <malloc.h> #include <unistd.h> @@ -38,7 +42,6 @@ extern "C" { #include "mp_serial.h" } -#include "bool.h" #include "bufferstore.h" #include "packet.h" #include "iowatch.h" diff --git a/ncpd/packet.h b/ncpd/packet.h index 86db078..afab41d 100644 --- a/ncpd/packet.h +++ b/ncpd/packet.h @@ -25,10 +25,11 @@ #ifndef _packet_h #define _packet_h +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif #include <stdio.h> -#include "bool.h" -class psiEmul; class bufferStore; class IOWatch; diff --git a/ncpd/socketchan.cc b/ncpd/socketchan.cc index a7d612e..1e3fd08 100644 --- a/ncpd/socketchan.cc +++ b/ncpd/socketchan.cc @@ -22,12 +22,14 @@ // // e-mail philip.proudman@btinternet.com +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif #include <stream.h> #include "stdio.h" #include "string.h" #include "malloc.h" -#include "bool.h" #include "socketchan.h" #include "ncp.h" #include "ppsocket.h" diff --git a/ncpd/socketchan.h b/ncpd/socketchan.h index 5fe7a13..15645dd 100644 --- a/ncpd/socketchan.h +++ b/ncpd/socketchan.h @@ -25,7 +25,9 @@ #ifndef _socketchan_h_ #define _socketchan_h_ -#include "bool.h" +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif #include "channel.h" class ppsocket; class IOWatch; diff --git a/plpbackup/plpbackup.cc b/plpbackup/plpbackup.cc index ebc77e5..8735ea3 100644 --- a/plpbackup/plpbackup.cc +++ b/plpbackup/plpbackup.cc @@ -20,7 +20,7 @@ // #ifdef HAVE_CONFIG_H -#include "config.h" +#include <config.h> #endif #include <sys/types.h> @@ -36,8 +36,8 @@ #include <sys/stat.h> #include <errno.h> #include <pwd.h> +#include <getopt.h> -#include "bool.h" #include "ppsocket.h" #include "rfsv.h" #include "rfsvfactory.h" @@ -50,20 +50,24 @@ void usage(ostream *hlp) { - *hlp << "Usage : plpbackup [-p <port>] [-v] [-f] [drive1:] [drive2:] ..." << endl; - *hlp << endl; - *hlp << " Options:" << endl; - *hlp << " -h Print this message and exit." << endl; - *hlp << " -V Print version and exit." << endl; - *hlp << " -p <port> Connect to ncpd using given port." << endl; - *hlp << " -v Increase verbosity." << endl; - *hlp << " -f Do a full backup. (Incremental otherwise)" << endl; - *hlp << " <drive> A drive character. If none given, scan all drives" << endl; + *hlp + << "Usage: plpbackup OPTIONS [<drive>:] [<drive>:] ..." << endl + << endl + << " Options:" << endl + << " -h, --help Print this message and exit." << endl + << " -V, --version Print version and exit." << endl + << " -p, --port=<port> Connect to ncpd using given port." << endl + << " -v, --verbose Increase verbosity." << endl + << " -q, --quiet Decrease verbosity." << endl + << " -f, --full Do a full backup (incremental otherwise)." << endl + << endl + << " <drive> A drive character. If none given, scan all drives." << endl + << endl; } bool full; int verbose = 0; -bufferArray toBackup; +PlpDir toBackup; unsigned long backupSize = 0; unsigned long totalBytes = 0; unsigned long fileSize = 0; @@ -183,7 +187,7 @@ runrestore(rfsv *a, rpcs *r) { static void collectFiles(rfsv *a, char *dir) { Enum<rfsv::errs> res; - bufferArray files; + PlpDir files; char tmp[1024]; strcpy(tmp, dir); @@ -191,22 +195,20 @@ collectFiles(rfsv *a, char *dir) { if ((res = a->dir(tmp, files)) != rfsv::E_PSI_GEN_NONE) cerr << "Error: " << res << endl; else - while (!files.empty()) { - bufferStore s; + for (int i = 0; i < files.size(); i++) { + PlpDirent e = files[i]; - s = files.pop(); - long size = s.getDWord(4); - long attr = s.getDWord(8); + // long size = s.getDWord(4); + long attr = e.getAttr(); strcpy(tmp, dir); strcat(tmp, "\\"); - strcat(tmp, s.getString(12)); + strcat(tmp, e.getName()); if (attr & rfsv::PSI_A_DIR) { collectFiles(a, tmp); } else { if ((attr & rfsv::PSI_A_ARCHIVE) || full) { - s.truncate(12); - s.addStringT(tmp); - toBackup += s; + e.setName(tmp); + toBackup.push_back(e); } } } @@ -220,14 +222,15 @@ reportProgress(void *, long size) char bstr[10]; switch (verbose) { - case 0: - return 1; - case 1: - percent = (totalBytes + size) * 100 / backupSize; - break; - case 2: - percent = size * 100 / fileSize; - break; + case -1: + case 0: + return 1; + case 1: + percent = (totalBytes + size) * 100 / backupSize; + break; + case 2: + percent = size * 100 / fileSize; + break; } sprintf(pstr, " %3d%%", percent); memset(bstr, 8, sizeof(bstr)); @@ -245,7 +248,7 @@ mkdirp(char *path) { *p = '\0'; switch (mkdir(path, S_IRWXU|S_IRWXG)) { struct stat stbuf; - + case 0: break; default: @@ -266,6 +269,16 @@ mkdirp(char *path) { return 0; } +static struct option opts[] = { + { "full", no_argument, 0, 'f' }, + { "help", no_argument, 0, 'h' }, + { "port", required_argument, 0, 'V' }, + { "verbose", no_argument, 0, 'v' }, + { "quiet", no_argument, 0, 'q' }, + { "version", no_argument, 0, 'V' }, + { 0, 0, 0, 0 }, +}; + int main(int argc, char **argv) { @@ -276,6 +289,7 @@ main(int argc, char **argv) cpCallback_t cab = reportProgress; int status = 0; int sockNum = DPORT; + int op; char dstPath[1024]; struct passwd *pw; sigset_t sigset; @@ -287,42 +301,44 @@ main(int argc, char **argv) struct servent *se = getservbyname("psion", "tcp"); endservent(); if (se != 0L) - sockNum = ntohs(se->s_port); + sockNum = ntohs(se->s_port); // Command line parameter processing - bool parmFound; - do { - parmFound = false; - if ((argc > 1) && !strcmp(argv[1], "-V")) { - cout << "plpbackup version " << VERSION << endl; - exit(0); - } - if ((argc > 1) && !strcmp(argv[1], "-h")) { - usage(&cout); - exit(0); - } - if ((argc > 2) && !strcmp(argv[1], "-p")) { - sockNum = atoi(argv[2]); - argc -= 2; - parmFound = true; - for (int i = 1; i < argc; i++) - argv[i] = argv[i + 2]; - } - if ((argc > 1) && !strcmp(argv[1], "-v")) { - verbose++; - argc -= 1; - parmFound = true; - for (int i = 1; i < argc; i++) - argv[i] = argv[i + 1]; + opterr = 1; + while ((op = getopt_long(argc, argv, "qfhp:vV", opts, NULL)) != EOF) { + switch (op) { + case 'V': + cout << "plpbackup version " << VERSION << endl; + exit(0); + case 'h': + usage(&cout); + exit(0); + case 'f': + full = true; + break; + case 'v': + verbose++; + break; + case 'q': + verbose--; + break; + case 'p': + sockNum = atoi(optarg); + break; + default: + usage(&cerr); + exit(1); } - if ((argc > 1) && !strcmp(argv[1], "-f")) { - full = true; - argc -= 1; - parmFound = true; - for (int i = 1; i < argc; i++) - argv[i] = argv[i + 1]; + } + for (int i = optind; i < argc; i++) { + if ((strlen(argv[i]) != 2) || + (toupper(argv[i][0]) < 'A') || + (toupper(argv[i][0]) > 'Z') || + (argv[i][1] != ':')) { + usage(&cerr); + exit(1); } - } while (parmFound); + } pw = getpwuid(getuid()); if (pw && pw->pw_dir && strlen(pw->pw_dir)) { @@ -368,20 +384,33 @@ main(int argc, char **argv) S5mx = true; } } - if (verbose) { - cout << "Performing " << (full ? "Full" : "Incremental") << - " backup to " << dstPath << endl; + if (verbose >= 0) { + cout << "Performing " << (full ? "full" : "incremental") << + " backup of "; + if (optind < argc) { + cout << "Drive "; + for (i = optind; i < argc; ) { + cout << argv[i++]; + if (i > optind) { + if (i < (argc - 1)) + cout << ", "; + else + if (i < argc) + cout << " and "; + } + } + } else + cout << "all drives"; + + cout << " to " << dstPath << endl; + } + if (verbose > 0) { cout << "Stopping programs ..." << endl; } killsave(r, S5mx); - if (argc > 1) { - for (i = 1; i < argc; i++) { - if ((strlen(argv[i]) != 2) || (argv[i][1] != ':')) { - usage(&cerr); - exit(1); - runrestore(a, r); - } - if (verbose) + if (optind < argc) { + for (i = optind; i < argc; i++) { + if (verbose > 0) cout << "Scanning Drive " << argv[i] << " ..." << endl; collectFiles(a, argv[i]); } @@ -395,7 +424,7 @@ main(int argc, char **argv) if ((devbits & 1) && a->devinfo(i, vfree, vtotal, vattr, vuniqueid, NULL) == rfsv::E_PSI_GEN_NONE) { if (vattr != 7) { sprintf(drive, "%c:\0", 'A' + i); - if (verbose) + if (verbose > 0) cout << "Scanning Drive " << drive << " ..." << endl; collectFiles(a, drive); } @@ -405,46 +434,45 @@ main(int argc, char **argv) } else cerr << "Couldn't get Drive list" << endl; } - for (i = 0; i < toBackup.length(); i++) { - bufferStore s = toBackup[i]; - backupSize += s.getDWord(4); + for (i = 0; i < toBackup.size(); i++) { + backupSize += toBackup[i].getSize(); backupCount++; } - if (verbose) + if (verbose > 0) cout << "Size of backup: " << backupSize << " bytes in " << backupCount << " files." << endl; if (backupCount == 0) cerr << "Nothing to backup" << endl; else { - for (i = 0; i < toBackup.length(); i++) { - bufferStore s = toBackup[i]; - const char *fn = s.getString(12); + for (i = 0; i < toBackup.size(); i++) { + PlpDirent e = toBackup[i]; + const char *fn = e.getName(); const char *p; char *q; char tmp[1024]; for (p = fn, q = tmp; *p; p++, q++) switch (*p) { - case '%': - *q++ = '%'; - *q++ = '2'; - *q = '5'; - break; - case '/': - *q++ = '%'; - *q++ = '2'; - *q= 'f'; - break; - case '\\': - *q = '/'; - break; - default: - *q = *p; + case '%': + *q++ = '%'; + *q++ = '2'; + *q = '5'; + break; + case '/': + *q++ = '%'; + *q++ = '2'; + *q= 'f'; + break; + case '\\': + *q = '/'; + break; + default: + *q = *p; } *q = '\0'; strcpy(dest, dstPath); strcat(dest, tmp); - fileSize = s.getDWord(4); + fileSize = e.getSize(); if (verbose > 1) cout << "Backing up " << fn << flush; if (mkdirp(dest) != 0) { @@ -463,30 +491,29 @@ main(int argc, char **argv) } } if (!bErr) { - if (verbose) + if (verbose > 0) cout << "Writing index ..." << endl; strcpy(dest, dstPath); strcat(dest, ".index"); ofstream op(dest); if (op) { - op << "#plpbackup index" << endl; - for (i = 0; i < toBackup.length(); i++) { - bufferStore s = toBackup[i]; - PsiTime *t = (PsiTime *)s.getDWord(0); - long size = s.getDWord(4); - long attr = s.getDWord(8); - const char *fn = s.getString(12); - attr &= ~rfsv::PSI_A_ARCHIVE; + op << "#plpbackup index " << + (full ? "F" : "I") << endl; + for (i = 0; i < toBackup.size(); i++) { + PlpDirent e = toBackup[i]; + PsiTime t = e.getPsiTime(); + long attr = e.getAttr() & + ~rfsv::PSI_A_ARCHIVE; op << hex << setw(8) << setfill('0') << - t->getPsiTimeHi() << " " + t.getPsiTimeHi() << " " << setw(8) << setfill('0') << - t->getPsiTimeLo() << " " + t.getPsiTimeLo() << " " << setw(8) << setfill('0') << - size << " " + e.getSize() << " " << setw(8) << setfill('0') << attr << " " - << setw(0) << fn << endl; + << setw(0) << e.getName() << endl; } op.close(); } else { @@ -495,26 +522,24 @@ main(int argc, char **argv) } } if (!bErr) { - if (verbose) + if (verbose > 0) cout << "Resetting archive attributes ..." << endl; - for (i = 0; i < toBackup.length(); i++) { - bufferStore s = toBackup[i]; - long attr = s.getDWord(8); - const char *fn = s.getString(12); - if (attr & rfsv::PSI_A_ARCHIVE) { - res = a->fsetattr(fn, 0, - rfsv::PSI_A_ARCHIVE); - if (res != rfsv::E_PSI_GEN_NONE) { - bErr = true; - break; - } + for (i = 0; i < toBackup.size(); i++) { + PlpDirent e = toBackup[i]; + if (e.getAttr() & rfsv::PSI_A_ARCHIVE) { + res = a->fsetattr(e.getName(), 0, + rfsv::PSI_A_ARCHIVE); + if (res != rfsv::E_PSI_GEN_NONE) { + bErr = true; + break; } } + } } } if (bErr) cerr << "Backup aborted due to error" << endl; - if (verbose) + if (verbose > 0) cout << "Restarting programs ..." << endl; runrestore(a, r); delete r; diff --git a/plpftp/ftp.cc b/plpftp/ftp.cc index 5041322..837f668 100644 --- a/plpftp/ftp.cc +++ b/plpftp/ftp.cc @@ -198,8 +198,6 @@ sigint_handler2(int i) { signal(SIGINT, sigint_handler2); } -const char *datefmt = "%c"; - int ftp:: session(rfsv & a, rpcs & r, int xargc, char **xargv) { @@ -441,19 +439,13 @@ session(rfsv & a, rpcs & r, int xargc, char **xargv) continue; } if (!strcmp(argv[0], "ls") || !strcmp(argv[0], "dir")) { - bufferArray files; + PlpDir files; if ((res = a.dir(psionDir, files)) != rfsv::E_PSI_GEN_NONE) cerr << "Error: " << res << endl; else while (!files.empty()) { - bufferStore s; - s = files.pop(); - PsiTime *date = (PsiTime *)s.getDWord(0); - long size = s.getDWord(4); - long attr = s.getDWord(8); - cout << a.attr2String(attr); - cout << " " << dec << setw(10) << setfill(' ') << size; - cout << " " << *date << " " << s.getString(12) << endl; + cout << files[0] << endl; + files.pop_front(); } continue; } @@ -553,23 +545,22 @@ session(rfsv & a, rpcs & r, int xargc, char **xargv) continue; } else if ((!strcmp(argv[0], "mget")) && (argc == 2)) { char *pattern = argv[1]; - bufferArray files; + PlpDir files; if ((res = a.dir(psionDir, files)) != rfsv::E_PSI_GEN_NONE) { cerr << "Error: " << res << endl; continue; } - while (!files.empty()) { - bufferStore s; - s = files.pop(); + for (int i = 0; i < files.size(); i++) { + PlpDirent e = files[i]; char temp[100]; - long attr = s.getDWord(8); + long attr = e.getAttr(); - if (attr & 0x10) + if (attr & (rfsv::PSI_A_DIR | rfsv::PSI_A_VOLUME)) continue; - if (!Wildmat(s.getString(12), pattern)) + if (!Wildmat(e.getName(), pattern)) continue; do { - cout << "Get \"" << s.getString(12) << "\" (y,n): "; + cout << "Get \"" << e.getName() << "\" (y,n): "; if (prompt) { cout.flush(); cin.getline(temp, 100); @@ -582,9 +573,9 @@ session(rfsv & a, rpcs & r, int xargc, char **xargv) } while (temp[1] != 0 || (temp[0] != 'y' && temp[0] != 'n')); if (temp[0] != 'n') { strcpy(f1, psionDir); - strcat(f1, s.getString(12)); + strcat(f1, e.getName()); strcpy(f2, localDir); - strcat(f2, s.getString(12)); + strcat(f2, e.getName()); if (temp[0] == 'l') { for (char *p = f2; *p; p++) *p = tolower(*p); @@ -1000,7 +991,7 @@ static char *remote_dir_commands[] = { "cd ", "rmdir ", NULL }; -static bufferArray *comp_files = NULL; +static PlpDir comp_files; static long maskAttr; static char tmpPath[1024]; static char cplPath[1024]; @@ -1015,29 +1006,25 @@ filename_generator(char *text, int state) char *p; Enum<rfsv::errs> res; len = strlen(text); - if (comp_files) - delete comp_files; - comp_files = new bufferArray(); strcpy(tmpPath, psionDir); strcat(tmpPath, cplPath); for (p = tmpPath; *p; p++) if (*p == '/') *p = '\\'; - if ((res = comp_a->dir(tmpPath, *comp_files)) != rfsv::E_PSI_GEN_NONE) { + if ((res = comp_a->dir(tmpPath, comp_files)) != rfsv::E_PSI_GEN_NONE) { cerr << "Error: " << res << endl; return NULL; } } - while (!comp_files->empty()) { - bufferStore s; + for (int i = 0; i < comp_files.size(); i++) { + PlpDirent e = comp_files[i]; + long attr = e.getAttr(); char *p; - s = comp_files->pop(); - long attr = s.getDWord(8); if ((attr & maskAttr) == 0) continue; strcpy(tmpPath, cplPath); - strcat(tmpPath, s.getString(12)); + strcat(tmpPath, e.getName()); for (p = tmpPath; *p; p++) if (*p == '\\') *p = '/'; diff --git a/plpftp/ftp.h b/plpftp/ftp.h index 86c3d42..e825752 100644 --- a/plpftp/ftp.h +++ b/plpftp/ftp.h @@ -25,7 +25,9 @@ #ifndef _ftp_h_ #define _ftp_h_ -#include "bool.h" +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif #include "rfsv.h" #include "Enum.h" diff --git a/plpftp/main.cc b/plpftp/main.cc index 2d5140a..1755f38 100644 --- a/plpftp/main.cc +++ b/plpftp/main.cc @@ -23,7 +23,7 @@ // e-mail philip.proudman@btinternet.com #ifdef HAVE_CONFIG_H -#include "config.h" +#include <config.h> #endif #include <stream.h> @@ -32,7 +32,6 @@ #include <stdio.h> #include <signal.h> -#include "bool.h" #include "ppsocket.h" #include "rfsv.h" #include "rfsvfactory.h" diff --git a/plpnfsd/main.cc b/plpnfsd/main.cc index 261dfd5..96c2be4 100644 --- a/plpnfsd/main.cc +++ b/plpnfsd/main.cc @@ -4,7 +4,7 @@ // #ifdef HAVE_CONFIG_H -#include "config.h" +#include <config.h> #endif #include <stream.h> @@ -14,7 +14,6 @@ #include <signal.h> #include <syslog.h> -#include "bool.h" #include "rfsv.h" #include "rpcs.h" #include "rfsvfactory.h" @@ -210,24 +209,24 @@ long rfsv_isalive() { } long rfsv_dir(const char *file, dentry **e) { - bufferArray entries; + PlpDir entries; dentry *tmp; long ret; if (!a) return -1; ret = a->dir(file, entries); - while (!entries.empty()) { - bufferStore s; - s = entries.pop(); + + for (int i = 0; i < entries.size(); i++) { + PlpDirent pe = entries[i]; tmp = *e; *e = (dentry *)malloc(sizeof(dentry)); if (!*e) return -1; - (*e)->time = ((PsiTime *)s.getDWord(0))->getTime(); - (*e)->size = s.getDWord(4); - (*e)->attr = s.getDWord(8); - (*e)->name = strdup(s.getString(12)); + (*e)->time = pe.getPsiTime().getTime(); + (*e)->size = pe.getSize(); + (*e)->attr = pe.getAttr(); + (*e)->name = strdup(pe.getName()); (*e)->next = tmp; } return ret; |