Logo Search packages:      
Sourcecode: freetds version File versions

int tds_put_string ( TDSSOCKET *  tds,
const char *  s,
int  len 
)

Output a string to wire automatic translate string to unicode if needed

Parameters:
s string to write
len lenth of string or -1 for null terminated

Definition at line 99 of file write.c.

References tds7_ascii2unicode(), and tds_put_string().

Referenced by tds_put_string(), tds_submit_prepare(), tds_submit_query(), and tds_submit_rpc().

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

      if (len < 0)
            len = strlen(s);
      if (IS_TDS7_PLUS(tds)) {
            p = s;
            res = 0;
            while (len > 0) {
                  bytes_left = len > (sizeof(temp) / 2) ? (sizeof(temp) / 2) : len;
                  tds7_ascii2unicode(tds, p, temp, bytes_left * 2);
                  res = tds_put_n(tds, temp, bytes_left * 2);
                  p += bytes_left;
                  len -= bytes_left;
            }
            return res;

      }
      return tds_put_n(tds, s, len);
}


Generated by  Doxygen 1.6.0   Back to index