libssh 0.12.0
The SSH library
Loading...
Searching...
No Matches
config_parser.h
1/*
2 * config_parser.h - Common configuration file parser functions
3 *
4 * This file is part of the SSH Library
5 *
6 * Copyright (c) 2019 by Red Hat, Inc.
7 *
8 * Author: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
9 *
10 * The SSH Library is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License as published by
12 * the Free Software Foundation; either version 2.1 of the License, or (at your
13 * option) any later version.
14 *
15 * The SSH Library is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
18 * License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with the SSH Library; see the file COPYING. If not, write to
22 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
23 * MA 02111-1307, USA.
24 */
25
26#ifndef CONFIG_PARSER_H_
27#define CONFIG_PARSER_H_
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33#include "libssh/libssh.h"
34#include <stdbool.h>
35
36char *ssh_config_get_cmd(char **str);
37
39 /* found is false only when no token was present at all. An explicit empty
40 * token such as "" still returns found=true with an empty string.
41 */
42 bool found;
43 bool had_equal;
44 bool invalid;
45};
46
47char *ssh_config_get_token(char **str);
48
49char *ssh_config_get_token_info(char **str, struct ssh_config_token_info *info);
50long ssh_config_get_long(char **str, long notfound);
51
52const char *ssh_config_get_str_tok(char **str, const char *def);
53
54int ssh_config_get_yesno(char **str, int notfound);
55
56/* @brief Parse SSH URI in format [user@]host[:port] from the given string
57 *
58 * @param[in] tok String to parse
59 * @param[out] username Pointer to the location, where the new username will
60 * be stored or NULL if we do not care about the result.
61 * @param[out] hostname Pointer to the location, where the new hostname will
62 * be stored or NULL if we do not care about the result.
63 * @param[out] port Pointer to the location, where the new port will
64 * be stored or NULL if we do not care about the result.
65 * @param[in] ignore_port Set to true if we should not attempt to parse
66 * port number.
67 * @param[in] strict Set to true to validate hostname against RFC1035
68 * (for resolving to a real host).
69 * Set to false to only reject shell metacharacters
70 * (allowing config aliases with non-RFC1035 chars
71 * like underscores, resolved later via Hostname).
72 *
73 * @returns SSH_OK if the provided string is in format of SSH URI,
74 * SSH_ERROR on failure
75 */
76int ssh_config_parse_uri(const char *tok,
77 char **username,
78 char **hostname,
79 char **port,
80 bool ignore_port,
81 bool strict);
82
94int ssh_config_parse_proxy_jump(ssh_session session,
95 const char *s,
96 bool do_parsing);
97
98#ifdef __cplusplus
99}
100#endif
101
102#endif /* LIBSSH_CONFIG_H_ */
Definition config_parser.h:38