Code

query language: Add support for attribute.value access.
[sysdb.git] / src / frontend / scanner.l
index c8d0dcbca25de94fe27196f7b1d65ff034370522..ab8b80daf560459822714f473ebc7a5adc76f21f 100644 (file)
@@ -59,6 +59,7 @@ static struct {
        { "FILTER",      FILTER },
        { "IN",          IN },
        { "IS",          IS },
+       { "LAST",        LAST },
        { "LIST",        LIST },
        { "LOOKUP",      LOOKUP },
        { "MATCHING",    MATCHING },
@@ -66,7 +67,9 @@ static struct {
        { "NULL",        NULL_T },
        { "OR",          OR },
        { "START",       START },
+       { "STORE",       STORE },
        { "TIMESERIES",  TIMESERIES },
+       { "UPDATE",      UPDATE },
 
        /* object types */
        { "host",        HOST_T },
@@ -83,6 +86,7 @@ static struct {
        { "age",         AGE_T },
        { "interval",    INTERVAL_T },
        { "backend",     BACKEND_T },
+       { "value",       VALUE_T },
 };
 
 void
@@ -210,6 +214,7 @@ time                ([0-9]{1,2}:[0-9]{1,2}(:[0-9]{1,2}(\.[0-9]{1,9})?)?)
                struct tm tm;
                char time[9], ns[10];
                char *tmp;
+               int t;
 
                memset(&tm, 0, sizeof(tm));
                memset(time, '\0', sizeof(time));
@@ -236,7 +241,7 @@ time                ([0-9]{1,2}:[0-9]{1,2}(:[0-9]{1,2}(\.[0-9]{1,9})?)?)
                assert(tmp);
                tmp = strchr(tmp + 1, ':');
                if (! tmp)
-                       strncat(time, ":00", sizeof(time));
+                       strncat(time, ":00", sizeof(time) - strlen(time) - 1);
 
                if (! strptime(time, "%H:%M:%S", &tm)) {
                        char errmsg[1024];
@@ -246,7 +251,8 @@ time                ([0-9]{1,2}:[0-9]{1,2}(:[0-9]{1,2}(\.[0-9]{1,9})?)?)
                        return SCANNER_ERROR;
                }
 
-               yylval->datetime = SECS_TO_SDB_TIME(mktime(&tm));
+               t = tm.tm_sec + 60 * tm.tm_min + 3600 * tm.tm_hour;
+               yylval->datetime = SECS_TO_SDB_TIME(t);
                yylval->datetime += (sdb_time_t)strtoll(ns, NULL, 10);
                return TIME;
        }
@@ -275,7 +281,7 @@ sdb_fe_scanner_init(const char *str, int len, sdb_fe_yyextra_t *yyext)
 
        if (sdb_fe_yylex_init(&scanner)) {
                char errbuf[1024];
-               sdb_log(SDB_LOG_ERR, "frontend: yylex_init failed: %s",
+               sdb_strbuf_sprintf(yyext->errbuf, "yylex_init_failed: %s",
                        sdb_strerror(errno, errbuf, sizeof(errbuf)));
                return NULL;
        }