• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /netgear-WNDR4500v2-V1.0.0.60_1.0.38/ap/gpl/timemachine/gettext-0.17/gettext-tools/gnulib-lib/
1/* quotearg.h - quote arguments for output
2
3   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2006 Free
4   Software Foundation, Inc.
5
6   This program is free software: you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 3 of the License, or
9   (at your option) any later version.
10
11   This program is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15
16   You should have received a copy of the GNU General Public License
17   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
18
19/* Written by Paul Eggert <eggert@twinsun.com> */
20
21#ifndef QUOTEARG_H_
22# define QUOTEARG_H_ 1
23
24# include <stddef.h>
25
26/* Basic quoting styles.  */
27enum quoting_style
28  {
29    /* Output names as-is (ls --quoting-style=literal).  */
30    literal_quoting_style,
31
32    /* Quote names for the shell if they contain shell metacharacters
33       or would cause ambiguous output (ls --quoting-style=shell).  */
34    shell_quoting_style,
35
36    /* Quote names for the shell, even if they would normally not
37       require quoting (ls --quoting-style=shell-always).  */
38    shell_always_quoting_style,
39
40    /* Quote names as for a C language string (ls --quoting-style=c).  */
41    c_quoting_style,
42
43    /* Like c_quoting_style except omit the surrounding double-quote
44       characters (ls --quoting-style=escape).  */
45    escape_quoting_style,
46
47    /* Like clocale_quoting_style, but quote `like this' instead of
48       "like this" in the default C locale (ls --quoting-style=locale).  */
49    locale_quoting_style,
50
51    /* Like c_quoting_style except use quotation marks appropriate for
52       the locale (ls --quoting-style=clocale).  */
53    clocale_quoting_style
54  };
55
56/* For now, --quoting-style=literal is the default, but this may change.  */
57# ifndef DEFAULT_QUOTING_STYLE
58#  define DEFAULT_QUOTING_STYLE literal_quoting_style
59# endif
60
61/* Names of quoting styles and their corresponding values.  */
62extern char const *const quoting_style_args[];
63extern enum quoting_style const quoting_style_vals[];
64
65struct quoting_options;
66
67/* The functions listed below set and use a hidden variable
68   that contains the default quoting style options.  */
69
70/* Allocate a new set of quoting options, with contents initially identical
71   to O if O is not null, or to the default if O is null.
72   It is the caller's responsibility to free the result.  */
73struct quoting_options *clone_quoting_options (struct quoting_options *o);
74
75/* Get the value of O's quoting style.  If O is null, use the default.  */
76enum quoting_style get_quoting_style (struct quoting_options *o);
77
78/* In O (or in the default if O is null),
79   set the value of the quoting style to S.  */
80void set_quoting_style (struct quoting_options *o, enum quoting_style s);
81
82/* In O (or in the default if O is null),
83   set the value of the quoting options for character C to I.
84   Return the old value.  Currently, the only values defined for I are
85   0 (the default) and 1 (which means to quote the character even if
86   it would not otherwise be quoted).  */
87int set_char_quoting (struct quoting_options *o, char c, int i);
88
89/* Place into buffer BUFFER (of size BUFFERSIZE) a quoted version of
90   argument ARG (of size ARGSIZE), using O to control quoting.
91   If O is null, use the default.
92   Terminate the output with a null character, and return the written
93   size of the output, not counting the terminating null.
94   If BUFFERSIZE is too small to store the output string, return the
95   value that would have been returned had BUFFERSIZE been large enough.
96   If ARGSIZE is -1, use the string length of the argument for ARGSIZE.  */
97size_t quotearg_buffer (char *buffer, size_t buffersize,
98			char const *arg, size_t argsize,
99			struct quoting_options const *o);
100
101/* Like quotearg_buffer, except return the result in a newly allocated
102   buffer.  It is the caller's responsibility to free the result.  */
103char *quotearg_alloc (char const *arg, size_t argsize,
104		      struct quoting_options const *o);
105
106/* Use storage slot N to return a quoted version of the string ARG.
107   Use the default quoting options.
108   The returned value points to static storage that can be
109   reused by the next call to this function with the same value of N.
110   N must be nonnegative.  */
111char *quotearg_n (int n, char const *arg);
112
113/* Equivalent to quotearg_n (0, ARG).  */
114char *quotearg (char const *arg);
115
116/* Use style S and storage slot N to return a quoted version of the string ARG.
117   This is like quotearg_n (N, ARG), except that it uses S with no other
118   options to specify the quoting method.  */
119char *quotearg_n_style (int n, enum quoting_style s, char const *arg);
120
121/* Use style S and storage slot N to return a quoted version of the
122   argument ARG of size ARGSIZE.  This is like quotearg_n_style
123   (N, S, ARG), except it can quote null bytes.  */
124char *quotearg_n_style_mem (int n, enum quoting_style s,
125			    char const *arg, size_t argsize);
126
127/* Equivalent to quotearg_n_style (0, S, ARG).  */
128char *quotearg_style (enum quoting_style s, char const *arg);
129
130/* Like quotearg (ARG), except also quote any instances of CH.  */
131char *quotearg_char (char const *arg, char ch);
132
133/* Equivalent to quotearg_char (ARG, ':').  */
134char *quotearg_colon (char const *arg);
135
136/* Free any dynamically allocated memory.  */
137void quotearg_free (void);
138
139#endif /* !QUOTEARG_H_ */
140