* \brief Helper for checking cache timeout * \param tv pointer to timeval, date of cache * \param timeout duration of cache validity, in millisec * \return 1 when timed out, 0 when cache shall be used */
| 1858 | * \return 1 when timed out, 0 when cache shall be used |
| 1859 | */ |
| 1860 | int HAMLIB_API rig_check_cache_timeout(const struct timeval *tv, int timeout) |
| 1861 | { |
| 1862 | struct timeval curr; |
| 1863 | long t; |
| 1864 | |
| 1865 | rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); |
| 1866 | |
| 1867 | if (tv->tv_sec == 0 && tv->tv_usec == 0) |
| 1868 | { |
| 1869 | rig_debug(RIG_DEBUG_VERBOSE, |
| 1870 | "%s: forced cache timeout\n", |
| 1871 | __func__); |
| 1872 | return 1; |
| 1873 | } |
| 1874 | |
| 1875 | gettimeofday(&curr, NULL); |
| 1876 | |
| 1877 | t = timediff(&curr, tv); |
| 1878 | |
| 1879 | if (t < timeout) |
| 1880 | { |
| 1881 | rig_debug(RIG_DEBUG_VERBOSE, |
| 1882 | "%s: using cache (%ld ms)\n", |
| 1883 | __func__, |
| 1884 | t); |
| 1885 | return 0; |
| 1886 | } |
| 1887 | else |
| 1888 | { |
| 1889 | rig_debug(RIG_DEBUG_VERBOSE, |
| 1890 | "%s: cache timed out (%ld ms)\n", |
| 1891 | __func__, |
| 1892 | t); |
| 1893 | return 1; |
| 1894 | } |
| 1895 | } |
| 1896 | |
| 1897 | |
| 1898 | /** |
no test coverage detected