diff options
author | Werner Koch <wk@gnupg.org> | 2019-09-09 09:01:28 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2019-09-09 09:01:28 +0200 |
commit | 1545b948e1c8e8fa4873d434fb790a88ed96091c (patch) | |
tree | df2046d2340dbb1c8e60bea1e5b6d173652a5691 /kbx | |
parent | kbx: Add framework for the SEARCH command (diff) | |
download | gnupg2-1545b948e1c8e8fa4873d434fb790a88ed96091c.tar.xz gnupg2-1545b948e1c8e8fa4873d434fb790a88ed96091c.zip |
kbx: Allow searching from start.
* kbx/kbxserver.c (cmd_search): Detect empty pattern.
--
Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'kbx')
-rw-r--r-- | kbx/backend-kbx.c | 2 | ||||
-rw-r--r-- | kbx/kbxserver.c | 34 |
2 files changed, 24 insertions, 12 deletions
diff --git a/kbx/backend-kbx.c b/kbx/backend-kbx.c index 7f9ef358b..b8d39c2ed 100644 --- a/kbx/backend-kbx.c +++ b/kbx/backend-kbx.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, see <https://www.gnu.org/licenses/>. - * SPDX-License-Identifier: GPL-3.0+ + * SPDX-License-Identifier: GPL-3.0-or-later */ #include <config.h> diff --git a/kbx/kbxserver.c b/kbx/kbxserver.c index 1f70ef779..a54444178 100644 --- a/kbx/kbxserver.c +++ b/kbx/kbxserver.c @@ -225,22 +225,34 @@ cmd_search (assuan_context_t ctx, char *line) ctrl->server_local->search_any_found = 0; - if (!*line && opt_more) + if (!*line) { - err = set_error (GPG_ERR_INV_ARG, "--more but no pattern"); - goto leave; + if (opt_more) + { + err = set_error (GPG_ERR_INV_ARG, "--more but no pattern"); + goto leave; + } + else if (!*line && ctrl->server_local->search_expecting_more) + { + /* It would be too surprising to first set a pattern but + * finally add no pattern to search the entire DB. */ + err = set_error (GPG_ERR_INV_ARG, "--more pending but no pattern"); + goto leave; + } + else /* No pattern - return the first item. */ + { + memset (&ctrl->server_local->search_desc, 0, + sizeof ctrl->server_local->search_desc); + ctrl->server_local->search_desc.mode = KEYDB_SEARCH_MODE_FIRST; + } } - else if (!*line && ctrl->server_local->search_expecting_more) + else { - /* It would be too surprising to first set a pattern but finally - * add no pattern to search the entire DB. */ - err = set_error (GPG_ERR_INV_ARG, "--more pending but no pattern"); - goto leave; + err = classify_user_id (line, &ctrl->server_local->search_desc, 0); + if (err) + goto leave; } - err = classify_user_id (line, &ctrl->server_local->search_desc, 0); - if (err) - goto leave; if (opt_more || ctrl->server_local->search_expecting_more) { /* More pattern are expected - store the current one and return |