pike.git / lib / modules / Protocols.pmod / Bittorrent.pmod / Bencoding.pmod

version» Context lines:

pike.git/lib/modules/Protocols.pmod/Bittorrent.pmod/Bencoding.pmod:1:   #pike __REAL_VERSION__      //! Decodes a Bittorrent bencoded data chunk and ignores the remaining   //! string. Returns @expr{UNDEFINED@} if the data is incomplete.   string|int|array|mapping decode(Stdio.Buffer buf)   { -  // Decode strings. Returns -1 if the declared size is smaller than -  // the rest of the buffer. +  // Decode strings. Returns UNDEFINED if the declared size is smaller +  // than the rest of the buffer.    if( array a = buf->sscanf("%d:") )    return buf->read(a[0]) || UNDEFINED;       mixed prefix;    switch(prefix=buf->read(1))    {    case "":    case 0:    // End of buffer    return UNDEFINED;