1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
|
#include "module.h"
#include "net_endian.h"
#include "net_struct.h"
#include "net_func.h"
#include "net_client.h"
#include <stddef.h>
#include <string.h>
/// test_module params formatting function.
/**
* \param target A pointer to the structure.
* \param ap A list of parameters.
*/
void
test_module_params_format_fn ( struct test_module_params * target, va_list ap );
/// test_module params byte swapping function.
/**
* This function byte swap the structure in-place.
* \param target A pointer to the structure.
*/
void
test_module_params_bswap_fn ( struct test_module_params * target );
/// test_module params format definition.
static const struct net_struct test_module_params_format = {
1, sizeof(struct test_module_params),
NULL, /* not used by client */
(net_struct_format_fn_t)test_module_params_format_fn,
(net_struct_bswap_fn_t)test_module_params_bswap_fn,
{
{ NET_TYPE_INT, 1, offsetof(struct test_module_params, arg) }
}
};
void
test_module_params_format_fn ( struct test_module_params * target, va_list ap )
{
{
target->arg = va_arg(ap, net_int_t);
}
}
void
test_module_params_bswap_fn ( struct test_module_params * target )
{
net_bswap_int(&target->arg);
}
/// test_module result byte swapping function.
/**
* This function byte swap the structure in-place.
* \param target A pointer to the structure.
*/
void
test_module_result_bswap_fn ( struct test_module_result * target );
/// test_module result format definition.
static const struct net_struct test_module_result_format = {
1, sizeof(struct test_module_result),
NULL, /* not used by client */
NULL, /* not used for results */
(net_struct_bswap_fn_t)test_module_result_bswap_fn,
{
{ NET_TYPE_INT, 1, offsetof(struct test_module_result, ret) }
}
};
void
test_module_result_bswap_fn ( struct test_module_result * target )
{
net_bswap_int(&target->ret);
}
/// test_module function definition.
static const struct net_func test_module_func_def = {
1,
0,
&test_module_params_format,
&test_module_result_format
};
struct net_func_instance *
test_module ( struct net_client * client, const struct net_func_callbacks * callbacks, const net_int_t arg )
{
return net_client_call_function(client, &test_module_func_def, callbacks, arg);
}
const struct test_module_result *
test_module_result ( struct net_func_instance * instance )
{
return (const struct test_module_result *)net_func_pop_result(instance);
}
/// test_sql params formatting function.
/**
* \param target A pointer to the structure.
* \param ap A list of parameters.
*/
void
test_sql_params_format_fn ( struct test_sql_params * target, va_list ap );
/// test_sql params byte swapping function.
/**
* This function byte swap the structure in-place.
* \param target A pointer to the structure.
*/
void
test_sql_params_bswap_fn ( struct test_sql_params * target );
/// test_sql params format definition.
static const struct net_struct test_sql_params_format = {
1, sizeof(struct test_sql_params),
NULL, /* not used by client */
(net_struct_format_fn_t)test_sql_params_format_fn,
(net_struct_bswap_fn_t)test_sql_params_bswap_fn,
{
{ NET_TYPE_CHAR, 32, offsetof(struct test_sql_params, name) }
}
};
void
test_sql_params_format_fn ( struct test_sql_params * target, va_list ap )
{
{
const char * source = va_arg(ap, const char *);
strncpy(target->name, source, 32);
}
}
void
test_sql_params_bswap_fn ( struct test_sql_params * target )
{
}
/// test_sql result byte swapping function.
/**
* This function byte swap the structure in-place.
* \param target A pointer to the structure.
*/
void
test_sql_result_bswap_fn ( struct test_sql_result * target );
/// test_sql result format definition.
static const struct net_struct test_sql_result_format = {
3, sizeof(struct test_sql_result),
NULL, /* not used by client */
NULL, /* not used for results */
(net_struct_bswap_fn_t)test_sql_result_bswap_fn,
{
{ NET_TYPE_INT, 1, offsetof(struct test_sql_result, intval) },
{ NET_TYPE_FLOAT, 1, offsetof(struct test_sql_result, floatval) },
{ NET_TYPE_CHAR, 32, offsetof(struct test_sql_result, strval) }
}
};
void
test_sql_result_bswap_fn ( struct test_sql_result * target )
{
net_bswap_int(&target->intval);
net_bswap_float(&target->floatval);
}
/// test_sql function definition.
static const struct net_func test_sql_func_def = {
1,
1,
&test_sql_params_format,
&test_sql_result_format
};
struct net_func_instance *
test_sql ( struct net_client * client, const struct net_func_callbacks * callbacks, const net_char_t name [32] )
{
return net_client_call_function(client, &test_sql_func_def, callbacks, name);
}
const struct test_sql_result *
test_sql_result ( struct net_func_instance * instance )
{
return (const struct test_sql_result *)net_func_pop_result(instance);
} |
Partager