diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2006-02-08 03:20:03 +0000 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2006-02-08 03:20:03 +0000 |
commit | c5f81f1139c33eccc59146d45893c8037d63e94f (patch) | |
tree | d7ea60cae20cdc918a959a72f2808199426a7c31 /hcid/storage.c | |
parent | a1018ae90706783c45c1c3814af3354b4b5504c8 (diff) |
Add support for last seen information
Diffstat (limited to 'hcid/storage.c')
-rw-r--r-- | hcid/storage.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/hcid/storage.c b/hcid/storage.c index 02c5dc0c..063b6952 100644 --- a/hcid/storage.c +++ b/hcid/storage.c @@ -32,6 +32,7 @@ #include <unistd.h> #include <stdlib.h> #include <malloc.h> +#include <time.h> #include <sys/file.h> #include <sys/stat.h> #include <sys/param.h> @@ -120,6 +121,22 @@ int write_features_info(bdaddr_t *local, bdaddr_t *peer, unsigned char *features return textfile_put(filename, addr, str); } +int write_lastseen_info(bdaddr_t *local, bdaddr_t *peer, struct tm *tm) +{ + char filename[PATH_MAX + 1], addr[18], str[24]; + + memset(str, 0, sizeof(str)); + strftime(str, sizeof(str), "%Y-%m-%d %H:%M:%S %Z", tm); + + ba2str(local, addr); + snprintf(filename, PATH_MAX, "%s/%s/lastseen", STORAGEDIR, addr); + + create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + + ba2str(peer, addr); + return textfile_put(filename, addr, str); +} + int write_link_key(bdaddr_t *local, bdaddr_t *peer, unsigned char *key, int type) { char filename[PATH_MAX + 1], addr[18], str[35]; |