-
Notifications
You must be signed in to change notification settings - Fork 26
/
lib_mysqludf_preg_info.c
161 lines (141 loc) · 4.86 KB
/
lib_mysqludf_preg_info.c
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
/*
* Copyright (C) 2007-2013 Rich Waters <[email protected]>
*
* This file is part of lib_mysqludf_preg.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/**
* @file lib_mysqludf_preg_info.c
*
* @brief Implements the LIB_MYSQLUDF_INFO mysql udf
*/
/**
* @page LIB_MYSQLUDF_PREG_INFO LIB_MYSQLUDF_PREG_INFO
*
* @brief Return version information for lib_mysqludf_preg package
*
* @par Function Installation
* CREATE FUNCTION lib_mysqludf_preg_info RETURNS STRING SONAME 'lib_mysqludf_preg.so' ;
*
* @par Synopsis
* LIB_MYSQLUDF_PREG_INFO()
*
* @return string - version information for the lib_mysqludf_preg package
*
* @par Examples:
* SELECT LIB_MYSQLUDF_PREG_INFO();
*
* @b Yields:
* @verbatim
+--------------------------+
| LIB_MYSQLUDF_PREG_INFO() |
+--------------------------+
| lib_mysqludf_preg 0.6.1 |
+--------------------------+
@endverbatim
*/
#include "ghmysql.h"
//#include "preg.h"
/**
* Public function declarations:
*/
bool lib_mysqludf_preg_info_init(UDF_INIT *initid, UDF_ARGS *args, char *message);
char *lib_mysqludf_preg_info(UDF_INIT *initid __attribute__((unused)),
UDF_ARGS *args,
char *result, unsigned long *length,
char *is_null __attribute__((unused)),
char *error __attribute__((unused)));
void lib_mysqludf_info_deinit( UDF_INIT* initid );
/*
* Public function definitions:
*/
/**
* @fn bool lib_mysqludf_preg_info_init(UDF_INIT *initid, UDF_ARGS *args,
* char *message)
*
* @brief
* Perform the per-query initializations
*
* @param initid - various info supplied by mysql api - read more at
* http://dev.mysql.com/doc/refman/5.0/en/adding-udf.html
*
* @param args - array of information about arguments from the SQL call
* See file documentation for the description of the SQL arguments
*
* @param message - for error messages. Should be <80 but can be 255.
*
* @return 0 - on success
* @return 1 - on error
*
* @details This function checks to make sure there are no arguments.
*/
bool lib_mysqludf_preg_info_init(UDF_INIT *initid, UDF_ARGS *args,
char *message)
{
if (args->arg_count != 0)
{
strncpy(message, "lib_mysqludf_preg_info: does not accept arguments", MYSQL_ERRMSG_SIZE) ;
return 1;
}
return 0;
}
/**
* @fn char *lib_mysqludf_preg_info( UDF_INIT *initid , UDF_ARGS *args,
* char *result, unsigned long *length,
* char *is_null , char *error )
*
* @brief
* Get information about the installed lib_mysqludf_preg library
*
* @param initid - various info supplied by mysql api - read more at
* http://dev.mysql.com/doc/refman/5.0/en/adding-udf.html
*
* @param args - array of information about arguments from the SQL call
* See file documentation for the description of the SQL arguments
*
* @param result - a place the captured string can be placed (255 len max)
* @param length - put the length of the captured item here.
* @param is_null - set this if return value is null
* @param error - to be set if an error occurs
*
* @return string - The information requested.
*
* @note: PACKAGE_STRING comes from autotools
*/
char *lib_mysqludf_preg_info( UDF_INIT *initid , UDF_ARGS *args,
char *result, unsigned long *length,
char *is_null , char *error )
{
strcpy( result , PACKAGE_STRING );
*length = strlen( result ) ;
*is_null = 0 ;
*error = 0 ;
return result ;
}
/**
* @fn void lib_mysqludf_preg_info_deinit(UDF_INIT *initid)
*
* @brief cleanup after LIB_MYSQLUDF_PREG_INFO call
*
* @param initid - pointer to struct to be cleaned.
*/
void lib_mysqludf_preg_info_deinit(UDF_INIT *initid)
{
}