~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to libdrizzle/pack.c

MergeĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
  return (ulong) uint4korr(pos+1);
45
45
}
46
46
 
47
 
/* The same as above but returns longlong */
48
 
my_ulonglong net_field_length_ll(uchar **packet)
 
47
/* The same as above but returns int64_t */
 
48
uint64_t net_field_length_ll(uchar **packet)
49
49
{
50
50
  register uchar *pos= *packet;
51
51
  if (*pos < 251)
52
52
  {
53
53
    (*packet)++;
54
 
    return (my_ulonglong) *pos;
 
54
    return (uint64_t) *pos;
55
55
  }
56
56
  if (*pos == 251)
57
57
  {
58
58
    (*packet)++;
59
 
    return (my_ulonglong) NULL_LENGTH;
 
59
    return (uint64_t) NULL_LENGTH;
60
60
  }
61
61
  if (*pos == 252)
62
62
  {
63
63
    (*packet)+=3;
64
 
    return (my_ulonglong) uint2korr(pos+1);
 
64
    return (uint64_t) uint2korr(pos+1);
65
65
  }
66
66
  if (*pos == 253)
67
67
  {
68
68
    (*packet)+=4;
69
 
    return (my_ulonglong) uint3korr(pos+1);
 
69
    return (uint64_t) uint3korr(pos+1);
70
70
  }
71
71
  (*packet)+=9;                                 /* Must be 254 when here */
72
72
#ifdef NO_CLIENT_LONGLONG
73
 
  return (my_ulonglong) uint4korr(pos+1);
 
73
  return (uint64_t) uint4korr(pos+1);
74
74
#else
75
 
  return (my_ulonglong) uint8korr(pos+1);
 
75
  return (uint64_t) uint8korr(pos+1);
76
76
#endif
77
77
}
78
78
 
93
93
   Position in 'pkg' after the packed length
94
94
*/
95
95
 
96
 
uchar *net_store_length(uchar *packet, ulonglong length)
 
96
uchar *net_store_length(uchar *packet, uint64_t length)
97
97
{
98
 
  if (length < (ulonglong) 251LL)
 
98
  if (length < (uint64_t) 251LL)
99
99
  {
100
100
    *packet=(uchar) length;
101
101
    return packet+1;
102
102
  }
103
103
  /* 251 is reserved for NULL */
104
 
  if (length < (ulonglong) 65536LL)
 
104
  if (length < (uint64_t) 65536LL)
105
105
  {
106
106
    *packet++=252;
107
107
    int2store(packet,(uint) length);
108
108
    return packet+2;
109
109
  }
110
 
  if (length < (ulonglong) 16777216LL)
 
110
  if (length < (uint64_t) 16777216LL)
111
111
  {
112
112
    *packet++=253;
113
113
    int3store(packet,(ulong) length);