~drizzle-trunk/drizzle/development

1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
1
/*
2
 * Drizzle Client & Protocol Library
3
 *
4
 * Copyright (C) 2008 Eric Day (eday@oddments.org)
5
 * All rights reserved.
6
 *
7
 * Use and distribution licensed under the BSD license.  See
1799.2.3 by Monty Taylor
Reference root BSD copying file.
8
 * the COPYING.BSD file in the root source directory for full text.
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
9
 */
10
11
/**
12
 * @file
13
 * @brief Local Connection Declarations
14
 */
15
16
#ifndef __DRIZZLE_CONN_LOCAL_H
17
#define __DRIZZLE_CONN_LOCAL_H
18
19
#ifdef __cplusplus
20
extern "C" {
21
#endif
22
23
/**
24
 * @addtogroup drizzle_con_local Local Connection Declarations
25
 * @ingroup drizzle_con
26
 * @{
27
 */
28
29
/**
30
 * Clear address info, freeing structs if needed.
31
 *
32
 * @param[in] con Connection structure previously initialized with
33
 *  drizzle_con_create(), drizzle_con_clone(), or related functions.
34
 */
35
DRIZZLE_LOCAL
36
void drizzle_con_reset_addrinfo(drizzle_con_st *con);
37
 
38
/**
39
 * Check if state stack is empty.
40
 *
41
 * @param[in] con Connection structure previously initialized with
42
 *  drizzle_con_create(), drizzle_con_clone(), or related functions.
43
 * @return True if empty, false if something is on the stack.
44
 */
45
static inline bool drizzle_state_none(drizzle_con_st *con)
46
{
47
  return con->state_current == 0;
48
}
49
50
/**
51
 * Push a function onto the stack.
52
 *
53
 * @param[in] con Connection structure previously initialized with
54
 *  drizzle_con_create(), drizzle_con_clone(), or related functions.
55
 * @param[in] function Function to push.
56
 */
57
static inline void drizzle_state_push(drizzle_con_st *con,
58
                                      drizzle_state_fn *function)
59
{
60
  /* The maximum stack depth can be determined at compile time, so bump this
61
     constant if needed to avoid the dynamic memory management. */
62
  assert(con->state_current < DRIZZLE_STATE_STACK_SIZE);
63
  con->state_stack[con->state_current]= function;
64
  con->state_current++;
65
}
66
67
/**
68
 * Pop a function off of the stack.
69
 *
70
 * @param[in] con Connection structure previously initialized with
71
 *  drizzle_con_create(), drizzle_con_clone(), or related functions.
72
 */
73
static inline void drizzle_state_pop(drizzle_con_st *con)
74
{
75
  con->state_current--;
76
}
77
78
/**
79
 * Reset the stack so it is empty.
80
 *
81
 * @param[in] con Connection structure previously initialized with
82
 *  drizzle_con_create(), drizzle_con_clone(), or related functions.
83
 */
84
static inline void drizzle_state_reset(drizzle_con_st *con)
85
{
86
  con->state_current= 0;
87
}
88
89
/** @} */
90
91
#ifdef __cplusplus
92
}
93
#endif
94
95
#endif /* __DRIZZLE_CONN_LOCAL_H */