diff options
author | Anderson Toshiyuki Sasaki <ansasaki@redhat.com> | 2019-02-22 13:06:49 +0100 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2019-04-01 08:25:22 +0200 |
commit | 79049981a513f9a10fac0f153e9b0b588326021f (patch) | |
tree | ef01c66bf9bffe42b40e98ac4614cc5d5a7ddcb2 /include/libssh | |
parent | 19e886d6b1ed59bed6b8f6ba2eb5dd9e70395809 (diff) | |
download | libssh-79049981a513f9a10fac0f153e9b0b588326021f.tar.gz libssh-79049981a513f9a10fac0f153e9b0b588326021f.tar.xz libssh-79049981a513f9a10fac0f153e9b0b588326021f.zip |
config: Move common parser functions to config_parser.c
This will allow the moved functions to be used in the server side
configuration parser implementation.
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'include/libssh')
-rw-r--r-- | include/libssh/config_parser.h | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/include/libssh/config_parser.h b/include/libssh/config_parser.h new file mode 100644 index 00000000..e974917c --- /dev/null +++ b/include/libssh/config_parser.h @@ -0,0 +1,57 @@ +/* + * config_parser.h - Common configuration file parser functions + * + * This file is part of the SSH Library + * + * Copyright (c) 2019 by Red Hat, Inc. + * + * Author: Anderson Toshiyuki Sasaki <ansasaki@redhat.com> + * + * The SSH Library is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or (at your + * option) any later version. + * + * The SSH Library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the SSH Library; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, + * MA 02111-1307, USA. + */ + +#ifndef CONFIG_PARSER_H_ +#define CONFIG_PARSER_H_ + +char *ssh_config_get_cmd(char **str); + +char *ssh_config_get_token(char **str); + +long ssh_config_get_long(char **str, long notfound); + +const char *ssh_config_get_str_tok(char **str, const char *def); + +int ssh_config_get_yesno(char **str, int notfound); + +/* @brief Parse SSH URI in format [user@]host[:port] from the given string + * + * @param[in] tok String to parse + * @param[out] username Pointer to the location, where the new username will + * be stored or NULL if we do not care about the result. + * @param[out] hostname Pointer to the location, where the new hostname will + * be stored or NULL if we do not care about the result. + * @param[out] port Pointer to the location, where the new port will + * be stored or NULL if we do not care about the result. + * + * @returns SSH_OK if the provided string is in format of SSH URI, + * SSH_ERROR on failure + */ +int ssh_config_parse_uri(const char *tok, + char **username, + char **hostname, + char **port); + +#endif /* LIBSSH_CONFIG_H_ */ |