lib/getdate.c File Reference

#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <sys/types.h>
#include <time.h>

Go to the source code of this file.

Data Structures

struct  timeb
struct  _TABLE
union  YYSTYPE

Defines

#define YYBYACC   1
#define YYMAJOR   1
#define YYMINOR   9
#define YYLEX   yylex()
#define YYEMPTY   -1
#define yyclearin   (yychar=(YYEMPTY))
#define yyerrok   (yyerrflag=0)
#define YYRECOVERING()   (yyerrflag!=0)
#define YYPREFIX   "yy"
#define yyparse   getdate_yyparse
#define yylex   getdate_yylex
#define yyerror   getdate_yyerror
#define EPOCH   1970
#define HOUR(x)   ((time_t)(x) * 60)
#define SECSPERDAY   (24L * 60L * 60L)
#define YYERRCODE   256
#define tAGO   257
#define tDAY   258
#define tDAYZONE   259
#define tID   260
#define tMERIDIAN   261
#define tMINUTE_UNIT   262
#define tMONTH   263
#define tMONTH_UNIT   264
#define tSEC_UNIT   265
#define tSNUMBER   266
#define tUNUMBER   267
#define tZONE   268
#define tDST   269
#define YYTABLESIZE   337
#define YYFINAL   1
#define YYDEBUG   0
#define YYMAXTOKEN   269
#define YYSTACKSIZE   10000
#define YYMAXDEPTH   10000
#define YYINITSTACKSIZE   200
#define TM_YEAR_ORIGIN   1900
#define YYABORT   goto yyabort
#define YYREJECT   goto yyabort
#define YYACCEPT   goto yyaccept
#define YYERROR   goto yyerrlab
#define YYPARSE_PARAM_ARG
#define YYPARSE_PARAM_DECL

Typedefs

typedef _TABLE TABLE
typedef enum _DSTMODE DSTMODE
typedef enum _MERIDIAN MERIDIAN

Enumerations

enum  _DSTMODE { DSTon, DSToff, DSTmaybe }
enum  _MERIDIAN { MERam, MERpm, MER24 }

Functions

static int yygrowstack ()
time_t get_date (char *p, struct timeb *now)
static int getdate_yyparse (void)
static int getdate_yylex (void)
static int getdate_yyerror (const char *s)
static time_t ToSeconds (time_t Hours, time_t Minutes, time_t Seconds, MERIDIAN Meridian)
static time_t Convert (time_t Month, time_t Day, time_t Year, time_t Hours, time_t Minutes, time_t Seconds, MERIDIAN Meridian, DSTMODE DSTmode)
static time_t DSTcorrect (time_t Start, time_t Future)
static time_t RelativeDate (time_t Start, time_t DayOrdinal, time_t DayNumber)
static time_t RelativeMonth (time_t Start, time_t RelMonth)
static int LookupWord (char *buff)
static long difftm (const struct tm *a, const struct tm *b)

Variables

static char const yyrcsid [] = "$FreeBSD: src/usr.bin/yacc/skeleton.c,v 1.28 2000/01/17 02:04:06 bde Exp $"
static char * yyInput
static DSTMODE yyDSTmode
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 time_t yyDay
static time_t yyHour
static time_t yyMinutes
static time_t yyMonth
static time_t yySeconds
static time_t yyYear
static MERIDIAN yyMeridian
static time_t yyRelMonth
static time_t yyRelSeconds
static const short yylhs []
static const short yylen []
static const short yydefred []
static const short yydgoto []
static const short yysindex []
static const short yyrindex []
static const short yygindex []
static const short yytable []
static const short yycheck []
static int yydebug
static int yynerrs
static int yyerrflag
static int yychar
static short * yyssp
static YYSTYPEyyvsp
static YYSTYPE yyval
static YYSTYPE yylval
static short * yyss
static short * yysslim
static YYSTYPEyyvs
static int yystacksize
static TABLE const MonthDayTable []
static TABLE const UnitsTable []
static TABLE const OtherTable []
static TABLE const TimezoneTable []
static TABLE const MilitaryTable []


Define Documentation

#define EPOCH   1970

Definition at line 149 of file getdate.c.

Referenced by Convert().

#define HOUR (  )     ((time_t)(x) * 60)

Definition at line 150 of file getdate.c.

#define SECSPERDAY   (24L * 60L * 60L)

Definition at line 151 of file getdate.c.

Referenced by Convert(), and RelativeDate().

#define tAGO   257

Definition at line 212 of file getdate.c.

#define tDAY   258

Definition at line 213 of file getdate.c.

#define tDAYZONE   259

Definition at line 214 of file getdate.c.

#define tDST   269

Definition at line 224 of file getdate.c.

#define tID   260

Definition at line 215 of file getdate.c.

#define TM_YEAR_ORIGIN   1900

Definition at line 908 of file getdate.c.

Referenced by difftm().

#define tMERIDIAN   261

Definition at line 216 of file getdate.c.

Referenced by LookupWord().

#define tMINUTE_UNIT   262

Definition at line 217 of file getdate.c.

#define tMONTH   263

Definition at line 218 of file getdate.c.

#define tMONTH_UNIT   264

Definition at line 219 of file getdate.c.

#define tSEC_UNIT   265

Definition at line 220 of file getdate.c.

#define tSNUMBER   266

Definition at line 221 of file getdate.c.

Referenced by getdate_yylex().

#define tUNUMBER   267

Definition at line 222 of file getdate.c.

Referenced by getdate_yylex().

#define tZONE   268

Definition at line 223 of file getdate.c.

#define YYABORT   goto yyabort

Definition at line 1089 of file getdate.c.

#define YYACCEPT   goto yyaccept

Definition at line 1091 of file getdate.c.

#define YYBYACC   1

Definition at line 12 of file getdate.c.

#define yyclearin   (yychar=(YYEMPTY))

Definition at line 17 of file getdate.c.

#define YYDEBUG   0

Definition at line 341 of file getdate.c.

Referenced by getdate_yyparse().

#define YYEMPTY   -1

Definition at line 16 of file getdate.c.

#define YYERRCODE   256

Definition at line 211 of file getdate.c.

Referenced by getdate_yyparse().

#define yyerrok   (yyerrflag=0)

Definition at line 18 of file getdate.c.

#define YYERROR   goto yyerrlab

Definition at line 1092 of file getdate.c.

#define yyerror   getdate_yyerror

Definition at line 143 of file getdate.c.

Referenced by getdate_yyparse().

#define YYFINAL   1

Definition at line 339 of file getdate.c.

Referenced by getdate_yyparse().

#define YYINITSTACKSIZE   200

Definition at line 415 of file getdate.c.

Referenced by yygrowstack().

#define yylex   getdate_yylex

Definition at line 142 of file getdate.c.

Referenced by getdate_yyparse().

#define YYLEX   yylex()

Definition at line 15 of file getdate.c.

#define YYMAJOR   1

Definition at line 13 of file getdate.c.

#define YYMAXDEPTH   10000

Definition at line 412 of file getdate.c.

Referenced by yygrowstack().

#define YYMAXTOKEN   269

Definition at line 343 of file getdate.c.

Referenced by getdate_yyparse().

#define YYMINOR   9

Definition at line 14 of file getdate.c.

#define yyparse   getdate_yyparse

Definition at line 141 of file getdate.c.

Referenced by get_date().

#define YYPARSE_PARAM_ARG

Definition at line 1099 of file getdate.c.

#define YYPARSE_PARAM_DECL

Definition at line 1100 of file getdate.c.

#define YYPREFIX   "yy"

Definition at line 21 of file getdate.c.

Referenced by getdate_yyparse().

 
#define YYRECOVERING (  )     (yyerrflag!=0)

Definition at line 19 of file getdate.c.

#define YYREJECT   goto yyabort

Definition at line 1090 of file getdate.c.

#define YYSTACKSIZE   10000

Definition at line 411 of file getdate.c.

#define YYTABLESIZE   337

Definition at line 266 of file getdate.c.

Referenced by getdate_yyparse().


Typedef Documentation

typedef enum _DSTMODE DSTMODE

typedef enum _MERIDIAN MERIDIAN

typedef struct _TABLE TABLE


Enumeration Type Documentation

enum _DSTMODE

Enumerator:
DSTon 
DSToff 
DSTmaybe 

Definition at line 167 of file getdate.c.

enum _MERIDIAN

Enumerator:
MERam 
MERpm 
MER24 

Definition at line 174 of file getdate.c.


Function Documentation

static time_t Convert ( time_t  Month,
time_t  Day,
time_t  Year,
time_t  Hours,
time_t  Minutes,
time_t  Seconds,
MERIDIAN  Meridian,
DSTMODE  DSTmode 
) [static]

Definition at line 659 of file getdate.c.

References DSTmaybe, DSTon, EPOCH, SECSPERDAY, ToSeconds(), and yyTimezone.

Referenced by get_date(), and RelativeMonth().

static long difftm ( const struct tm *  a,
const struct tm *  b 
) [static]

Definition at line 912 of file getdate.c.

References TM_YEAR_ORIGIN.

Referenced by get_date().

static time_t DSTcorrect ( time_t  Start,
time_t  Future 
) [static]

Definition at line 703 of file getdate.c.

Referenced by RelativeDate(), and RelativeMonth().

time_t get_date ( char *  p,
struct timeb now 
)

Definition at line 932 of file getdate.c.

References Convert(), difftm(), DSTmaybe, MER24, RelativeDate(), RelativeMonth(), timeb::time, timeb::timezone, yyDay, yyDayNumber, yyDayOrdinal, yyDSTmode, yyHaveDate, yyHaveDay, yyHaveRel, yyHaveTime, yyHaveZone, yyHour, yyInput, yyMeridian, yyMinutes, yyMonth, yyparse, yyRelMonth, yyRelSeconds, yySeconds, yyTimezone, and yyYear.

Referenced by installArgCallback().

static int getdate_yyerror ( const char *  s  )  [static]

Definition at line 619 of file getdate.c.

static int getdate_yylex ( void   )  [static]

Definition at line 855 of file getdate.c.

References LookupWord(), YYSTYPE::Number, tSNUMBER, tUNUMBER, yyInput, and yylval.

int getdate_yyparse ( void   )  [static]

Definition at line 1116 of file getdate.c.

References DSToff, DSTon, getenv(), MER24, YYSTYPE::Meridian, YYSTYPE::Number, yychar, yycheck, yyDay, yyDayNumber, yyDayOrdinal, YYDEBUG, yydebug, yydefred, yydgoto, yyDSTmode, YYERRCODE, yyerrflag, yyerror, YYFINAL, yygindex, yygrowstack(), yyHaveDate, yyHaveDay, yyHaveRel, yyHaveTime, yyHaveZone, yyHour, yylen, yylex, yylhs, yylval, YYMAXTOKEN, yyMeridian, yyMinutes, yyMonth, yynerrs, YYPREFIX, yyRelMonth, yyRelSeconds, yyrindex, yySeconds, yysindex, yyss, yysslim, yyssp, yytable, YYTABLESIZE, yyTimezone, yyval, yyvs, yyvsp, and yyYear.

static int LookupWord ( char *  buff  )  [static]

Definition at line 749 of file getdate.c.

References MERam, YYSTYPE::Meridian, MERpm, MonthDayTable, _TABLE::name, YYSTYPE::Number, tMERIDIAN, _TABLE::type, _TABLE::value, and yylval.

Referenced by getdate_yylex().

static time_t RelativeDate ( time_t  Start,
time_t  DayOrdinal,
time_t  DayNumber 
) [static]

Definition at line 715 of file getdate.c.

References DSTcorrect(), and SECSPERDAY.

Referenced by get_date().

static time_t RelativeMonth ( time_t  Start,
time_t  RelMonth 
) [static]

Definition at line 729 of file getdate.c.

References Convert(), DSTcorrect(), DSTmaybe, and MER24.

Referenced by get_date().

static time_t ToSeconds ( time_t  Hours,
time_t  Minutes,
time_t  Seconds,
MERIDIAN  Meridian 
) [static]

Definition at line 626 of file getdate.c.

References MER24, MERam, and MERpm.

Referenced by Convert().

static int yygrowstack (  )  [static]

Definition at line 1059 of file getdate.c.

References YYINITSTACKSIZE, YYMAXDEPTH, yyss, yysslim, yyssp, yystacksize, yyvs, and yyvsp.

Referenced by getdate_yyparse().


Variable Documentation

TABLE const MilitaryTable[] [static]

Initial value:

 {
    { "a",       268 ,  ((time_t)( 1 ) * 60) },
    { "b",       268 ,  ((time_t)( 2 ) * 60) },
    { "c",       268 ,  ((time_t)( 3 ) * 60) },
    { "d",       268 ,  ((time_t)( 4 ) * 60) },
    { "e",       268 ,  ((time_t)( 5 ) * 60) },
    { "f",       268 ,  ((time_t)( 6 ) * 60) },
    { "g",       268 ,  ((time_t)( 7 ) * 60) },
    { "h",       268 ,  ((time_t)( 8 ) * 60) },
    { "i",       268 ,  ((time_t)( 9 ) * 60) },
    { "k",       268 ,  ((time_t)( 10 ) * 60) },
    { "l",       268 ,  ((time_t)( 11 ) * 60) },
    { "m",       268 ,  ((time_t)( 12 ) * 60) },
    { "n",       268 ,  ((time_t)( - 1 ) * 60) },
    { "o",       268 ,  ((time_t)( - 2 ) * 60) },
    { "p",       268 ,  ((time_t)( - 3 ) * 60) },
    { "q",       268 ,  ((time_t)( - 4 ) * 60) },
    { "r",       268 ,  ((time_t)( - 5 ) * 60) },
    { "s",       268 ,  ((time_t)( - 6 ) * 60) },
    { "t",       268 ,  ((time_t)( - 7 ) * 60) },
    { "u",       268 ,  ((time_t)( - 8 ) * 60) },
    { "v",       268 ,  ((time_t)( - 9 ) * 60) },
    { "w",       268 ,  ((time_t)( -10 ) * 60) },
    { "x",       268 ,  ((time_t)( -11 ) * 60) },
    { "y",       268 ,  ((time_t)( -12 ) * 60) },
    { "z",       268 ,  ((time_t)( 0 ) * 60) },
    { NULL, 0, 0 }
}

Definition at line 585 of file getdate.c.

TABLE const MonthDayTable[] [static]

Initial value:

 {
    { "january",         263 ,  1 },
    { "february",        263 ,  2 },
    { "march",           263 ,  3 },
    { "april",           263 ,  4 },
    { "may",             263 ,  5 },
    { "june",            263 ,  6 },
    { "july",            263 ,  7 },
    { "august",          263 ,  8 },
    { "september",       263 ,  9 },
    { "sept",            263 ,  9 },
    { "october",         263 , 10 },
    { "november",        263 , 11 },
    { "december",        263 , 12 },
    { "sunday",          258 , 0 },
    { "monday",          258 , 1 },
    { "tuesday",         258 , 2 },
    { "tues",            258 , 2 },
    { "wednesday",       258 , 3 },
    { "wednes",          258 , 3 },
    { "thursday",        258 , 4 },
    { "thur",            258 , 4 },
    { "thurs",           258 , 4 },
    { "friday",          258 , 5 },
    { "saturday",        258 , 6 },
    { NULL, 0, 0 }
}

Definition at line 431 of file getdate.c.

Referenced by LookupWord().

TABLE const OtherTable[] [static]

Initial value:

 {
    { "tomorrow",        262 ,  1 * 24 * 60 },
    { "yesterday",       262 ,  -1 * 24 * 60 },
    { "today",           262 ,  0 },
    { "now",             262 ,  0 },
    { "last",            267 ,  -1 },
    { "this",            262 ,  0 },
    { "next",            267 ,  2 },
    { "first",           267 ,  1 },

    { "third",           267 ,  3 },
    { "fourth",          267 ,  4 },
    { "fifth",           267 ,  5 },
    { "sixth",           267 ,  6 },
    { "seventh",         267 ,  7 },
    { "eighth",          267 ,  8 },
    { "ninth",           267 ,  9 },
    { "tenth",           267 ,  10 },
    { "eleventh",        267 ,  11 },
    { "twelfth",         267 ,  12 },
    { "ago",             257 ,  1 },
    { NULL, 0, 0 }
}

Definition at line 475 of file getdate.c.

TABLE const TimezoneTable[] [static]

Definition at line 501 of file getdate.c.

TABLE const UnitsTable[] [static]

Initial value:

 {
    { "year",            264 ,  12 },
    { "month",           264 ,  1 },
    { "fortnight",       262 ,  14 * 24 * 60 },
    { "week",            262 ,  7 * 24 * 60 },
    { "day",             262 ,  1 * 24 * 60 },
    { "hour",            262 ,  60 },
    { "minute",          262 ,  1 },
    { "min",             262 ,  1 },
    { "second",          265 ,  1 },
    { "sec",             265 ,  1 },
    { NULL, 0, 0 }
}

Definition at line 460 of file getdate.c.

int yychar [static]

Definition at line 419 of file getdate.c.

Referenced by getdate_yyparse().

const short yycheck[] [static]

Definition at line 303 of file getdate.c.

Referenced by getdate_yyparse().

time_t yyDay [static]

Definition at line 195 of file getdate.c.

Referenced by get_date(), and getdate_yyparse().

time_t yyDayNumber [static]

Definition at line 188 of file getdate.c.

Referenced by get_date(), and getdate_yyparse().

time_t yyDayOrdinal [static]

Definition at line 187 of file getdate.c.

Referenced by get_date(), and getdate_yyparse().

int yydebug [static]

Definition at line 416 of file getdate.c.

Referenced by getdate_yyparse().

const short yydefred[] [static]

Initial value:

 {                                      1,
    0,    0,   15,   32,    0,   38,   35,    0,    0,    0,
    2,    3,    4,    5,    6,    7,    8,    0,   18,    0,
   31,   36,   33,   19,    9,   30,    0,   37,   34,    0,
    0,    0,   16,   28,    0,   23,   27,   22,    0,    0,
   25,   41,   11,    0,   10,    0,    0,   21,   13,   12,
}

Definition at line 239 of file getdate.c.

Referenced by getdate_yyparse().

const short yydgoto[] [static]

Initial value:

 {                                       1,
   45,   11,   12,   13,   14,   15,   16,   17,   18,
}

Definition at line 246 of file getdate.c.

Referenced by getdate_yyparse().

DSTMODE yyDSTmode [static]

Definition at line 186 of file getdate.c.

Referenced by get_date(), and getdate_yyparse().

int yyerrflag [static]

Definition at line 418 of file getdate.c.

Referenced by getdate_yyparse().

const short yygindex[] [static]

Initial value:

 {                                      0,
  -17,    0,    0,    0,    0,    0,    0,    0,    0,
}

Definition at line 263 of file getdate.c.

Referenced by getdate_yyparse().

int yyHaveDate [static]

Definition at line 189 of file getdate.c.

Referenced by get_date(), and getdate_yyparse().

int yyHaveDay [static]

Definition at line 190 of file getdate.c.

Referenced by get_date(), and getdate_yyparse().

int yyHaveRel [static]

Definition at line 191 of file getdate.c.

Referenced by get_date(), and getdate_yyparse().

int yyHaveTime [static]

Definition at line 192 of file getdate.c.

Referenced by get_date(), and getdate_yyparse().

int yyHaveZone [static]

Definition at line 193 of file getdate.c.

Referenced by get_date(), and getdate_yyparse().

time_t yyHour [static]

Definition at line 196 of file getdate.c.

Referenced by get_date(), and getdate_yyparse().

char* yyInput [static]

Definition at line 185 of file getdate.c.

Referenced by get_date(), and getdate_yylex().

const short yylen[] [static]

Initial value:

 {                                         2,
    0,    2,    1,    1,    1,    1,    1,    1,    2,    4,
    4,    6,    6,    1,    1,    2,    1,    2,    2,    3,
    5,    3,    3,    2,    4,    2,    3,    2,    1,    2,
    2,    1,    2,    2,    1,    2,    2,    1,    1,    0,
    1,
}

Definition at line 232 of file getdate.c.

Referenced by getdate_yyparse().

const short yylhs[] [static]

Initial value:

 {                                        -1,
    0,    0,    2,    2,    2,    2,    2,    2,    3,    3,
    3,    3,    3,    4,    4,    4,    6,    6,    6,    5,
    5,    5,    5,    5,    5,    5,    5,    7,    7,    9,
    9,    9,    9,    9,    9,    9,    9,    9,    8,    1,
    1,
}

Definition at line 225 of file getdate.c.

Referenced by getdate_yyparse().

YYSTYPE yylval [static]

Definition at line 423 of file getdate.c.

Referenced by getdate_yylex(), getdate_yyparse(), and LookupWord().

MERIDIAN yyMeridian [static]

Definition at line 201 of file getdate.c.

Referenced by get_date(), and getdate_yyparse().

time_t yyMinutes [static]

Definition at line 197 of file getdate.c.

Referenced by get_date(), and getdate_yyparse().

time_t yyMonth [static]

Definition at line 198 of file getdate.c.

Referenced by get_date(), and getdate_yyparse().

int yynerrs [static]

Definition at line 417 of file getdate.c.

Referenced by getdate_yyparse().

char const yyrcsid[] = "$FreeBSD: src/usr.bin/yacc/skeleton.c,v 1.28 2000/01/17 02:04:06 bde Exp $" [static]

Definition at line 9 of file getdate.c.

time_t yyRelMonth [static]

Definition at line 202 of file getdate.c.

Referenced by get_date(), and getdate_yyparse().

time_t yyRelSeconds [static]

Definition at line 203 of file getdate.c.

Referenced by get_date(), and getdate_yyparse().

const short yyrindex[] [static]

Initial value:

 {                                      0,
    0,    1,    0,    0,    0,    0,    0,    0,   69,   12,
    0,    0,    0,    0,    0,    0,    0,   23,    0,   34,
    0,    0,    0,    0,    0,    0,   67,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,   56,   45,
    0,    0,    0,    0,    0,    0,   56,    0,    0,    0,
}

Definition at line 256 of file getdate.c.

Referenced by getdate_yyparse().

time_t yySeconds [static]

Definition at line 199 of file getdate.c.

Referenced by get_date(), and getdate_yyparse().

const short yysindex[] [static]

Initial value:

 {                                      0,
 -249,  -38,    0,    0, -260,    0,    0, -240,  -47, -248,
    0,    0,    0,    0,    0,    0,    0, -237,    0,  -18,
    0,    0,    0,    0,    0,    0, -262,    0,    0, -239,
 -238, -236,    0,    0, -235,    0,    0,    0,  -56,  -19,
    0,    0,    0, -234,    0, -232, -258,    0,    0,    0,
}

Definition at line 249 of file getdate.c.

Referenced by getdate_yyparse().

short* yyss [static]

Definition at line 424 of file getdate.c.

Referenced by getdate_yyparse(), and yygrowstack().

short* yysslim [static]

Definition at line 425 of file getdate.c.

Referenced by getdate_yyparse(), and yygrowstack().

short* yyssp [static]

Definition at line 420 of file getdate.c.

Referenced by getdate_yyparse(), and yygrowstack().

int yystacksize [static]

Definition at line 427 of file getdate.c.

Referenced by yygrowstack().

const short yytable[] [static]

Definition at line 267 of file getdate.c.

Referenced by getdate_yyparse().

time_t yyTimezone [static]

Definition at line 194 of file getdate.c.

Referenced by Convert(), get_date(), and getdate_yyparse().

YYSTYPE yyval [static]

Definition at line 422 of file getdate.c.

Referenced by getdate_yyparse().

YYSTYPE* yyvs [static]

Definition at line 426 of file getdate.c.

Referenced by getdate_yyparse(), and yygrowstack().

YYSTYPE* yyvsp [static]

Definition at line 421 of file getdate.c.

Referenced by getdate_yyparse(), and yygrowstack().

time_t yyYear [static]

Definition at line 200 of file getdate.c.

Referenced by get_date(), and getdate_yyparse().


Generated on Mon Mar 5 13:44:10 2007 for rpm by  doxygen 1.5.1