}
/*
- * XXX TODO:
- * These functions were lifted from mod_proxy
- * Consider putting them in APR or some other common accessable
- * location.
+ * Converts apr_time_t expressed as hex digits to
+ * a true apr_time_t.
*/
-/*
- * Converts apr_time_t hex digits to a time integer
- */
-CACHE_DECLARE(apr_time_t) ap_cache_hex2msec(const char *x)
+CACHE_DECLARE(apr_time_t) ap_cache_hex2usec(const char *x)
{
int i, ch;
apr_time_t j;
}
/*
- * Converts a time integer to apr_time_t hex digits
+ * Converts apr_time_t to apr_time_t expressed as hex digits.
*/
-CACHE_DECLARE(void) ap_cache_msec2hex(apr_time_t j, char *y)
+CACHE_DECLARE(void) ap_cache_usec2hex(apr_time_t j, char *y)
{
int i, ch;
/**
*
*/
-CACHE_DECLARE(apr_time_t) ap_cache_hex2msec(const char *x);
-CACHE_DECLARE(void) ap_cache_msec2hex(apr_time_t j, char *y);
+CACHE_DECLARE(apr_time_t) ap_cache_hex2usec(const char *x);
+CACHE_DECLARE(void) ap_cache_usec2hex(apr_time_t j, char *y);
CACHE_DECLARE(char *) generate_name(apr_pool_t *p, int dirlevels,
int dirlength,
const char *name);
/* read the data from the cache file */
/* format
* date SP expire SP count CRLF
- * dates are stored as hex seconds since 1970
+ * dates are stored as a hex representation of apr_time_t (number of
+ * microseconds since 00:00:00 january 1, 1970 UTC)
*/
rv = apr_file_gets(&urlbuff[0], urllen, fd);
if (rv != APR_SUCCESS) {
return APR_EGENERAL;
}
- info->date = ap_cache_hex2msec(urlbuff + offset);
+ info->date = ap_cache_hex2usec(urlbuff + offset);
offset += (sizeof(info->date)*2) + 1;
- info->expire = ap_cache_hex2msec(urlbuff + offset);
+ info->expire = ap_cache_hex2usec(urlbuff + offset);
offset += (sizeof(info->expire)*2) + 1;
- dobj->version = ap_cache_hex2msec(urlbuff + offset);
+ dobj->version = ap_cache_hex2usec(urlbuff + offset);
/* check that we have the same URL */
rv = apr_file_gets(&urlbuff[0], urllen, fd);
return 0;
}
- ap_cache_msec2hex(info->date, dateHexS);
- ap_cache_msec2hex(info->expire, expireHexS);
- ap_cache_msec2hex(dobj->version++, verHexS);
+ ap_cache_usec2hex(info->date, dateHexS);
+ ap_cache_usec2hex(info->expire, expireHexS);
+ ap_cache_usec2hex(dobj->version++, verHexS);
buf = apr_pstrcat(r->pool, dateHexS, " ", expireHexS, " ", verHexS, "\n", NULL);
amt = strlen(buf);
rc = apr_file_write(fd, buf, &amt);