libUPnP  1.6.17
gmtdate.h
1 //
3 // Copyright (c) 2000-2003 Intel Corporation
4 // All rights reserved.
5 //
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions are met:
8 //
9 // * Redistributions of source code must retain the above copyright notice,
10 // this list of conditions and the following disclaimer.
11 // * Redistributions in binary form must reproduce the above copyright notice,
12 // this list of conditions and the following disclaimer in the documentation
13 // and/or other materials provided with the distribution.
14 // * Neither name of Intel Corporation nor the names of its contributors
15 // may be used to endorse or promote products derived from this software
16 // without specific prior written permission.
17 //
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
22 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26 // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
31 
32 #ifndef GENLIB_UTIL_GMTDATE_H
33 #define GENLIB_UTIL_GMTDATE_H
34 
35 #include <time.h>
36 #include <genlib/util/util.h>
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
42 // input: monthStr: 3-letter or full month
43 // returns month=0..11 or -1 on failure
44 // output:
45 // charsRead - num chars that match the month
46 // fullNameMatch - full name match(1) or 3-letter match(0)
47 //
48 int ParseMonth( IN const char* monthStr,
49  OUT int* charsRead, OUT int* fullNameMatch );
50 
51 // input: dayOfWeek: 3-letter or full day of week ("mon" etc)
52 // returns dayOfWeek=0..6 or -1 on failure
53 // output:
54 // charsRead - num chars that match the month
55 // fullNameMatch - full name match(1) or 3-letter match(0)
56 //
57 int ParseDayOfWeek( IN const char* dayOfWeek,
58  OUT int* charsRead, OUT int* fullNameMatch );
59 
60 // converts date to string format: RFC 1123 format:
61 // Sun, 06 Nov 1994 08:49:37 GMT
62 // String returned must be freed using free() function
63 // returns NULL if date is NULL
64 //
65 // throws OutOfMemoryException
66 char* DateToString( const struct tm* date );
67 
68 // parses time in fmt hh:mm:ss, military fmt
69 // returns 0 on success; -1 on error
70 int ParseTime( const char* s, int* hour, int* minute, int* second );
71 
72 
73 
74 // tries to parse date according to RFCs 1123, 850, or asctime()
75 // format
76 // params:
77 // str - contains date/time in string format
78 // dateTime - date and time obtained from 'str'
79 // returns: 0 on success, -1 on error
80 int ParseRFC850DateTime( IN const char* str,
81  OUT struct tm* dateTime, OUT int* numCharsParsed );
82 
83 int ParseRFC1123DateTime( IN const char* str,
84  OUT struct tm* dateTime, OUT int* numCharsParsed );
85 
86 int ParseAsctimeFmt( IN const char* str,
87  OUT struct tm* dateTime, OUT int* numCharsParsed );
88 
89 // parses any of these formats: 1123, 850 or asctime()
90 int ParseDateTime( IN const char* str,
91  OUT struct tm* dateTime, OUT int* numCharsParsed );
92 
93 #ifdef __cplusplus
94 } /* extern C */
95 #endif
96 
97 #endif /* GENLIB_UTIL_GMTDATE_H */