pike.git / lib / modules / Sql.pmod / tds.pike

version» Context lines:

pike.git/lib/modules/Sql.pmod/tds.pike:1:   /* -  * $Id: tds.pike,v 1.3 2006/02/10 10:27:43 grubba Exp $ +  * $Id: tds.pike,v 1.4 2006/02/10 10:31:44 grubba Exp $    *    * A Pike implementation of the TDS protocol.    *    * Henrik Grubbström 2006-02-08.    */      #define TDS_DEBUG      #ifdef TDS_DEBUG   #define TDS_WERROR(X...) werror("TDS:" + X)
pike.git/lib/modules/Sql.pmod/tds.pike:1009:    TDS_WERROR("Datetime4:%{ %d}\n", (array)raw);    }    TDS_WERROR("ROW: %O\n", raw);    return raw;    }    }       static string|int convert(string|int raw, mapping(string:mixed) info)    {    if (!raw) return raw; /* NULL */ -  switch(info->cardinal_type) { +  int cardinal_type; +  switch(cardinal_type = info->cardinal_type) {    case SYBCHAR:    case SYBVARCHAR:    case SYBTEXT:    case XSYBCHAR:    case XSYBVARCHAR:    case SYBNVARCHAR:    case SYBNTEXT:    case SYBLONGBINARY:    case SYBBINARY:    case SYBVARBINARY:
pike.git/lib/modules/Sql.pmod/tds.pike:1072:    return sprintf("%d", array_sscanf(raw, "%-1c")[0]);    case SYBINT2:    // FIXME: SIGN!    return sprintf("%d", array_sscanf(raw, "%-2c")[0]);    case SYBINT4:    // FIXME: SIGN!    return sprintf("%d", array_sscanf(raw, "%-4c")[0]);    case SYBINT8:    // FIXME: SIGN!    return sprintf("%d", array_sscanf(raw, "%-8c")[0]); +  case SYBDATETIMN: +  if (sizeof(raw) == 8) cardinal_type = SYBDATETIME; +  // FALL_THROUGH    case SYBDATETIME:    case SYBDATETIME4:    {    int day, min, sec, sec_300; -  if (info->cardinal_type == SYBDATETIME) { +  if (cardinal_type == SYBDATETIME) {    sscanf(raw, "%-4c%-4c", day, sec_300);    sec = sec_300/300;    sec_300 %= 300;    min = sec/60;    sec %= 60;    } else {    sscanf(raw, "%-2c%-2c", day, min);    }    int hour = min/60;    min %= 60;
pike.git/lib/modules/Sql.pmod/tds.pike:1105:    int j = (l * 80)/2447;    int mday = l - (j * 2447)/80;    l = j/11;    int mon = j + 1 - l*12;    year += (century + 15)*100 + l;    if (!l && !(year & 3) && ((year % 100) || !(year % 400)))    yday++;    return sprintf("%04d-%02d-%02dT%02d:%02d:%02d",    year, mon, mday, hour, min, sec);    } - #if 0 -  case SYBDATETIMN: -  -  break; - #endif /* 0 */ +     }    return raw;    }       static array(string|int) process_row()    {    if (!column_info) return 0;    array(string|int) res = allocate(sizeof(column_info));    foreach(column_info; int i; mapping(string:mixed) info) {    res[i] = convert(get_data(info, i), info);