Main Page
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
aerospike
as_host.h
Go to the documentation of this file.
1
/*
2
* Copyright 2008-2016 Aerospike, Inc.
3
*
4
* Portions may be licensed to Aerospike, Inc. under one or more contributor
5
* license agreements.
6
*
7
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
8
* use this file except in compliance with the License. You may obtain a copy of
9
* the License at http://www.apache.org/licenses/LICENSE-2.0
10
*
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
* License for the specific language governing permissions and limitations under
15
* the License.
16
*/
17
#pragma once
18
19
#include <citrusleaf/alloc.h>
20
#include <stdint.h>
21
22
#ifdef __cplusplus
23
extern
"C"
{
24
#endif
25
26
/******************************************************************************
27
* TYPES
28
*****************************************************************************/
29
30
/**
31
* Host information.
32
*/
33
typedef
struct
as_host_s {
34
/**
35
* Host name or IP address of database server.
36
*/
37
char
*
name
;
38
39
/**
40
* TLS certificate name for secure connections.
41
*/
42
char
*
tls_name
;
43
44
/**
45
* Port of database server.
46
*/
47
uint16_t
port
;
48
}
as_host
;
49
50
/******************************************************************************
51
* FUNCTIONS
52
*****************************************************************************/
53
54
/**
55
* Deep copy host.
56
*/
57
static
inline
void
58
as_host_copy
(
const
as_host
* src,
as_host
* trg)
59
{
60
trg->
name
= (
char
*)cf_strdup(src->
name
);
61
trg->
tls_name
= src->
tls_name
? (
char
*)cf_strdup(src->
tls_name
) : NULL;
62
trg->
port
= src->
port
;
63
}
64
65
/**
66
* Deep copy host from fields.
67
*/
68
static
inline
void
69
as_host_copy_fields
(
as_host
* trg,
const
char
* hostname,
const
char
* tls_name, uint16_t port)
70
{
71
trg->
name
= (
char
*)cf_strdup(hostname);
72
trg->
tls_name
= tls_name ? (
char
*)cf_strdup(tls_name) : NULL;
73
trg->
port
= port;
74
}
75
76
/**
77
* Release memory associated with host.
78
*/
79
static
inline
void
80
as_host_destroy
(
as_host
* host)
81
{
82
cf_free(host->
name
);
83
cf_free(host->
tls_name
);
84
}
85
86
#ifdef __cplusplus
87
}
// end extern "C"
88
#endif