38 lines
1009 B
C
38 lines
1009 B
C
#ifndef _ADDRBOOK_H_
|
|
#define _ADDRBOOK_H_
|
|
|
|
#include "crypt.h"
|
|
#include <netinet/in.h>
|
|
|
|
#define ADDRBOOK_NAME_MAXLEN 64
|
|
#define ADDRBOOK_PORT_MAXLEN 5
|
|
|
|
typedef struct addrbook_entry_t {
|
|
char pubk[CRYPT_PKEY_HEXLEN];
|
|
char *name;
|
|
char *last_addr;
|
|
char *last_port;
|
|
unsigned char name_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;
|
|
} addrbook_t;
|
|
|
|
int addrbook_init(addrbook_t *const ab);
|
|
void addrbook_destroy(addrbook_t *const ab);
|
|
|
|
int addrbook_load(addrbook_t *ab, FILE *in);
|
|
int addrbook_store(addrbook_t *ab, FILE *out);
|
|
|
|
int addrbook_add(addrbook_t *const ab, const addrbook_entry_t *const ent);
|
|
addrbook_entry_t *addrbook_get(const addrbook_t *const ab, const char pkey[CRYPT_PKEY_HEXLEN]);
|
|
|
|
#endif /* _ADDRBOOK_H_ */
|