Logo Search packages:      
Sourcecode: freetds version File versions

void* tds_get_n ( TDSSOCKET *  tds,
void *  dest,
int  need 
)

Get N bytes from the buffer and return them in the already allocated space given to us. We ASSUME that the person calling this function has done the bounds checking for us since they know how many bytes they want here. dest of NULL means we just want to eat the bytes. (tetherow@nol.org)

Definition at line 275 of file read.c.

References tds_get_n(), and tds_read_packet().

Referenced by tds_get_int(), tds_get_n(), tds_get_smallint(), tds_get_string(), tds_process_default_tokens(), and tds_process_login_tokens().

{
      int pos, have;

      pos = 0;

      have = (tds->in_len - tds->in_pos);
      while (need > have) {
            /* We need more than is in the buffer, copy what is there */
            if (dest != NULL) {
                  memcpy((char *) dest + pos, tds->in_buf + tds->in_pos, have);
            }
            pos += have;
            need -= have;
            tds_read_packet(tds);
            have = tds->in_len;
      }
      if (need > 0) {
            /* get the remainder if there is any */
            if (dest != NULL) {
                  memcpy((char *) dest + pos, tds->in_buf + tds->in_pos, need);
            }
            tds->in_pos += need;
      }
      return dest;
}


Generated by  Doxygen 1.6.0   Back to index