From f0909cd71a7a1d0904845af4e5e06d213f911de1 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 23 Apr 2003 19:37:33 +0500 Subject: SCRUM Protocol_cursor class and sql-common/ directory Makefile.am: pack.c added to linked sources include/mysql.h: net_field_length_ll declaration added include/mysql_com.h: net_field_length declaration added libmysql/Makefile.am: sql-common files symlinked libmysql/Makefile.shared: pack.lo target added libmysql/libmysql.c: net_field_length removed from here sql/Makefile.am: pack.c added to the sources sql/mini_client.cc: mc_net_field_length functions replaced with net_field_length sql/protocol.h: Protocol_cursor class added --- sql-common/pack.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 sql-common/pack.c (limited to 'sql-common') diff --git a/sql-common/pack.c b/sql-common/pack.c new file mode 100644 index 00000000000..e363d600e20 --- /dev/null +++ b/sql-common/pack.c @@ -0,0 +1,64 @@ +#include +#include +#include + +/* Get the length of next field. Change parameter to point at fieldstart */ +ulong STDCALL net_field_length(uchar **packet) +{ + reg1 uchar *pos= (uchar *)*packet; + if (*pos < 251) + { + (*packet)++; + return (ulong) *pos; + } + if (*pos == 251) + { + (*packet)++; + return NULL_LENGTH; + } + if (*pos == 252) + { + (*packet)+=3; + return (ulong) uint2korr(pos+1); + } + if (*pos == 253) + { + (*packet)+=4; + return (ulong) uint3korr(pos+1); + } + (*packet)+=9; /* Must be 254 when here */ + return (ulong) uint4korr(pos+1); +} + +/* The same as above but returns longlong */ +my_ulonglong net_field_length_ll(uchar **packet) +{ + reg1 uchar *pos= *packet; + if (*pos < 251) + { + (*packet)++; + return (my_ulonglong) *pos; + } + if (*pos == 251) + { + (*packet)++; + return (my_ulonglong) NULL_LENGTH; + } + if (*pos == 252) + { + (*packet)+=3; + return (my_ulonglong) uint2korr(pos+1); + } + if (*pos == 253) + { + (*packet)+=4; + return (my_ulonglong) uint3korr(pos+1); + } + (*packet)+=9; /* Must be 254 when here */ +#ifdef NO_CLIENT_LONGLONG + return (my_ulonglong) uint4korr(pos+1); +#else + return (my_ulonglong) uint8korr(pos+1); +#endif +} + -- cgit v1.2.1