Logo Search packages:      
Sourcecode: freetds version File versions

char* tds_get_string ( TDSSOCKET *  tds,
char *  dest,
int  need 
)

Fetch a string from the wire If TDS version is 7 or 8 read unicode string and convert it

Parameters:
tds connection information
dest destination buffer, if NULL string is readed and discarded
need length to read (in characters)
Returns:
buffer of character

Definition at line 233 of file read.c.

References tds7_unicode2ascii(), tds_get_n(), and tds_get_string().

Referenced by tds_alloc_get_string(), and tds_get_string().

{
      char temp[256];
      char *p;
      unsigned int bytes_left;

      /*
       * FIX: 02-Jun-2000 by Scott C. Gray (SCG)
       * 
       * Bug to malloc(0) on some platforms.
       */
      if (need == 0) {
            return dest;
      }

      if (IS_TDS7_PLUS(tds)) {
            if (dest == NULL) {
                  tds_get_n(tds, NULL, need * 2);
                  return (NULL);
            }
            p = (char *) dest;
            while (need > 0) {
                  bytes_left = need > (sizeof(temp) / 2) ? (sizeof(temp) / 2) : need;
                  tds_get_n(tds, temp, bytes_left * 2);
                  tds7_unicode2ascii(tds, temp, p, bytes_left);
                  p += bytes_left;
                  need -= bytes_left;
            }
            return dest;

      } else {
            return (char *) tds_get_n(tds, dest, need);
      }
}


Generated by  Doxygen 1.6.0   Back to index