1 /* 2 * strq.h -- string functions, handles quoted text 3 * 4 * Yet Another FTP Client 5 * Copyright (C) 1998-2001, Martin Hedenfalk <mhe@stacken.kth.se> 6 * Copyright (C) 2013, Sebastian Ramacher <sebastian+dev@ramacher.at> 7 * 8 * This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation; either version 2 of the License, or 11 * (at your option) any later version. See COPYING for more details. 12 */ 13 14 #ifndef _strq_h_included 15 #define _strq_h_included 16 17 void strpush(char *s, int n); 18 void strpull(char *s, int n); 19 int strqnchr(const char *str, char c); 20 char *strqchr(char *s, int ch); 21 char *strqsep(char **s, char delim); 22 void unquote(char *str); 23 void unquote_escapes(char *str); 24 25 char *stripslash(char *p); 26 const char *base_name_ptr(const char *s); 27 char *base_name_xptr(const char* s); 28 char *base_dir_xptr(const char *path); 29 char *strip_blanks(char *str); 30 void fix_unprintable(char *str); 31 32 char *tilde_expand_home(const char *str, const char *home); 33 char *path_absolute(const char *path, 34 const char *curdir, const char *homedir); 35 char *path_collapse(char *path); 36 char *path_dos2unix(char *path); 37 38 int str2bool(const char *e); 39 40 char *encode_rfc1738(const char *str, const char *xtra); 41 char *decode_rfc1738(const char *str); 42 char *encode_url_directory(const char *str); 43 #define encode_url_username(str) encode_rfc1738(str, ":@/") 44 #define encode_url_password(str) encode_rfc1738(str, ":@/") 45 46 void strip_trailing_chars(char *str, const char *chrs); 47 48 #ifdef HAVE_CONFIG_H 49 #include <config.h> 50 #endif 51 52 #if defined(HAVE_LIBREADLINE) && !defined(HAVE_LIBEDIT) 53 /* Quote a filename using double quotes, single quotes, or backslashes 54 depending on the value of completion_quoting_style. If we're 55 completing using backslashes, we need to quote some additional 56 characters (those that readline treats as word breaks), so we call 57 quote_word_break_chars on the result. */ 58 char* quote_filename(const char* s, int rtype, const char* qcp); 59 #endif 60 61 /* A function to strip quotes that are not protected by backquotes. It 62 allows single quotes to appear within double quotes, and vice versa. 63 It should be smarter. */ 64 char* dequote_filename(const char* text, int quote_char); 65 /* Quote special characters in STRING using backslashes. Return a new 66 string. */ 67 char* backslash_quote(const char* string); 68 /* Return 1 if the portion of STRING ending at EINDEX is quoted (there is 69 an unclosed quoted string), or if the character at EINDEX is quoted 70 by a backslash. */ 71 int char_is_quoted(const char* string, int eindex); 72 73 #endif 74