pike.git / lib / modules / Protocols.pmod / LDAP.pmod / protocol.pike

version» Context lines:

pike.git/lib/modules/Protocols.pmod/LDAP.pmod/protocol.pike:1:   #pike __REAL_VERSION__      // LDAP client protocol implementation for Pike.   // - // $Id: protocol.pike,v 1.7 2001/09/17 02:45:43 hop Exp $ + // $Id: protocol.pike,v 1.8 2004/10/13 15:45:28 wellhard Exp $   //   // Honza Petrous, hop@unibase.cz   //   // ----------------------------------------------------------------------   //   // History:   //   // v1.9 1999-02-19 created separate file   // - improved checking of readed bytes in 'readmsg'   // v1.9.1.1
pike.git/lib/modules/Protocols.pmod/LDAP.pmod/protocol.pike:164:       return(1);    }       void create(object fd) {    // -------------------    ldapfd = fd;    }       -  string|int do_op(object msgop) { +  string|int do_op(object msgop, object|void controls) {    // ---------------------------    // Make LDAP PDU envelope for 'msgop', send it and read answer ...       object msgval;    object msgid;    int rv = 0, msgnum;    string s;       //THREAD_LOCK    msgnum = next_id++;    //THREAD_UNLOCK    msgid = Standards.ASN1.Types.asn1_integer(msgnum); -  +  if (controls) { +  msgval = Standards.ASN1.Types.asn1_sequence(({msgid, msgop, controls})); +  } else {    msgval = Standards.ASN1.Types.asn1_sequence(({msgid, msgop})); -  +  }       if (objectp(msgval)) {    DWRITE(sprintf("protocol.do_op: msg = [%d]\n",sizeof(msgval->get_der())));    } else    DWRITE("protocol.do_op: msg is null!\n");       // call_out    writebuf = msgval->get_der();    rv = ldapfd->write(writebuf); // !!!!! - jak rozlisit async a sync ????    // call_out
pike.git/lib/modules/Protocols.pmod/LDAP.pmod/protocol.pike:217:   /* ------------ legacy support -----------------*/       string|int readmsg(int msgid) {    // Reads LDAP PDU (with defined msgid) from server, checks msgid ...       int msglen = 0, ix;    string|int retv;    string s, shlp;       retv = ldapfd->read(2); // 1. byte = 0x0C, 2. byte = msglen -  if (intp(retv) && (retv == -1)) { +  if (retv == -1) {    seterr (LDAP_TIMEOUT);    DWRITE_HI("protocol.readmsg: ERROR: connection timeout.\n");    THROW(({"LDAP: connection timeout.\n",backtrace()}));    return(-ldap_errno);    }    if (!retv || (sizeof(retv) != 2) || (retv[0] != '0')) {    seterr (LDAP_PROTOCOL_ERROR);    DWRITE_HI("protocol.readmsg: ERROR: retv=<"+sprintf("%O",retv)+">\n");    THROW(({"LDAP: Protocol mismatch.\n",backtrace()}));    return(-ldap_errno);    }    DWRITE(sprintf("protocol.readmsg: sizeof = %d\n", sizeof(retv)));       msglen = retv[1];    if (msglen & 0x80) { // > 0x7f -  if (msglen == 0x80) { // RFC not allows unexplicitly defined length +  if (msglen == 0x80) { // RFC not allows nonexplicitly defined length    seterr (LDAP_PROTOCOL_ERROR);    THROW(({"LDAP: Protocol mismatch.\n",backtrace()}));    return(-ldap_errno);    }    s = ldapfd->read(msglen & 0x7f);    if (!s) {    seterr (LDAP_PROTOCOL_ERROR);    THROW(({"LDAP: Protocol mismatch.\n",backtrace()}));    return(-ldap_errno);    }