- /* Citadel does not yet implement the abovementioned extension, and
- * therefore the root and pattern will always be in these positions.
+ /*
+ * If parameter 2 begins with a '(' character, the client is specifying
+ * selection options. Extract their exact position, and then modify our
+ * expectation of where the root folder will be specified.
+ * (FIXME this is part of draft-ietf-imapext-list-extensions-18, not finished yet)
+ */
+ if (parms[2][0] == '(') {
+ selection_left = 2;
+ paren_nest = 0;
+ for (i=2; i<num_parms; ++i) {
+ for (j=0; j<strlen(parms[i]); ++j) {
+ if (parms[i][j] == '(') ++paren_nest;
+ if (parms[i][j] == ')') --paren_nest;
+ }
+ if (paren_nest == 0) {
+ selection_right = i; /* found end of selection options */
+ root_pos = i+1; /* folder root appears after selection options */
+ i = num_parms + 1; /* break out of the loop */
+ }
+ }
+ }
+
+ /* The folder root appears immediately after the selection options,
+ * or in position 2 if no selection options were specified.