summaryrefslogtreecommitdiff
path: root/sql-common/pack.c
diff options
context:
space:
mode:
authorhf@deer.mysql.r18.ru <>2003-04-23 19:37:33 +0500
committerhf@deer.mysql.r18.ru <>2003-04-23 19:37:33 +0500
commitca0271471507cfa940337a7db63f415e504de768 (patch)
treeca16079f1d4f7eae6f2205e124d0c90afbec8409 /sql-common/pack.c
parenta3d08eaaf97c013569516294ae97b8118b3db0b0 (diff)
downloadmariadb-git-ca0271471507cfa940337a7db63f415e504de768.tar.gz
SCRUM
Protocol_cursor class and sql-common/ directory
Diffstat (limited to 'sql-common/pack.c')
-rw-r--r--sql-common/pack.c64
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
+}
+