Logo Search packages:      
Sourcecode: freetds version File versions

int tds_get_dynid ( TDSSOCKET *  tds,
char **  id 
)

Get an id for dynamic query based on TDS information

Returns:
TDS_FAIL or TDS_SUCCEED

Definition at line 601 of file query.c.

References tds_get_dynid().

Referenced by tds_get_dynid(), and tds_submit_prepare().

{
      unsigned long n;
      int i;
      char *p;
      char c;

      inc_num = (inc_num + 1) & 0xffff;
      /* some version of Sybase require length <= 10, so we code id */
      n = (unsigned long) tds;
      if (!(p = (char *) malloc(16)))
            return TDS_FAIL;
      *id = p;
      *p++ = (char) ('a' + (n % 26u));
      n /= 26u;
      for (i = 0; i < 9; ++i) {
            c = (char) ('0' + (n % 36u));
            *p++ = (c < ('0' + 10)) ? c : c + ('a' - '0' - 10);
            /* printf("%d -> %d(%c)\n",n%36u,p[-1],p[-1]); */
            n /= 36u;
            if (i == 4)
                  n += 3u * inc_num;
      }
      *p++ = 0;
      return TDS_SUCCEED;
}


Generated by  Doxygen 1.6.0   Back to index