36 lines
1.0 KiB
C
36 lines
1.0 KiB
C
#ifndef _ADDRBOOK_H_
|
|
#define _ADDRBOOK_H_
|
|
|
|
#include "crypt.h"
|
|
#include <netinet/in.h>
|
|
|
|
typedef struct addrbook_entry_t {
|
|
char pubk[CRYPT_PKEY_HEXLEN];
|
|
char *alias;
|
|
char *last_addr;
|
|
char *last_port;
|
|
unsigned char alias_len;
|
|
unsigned char last_addr_len;
|
|
unsigned char last_port_len;
|
|
} addrbook_entry_t;
|
|
|
|
char *addrbook_entry_to_string(const addrbook_entry_t *const ent);
|
|
int addrbook_entry_from_string(addrbook_entry_t *const ent, char * str);
|
|
|
|
typedef struct addrbook_t {
|
|
addrbook_entry_t *entries;
|
|
size_t entries_len;
|
|
size_t entries_cap;
|
|
} addrbook_t;
|
|
|
|
|
|
int addrbook_load(addrbook_t *ab, FILE *in);
|
|
int addrbook_store(addrbook_t *ab, FILE *out);
|
|
void addrbook_destroy(addrbook_t *const ab);
|
|
|
|
int addrbook_add(addrbook_t *const ab, const addrbook_entry_t *const ent);
|
|
addrbook_entry_t *addrbook_get_by_pk(const addrbook_t *const ab, const char pkey[CRYPT_PKEY_HEXLEN]);
|
|
addrbook_entry_t *addrbook_get_by_alias(const addrbook_t *const ab, const char *const alias);
|
|
|
|
#endif /* _ADDRBOOK_H_ */
|