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.13 2006/02/15 13:15:44 grubba Exp $ +  * $Id: tds.pike,v 1.14 2006/02/15 13:46:40 grubba Exp $    *    * A Pike implementation of the TDS protocol.    *    * Henrik Grubbström 2006-02-08.    */      /* #define TDS_DEBUG */   /* #define TDS_CONVERT_DEBUG */      #ifdef TDS_DEBUG
pike.git/lib/modules/Sql.pmod/tds.pike:173:    TDS_UT_TIMESTAMP = 80, /* User type. */    };       string server_data;    string last_error;       //! Format and report an error.    void tds_error(string msg, mixed ... args)    {    if (sizeof(args)) msg = sprintf(msg, @args); +  TDS_WERROR("ERROR: %s", msg);    predef::error(last_error = msg);    }       static object utf16enc = Locale.Charset.encoder("UTF16LE");    static string string_to_utf16(string s)    {    return utf16enc->feed(s)->drain();    }    static object utf16dec = Locale.Charset.decoder("UTF16LE");    static string utf16_to_string(string s)
pike.git/lib/modules/Sql.pmod/tds.pike:231:    TDS_WERROR("Filling buffer on finished packet!\n"    "%s\n", hex_dump(inbuf));    tds_error("Filling buffer on finished packet!\n");    }       string header = socket->read(8);    if (!header || sizeof(header) < 8) {    busy = !(done = 1);    int errno = socket->errno();    Disconnect(); -  tds_error("Failed to read packet header: %O, %s.\n", +  predef::error("Failed to read packet header: %O, %s.\n",    header, strerror(errno));    }    TDS_WERROR("Read header:\n%s\n", hex_dump(header));    int packet_type;    int last_packet;    int len;    // NOTE: Network byteorder!!    sscanf(header, "%-1c%-1c%2c", packet_type, last_packet, len);    len -= 8;   
pike.git/lib/modules/Sql.pmod/tds.pike:460:    //!    //! @returns    //! If @[last] is true an @[InPacket] with the result    //! will be returned.    InPacket send_packet(Packet p, int flag, int|void last)    {    if (busy) {    tds_error("Sending packet on busy connection!\n");    }    -  array(string) packets = ((string) p)/32768.0; +  array(string) packets = ((string) p)/(float)(block_size-8);    foreach(packets; int i; string raw) {    // NOTE: Network byteorder!!    raw = sprintf("%1c%1c%2c\0\0%1c\0%s",    flag, (i == (sizeof(packets)-1)) && last,    sizeof(raw) + 8,    1, /* TDS 7 or 8. */    raw);    TDS_WERROR("Wrapped packet: %O\n%s\n", raw, hex_dump(raw));    if (socket->write(raw) != sizeof(raw)) {    Disconnect(); -  tds_error("Failed to send packet.\n" +  predef::error("Failed to send packet.\n"    "raw: %O\n", raw);    }    }    //Stdio.write_file("packet.bin", raw);    if (last) return InPacket();    return 0;    }       static string crypt_pass(string password)    {
pike.git/lib/modules/Sql.pmod/tds.pike:661:    process_default_tokens(inp, inp->get_byte());    continue;    }    break;    }    }    if (is_error) {    tds_error("%d: %s:%s:%d %s\n",    level, proc_name, server, line, message);    } else { + #if 0    last_error = sprintf("%d: %s:%s:%d %s\n",    level, proc_name, server, line, message); -  + #endif    TDS_WERROR("%d: %s:%s:%d %s\n",    level, proc_name, server, line, message);    }    }       static void process_env_chg(InPacket inp)    {    int size = inp->get_smallint();    int env_type = inp->get_byte();    if (env_type == TDS_ENV_SQLCOLLATION) {
pike.git/lib/modules/Sql.pmod/tds.pike:1304:    Packet p = Packet();    if (!query->n_param || !params || !sizeof(params)) {    string raw = query->splitted_query*"?";    p->put_raw(raw, sizeof(raw));    return send_packet(p, 0x01, 1);    } else {    tds_error("parametrized queries not supported yet.\n");    }    }    -  static void disconnect() +  void disconnect()    {    socket->close();    destruct();    }       static void create(string server, int port, string database,    string username, string auth)    {    string domain;    array(string) tmp = username/"\\";