pike.git / lib / modules / Protocols.pmod / IMAP.pmod / parse_line.pike

version» Context lines:

pike.git/lib/modules/Protocols.pmod/IMAP.pmod/parse_line.pike:1: - /* parse_line.pike -  * -  */ + //! parse_line.pike      #pike __REAL_VERSION__      class partial_literal   {    int length;       void create(int l) { length = l; }   }   
pike.git/lib/modules/Protocols.pmod/IMAP.pmod/parse_line.pike:24:   }      #if 0   int eolp()   {    skip_whitespace();    return !sizeof(buffer);   }   #endif    - // Returns -1 on error. All valid numbers ar non-negative. + // Returns -1 on error. All valid numbers are non-negative.   int get_number()   {    skip_whitespace();       if (!sizeof(buffer))    return -1;       int i;    for(i = 0; i<sizeof(buffer); i++)    if ( (buffer[i] < '0') || ('9' < buffer[i]) )
pike.git/lib/modules/Protocols.pmod/IMAP.pmod/parse_line.pike:126:    switch(buffer[0])    {    case '"':    case '{':    return get_string();    default:    return get_atom();    }   }    - /* Returns a set object. */ + //! Returns a set object.   object get_set()   {    string atom = get_atom();    if (!atom)    return 0;       return .types.imap_set()->init(atom);   }    - /* Parses an object that can be a string, an atom (possibly with -  * options in brackets) or a list. -  * -  * eol can be 0, meaning no end of line or list expected, -  * a positive int, meaning a character (e.g. ')' or ']' that terminates the list, -  * or -1, meaning that the list terminates at end of line. -  */ + //! Parses an object that can be a string, an atom (possibly with + //! options in brackets) or a list. + //! + //! eol can be 0, meaning no end of line or list expected, + //! a positive int, meaning a character (e.g. ')' or ']' that terminates the list, + //! or -1, meaning that the list terminates at end of line.   mapping get_token(int eol, int accept_options)   {    skip_whitespace();    if (!sizeof(buffer))    return (eol == -1) && ([ "type" : "eol", "eol" : 1 ]);       if (eol && (buffer[0] == eol))    {    buffer = buffer[1..];    return ([ "type" : "eol", "eol" : 1 ]);
pike.git/lib/modules/Protocols.pmod/IMAP.pmod/parse_line.pike:178:    if (accept_options) {    return get_atom_options(2);    } else {    string atom = get_atom(accept_options);    return ([ "type" : "atom", "atom" : atom ]);    }    }    }   }    - /* Reads a <start.size> suffix */ + //! Reads a <start.size> suffix   mapping get_range(mapping atom)   {    if (!sizeof(buffer) || (buffer[0] != '<'))    return atom;       buffer = buffer[1..];       int start = get_number();    if ((start < 0) || !sizeof(buffer) || (buffer[0] != '.'))    return 0;
pike.git/lib/modules/Protocols.pmod/IMAP.pmod/parse_line.pike:203:    if ((size <= 0) || !sizeof(buffer) || (buffer[0] != '>'))    return 0;       buffer = buffer[1..];       atom->range = ({ start, size });       return atom;   }    - /* Get a list of atoms. -  * Primarily intended for use by STORE for the flags argument. -  */ + //! Get a list of atoms. + //! Primarily intended for use by STORE for the flags argument.   array(string) get_flag_list()   {    skip_whitespace();       if (!sizeof(buffer) || (buffer[0] != '(') )    return 0;       buffer = buffer[1..];    array(string) res = ({});   
pike.git/lib/modules/Protocols.pmod/IMAP.pmod/parse_line.pike:240:    if (buffer[0] = ')')    {    buffer = buffer[1..];    return res;    }       return 0;   }       - /* Parses an object that (recursivly) can contain atoms (possible -  * with options in brackets) or lists. Note that strings are not -  * accepted, as it is a little difficult to wait for the -  * continuation of the request. -  * -  * FIXME: This function is used to read fetch commands. This breaks -  * rfc-2060 compliance, as the names of headers can be represented -  * as string literals. */ -  + //! Parses an object that (recursivly) can contain atoms (possible + //! with options in brackets) or lists. Note that strings are not + //! accepted, as it is a little difficult to wait for the + //! continuation of the request. + //! + //! FIXME: This function is used to read fetch commands. This breaks + //! rfc-2060 compliance, as the names of headers can be represented + //! as string literals.   mapping get_simple_list(int max_depth)   {    skip_whitespace();    if (!sizeof(buffer))    return 0;       if (buffer[0] == '(') {    /* Recurse */    if (max_depth > 0) {    array a = do_parse_simple_list(max_depth - 1, ')');
pike.git/lib/modules/Protocols.pmod/IMAP.pmod/parse_line.pike:307:       mapping m = get_simple_list(max_depth);    if (!m) {    werror("get_simple_list(%d) failed\n", max_depth);    } else {    a += ({ m });    }    }   }    - /* Reads an atom, optionally followd by a list enclosed in square -  * brackets. Naturally, the atom itself cannot contain any brackets. -  * -  * Returns a mapping -  * type : "atom", -  * atom : name, -  * raw : name[options] -  * options : parsed options, -  * range : ({ start, size }) -  */ + //! Reads an atom, optionally followd by a list enclosed in square + //! brackets. Naturally, the atom itself cannot contain any brackets. + //! + //! Returns a mapping + //! type : "atom", + //! atom : name, + //! raw : name[options] + //! options : parsed options, + //! range : ({ start, size })   mapping get_atom_options(int max_depth)   {    string atom = get_atom(1);    if (!atom)    return 0;       mapping res = ([ "type" : "atom",    "atom" : atom ]);    if (!sizeof(buffer) || (buffer[0] != '['))    {