| 420 | |
| 421 | |
| 422 | int msValidateTimeValue(char *timestring, const char *timeextent) |
| 423 | { |
| 424 | char **atimes = NULL; |
| 425 | int i, numtimes=0; |
| 426 | |
| 427 | /* we need to validate the time passsed in the request */ |
| 428 | /* against the time extent defined */ |
| 429 | |
| 430 | if (!timestring || !timeextent) |
| 431 | return MS_FALSE; |
| 432 | |
| 433 | |
| 434 | /* parse the time string. We support descrete times (eg 2004-09-21), */ |
| 435 | /* multiple times (2004-09-21, 2004-09-22, ...) */ |
| 436 | /* and range(s) (2004-09-21/2004-09-25, 2004-09-27/2004-09-29) */ |
| 437 | if (strstr(timestring, ",") == NULL && |
| 438 | strstr(timestring, "/") == NULL) /* discrete time */ |
| 439 | { |
| 440 | return _msValidateTime(timestring, timeextent); |
| 441 | |
| 442 | } |
| 443 | else |
| 444 | { |
| 445 | atimes = msStringSplit (timestring, ',', &numtimes); |
| 446 | if (numtimes >=1) /* multiple times */ |
| 447 | { |
| 448 | |
| 449 | if (strstr(atimes[0], "/") == NULL) /* multiple descrete times */ |
| 450 | { |
| 451 | for (i=0; i<numtimes; i++) |
| 452 | { |
| 453 | if (_msValidateTime(atimes[i], timeextent) == MS_FALSE) |
| 454 | { |
| 455 | msFreeCharArray(atimes, numtimes); |
| 456 | return MS_FALSE; |
| 457 | } |
| 458 | } |
| 459 | msFreeCharArray(atimes, numtimes); |
| 460 | return MS_TRUE; |
| 461 | } |
| 462 | else /* multiple ranges */ |
| 463 | { |
| 464 | for (i=0; i<numtimes; i++) |
| 465 | { |
| 466 | if (_msValidateTime(atimes[i], timeextent) == MS_FALSE) |
| 467 | { |
| 468 | msFreeCharArray(atimes, numtimes); |
| 469 | return MS_FALSE; |
| 470 | } |
| 471 | |
| 472 | } |
| 473 | msFreeCharArray(atimes, numtimes); |
| 474 | return MS_TRUE; |
| 475 | } |
| 476 | |
| 477 | } |
| 478 | |
| 479 | } |
no test coverage detected