1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir /************************************************************************** 29*cdf0e10cSrcweir TODO 30*cdf0e10cSrcweir ************************************************************************** 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir *************************************************************************/ 33*cdf0e10cSrcweir #ifndef _FTP_FTPDIRP_HXX_ 34*cdf0e10cSrcweir #define _FTP_FTPDIRP_HXX_ 35*cdf0e10cSrcweir 36*cdf0e10cSrcweir #include <osl/time.h> 37*cdf0e10cSrcweir #include <rtl/ustring.hxx> 38*cdf0e10cSrcweir #include <com/sun/star/util/DateTime.hpp> 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir namespace ftp { 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir /*======================================================================== 44*cdf0e10cSrcweir * 45*cdf0e10cSrcweir * the DateTime structure 46*cdf0e10cSrcweir * 47*cdf0e10cSrcweir *======================================================================*/ 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir struct DateTime 50*cdf0e10cSrcweir : public com::sun::star::util::DateTime 51*cdf0e10cSrcweir { 52*cdf0e10cSrcweir DateTime(const sal_uInt16& hundredthSeconds, 53*cdf0e10cSrcweir const sal_uInt16& seconds, 54*cdf0e10cSrcweir const sal_uInt16& minutes, 55*cdf0e10cSrcweir const sal_uInt16& hours, 56*cdf0e10cSrcweir const sal_uInt16& day, 57*cdf0e10cSrcweir const sal_uInt16& month, 58*cdf0e10cSrcweir const sal_uInt16& year) SAL_THROW( () ) 59*cdf0e10cSrcweir : com::sun::star::util::DateTime(hundredthSeconds, 60*cdf0e10cSrcweir seconds, 61*cdf0e10cSrcweir minutes, 62*cdf0e10cSrcweir hours, 63*cdf0e10cSrcweir day, 64*cdf0e10cSrcweir month, 65*cdf0e10cSrcweir year) { } 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir void SetYear(sal_uInt16 year) { Year = year; } 68*cdf0e10cSrcweir void SetMonth(sal_uInt16 month) { Month = month; } 69*cdf0e10cSrcweir void SetDay(sal_uInt16 day) { Day = day; } 70*cdf0e10cSrcweir // Only zero allowed and used for time-argument 71*cdf0e10cSrcweir void SetTime(sal_uInt16) { Hours = Minutes = Seconds = HundredthSeconds = 0; } 72*cdf0e10cSrcweir void SetHour(sal_uInt16 hours) { Hours = hours; } 73*cdf0e10cSrcweir void SetMin(sal_uInt16 minutes) { Minutes = minutes; } 74*cdf0e10cSrcweir void SetSec(sal_uInt16 seconds) { Seconds = seconds; } 75*cdf0e10cSrcweir void Set100Sec(sal_uInt16 hundredthSec) { HundredthSeconds = hundredthSec; } 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir sal_uInt16 GetMonth(void) { return Month; } 78*cdf0e10cSrcweir }; 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir /*======================================================================== 83*cdf0e10cSrcweir * 84*cdf0e10cSrcweir * the directory information structure 85*cdf0e10cSrcweir * 86*cdf0e10cSrcweir *======================================================================*/ 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir enum FTPDirentryMode { INETCOREFTP_FILEMODE_UNKNOWN = 0x00, 89*cdf0e10cSrcweir INETCOREFTP_FILEMODE_READ = 0x01, 90*cdf0e10cSrcweir INETCOREFTP_FILEMODE_WRITE = 0x02, 91*cdf0e10cSrcweir INETCOREFTP_FILEMODE_ISDIR = 0x04, 92*cdf0e10cSrcweir INETCOREFTP_FILEMODE_ISLINK = 0x08 }; 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir struct FTPDirentry 95*cdf0e10cSrcweir { 96*cdf0e10cSrcweir rtl::OUString m_aURL; 97*cdf0e10cSrcweir rtl::OUString m_aName; 98*cdf0e10cSrcweir DateTime m_aDate; 99*cdf0e10cSrcweir sal_uInt32 m_nMode; 100*cdf0e10cSrcweir sal_uInt32 m_nSize; 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir FTPDirentry(void) 103*cdf0e10cSrcweir : m_aDate(0,0,0,0,0,0,0), 104*cdf0e10cSrcweir m_nMode(INETCOREFTP_FILEMODE_UNKNOWN), 105*cdf0e10cSrcweir m_nSize((sal_uInt32)(-1)) { } 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir void clear() { 108*cdf0e10cSrcweir m_aURL = m_aName = rtl::OUString(); 109*cdf0e10cSrcweir m_aDate = DateTime(0,0,0,0,0,0,0); 110*cdf0e10cSrcweir m_nMode = INETCOREFTP_FILEMODE_UNKNOWN; 111*cdf0e10cSrcweir m_nSize = sal_uInt32(-1); 112*cdf0e10cSrcweir } 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir bool isDir() const { 115*cdf0e10cSrcweir return bool(m_nMode && INETCOREFTP_FILEMODE_ISDIR); 116*cdf0e10cSrcweir } 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir bool isFile() const { 119*cdf0e10cSrcweir return ! bool(m_nMode && INETCOREFTP_FILEMODE_ISDIR); 120*cdf0e10cSrcweir } 121*cdf0e10cSrcweir }; 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir /*======================================================================== 125*cdf0e10cSrcweir * 126*cdf0e10cSrcweir * the directory parser 127*cdf0e10cSrcweir * 128*cdf0e10cSrcweir *======================================================================*/ 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir class FTPDirectoryParser 132*cdf0e10cSrcweir { 133*cdf0e10cSrcweir public: 134*cdf0e10cSrcweir static sal_Bool parseDOS ( 135*cdf0e10cSrcweir FTPDirentry &rEntry, 136*cdf0e10cSrcweir const sal_Char *pBuffer ); 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir static sal_Bool parseVMS ( 139*cdf0e10cSrcweir FTPDirentry &rEntry, 140*cdf0e10cSrcweir const sal_Char *pBuffer ); 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir static sal_Bool parseUNIX ( 143*cdf0e10cSrcweir FTPDirentry &rEntry, 144*cdf0e10cSrcweir const sal_Char *pBuffer ); 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir private: 148*cdf0e10cSrcweir 149*cdf0e10cSrcweir static sal_Bool parseUNIX_isSizeField ( 150*cdf0e10cSrcweir const sal_Char *pStart, 151*cdf0e10cSrcweir const sal_Char *pEnd, 152*cdf0e10cSrcweir sal_uInt32 &rSize); 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir static sal_Bool parseUNIX_isMonthField ( 155*cdf0e10cSrcweir const sal_Char *pStart, 156*cdf0e10cSrcweir const sal_Char *pEnd, 157*cdf0e10cSrcweir DateTime& rDateTime); 158*cdf0e10cSrcweir 159*cdf0e10cSrcweir static sal_Bool parseUNIX_isDayField ( 160*cdf0e10cSrcweir const sal_Char *pStart, 161*cdf0e10cSrcweir const sal_Char *pEnd, 162*cdf0e10cSrcweir DateTime& rDateTime); 163*cdf0e10cSrcweir 164*cdf0e10cSrcweir static sal_Bool parseUNIX_isYearTimeField ( 165*cdf0e10cSrcweir const sal_Char *pStart, 166*cdf0e10cSrcweir const sal_Char *pEnd, 167*cdf0e10cSrcweir DateTime& rDateTime); 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir static sal_Bool parseUNIX_isTime ( 170*cdf0e10cSrcweir const sal_Char *pStart, 171*cdf0e10cSrcweir const sal_Char *pEnd, 172*cdf0e10cSrcweir sal_uInt16 nHour, 173*cdf0e10cSrcweir DateTime& rDateTime); 174*cdf0e10cSrcweir 175*cdf0e10cSrcweir static sal_Bool setYear ( 176*cdf0e10cSrcweir DateTime& rDateTime, 177*cdf0e10cSrcweir sal_uInt16 nYear); 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir static sal_Bool setPath ( 180*cdf0e10cSrcweir rtl::OUString& rPath, 181*cdf0e10cSrcweir const sal_Char *value, 182*cdf0e10cSrcweir sal_Int32 length = -1); 183*cdf0e10cSrcweir }; 184*cdf0e10cSrcweir 185*cdf0e10cSrcweir 186*cdf0e10cSrcweir } 187*cdf0e10cSrcweir 188*cdf0e10cSrcweir 189*cdf0e10cSrcweir #endif 190