diff options
author | unknown <hf@deer.mysql.r18.ru> | 2003-04-23 19:37:33 +0500 |
---|---|---|
committer | unknown <hf@deer.mysql.r18.ru> | 2003-04-23 19:37:33 +0500 |
commit | f0909cd71a7a1d0904845af4e5e06d213f911de1 (patch) | |
tree | ca16079f1d4f7eae6f2205e124d0c90afbec8409 /sql-common/pack.c | |
parent | 7c87a3f140ac801c0922b3a24e59381f627f105a (diff) | |
download | mariadb-git-f0909cd71a7a1d0904845af4e5e06d213f911de1.tar.gz |
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
Diffstat (limited to 'sql-common/pack.c')
-rw-r--r-- | sql-common/pack.c | 64 |
1 files changed, 64 insertions, 0 deletions
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 <my_global.h> +#include <mysql_com.h> +#include <mysql.h> + +/* 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 +} + |