2
2
Homepage: http://netkiller.github.io/
3
3
Author: netkiller<netkiller@msn.com>
4
4
*/
5
-
5
+ #include <stdlib.h>
6
+ #include <stdio.h>
6
7
#include <mysql.h>
7
8
#include <string.h>
8
- #include <stdio.h>
9
- #include <stdlib.h>
9
+ #include <io.h>
10
10
11
11
#include "image.h"
12
12
@@ -18,7 +18,7 @@ my_bool image_check_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
18
18
if (args -> arg_count != 1 )
19
19
{
20
20
strncpy (message ,
21
- "two arguments must be supplied: image_check('<data >')." ,
21
+ "two arguments must be supplied: image_check('<filename >')." ,
22
22
MYSQL_ERRMSG_SIZE );
23
23
return 1 ;
24
24
}
@@ -35,7 +35,11 @@ char *image_check(UDF_INIT *initid, UDF_ARGS *args,
35
35
{
36
36
37
37
char * data ;
38
- data = "image_check" ;
38
+ if (!access (args -> args [0 ],0 ) )
39
+ data = "ture" ;
40
+ else
41
+ data = "false" ;
42
+
39
43
* length = strlen (data );
40
44
return ((char * )data );
41
45
@@ -46,6 +50,49 @@ void image_check_deinit(UDF_INIT *initid)
46
50
return ;
47
51
}
48
52
53
+ /* ------------------------ image_rename ----------------------------- */
54
+
55
+ my_bool image_rename_init (UDF_INIT * initid , UDF_ARGS * args , char * message )
56
+ {
57
+
58
+ if (args -> arg_count != 2 )
59
+ {
60
+ strcpy (message ,
61
+ "two arguments must be supplied: image_move('<file1>','<file2>')." );
62
+ return 1 ;
63
+ }
64
+
65
+ args -> arg_type [0 ]= STRING_RESULT ;
66
+
67
+ return 0 ;
68
+ }
69
+
70
+ char * image_rename (UDF_INIT * initid , UDF_ARGS * args ,
71
+ __attribute__ ((unused )) char * result ,
72
+ unsigned long * length ,
73
+ __attribute__ ((unused )) char * is_null ,
74
+ __attribute__ ((unused )) char * error )
75
+ {
76
+
77
+ char * data ;
78
+ int errno ;
79
+ errno = rename (args -> args [0 ], args -> args [1 ]);
80
+ if ( errno == 0 )
81
+ data = "true" ;
82
+ else
83
+ //asprintf(&data, "ARG0=%s, ARG1=%d", args->args[0], errno);
84
+ data = "false" ;
85
+
86
+ * length = strlen (data );
87
+ return ((char * )data );
88
+
89
+ }
90
+
91
+ void image_rename_deinit (UDF_INIT * initid )
92
+ {
93
+ return ;
94
+ }
95
+
49
96
/* ------------------------ image_move ----------------------------- */
50
97
51
98
my_bool image_move_init (UDF_INIT * initid , UDF_ARGS * args , char * message )
@@ -54,7 +101,7 @@ my_bool image_move_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
54
101
if (args -> arg_count != 1 )
55
102
{
56
103
strncpy (message ,
57
- "two arguments must be supplied: image_move('<data >')." ,
104
+ "two arguments must be supplied: image_move('<filename >')." ,
58
105
MYSQL_ERRMSG_SIZE );
59
106
return 1 ;
60
107
}
@@ -87,6 +134,15 @@ void image_move_deinit(UDF_INIT *initid)
87
134
88
135
my_bool image_remove_init (UDF_INIT * initid , UDF_ARGS * args , char * message )
89
136
{
137
+ if (args -> arg_count != 1 )
138
+ {
139
+ strncpy (message ,
140
+ "two arguments must be supplied: image_remove('<filename>')." ,
141
+ MYSQL_ERRMSG_SIZE );
142
+ return 1 ;
143
+ }
144
+
145
+ args -> arg_type [0 ]= STRING_RESULT ;
90
146
return 0 ;
91
147
}
92
148
@@ -97,11 +153,15 @@ char *image_remove(UDF_INIT *initid, UDF_ARGS *args,
97
153
__attribute__ ((unused )) char * error )
98
154
{
99
155
100
- char * config ;
101
- //asprintf(&config, "SAFENET_URL=%s, SAFENET_KEY=%s", safe_url, safe_key);
102
- config = "image_remove" ;
103
- * length = strlen (config );
104
- return ((char * )config );
156
+ char * status ;
157
+ //asprintf(&status, "SAFENET_URL=%s, SAFENET_KEY=%s", safe_url, safe_key);
158
+ if ( !remove ( args -> args [0 ] ) )
159
+ status = "true" ;
160
+ else
161
+ status = "false" ;
162
+
163
+ * length = strlen (status );
164
+ return ((char * )status );
105
165
}
106
166
107
167
void image_remove_deinit (UDF_INIT * initid )
0 commit comments