2000-04-01 08:27:45 +00:00
|
|
|
*** util.c.orig Thu Dec 2 18:07:10 1999
|
2000-07-19 08:14:09 +00:00
|
|
|
--- util.c Thu Jan 27 11:41:36 2000
|
2000-04-01 08:27:45 +00:00
|
|
|
***************
|
2000-07-19 08:14:09 +00:00
|
|
|
*** 15,20 ****
|
|
|
|
--- 15,22 ----
|
2000-04-01 08:27:45 +00:00
|
|
|
* is provided ``as is'' without express or implied warranty.
|
|
|
|
*/
|
|
|
|
|
2000-07-19 08:14:09 +00:00
|
|
|
+ #include <unistd.h>
|
|
|
|
+ #include <gnuregex.h>
|
2000-04-01 08:27:45 +00:00
|
|
|
#include "web500gw.h"
|
|
|
|
|
|
|
|
/* msg_?printf: formats (and prints out) a string contained in message file */
|
|
|
|
***************
|
2000-07-19 08:14:09 +00:00
|
|
|
*** 438,443 ****
|
|
|
|
--- 440,449 ----
|
2000-04-01 08:27:45 +00:00
|
|
|
mday++;
|
|
|
|
}
|
2000-07-19 08:14:09 +00:00
|
|
|
year = YEAR (tm -> tm_year);
|
|
|
|
+ /* note that 2-digit-year LDAP timestamp will have "00" for "2000" */
|
|
|
|
+ /* above year transformation will return "1900" for "00", 2-digit "2000" */
|
|
|
|
+ /* the following assumes no real dates < 1970 */
|
|
|
|
+ if (year < 1970) year += 100; /* turn "1900" into "2000" */
|
2000-04-01 08:27:45 +00:00
|
|
|
result = 0L;
|
|
|
|
for (i = 1970; i < year; i++)
|
|
|
|
result += dysize (i);
|
|
|
|
***************
|
2000-07-19 08:14:09 +00:00
|
|
|
*** 465,470 ****
|
|
|
|
--- 471,477 ----
|
|
|
|
char mydate[256];
|
|
|
|
struct tm tm, *ntm;
|
|
|
|
time_t t;
|
|
|
|
+ int ds_off; /* date string offset */
|
2000-04-01 08:27:45 +00:00
|
|
|
|
2000-07-19 08:14:09 +00:00
|
|
|
#ifdef WEB500GW_DEBUG
|
|
|
|
Web500gw_debug(WEB500GW_DEBUG_UTIL, " format_date (%s, \"%s\")\n",
|
2000-04-01 08:27:45 +00:00
|
|
|
***************
|
|
|
|
*** 473,487 ****
|
|
|
|
if (!s)
|
|
|
|
return(NULL);
|
|
|
|
|
|
|
|
! /* s should point to: YYMMDDHHmmSSZ */
|
2000-07-19 08:14:09 +00:00
|
|
|
/* ... well 2 digits for year :-( */
|
2000-04-01 08:27:45 +00:00
|
|
|
!
|
|
|
|
! tm.tm_year = 10*(s[0] - '0') + (s[1] - '0');
|
|
|
|
! tm.tm_mon = 10*(s[2] - '0') + (s[3] - '0') - 1;
|
|
|
|
! tm.tm_mday = 10*(s[4] - '0') + (s[5] - '0');
|
|
|
|
! tm.tm_hour = 10*(s[6] - '0') + (s[7] - '0');
|
|
|
|
! tm.tm_min = 10*(s[8] - '0') + (s[9] - '0');
|
|
|
|
! tm.tm_sec = 10*(s[10] - '0') + (s[11] - '0');
|
|
|
|
tm.tm_isdst = 0;
|
|
|
|
|
|
|
|
#if ! (defined(__hpux) || defined(_AIX) || defined(sunos5) || defined(linux) || defined(unixware7))
|
2000-07-19 08:14:09 +00:00
|
|
|
--- 480,498 ----
|
2000-04-01 08:27:45 +00:00
|
|
|
if (!s)
|
|
|
|
return(NULL);
|
|
|
|
|
2000-07-19 08:14:09 +00:00
|
|
|
! /* s should point to: YYMMDDHHmmSSZ (13 chars) */
|
|
|
|
/* ... well 2 digits for year :-( */
|
|
|
|
! /* or: YYYYMMDDHHmmSSZ (15 chars; 4-digit years) */
|
|
|
|
! if (strlen(s) == 13) {
|
|
|
|
! tm.tm_year = 10*(s[0] - '0') + (s[1] - '0'); ds_off = 2;}
|
|
|
|
! else {
|
|
|
|
! tm.tm_year = 1000*(s[0] - '0') + 100*(s[1] - '0') +
|
|
|
|
! 10*(s[2] - '0') + (s[3] - '0'); ds_off = 4;}
|
|
|
|
! tm.tm_mon = 10*(s[ds_off] - '0') + (s[ds_off+1] - '0') - 1;
|
|
|
|
! tm.tm_mday = 10*(s[ds_off+2] - '0') + (s[ds_off+3] - '0');
|
|
|
|
! tm.tm_hour = 10*(s[ds_off+4] - '0') + (s[ds_off+5] - '0');
|
|
|
|
! tm.tm_min = 10*(s[ds_off+6] - '0') + (s[ds_off+7] - '0');
|
|
|
|
! tm.tm_sec = 10*(s[ds_off+8] - '0') + (s[ds_off+9] - '0');
|
2000-04-01 08:27:45 +00:00
|
|
|
tm.tm_isdst = 0;
|
|
|
|
|
|
|
|
#if ! (defined(__hpux) || defined(_AIX) || defined(sunos5) || defined(linux) || defined(unixware7))
|
|
|
|
***************
|
2000-07-19 08:14:09 +00:00
|
|
|
*** 524,529 ****
|
|
|
|
--- 535,541 ----
|
|
|
|
char month_name[4];
|
|
|
|
int year = 0, month = 0, day = 0, hour = 0, min = 0, sec = 0;
|
|
|
|
int i = 0;
|
|
|
|
+ int ds_off; /* date stamp offset */
|
2000-04-01 08:27:45 +00:00
|
|
|
|
2000-07-19 08:14:09 +00:00
|
|
|
#ifdef WEB500GW_DEBUG
|
|
|
|
Web500gw_debug(WEB500GW_DEBUG_UTIL, " cmp_dates (%s, %s)\n",
|
2000-04-01 08:27:45 +00:00
|
|
|
***************
|
|
|
|
*** 552,560 ****
|
|
|
|
/* RFC 850: dd-Mmm-yy hh:mm:ss */
|
|
|
|
sscanf(http_date, "%d-%3s-%d %d:%d:%d",
|
|
|
|
&day, month_name, &year, &hour, &min, &sec);
|
2000-07-19 08:14:09 +00:00
|
|
|
! if (year < 70)
|
|
|
|
! year += 100;
|
|
|
|
! year += 1900;
|
|
|
|
} else { /* normal HTTP date (RFC 822/1123): dd Mmm yyyy hh:mm:ss */
|
|
|
|
sscanf(http_date, "%d %s %d %d:%d:%d",
|
|
|
|
&day, month_name, &year, &hour, &min, &sec);
|
|
|
|
--- 564,572 ----
|
|
|
|
/* RFC 850: dd-Mmm-yy hh:mm:ss */
|
|
|
|
sscanf(http_date, "%d-%3s-%d %d:%d:%d",
|
|
|
|
&day, month_name, &year, &hour, &min, &sec);
|
|
|
|
! /* convert 2-digit year into 4-digit year based on Unix beg date */
|
|
|
|
! if (year < 70) year += 100;
|
|
|
|
! if (year < 1900) year += 1900;
|
2000-04-01 08:27:45 +00:00
|
|
|
} else { /* normal HTTP date (RFC 822/1123): dd Mmm yyyy hh:mm:ss */
|
|
|
|
sscanf(http_date, "%d %s %d %d:%d:%d",
|
|
|
|
&day, month_name, &year, &hour, &min, &sec);
|
|
|
|
***************
|
|
|
|
*** 568,584 ****
|
|
|
|
day, month, year, 0);
|
|
|
|
Web500gw_debug(WEB500GW_DEBUG_UTIL, "%d:%d:%d\n", hour, min, sec, 0);
|
|
|
|
#endif
|
|
|
|
! if ((i = ((10*(ldap_date[0] - '0') + (ldap_date[1] - '0') + 1900) - year)))
|
2000-07-19 08:14:09 +00:00
|
|
|
! return i > 0;
|
2000-04-01 08:27:45 +00:00
|
|
|
! if ((i = ((10*(ldap_date[2] - '0') + (ldap_date[3] - '0')) - month)))
|
|
|
|
return i > 0;
|
|
|
|
! if ((i = ((10*(ldap_date[4] - '0') + (ldap_date[5] - '0')) - day)))
|
|
|
|
return i > 0;
|
|
|
|
! if ((i = ((10*(ldap_date[6] - '0') + (ldap_date[7] - '0')) - hour)))
|
|
|
|
return i > 0;
|
|
|
|
! if ((i = ((10*(ldap_date[8] - '0') + (ldap_date[9] - '0')) - min)))
|
|
|
|
return i > 0;
|
|
|
|
! if ((i = ((10*(ldap_date[10] - '0') + (ldap_date[11] - '0')) - sec)))
|
|
|
|
return i > 0;
|
|
|
|
|
|
|
|
/* gone so far - dates are identical */
|
2000-07-19 08:14:09 +00:00
|
|
|
--- 580,608 ----
|
2000-04-01 08:27:45 +00:00
|
|
|
day, month, year, 0);
|
|
|
|
Web500gw_debug(WEB500GW_DEBUG_UTIL, "%d:%d:%d\n", hour, min, sec, 0);
|
|
|
|
#endif
|
2000-07-19 08:14:09 +00:00
|
|
|
! /* ldap_date should point to: YYMMDDHHmmSSZ (13 chars) */
|
|
|
|
! /* ... well 2 digits for year :-( */
|
|
|
|
! /* or: YYYYMMDDHHmmSSZ (15 chars; 4-digit years) */
|
|
|
|
! if (strlen(ldap_date) == 13) {
|
|
|
|
! ds_off=2;
|
|
|
|
! if ((i = ((10*(ldap_date[0] - '0') +
|
|
|
|
! (ldap_date[1] - '0') + 1900) - year))) return i > 0;}
|
|
|
|
! else {
|
|
|
|
! ds_off=4;
|
|
|
|
! if ((i = ((1000*(ldap_date[0] - '0') +
|
|
|
|
! 100*(ldap_date[1] - '0') +
|
|
|
|
! 10*(ldap_date[2] - '0') +
|
|
|
|
! (ldap_date[3] - '0')) - year ))) return i > 0;}
|
|
|
|
!
|
|
|
|
! if ((i = ((10*(ldap_date[ds_off] - '0') + (ldap_date[ds_off+1] - '0')) - month)))
|
2000-04-01 08:27:45 +00:00
|
|
|
return i > 0;
|
2000-07-19 08:14:09 +00:00
|
|
|
! if ((i = ((10*(ldap_date[ds_off+2] - '0') + (ldap_date[ds_off+3] - '0')) - day)))
|
2000-04-01 08:27:45 +00:00
|
|
|
return i > 0;
|
2000-07-19 08:14:09 +00:00
|
|
|
! if ((i = ((10*(ldap_date[ds_off+4] - '0') + (ldap_date[ds_off+5] - '0')) - hour)))
|
2000-04-01 08:27:45 +00:00
|
|
|
return i > 0;
|
2000-07-19 08:14:09 +00:00
|
|
|
! if ((i = ((10*(ldap_date[ds_off+6] - '0') + (ldap_date[ds_off+7] - '0')) - min)))
|
2000-04-01 08:27:45 +00:00
|
|
|
return i > 0;
|
2000-07-19 08:14:09 +00:00
|
|
|
! if ((i = ((10*(ldap_date[ds_off+8] - '0') + (ldap_date[ds_off+9] - '0')) - sec)))
|
2000-04-01 08:27:45 +00:00
|
|
|
return i > 0;
|
|
|
|
|
|
|
|
/* gone so far - dates are identical */
|