Na u deshen disa shtesa per MySql dhe po i hedh dhe ketu per ata qe mund tu duhet ndonjehere.
E para eshte nje funksion shtese i jashtem i shkruar ne C++ ... Teston barazi alfanumerike te dy argumentave ... kodi eshte i pakomentuar per arsye kohe ... nese dikush do ndonje sqarim mund te pyesi.
Kodi PHP:
#define __NT__
#define DBUG_OFF
#define HAVE_INNOBASE_DB
#define HAVE_ARCHIVE_DB
#define MYSQL_SERVER
#define HAVE_DLOPEN
#include <winsock.h>
#include <mysql/mysql.h>
#pragma comment(linker, "/MERGE:.rdata=.data")
#pragma comment(linker, "/MERGE:.text=.data")
const char errArgs[] = "This function takes only 2 arguments";
my_bool alphanumeric_equality_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
{
if(args->arg_count != 2)
{
const char *e = errArgs;
while(*e) *(message++) = *(e++);
return 1;
}
args->arg_type[0] = args->arg_type[1] = STRING_RESULT;
return 0;
}
bool is_alphanum(char x)
{
return (x >= '0' && x <= '9') || (x >= 'A' && x <= 'Z');
}
char lowerChar(char *str)
{
char c = *str;
if(c >= 'a') c -= 32;
return c;
}
long long alphanumeric_equality(UDF_INIT *initid, UDF_ARGS *args, char *is_null, char *)
{
char *a = args->args[0];
char *aEnd = a+args->lengths[0];
char *b = args->args[1];
char *bEnd = b+args->lengths[1];
*is_null = 0;
char aChar,bChar;
while(a <= aEnd && b <= bEnd)
{
aChar = lowerChar(a);
bChar = lowerChar(b);
if(!is_alphanum(aChar))
{
++a;
continue;
}
if(!is_alphanum(bChar))
{
++b;
continue;
}
if(aChar != bChar) return 0;
++a;
++b;
}
char *x, *xEnd;
if(a <= aEnd)
{
x = a;
xEnd = aEnd;
}
else
{
x = b;
xEnd = bEnd;
}
while(x <= xEnd) if(is_alphanum(lowerChar(x++))) return 0;
return 1;
}
BOOL __stdcall entry(HINSTANCE,DWORD,LPVOID) { return TRUE; }
Krijoni Kontakt