escape.h revision 3565e09594a9cd2786b5682ad13812491e6781c1
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen This file is part of systemd.
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen Copyright 2010 Lennart Poettering
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen systemd is free software; you can redistribute it and/or modify it
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen under the terms of the GNU Lesser General Public License as published by
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen the Free Software Foundation; either version 2.1 of the License, or
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen (at your option) any later version.
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen systemd is distributed in the hope that it will be useful, but
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen WITHOUT ANY WARRANTY; without even the implied warranty of
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen Lesser General Public License for more details.
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen You should have received a copy of the GNU Lesser General Public License
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen along with systemd; If not, see <http://www.gnu.org/licenses/>.
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen/* What characters are special in the shell? */
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen/* must be escaped outside and inside double-quotes */
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen#define SHELL_NEED_ESCAPE "\"\\`$"
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen/* can be escaped or double-quoted */
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen#define SHELL_NEED_QUOTES SHELL_NEED_ESCAPE GLOB_CHARS "'()<>|&;"
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersenchar *cescape(const char *s);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersenchar *cescape_length(const char *s, size_t n);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersensize_t cescape_char(char c, char *buf);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersenint cunescape(const char *s, UnescapeFlags flags, char **ret);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersenint cunescape_length(const char *s, size_t length, UnescapeFlags flags, char **ret);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersenint cunescape_length_with_prefix(const char *s, size_t length, const char *prefix, UnescapeFlags flags, char **ret);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersenint cunescape_one(const char *p, size_t length, uint32_t *ret, bool *eight_bit);
d5d8429a12c4b1ef0dcd226c0904f00f4fa4898aLennart Poetteringchar *xescape(const char *s, const char *bad);
d5d8429a12c4b1ef0dcd226c0904f00f4fa4898aLennart Poetteringchar *shell_escape(const char *s, const char *bad);
d5d8429a12c4b1ef0dcd226c0904f00f4fa4898aLennart Poetteringchar *shell_maybe_quote(const char *s);