1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements. See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include "win32/apr_arch_atime.h"
18 #include "apr_time.h"
19 #include "apr_general.h"
20 #include "apr_lib.h"
21
apr_get_curtime(struct atime_t * time,apr_time_t * rv)22 apr_status_t apr_get_curtime(struct atime_t *time, apr_time_t *rv)
23 {
24 if (time) {
25 (*rv) = time->currtime;
26 return APR_SUCCESS;
27 }
28 return APR_ENOTIME;
29 }
30
apr_get_sec(struct atime_t * time,apr_int32_t * rv)31 apr_status_t apr_get_sec(struct atime_t *time, apr_int32_t *rv)
32 {
33 if (time) {
34 (*rv) = time->explodedtime->wSecond;
35 return APR_SUCCESS;
36 }
37 return APR_ENOTIME;
38 }
39
apr_get_min(struct atime_t * time,apr_int32_t * rv)40 apr_status_t apr_get_min(struct atime_t *time, apr_int32_t *rv)
41 {
42 if (time) {
43 (*rv) = time->explodedtime->wMinute;
44 return APR_SUCCESS;
45 }
46 return APR_ENOTIME;
47 }
48
apr_get_hour(struct atime_t * time,apr_int32_t * rv)49 apr_status_t apr_get_hour(struct atime_t *time, apr_int32_t *rv)
50 {
51 if (time) {
52 (*rv) = time->explodedtime->wHour;
53 return APR_SUCCESS;
54 }
55 return APR_ENOTIME;
56 }
57
apr_get_mday(struct atime_t * time,apr_int32_t * rv)58 apr_status_t apr_get_mday(struct atime_t *time, apr_int32_t *rv)
59 {
60 if (time) {
61 (*rv) = time->explodedtime->wDay;
62 return APR_SUCCESS;
63 }
64 return APR_ENOTIME;
65 }
66
apr_get_mon(struct atime_t * time,apr_int32_t * rv)67 apr_status_t apr_get_mon(struct atime_t *time, apr_int32_t *rv)
68 {
69 if (time) {
70 (*rv) = time->explodedtime->wMonth;
71 return APR_SUCCESS;
72 }
73 return APR_ENOTIME;
74 }
75
apr_get_year(struct atime_t * time,apr_int32_t * rv)76 apr_status_t apr_get_year(struct atime_t *time, apr_int32_t *rv)
77 {
78 if (time) {
79 (*rv) = time->explodedtime->wYear;
80 return APR_SUCCESS;
81 }
82 return APR_ENOTIME;
83 }
84
apr_get_wday(struct atime_t * time,apr_int32_t * rv)85 apr_status_t apr_get_wday(struct atime_t *time, apr_int32_t *rv)
86 {
87 if (time) {
88 (*rv) = time->explodedtime->wDayOfWeek;
89 return APR_SUCCESS;
90 }
91 return APR_ENOTIME;
92 }
93
apr_set_sec(struct atime_t * time,apr_int32_t value)94 apr_status_t apr_set_sec(struct atime_t *time, apr_int32_t value)
95 {
96 if (!time) {
97 return APR_ENOTIME;
98 }
99 if (time->explodedtime == NULL) {
100 time->explodedtime = (SYSTEMTIME *)apr_pcalloc(time->cntxt,
101 sizeof(SYSTEMTIME));
102 }
103 if (time->explodedtime == NULL) {
104 return APR_ENOMEM;
105 }
106 time->explodedtime->wSecond = value;
107 return APR_SUCCESS;
108 }
109
apr_set_min(struct atime_t * time,apr_int32_t value)110 apr_status_t apr_set_min(struct atime_t *time, apr_int32_t value)
111 {
112 if (!time) {
113 return APR_ENOTIME;
114 }
115 if (time->explodedtime == NULL) {
116 time->explodedtime = (SYSTEMTIME *)apr_pcalloc(time->cntxt,
117 sizeof(SYSTEMTIME));
118 }
119 if (time->explodedtime == NULL) {
120 return APR_ENOMEM;
121 }
122 time->explodedtime->wMinute = value;
123 return APR_SUCCESS;
124 }
125
apr_set_hour(struct atime_t * time,apr_int32_t value)126 apr_status_t apr_set_hour(struct atime_t *time, apr_int32_t value)
127 {
128 if (!time) {
129 return APR_ENOTIME;
130 }
131 if (time->explodedtime == NULL) {
132 time->explodedtime = (SYSTEMTIME *)apr_pcalloc(time->cntxt,
133 sizeof(SYSTEMTIME));
134 }
135 if (time->explodedtime == NULL) {
136 return APR_ENOMEM;
137 }
138 time->explodedtime->wHour = value;
139 return APR_SUCCESS;
140 }
141
apr_set_mday(struct atime_t * time,apr_int32_t value)142 apr_status_t apr_set_mday(struct atime_t *time, apr_int32_t value)
143 {
144 if (!time) {
145 return APR_ENOTIME;
146 }
147 if (time->explodedtime == NULL) {
148 time->explodedtime = (SYSTEMTIME *)apr_pcalloc(time->cntxt,
149 sizeof(SYSTEMTIME));
150 }
151 if (time->explodedtime == NULL) {
152 return APR_ENOMEM;
153 }
154 time->explodedtime->wDay = value;
155 return APR_SUCCESS;
156 }
157
apr_set_mon(struct atime_t * time,apr_int32_t value)158 apr_status_t apr_set_mon(struct atime_t *time, apr_int32_t value)
159 {
160 if (!time) {
161 return APR_ENOTIME;
162 }
163 if (time->explodedtime == NULL) {
164 time->explodedtime = (SYSTEMTIME *)apr_pcalloc(time->cntxt,
165 sizeof(SYSTEMTIME));
166 }
167 if (time->explodedtime == NULL) {
168 return APR_ENOMEM;
169 }
170 time->explodedtime->wMonth = value;
171 return APR_SUCCESS;
172 }
173
apr_set_year(struct atime_t * time,apr_int32_t value)174 apr_status_t apr_set_year(struct atime_t *time, apr_int32_t value)
175 {
176 if (!time) {
177 return APR_ENOTIME;
178 }
179 if (time->explodedtime == NULL) {
180 time->explodedtime = (SYSTEMTIME *)apr_pcalloc(time->cntxt,
181 sizeof(SYSTEMTIME));
182 }
183 if (time->explodedtime == NULL) {
184 return APR_ENOMEM;
185 }
186 time->explodedtime->wYear = value;
187 return APR_SUCCESS;
188 }
189
apr_set_wday(struct atime_t * time,apr_int32_t value)190 apr_status_t apr_set_wday(struct atime_t *time, apr_int32_t value)
191 {
192 if (!time) {
193 return APR_ENOTIME;
194 }
195 if (time->explodedtime == NULL) {
196 time->explodedtime = (SYSTEMTIME *)apr_pcalloc(time->cntxt,
197 sizeof(SYSTEMTIME));
198 }
199 if (time->explodedtime == NULL) {
200 return APR_ENOMEM;
201 }
202 time->explodedtime->wDayOfWeek = value;
203 return APR_SUCCESS;
204 }
205