| 690 | |
| 691 | |
| 692 | int pv_get_time(struct sip_msg *msg, pv_param_t *param, |
| 693 | pv_value_t *res) |
| 694 | { |
| 695 | static struct tm stored_ts; |
| 696 | static time_t stored_t = 0; |
| 697 | time_t t; |
| 698 | |
| 699 | if(msg==NULL || param==NULL) |
| 700 | return -1; |
| 701 | |
| 702 | t = time(NULL); |
| 703 | if (t!=stored_t) { |
| 704 | stored_t = t; |
| 705 | if (localtime_r(&t, &stored_ts) == NULL) { |
| 706 | LM_ERR("unable to break time to attributes\n"); |
| 707 | return -1; |
| 708 | } |
| 709 | } |
| 710 | |
| 711 | switch(param->pvn.u.isname.name.n) |
| 712 | { |
| 713 | case 1: |
| 714 | return pv_get_uintval(msg, param, res, (unsigned int)stored_ts.tm_min); |
| 715 | case 2: |
| 716 | return pv_get_uintval(msg, param, res, (unsigned int)stored_ts.tm_hour); |
| 717 | case 3: |
| 718 | return pv_get_uintval(msg, param, res, (unsigned int)stored_ts.tm_mday); |
| 719 | case 4: |
| 720 | return pv_get_uintval(msg, param, res, |
| 721 | (unsigned int)(stored_ts.tm_mon+1)); |
| 722 | case 5: |
| 723 | return pv_get_uintval(msg, param, res, |
| 724 | (unsigned int)(stored_ts.tm_year+1900)); |
| 725 | case 6: |
| 726 | return pv_get_uintval(msg, param, res, |
| 727 | (unsigned int)(stored_ts.tm_wday+1)); |
| 728 | case 7: |
| 729 | return pv_get_uintval(msg, param, res, |
| 730 | (unsigned int)(stored_ts.tm_yday+1)); |
| 731 | case 8: |
| 732 | return pv_get_sintval(msg, param, res, stored_ts.tm_isdst); |
| 733 | default: |
| 734 | return pv_get_uintval(msg, param, res, (unsigned int)stored_ts.tm_sec); |
| 735 | } |
| 736 | } |
| 737 |
nothing calls this directly
no test coverage detected