2
0

access.c 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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. #include "win32/fspr_arch_atime.h"
  17. #include "fspr_time.h"
  18. #include "fspr_general.h"
  19. #include "fspr_lib.h"
  20. fspr_status_t fspr_get_curtime(struct atime_t *time, fspr_time_t *rv)
  21. {
  22. if (time) {
  23. (*rv) = time->currtime;
  24. return APR_SUCCESS;
  25. }
  26. return APR_ENOTIME;
  27. }
  28. fspr_status_t fspr_get_sec(struct atime_t *time, fspr_int32_t *rv)
  29. {
  30. if (time) {
  31. (*rv) = time->explodedtime->wSecond;
  32. return APR_SUCCESS;
  33. }
  34. return APR_ENOTIME;
  35. }
  36. fspr_status_t fspr_get_min(struct atime_t *time, fspr_int32_t *rv)
  37. {
  38. if (time) {
  39. (*rv) = time->explodedtime->wMinute;
  40. return APR_SUCCESS;
  41. }
  42. return APR_ENOTIME;
  43. }
  44. fspr_status_t fspr_get_hour(struct atime_t *time, fspr_int32_t *rv)
  45. {
  46. if (time) {
  47. (*rv) = time->explodedtime->wHour;
  48. return APR_SUCCESS;
  49. }
  50. return APR_ENOTIME;
  51. }
  52. fspr_status_t fspr_get_mday(struct atime_t *time, fspr_int32_t *rv)
  53. {
  54. if (time) {
  55. (*rv) = time->explodedtime->wDay;
  56. return APR_SUCCESS;
  57. }
  58. return APR_ENOTIME;
  59. }
  60. fspr_status_t fspr_get_mon(struct atime_t *time, fspr_int32_t *rv)
  61. {
  62. if (time) {
  63. (*rv) = time->explodedtime->wMonth;
  64. return APR_SUCCESS;
  65. }
  66. return APR_ENOTIME;
  67. }
  68. fspr_status_t fspr_get_year(struct atime_t *time, fspr_int32_t *rv)
  69. {
  70. if (time) {
  71. (*rv) = time->explodedtime->wYear;
  72. return APR_SUCCESS;
  73. }
  74. return APR_ENOTIME;
  75. }
  76. fspr_status_t fspr_get_wday(struct atime_t *time, fspr_int32_t *rv)
  77. {
  78. if (time) {
  79. (*rv) = time->explodedtime->wDayOfWeek;
  80. return APR_SUCCESS;
  81. }
  82. return APR_ENOTIME;
  83. }
  84. fspr_status_t fspr_set_sec(struct atime_t *time, fspr_int32_t value)
  85. {
  86. if (!time) {
  87. return APR_ENOTIME;
  88. }
  89. if (time->explodedtime == NULL) {
  90. time->explodedtime = (SYSTEMTIME *)fspr_pcalloc(time->cntxt,
  91. sizeof(SYSTEMTIME));
  92. }
  93. if (time->explodedtime == NULL) {
  94. return APR_ENOMEM;
  95. }
  96. time->explodedtime->wSecond = value;
  97. return APR_SUCCESS;
  98. }
  99. fspr_status_t fspr_set_min(struct atime_t *time, fspr_int32_t value)
  100. {
  101. if (!time) {
  102. return APR_ENOTIME;
  103. }
  104. if (time->explodedtime == NULL) {
  105. time->explodedtime = (SYSTEMTIME *)fspr_pcalloc(time->cntxt,
  106. sizeof(SYSTEMTIME));
  107. }
  108. if (time->explodedtime == NULL) {
  109. return APR_ENOMEM;
  110. }
  111. time->explodedtime->wMinute = value;
  112. return APR_SUCCESS;
  113. }
  114. fspr_status_t fspr_set_hour(struct atime_t *time, fspr_int32_t value)
  115. {
  116. if (!time) {
  117. return APR_ENOTIME;
  118. }
  119. if (time->explodedtime == NULL) {
  120. time->explodedtime = (SYSTEMTIME *)fspr_pcalloc(time->cntxt,
  121. sizeof(SYSTEMTIME));
  122. }
  123. if (time->explodedtime == NULL) {
  124. return APR_ENOMEM;
  125. }
  126. time->explodedtime->wHour = value;
  127. return APR_SUCCESS;
  128. }
  129. fspr_status_t fspr_set_mday(struct atime_t *time, fspr_int32_t value)
  130. {
  131. if (!time) {
  132. return APR_ENOTIME;
  133. }
  134. if (time->explodedtime == NULL) {
  135. time->explodedtime = (SYSTEMTIME *)fspr_pcalloc(time->cntxt,
  136. sizeof(SYSTEMTIME));
  137. }
  138. if (time->explodedtime == NULL) {
  139. return APR_ENOMEM;
  140. }
  141. time->explodedtime->wDay = value;
  142. return APR_SUCCESS;
  143. }
  144. fspr_status_t fspr_set_mon(struct atime_t *time, fspr_int32_t value)
  145. {
  146. if (!time) {
  147. return APR_ENOTIME;
  148. }
  149. if (time->explodedtime == NULL) {
  150. time->explodedtime = (SYSTEMTIME *)fspr_pcalloc(time->cntxt,
  151. sizeof(SYSTEMTIME));
  152. }
  153. if (time->explodedtime == NULL) {
  154. return APR_ENOMEM;
  155. }
  156. time->explodedtime->wMonth = value;
  157. return APR_SUCCESS;
  158. }
  159. fspr_status_t fspr_set_year(struct atime_t *time, fspr_int32_t value)
  160. {
  161. if (!time) {
  162. return APR_ENOTIME;
  163. }
  164. if (time->explodedtime == NULL) {
  165. time->explodedtime = (SYSTEMTIME *)fspr_pcalloc(time->cntxt,
  166. sizeof(SYSTEMTIME));
  167. }
  168. if (time->explodedtime == NULL) {
  169. return APR_ENOMEM;
  170. }
  171. time->explodedtime->wYear = value;
  172. return APR_SUCCESS;
  173. }
  174. fspr_status_t fspr_set_wday(struct atime_t *time, fspr_int32_t value)
  175. {
  176. if (!time) {
  177. return APR_ENOTIME;
  178. }
  179. if (time->explodedtime == NULL) {
  180. time->explodedtime = (SYSTEMTIME *)fspr_pcalloc(time->cntxt,
  181. sizeof(SYSTEMTIME));
  182. }
  183. if (time->explodedtime == NULL) {
  184. return APR_ENOMEM;
  185. }
  186. time->explodedtime->wDayOfWeek = value;
  187. return APR_SUCCESS;
  188. }