xref: /aoo42x/main/ucb/source/ucp/ftp/ftpdirp.hxx (revision 6df1ea1f)
1*6df1ea1fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*6df1ea1fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*6df1ea1fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*6df1ea1fSAndrew Rist  * distributed with this work for additional information
6*6df1ea1fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*6df1ea1fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*6df1ea1fSAndrew Rist  * "License"); you may not use this file except in compliance
9*6df1ea1fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*6df1ea1fSAndrew Rist  *
11*6df1ea1fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*6df1ea1fSAndrew Rist  *
13*6df1ea1fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*6df1ea1fSAndrew Rist  * software distributed under the License is distributed on an
15*6df1ea1fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*6df1ea1fSAndrew Rist  * KIND, either express or implied.  See the License for the
17*6df1ea1fSAndrew Rist  * specific language governing permissions and limitations
18*6df1ea1fSAndrew Rist  * under the License.
19*6df1ea1fSAndrew Rist  *
20*6df1ea1fSAndrew Rist  *************************************************************/
21*6df1ea1fSAndrew Rist 
22*6df1ea1fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir /**************************************************************************
25cdf0e10cSrcweir                                 TODO
26cdf0e10cSrcweir  **************************************************************************
27cdf0e10cSrcweir 
28cdf0e10cSrcweir  *************************************************************************/
29cdf0e10cSrcweir #ifndef _FTP_FTPDIRP_HXX_
30cdf0e10cSrcweir #define _FTP_FTPDIRP_HXX_
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #include <osl/time.h>
33cdf0e10cSrcweir #include <rtl/ustring.hxx>
34cdf0e10cSrcweir #include <com/sun/star/util/DateTime.hpp>
35cdf0e10cSrcweir 
36cdf0e10cSrcweir 
37cdf0e10cSrcweir namespace ftp {
38cdf0e10cSrcweir 
39cdf0e10cSrcweir     /*========================================================================
40cdf0e10cSrcweir      *
41cdf0e10cSrcweir      * the DateTime structure
42cdf0e10cSrcweir      *
43cdf0e10cSrcweir      *======================================================================*/
44cdf0e10cSrcweir 
45cdf0e10cSrcweir     struct DateTime
46cdf0e10cSrcweir         : public com::sun::star::util::DateTime
47cdf0e10cSrcweir     {
DateTimeftp::DateTime48cdf0e10cSrcweir         DateTime(const sal_uInt16& hundredthSeconds,
49cdf0e10cSrcweir                  const sal_uInt16& seconds,
50cdf0e10cSrcweir                  const sal_uInt16& minutes,
51cdf0e10cSrcweir                  const sal_uInt16& hours,
52cdf0e10cSrcweir                  const sal_uInt16& day,
53cdf0e10cSrcweir                  const sal_uInt16& month,
54cdf0e10cSrcweir                  const sal_uInt16& year) SAL_THROW( () )
55cdf0e10cSrcweir                      : com::sun::star::util::DateTime(hundredthSeconds,
56cdf0e10cSrcweir                                                       seconds,
57cdf0e10cSrcweir                                                       minutes,
58cdf0e10cSrcweir                                                       hours,
59cdf0e10cSrcweir                                                       day,
60cdf0e10cSrcweir                                                       month,
61cdf0e10cSrcweir                                                       year) { }
62cdf0e10cSrcweir 
SetYearftp::DateTime63cdf0e10cSrcweir         void SetYear(sal_uInt16 year) { Year = year; }
SetMonthftp::DateTime64cdf0e10cSrcweir         void SetMonth(sal_uInt16 month) { Month = month; }
SetDayftp::DateTime65cdf0e10cSrcweir         void SetDay(sal_uInt16 day) { Day = day; }
66cdf0e10cSrcweir         // Only zero allowed and used for time-argument
SetTimeftp::DateTime67cdf0e10cSrcweir         void SetTime(sal_uInt16) { Hours = Minutes = Seconds = HundredthSeconds = 0; }
SetHourftp::DateTime68cdf0e10cSrcweir         void SetHour(sal_uInt16 hours) { Hours = hours; }
SetMinftp::DateTime69cdf0e10cSrcweir         void SetMin(sal_uInt16 minutes) { Minutes = minutes; }
SetSecftp::DateTime70cdf0e10cSrcweir         void SetSec(sal_uInt16 seconds) { Seconds = seconds; }
Set100Secftp::DateTime71cdf0e10cSrcweir         void Set100Sec(sal_uInt16 hundredthSec) { HundredthSeconds = hundredthSec; }
72cdf0e10cSrcweir 
GetMonthftp::DateTime73cdf0e10cSrcweir         sal_uInt16 GetMonth(void) { return Month; }
74cdf0e10cSrcweir     };
75cdf0e10cSrcweir 
76cdf0e10cSrcweir 
77cdf0e10cSrcweir 
78cdf0e10cSrcweir /*========================================================================
79cdf0e10cSrcweir  *
80cdf0e10cSrcweir  * the directory information structure
81cdf0e10cSrcweir  *
82cdf0e10cSrcweir  *======================================================================*/
83cdf0e10cSrcweir 
84cdf0e10cSrcweir     enum FTPDirentryMode { INETCOREFTP_FILEMODE_UNKNOWN = 0x00,
85cdf0e10cSrcweir                            INETCOREFTP_FILEMODE_READ = 0x01,
86cdf0e10cSrcweir                            INETCOREFTP_FILEMODE_WRITE = 0x02,
87cdf0e10cSrcweir                            INETCOREFTP_FILEMODE_ISDIR = 0x04,
88cdf0e10cSrcweir                            INETCOREFTP_FILEMODE_ISLINK = 0x08 };
89cdf0e10cSrcweir 
90cdf0e10cSrcweir     struct FTPDirentry
91cdf0e10cSrcweir     {
92cdf0e10cSrcweir         rtl::OUString                       m_aURL;
93cdf0e10cSrcweir         rtl::OUString                       m_aName;
94cdf0e10cSrcweir         DateTime                            m_aDate;
95cdf0e10cSrcweir         sal_uInt32                          m_nMode;
96cdf0e10cSrcweir         sal_uInt32                          m_nSize;
97cdf0e10cSrcweir 
FTPDirentryftp::FTPDirentry98cdf0e10cSrcweir         FTPDirentry(void)
99cdf0e10cSrcweir             : m_aDate(0,0,0,0,0,0,0),
100cdf0e10cSrcweir               m_nMode(INETCOREFTP_FILEMODE_UNKNOWN),
101cdf0e10cSrcweir               m_nSize((sal_uInt32)(-1)) { }
102cdf0e10cSrcweir 
clearftp::FTPDirentry103cdf0e10cSrcweir         void clear() {
104cdf0e10cSrcweir             m_aURL = m_aName = rtl::OUString();
105cdf0e10cSrcweir             m_aDate = DateTime(0,0,0,0,0,0,0);
106cdf0e10cSrcweir             m_nMode = INETCOREFTP_FILEMODE_UNKNOWN;
107cdf0e10cSrcweir             m_nSize = sal_uInt32(-1);
108cdf0e10cSrcweir         }
109cdf0e10cSrcweir 
isDirftp::FTPDirentry110cdf0e10cSrcweir         bool isDir() const {
111cdf0e10cSrcweir             return bool(m_nMode && INETCOREFTP_FILEMODE_ISDIR);
112cdf0e10cSrcweir         }
113cdf0e10cSrcweir 
isFileftp::FTPDirentry114cdf0e10cSrcweir         bool isFile() const {
115cdf0e10cSrcweir             return ! bool(m_nMode && INETCOREFTP_FILEMODE_ISDIR);
116cdf0e10cSrcweir         }
117cdf0e10cSrcweir     };
118cdf0e10cSrcweir 
119cdf0e10cSrcweir 
120cdf0e10cSrcweir /*========================================================================
121cdf0e10cSrcweir  *
122cdf0e10cSrcweir  * the directory parser
123cdf0e10cSrcweir  *
124cdf0e10cSrcweir  *======================================================================*/
125cdf0e10cSrcweir 
126cdf0e10cSrcweir 
127cdf0e10cSrcweir     class FTPDirectoryParser
128cdf0e10cSrcweir     {
129cdf0e10cSrcweir     public:
130cdf0e10cSrcweir         static sal_Bool parseDOS (
131cdf0e10cSrcweir             FTPDirentry &rEntry,
132cdf0e10cSrcweir             const sal_Char  *pBuffer );
133cdf0e10cSrcweir 
134cdf0e10cSrcweir         static sal_Bool parseVMS (
135cdf0e10cSrcweir             FTPDirentry &rEntry,
136cdf0e10cSrcweir             const sal_Char  *pBuffer );
137cdf0e10cSrcweir 
138cdf0e10cSrcweir         static sal_Bool parseUNIX (
139cdf0e10cSrcweir             FTPDirentry &rEntry,
140cdf0e10cSrcweir             const sal_Char  *pBuffer );
141cdf0e10cSrcweir 
142cdf0e10cSrcweir 
143cdf0e10cSrcweir     private:
144cdf0e10cSrcweir 
145cdf0e10cSrcweir         static sal_Bool parseUNIX_isSizeField (
146cdf0e10cSrcweir             const sal_Char *pStart,
147cdf0e10cSrcweir             const sal_Char *pEnd,
148cdf0e10cSrcweir             sal_uInt32     &rSize);
149cdf0e10cSrcweir 
150cdf0e10cSrcweir         static sal_Bool parseUNIX_isMonthField (
151cdf0e10cSrcweir             const sal_Char *pStart,
152cdf0e10cSrcweir             const sal_Char *pEnd,
153cdf0e10cSrcweir             DateTime& rDateTime);
154cdf0e10cSrcweir 
155cdf0e10cSrcweir         static sal_Bool parseUNIX_isDayField (
156cdf0e10cSrcweir             const sal_Char *pStart,
157cdf0e10cSrcweir             const sal_Char *pEnd,
158cdf0e10cSrcweir             DateTime& rDateTime);
159cdf0e10cSrcweir 
160cdf0e10cSrcweir         static sal_Bool parseUNIX_isYearTimeField (
161cdf0e10cSrcweir             const sal_Char *pStart,
162cdf0e10cSrcweir             const sal_Char *pEnd,
163cdf0e10cSrcweir             DateTime& rDateTime);
164cdf0e10cSrcweir 
165cdf0e10cSrcweir         static sal_Bool parseUNIX_isTime (
166cdf0e10cSrcweir             const sal_Char *pStart,
167cdf0e10cSrcweir             const sal_Char *pEnd,
168cdf0e10cSrcweir             sal_uInt16      nHour,
169cdf0e10cSrcweir             DateTime& rDateTime);
170cdf0e10cSrcweir 
171cdf0e10cSrcweir         static sal_Bool setYear (
172cdf0e10cSrcweir             DateTime& rDateTime,
173cdf0e10cSrcweir             sal_uInt16  nYear);
174cdf0e10cSrcweir 
175cdf0e10cSrcweir         static sal_Bool setPath (
176cdf0e10cSrcweir             rtl::OUString& rPath,
177cdf0e10cSrcweir             const sal_Char *value,
178cdf0e10cSrcweir             sal_Int32       length = -1);
179cdf0e10cSrcweir     };
180cdf0e10cSrcweir 
181cdf0e10cSrcweir 
182cdf0e10cSrcweir }
183cdf0e10cSrcweir 
184cdf0e10cSrcweir 
185cdf0e10cSrcweir #endif
186