aboutsummaryrefslogtreecommitdiff
path: root/include/libssh/config_parser.h
blob: e974917cde29f484a5d52330e4d599024ed51ccc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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_ */