%{
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/* $OrigRevision: 2.1 $
**
** Originally written by Steven M. Bellovin <smb@research.att.com> while
** at the University of North Carolina at Chapel Hill. Later tweaked by
** a couple of people on Usenet. Completely overhauled by Rich $alz
** <rsalz@bbn.com> and Jim Berets <jberets@bbn.com> in August, 1990;
** send any email to Rich.
**
**
** This code is in the public domain and has no copyright.
*/
/* SUPPRESS 287 on yaccpar_sccsid *//* Unusd static variable */
/* SUPPRESS 288 on yyerrlab *//* Label unused */
#include <stdio.h>
#include <ctype.h>
#define NEED_TZSET
struct timeb {
unsigned short millitm; /* Field not used */
short timezone;
short dstflag; /* Field not used */
};
#include <time.h>
#include <locale.h>
#include <string.h>
#include <stdlib.h>
#include <note.h>
#include <libintl.h>
static char RCS[] =
"$Header: /home/laramie/berliner/ws/backup/usr/src/cmd/backup/lib/getdate.y,v 1.5 1992/06/09 21:46:21 sam Exp $";
#endif /* !defined(lint) && !defined(SABER) */
#define EPOCH 1970
#define HOURN(x) (x * 60)
/*
** An entry in the lexical lookup table.
*/
typedef struct _TABLE {
char *name;
int type;
} TABLE;
/*
** Daylight-savings mode: on, off, or not yet known.
*/
typedef enum _DSTMODE {
} DSTMODE;
/*
** Meridian: am, pm, or 24-hour style.
*/
typedef enum _MERIDIAN {
} MERIDIAN;
/*
** Global variables. We could get rid of most of these by using a good
** union as the yacc stack. (This routine was originally written before
** yacc had the %union construct.) Maybe someday; right now we only use
** the %union very rarely.
*/
static char *yyInput;
static time_t yyDayOrdinal;
static time_t yyDayNumber;
static int yyHaveDate;
static int yyHaveDay;
static int yyHaveRel;
static int yyHaveTime;
static int yyHaveZone;
static time_t yyTimezone;
static MERIDIAN yyMeridian;
static time_t yyRelMonth;
static time_t yyRelSeconds;
%}
%union {
}
%%
;
yyHaveTime++;
}
| zone {
yyHaveZone++;
}
| date {
yyHaveDate++;
}
| day {
yyHaveDay++;
}
| rel {
yyHaveRel++;
}
| number
;
yyHour = $1;
yyMinutes = 0;
yySeconds = 0;
yyMeridian = $2;
}
yyHour = $1;
yyMinutes = $3;
yySeconds = 0;
yyMeridian = $4;
}
yyHour = $1;
yyMinutes = $3;
yyMeridian = MER24;
}
yyHour = $1;
yyMinutes = $3;
yySeconds = $5;
yyMeridian = $6;
}
yyHour = $1;
yyMinutes = $3;
yySeconds = $5;
yyMeridian = MER24;
}
;
yyTimezone = $1;
}
| tDAYZONE {
yyTimezone = $1;
}
;
yyDayOrdinal = 1;
yyDayNumber = $1;
}
| tDAY ',' {
yyDayOrdinal = 1;
yyDayNumber = $1;
}
yyDayOrdinal = $1;
yyDayNumber = $2;
}
;
yyMonth = $1;
yyDay = $3;
}
yyMonth = $1;
yyDay = $3;
yyYear = $5;
}
yyMonth = $1;
yyDay = $2;
}
yyMonth = $1;
yyDay = $2;
yyYear = $4;
}
yyMonth = $2;
yyDay = $1;
}
yyMonth = $2;
yyDay = $1;
yyYear = $3;
}
;
yyRelMonth = -yyRelMonth;
}
| relunit
;
}
| tSNUMBER tMINUTE_UNIT {
}
| tMINUTE_UNIT {
}
yyRelSeconds += $1;
}
yyRelSeconds += $1;
}
| tSEC_UNIT {
yyRelSeconds++;
}
| tSNUMBER tMONTH_UNIT {
}
| tUNUMBER tMONTH_UNIT {
}
| tMONTH_UNIT {
yyRelMonth += $1;
}
;
yyYear = $1;
else {
yyHaveTime++;
if ($1 < 100) {
yyHour = $1;
yyMinutes = 0;
}
else {
}
yySeconds = 0;
yyMeridian = MER24;
}
}
;
$$ = MER24;
}
| tMERIDIAN {
$$ = $1;
}
;
%%
/* Month and day table. */
static TABLE MonthDayTable[] = {
{ "sunday", tDAY, 0 },
{ NULL }
};
/* Time units table. */
static TABLE UnitsTable[] = {
{ NULL }
};
/* Assorted relative-time words. */
static TABLE OtherTable[] = {
{ "today", tMINUTE_UNIT, 0 },
{ "now", tMINUTE_UNIT, 0 },
{ "this", tMINUTE_UNIT, 0 },
/* { "second", tUNUMBER, 2 }, */
{ NULL }
};
/* The timezone table. */
static TABLE TimezoneTable[] = {
#if 0
/* For completeness. BST is also British Summer, and GST is
* also Guam Standard. */
#endif
#if 0
/* For completeness. NST is also Newfoundland Stanard, nad SST is
* also Swedish Summer. */
#endif /* 0 */
{ NULL }
};
/* Military timezone table. */
static TABLE MilitaryTable[] = {
{ NULL }
};
/* ARGSUSED */
static void
yyerror(s)
char *s;
{
}
static time_t
{
return -1;
switch (Meridian) {
case MER24:
return -1;
case MERam:
return -1;
if (Hours != 12)
else
case MERpm:
return -1;
if (Hours != 12)
else
}
/* NOTREACHED */
return (-1);
}
static time_t
{
static int DaysInMonth[12] = {
31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
};
time_t i;
if (Year < 0)
if (Year < 138)
Year += 1900;
? 29 : 28;
/* LINTED Month is a time_t so intermediate results aren't truncated */
return -1;
Julian += DaysInMonth[i];
Julian *= SECSPERDAY;
return -1;
return Julian;
}
static time_t
{
}
static time_t
{
}
static time_t
{
if (RelMonth == 0)
return 0;
return DSTcorrect(Start,
}
static int
char *buff;
{
char *p;
char *q;
uint_t i;
int abbrev;
/* Make it lowercase. */
for (p = buff; *p; p++)
*p = tolower(*p);
return tMERIDIAN;
}
return tMERIDIAN;
}
/* See if we have an abbreviation for a month. */
abbrev = 1;
abbrev = 1;
}
else
abbrev = 0;
if (abbrev) {
}
}
}
}
}
}
/* Strip off any plural and try the units table again. */
if (buff[i] == 's') {
buff[i] = '\0';
}
}
}
/* Military timezones. */
}
}
/* Drop out any periods and try the timezone table again. */
for (i = 0, p = q = buff; *q; q++)
if (*q != '.')
*p++ = *q;
else
i++;
*p = '\0';
if (i)
}
return tID;
}
void
pdateerr(p)
char *p;
{
char *value;
if (value == (char *)0) {
p, name);
return;
}
switch (getdate_err) {
case 0:
default:
break;
case 1:
break;
case 2:
"%s: Cannot read template file %s\n"), p, value);
break;
case 3:
"%s: Failed to get file status information\n"), p);
break;
case 4:
"%s: Template file %s not a regular file\n"), p, value);
break;
case 5:
"%s: Error reading template file %s\n"), p, value);
break;
case 6:
"%s: %s failed\n"), p, "malloc()");
break;
case 7:
break;
"The following are examples of valid formats:\n"));
continue;
}
break;
case 8:
"%s: Invalid date specification\n"), p);
break;
}
}
static int
yylex()
{
char c;
char *p;
char buff[20];
int Count;
int sign;
for ( ; ; ) {
yyInput++;
if (c == '-' || c == '+') {
/* skip the '-' sign */
continue;
}
else
sign = 0;
int n;
char digit = c;
}
yyInput--;
if (sign < 0)
}
*p++ = c;
*p = '\0';
yyInput--;
return LookupWord(buff);
}
if (c != '(')
return *yyInput++;
Count = 0;
do {
c = *yyInput++;
if (c == '\0')
return c;
if (c == '(')
Count++;
else if (c == ')')
Count--;
} while (Count > 0);
}
}
getreldate(p, now)
char *p;
{
static char localedate[24];
do {
return(-1);
}
return(-1);
p = localedate;
}
yyInput = p;
/* Set the timezone global. */
tzset();
/* LINTED timezone is time_t so intermediate results aren't truncated */
}
yyMeridian = MER24;
yyRelSeconds = 0;
yyRelMonth = 0;
yyHaveDate = 0;
yyHaveDay = 0;
yyHaveRel = 0;
yyHaveTime = 0;
yyHaveZone = 0;
if (yyparse()
return -1;
if (Start < 0)
return -1;
}
else {
if (!yyHaveRel)
}
Start += yyRelSeconds;
if (yyHaveDay && !yyHaveDate) {
}
/* Have to do *something* with a legitimate -1 so it's distinguishable
* from the error return value. (Alternately could set errno on error.) */
}
#if defined(TEST)
/* ARGSUSED */
int ac;
char *av[];
{
char buff[128];
time_t d;
#if !defined(TEXT_DOMAIN)
#define TEXT_DOMAIN "SYS_TEST"
#endif
(void) textdomain(TEXT_DOMAIN);
if (d == -1)
else {
}
(void) printf("\t> ");
}
exit(0);
/* NOTREACHED */
}
#endif /* defined(TEST) */