/* $NetBSD: parse.c,v 1.40 2016/05/09 21:46:56 christos Exp $ */ /*- * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Christos Zoulas of Cornell University. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include "config.h" #if !defined(lint) && !defined(SCCSID) #if 0 static char sccsid[] = "@(#)parse.c 8.1 (Berkeley) 6/4/93"; #else __RCSID("$NetBSD: parse.c,v 1.40 2016/05/09 21:46:56 christos Exp $"); #endif #endif /* not lint && not SCCSID */ /* * parse.c: parse an editline extended command * * commands are: * * bind * echotc * edit * gettc * history * settc * setty */ #include #include #include "el.h" #include "parse.h" static const struct { const wchar_t *name; int (*func)(EditLine *, int, const wchar_t **); } cmds[] = { { L"bind", map_bind }, { L"echotc", terminal_echotc }, { L"edit", el_editmode }, { L"history", hist_command }, { L"telltc", terminal_telltc }, { L"settc", terminal_settc }, { L"setty", tty_stty }, { NULL, NULL } }; /* parse_line(): * Parse a line and dispatch it */ libedit_private int parse_line(EditLine *el, const wchar_t *line) { const wchar_t **argv; int argc; TokenizerW *tok; tok = tok_winit(NULL); tok_wstr(tok, line, &argc, &argv); argc = el_wparse(el, argc, argv); tok_wend(tok); return argc; } /* el_parse(): * Command dispatcher */ int el_wparse(EditLine *el, int argc, const wchar_t *argv[]) { const wchar_t *ptr; int i; if (argc < 1) return -1; ptr = wcschr(argv[0], L':'); if (ptr != NULL) { wchar_t *tprog; size_t l; if (ptr == argv[0]) return 0; l = (size_t)(ptr - argv[0] - 1); tprog = el_malloc((l + 1) * sizeof(*tprog)); if (tprog == NULL) return 0; (void) wcsncpy(tprog, argv[0], l); tprog[l] = '\0'; ptr++; l = (size_t)el_match(el->el_prog, tprog); el_free(tprog); if (!l) return 0; } else ptr = argv[0]; for (i = 0; cmds[i].name != NULL; i++) if (wcscmp(cmds[i].name, ptr) == 0) { i = (*cmds[i].func) (el, argc, argv); return -i; } return -1; } /* parse__escape(): * Parse a string of the form ^ \ \<2021-04-18 17:54:23 -0400 commit3bb2203d08dbddd9356334d350275be577e9fa84 (patch) treedfc4bf1648d4e0e4d3161267235b1b392e832228 parentBump version to 3.3.1p1 (diff)parentImport LibreSSL 3.3.2 (diff)downloadlibretls-3bb2203d08dbddd9356334d350275be577e9fa84.tar.gz
libretls-3bb2203d08dbddd9356334d350275be577e9fa84.zip
Merge LibreSSL 3.3.2 into master
Diffstat (limited to '')
-rw-r--r--LIBTLS_VERSION2
-rw-r--r--VERSION2