diff options
author | Jose Bollo <jose.bollo@iot.bzh> | 2019-09-30 17:40:04 +0200 |
---|---|---|
committer | José Bollo <jose.bollo@iot.bzh> | 2019-10-03 12:35:01 +0200 |
commit | f161cd8b8b83a29f42c275fe31a96825a8d27d86 (patch) | |
tree | f13aaf40ea67fe0c4459a283dd0773a00752c740 /src/expire.h | |
parent | 6bf1b8c3a8af299c04d9be0d59b42c3a6d7c9127 (diff) |
Improve comments
Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src/expire.h')
-rw-r--r-- | src/expire.h | 45 |
1 files changed, 42 insertions, 3 deletions
diff --git a/src/expire.h b/src/expire.h index c9e46bc..1de82c2 100644 --- a/src/expire.h +++ b/src/expire.h @@ -14,8 +14,47 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #pragma once +/******************************************************************************/ +/******************************************************************************/ +/* CONVERTION OF EXPIRATIONS TO AND FROM TEXT */ +/******************************************************************************/ +/******************************************************************************/ + +/** + * Converts the time of the string to an expiration + * + * The string code a time relative to now using the format + * XXXyXXXwXXXdXXXhXXXmXXXs where XXX are numbers. + * + * Examples: + * - 15 means 15 seconds + * - 4h15m30s means 4 hours 15 minutes 30 seconds + * - forever means forever + * - 2m2w means two months and 2 weeks + * + * @param txt the text to convert + * @return the value for the text + */ +extern +time_t +txt2exp( + const char *txt +); -extern time_t txt2exp(const char *txt); -extern size_t exp2txt(time_t expire, char *buffer, size_t buflen); +/** + * Converts the expiration in to its relative string representation + * + * @param expire the epiration to convert + * @param buffer the buffer where to store the converted string + * @param buflen length of the buffer + * @return the length of the resulting string, can be greater than buflen but + * in that case, no more than buflen characters are copied to buffer + */ +extern +size_t +exp2txt( + time_t expire, + char *buffer, + size_t buflen +); |