gsasl  1.10.0
About: GNU SASL is an implementation of the Simple Authentication and Security Layer (SASL). Development version.
  Fossies Dox: gsasl-1.10.0.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

quotearg.c File Reference
#include <config.h>
#include "quotearg.h"
#include "quote.h"
#include "attribute.h"
#include "minmax.h"
#include "xalloc.h"
#include "c-strcaseeq.h"
#include "localcharset.h"
#include <ctype.h>
#include <errno.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <wchar.h>
#include <wctype.h>
#include "gettext.h"
Include dependency graph for quotearg.c:

Go to the source code of this file.

Data Structures

struct  quoting_options
 
struct  slotvec
 

Macros

#define _(msgid)   gettext (msgid)
 
#define N_(msgid)   msgid
 
#define SIZE_MAX   ((size_t) -1)
 
#define INT_BITS   (sizeof (int) * CHAR_BIT)
 
#define STORE(c)
 
#define START_ESC()
 
#define END_ESC()
 

Functions

struct quoting_optionsclone_quoting_options (struct quoting_options *o)
 
enum quoting_style get_quoting_style (struct quoting_options const *o)
 
void set_quoting_style (struct quoting_options *o, enum quoting_style s)
 
int set_char_quoting (struct quoting_options *o, char c, int i)
 
int set_quoting_flags (struct quoting_options *o, int i)
 
void set_custom_quoting (struct quoting_options *o, char const *left_quote, char const *right_quote)
 
static struct quoting_options quoting_options_from_style (enum quoting_style style)
 
static char const * gettext_quote (char const *msgid, enum quoting_style s)
 
static size_t quotearg_buffer_restyled (char *buffer, size_t buffersize, char const *arg, size_t argsize, enum quoting_style quoting_style, int flags, unsigned int const *quote_these_too, char const *left_quote, char const *right_quote)
 
size_t quotearg_buffer (char *buffer, size_t buffersize, char const *arg, size_t argsize, struct quoting_options const *o)
 
char * quotearg_alloc (char const *arg, size_t argsize, struct quoting_options const *o)
 
char * quotearg_alloc_mem (char const *arg, size_t argsize, size_t *size, struct quoting_options const *o)
 
void quotearg_free (void)
 
static char * quotearg_n_options (int n, char const *arg, size_t argsize, struct quoting_options const *options)
 
char * quotearg_n (int n, char const *arg)
 
char * quotearg_n_mem (int n, char const *arg, size_t argsize)
 
char * quotearg (char const *arg)
 
char * quotearg_mem (char const *arg, size_t argsize)
 
char * quotearg_n_style (int n, enum quoting_style s, char const *arg)
 
char * quotearg_n_style_mem (int n, enum quoting_style s, char const *arg, size_t argsize)
 
char * quotearg_style (enum quoting_style s, char const *arg)
 
char * quotearg_style_mem (enum quoting_style s, char const *arg, size_t argsize)
 
char * quotearg_char_mem (char const *arg, size_t argsize, char ch)
 
char * quotearg_char (char const *arg, char ch)
 
char * quotearg_colon (char const *arg)
 
char * quotearg_colon_mem (char const *arg, size_t argsize)
 
char * quotearg_n_style_colon (int n, enum quoting_style s, char const *arg)
 
char * quotearg_n_custom (int n, char const *left_quote, char const *right_quote, char const *arg)
 
char * quotearg_n_custom_mem (int n, char const *left_quote, char const *right_quote, char const *arg, size_t argsize)
 
char * quotearg_custom (char const *left_quote, char const *right_quote, char const *arg)
 
char * quotearg_custom_mem (char const *left_quote, char const *right_quote, char const *arg, size_t argsize)
 
char const * quote_n_mem (int n, char const *arg, size_t argsize)
 
char const * quote_mem (char const *arg, size_t argsize)
 
char const * quote_n (int n, char const *arg)
 
char const * quote (char const *arg)
 

Variables

char const *const quoting_style_args []
 
enum quoting_style const quoting_style_vals []
 
static struct quoting_options default_quoting_options
 
static char slot0 [256]
 
static int nslots = 1
 
static struct slotvec slotvec0 = {sizeof slot0, slot0}
 
static struct slotvecslotvec = &slotvec0
 
struct quoting_options quote_quoting_options
 

Macro Definition Documentation

◆ _

#define _ (   msgid)    gettext (msgid)

Definition at line 49 of file quotearg.c.

◆ END_ESC

#define END_ESC ( )
Value:
do \
{ \
if (pending_shell_escape_end && ! escaping) \
{ \
STORE ('\''); \
STORE ('\''); \
pending_shell_escape_end = false; \
} \
} \
while (0)

◆ INT_BITS

#define INT_BITS   (sizeof (int) * CHAR_BIT)

Definition at line 56 of file quotearg.c.

◆ N_

#define N_ (   msgid)    msgid

Definition at line 50 of file quotearg.c.

◆ SIZE_MAX

#define SIZE_MAX   ((size_t) -1)

Definition at line 53 of file quotearg.c.

◆ START_ESC

#define START_ESC ( )
Value:
do \
{ \
if (elide_outer_quotes) \
goto force_outer_quoting_style; \
escaping = true; \
&& ! pending_shell_escape_end) \
{ \
STORE ('\''); \
STORE ('$'); \
STORE ('\''); \
pending_shell_escape_end = true; \
} \
STORE ('\\'); \
} \
while (0)
quoting_style
Definition: quotearg.h:33
@ shell_always_quoting_style
Definition: quotearg.h:74

◆ STORE

#define STORE (   c)
Value:
do \
{ \
if (len < buffersize) \
buffer[len] = (c); \
len++; \
} \
while (0)
unsigned char c

Function Documentation

◆ clone_quoting_options()

struct quoting_options* clone_quoting_options ( struct quoting_options o)

Definition at line 115 of file quotearg.c.

◆ get_quoting_style()

enum quoting_style get_quoting_style ( struct quoting_options const *  o)

Definition at line 115 of file quotearg.c.

References default_quoting_options, p, and xmemdup().

◆ gettext_quote()

static char const* gettext_quote ( char const *  msgid,
enum quoting_style  s 
)
static

Definition at line 200 of file quotearg.c.

References _, clocale_quoting_style, locale_charset(), and STRCASEEQ.

Referenced by quotearg_buffer_restyled().

◆ quote()

char const* quote ( char const *  arg)

Definition at line 1072 of file quotearg.c.

References quote_n().

Referenced by main().

◆ quote_mem()

char const* quote_mem ( char const *  arg,
size_t  argsize 
)

Definition at line 1060 of file quotearg.c.

References quote_n_mem().

◆ quote_n()

char const* quote_n ( int  n,
char const *  arg 
)

Definition at line 1066 of file quotearg.c.

References quote_n_mem(), and SIZE_MAX.

Referenced by quote().

◆ quote_n_mem()

char const* quote_n_mem ( int  n,
char const *  arg,
size_t  argsize 
)

Definition at line 1054 of file quotearg.c.

References quote_quoting_options, and quotearg_n_options().

Referenced by quote_mem(), and quote_n().

◆ quotearg()

char* quotearg ( char const *  arg)

Definition at line 936 of file quotearg.c.

References quotearg_n().

◆ quotearg_alloc()

char* quotearg_alloc ( char const *  arg,
size_t  argsize,
struct quoting_options const *  o 
)

Definition at line 792 of file quotearg.c.

References NULL, and quotearg_alloc_mem().

◆ quotearg_alloc_mem()

char* quotearg_alloc_mem ( char const *  arg,
size_t  argsize,
size_t size,
struct quoting_options const *  o 
)

◆ quotearg_buffer()

size_t quotearg_buffer ( char *  buffer,
size_t  buffersize,
char const *  arg,
size_t  argsize,
struct quoting_options const *  o 
)

Definition at line 777 of file quotearg.c.

References default_quoting_options, p, and quotearg_buffer_restyled().

◆ quotearg_buffer_restyled()

◆ quotearg_char()

char* quotearg_char ( char const *  arg,
char  ch 
)

Definition at line 984 of file quotearg.c.

References quotearg_char_mem(), and SIZE_MAX.

Referenced by quotearg_colon().

◆ quotearg_char_mem()

char* quotearg_char_mem ( char const *  arg,
size_t  argsize,
char  ch 
)

Definition at line 975 of file quotearg.c.

References default_quoting_options, quotearg_n_options(), and set_char_quoting().

Referenced by quotearg_char(), and quotearg_colon_mem().

◆ quotearg_colon()

char* quotearg_colon ( char const *  arg)

Definition at line 990 of file quotearg.c.

References quotearg_char().

◆ quotearg_colon_mem()

char* quotearg_colon_mem ( char const *  arg,
size_t  argsize 
)

Definition at line 996 of file quotearg.c.

References quotearg_char_mem().

◆ quotearg_custom()

char* quotearg_custom ( char const *  left_quote,
char const *  right_quote,
char const *  arg 
)

◆ quotearg_custom_mem()

char* quotearg_custom_mem ( char const *  left_quote,
char const *  right_quote,
char const *  arg,
size_t  argsize 
)

◆ quotearg_free()

void quotearg_free ( void  )

Definition at line 841 of file quotearg.c.

References nslots, slotvec::size, slot0, slotvec, slotvec0, and slotvec::val.

◆ quotearg_mem()

char* quotearg_mem ( char const *  arg,
size_t  argsize 
)

Definition at line 942 of file quotearg.c.

References quotearg_n_mem().

◆ quotearg_n()

char* quotearg_n ( int  n,
char const *  arg 
)

Definition at line 924 of file quotearg.c.

References default_quoting_options, quotearg_n_options(), and SIZE_MAX.

Referenced by quotearg().

◆ quotearg_n_custom()

char* quotearg_n_custom ( int  n,
char const *  left_quote,
char const *  right_quote,
char const *  arg 
)

◆ quotearg_n_custom_mem()

char* quotearg_n_custom_mem ( int  n,
char const *  left_quote,
char const *  right_quote,
char const *  arg,
size_t  argsize 
)

◆ quotearg_n_mem()

char* quotearg_n_mem ( int  n,
char const *  arg,
size_t  argsize 
)

Definition at line 930 of file quotearg.c.

References default_quoting_options, and quotearg_n_options().

Referenced by quotearg_mem().

◆ quotearg_n_options()

◆ quotearg_n_style()

char* quotearg_n_style ( int  n,
enum quoting_style  s,
char const *  arg 
)

Definition at line 948 of file quotearg.c.

References quotearg_n_options(), quoting_options_from_style(), and SIZE_MAX.

Referenced by quotearg_style().

◆ quotearg_n_style_colon()

char* quotearg_n_style_colon ( int  n,
enum quoting_style  s,
char const *  arg 
)

◆ quotearg_n_style_mem()

char* quotearg_n_style_mem ( int  n,
enum quoting_style  s,
char const *  arg,
size_t  argsize 
)

Definition at line 955 of file quotearg.c.

References quotearg_n_options(), and quoting_options_from_style().

Referenced by quotearg_style_mem().

◆ quotearg_style()

char* quotearg_style ( enum quoting_style  s,
char const *  arg 
)

Definition at line 963 of file quotearg.c.

References quotearg_n_style().

◆ quotearg_style_mem()

char* quotearg_style_mem ( enum quoting_style  s,
char const *  arg,
size_t  argsize 
)

Definition at line 969 of file quotearg.c.

References quotearg_n_style_mem().

◆ quoting_options_from_style()

static struct quoting_options quoting_options_from_style ( enum quoting_style  style)
static

Definition at line 172 of file quotearg.c.

Referenced by quotearg_n_style(), quotearg_n_style_colon(), and quotearg_n_style_mem().

◆ set_char_quoting()

int set_char_quoting ( struct quoting_options o,
char  c,
int  i 
)

◆ set_custom_quoting()

void set_custom_quoting ( struct quoting_options o,
char const *  left_quote,
char const *  right_quote 
)

◆ set_quoting_flags()

int set_quoting_flags ( struct quoting_options o,
int  i 
)

Definition at line 161 of file quotearg.c.

References default_quoting_options, and quoting_options::flags.

◆ set_quoting_style()

void set_quoting_style ( struct quoting_options o,
enum quoting_style  s 
)

Definition at line 134 of file quotearg.c.

References default_quoting_options, and quoting_options::style.

Variable Documentation

◆ default_quoting_options

◆ nslots

int nslots = 1
static

Definition at line 836 of file quotearg.c.

Referenced by quotearg_free(), and quotearg_n_options().

◆ quote_quoting_options

struct quoting_options quote_quoting_options
Initial value:
=
{
0,
{ 0 },
}
#define NULL
Definition: stddef.in.h:72
@ locale_quoting_style
Definition: quotearg.h:170

Definition at line 1036 of file quotearg.c.

Referenced by quote_n_mem().

◆ quoting_style_args

char const* const quoting_style_args[]
Initial value:
=
{
"literal",
"shell",
"shell-always",
"shell-escape",
"shell-escape-always",
"c",
"c-maybe",
"escape",
"locale",
"clocale",
0
}

Definition at line 78 of file quotearg.c.

◆ quoting_style_vals

enum quoting_style const quoting_style_vals[]
Initial value:

Definition at line 78 of file quotearg.c.

◆ slot0

char slot0[256]
static

Definition at line 835 of file quotearg.c.

Referenced by quotearg_free(), and quotearg_n_options().

◆ slotvec

struct slotvec* slotvec = &slotvec0
static

Definition at line 838 of file quotearg.c.

Referenced by quotearg_free(), and quotearg_n_options().

◆ slotvec0

struct slotvec slotvec0 = {sizeof slot0, slot0}
static

Definition at line 836 of file quotearg.c.

Referenced by quotearg_free(), and quotearg_n_options().