37#include    <snapdev/glob_to_list.h> 
   38#include    <snapdev/isatty.h> 
   39#include    <snapdev/not_used.h> 
   40#include    <snapdev/trim_string.h> 
   45#include    <cppthread/guard.h> 
   46#include    <cppthread/mutex.h> 
   68#include    <snapdev/poison.h> 
   98constexpr char const *  
g_simple_characters = 
"+-./0123456789=ABCEFGHIJKLMNOPQRSTUVWXYZabcefghijklmnopqrstuvwxyz_";
 
 
  126        cppthread::guard lock(*cppthread::g_system_mutex);
 
  128        if(g_mutex == 
nullptr)
 
  130            g_mutex = 
new cppthread::mutex();
 
 
  172        std::string::size_type 
const max(
pairs.length() - 1);
 
  178                return s.substr(1, 
s.length() - 2);
 
 
  211    for(
auto const c : 
s)
 
 
  263    for(
auto const & 
c : 
s)
 
 
  292    for(
auto const & 
c : 
s)
 
 
  351    std::string::size_type 
pos(0);
 
  352    std::string::size_type 
start(0);
 
 
  494    std::string::size_type 
const pos(
filename.find_last_of(
'/'));
 
  500                + 
"\" last slash (/) is at the start, which is not allowed.");
 
  502    if(
pos != std::string::npos
 
  519    snapdev::glob_to_list<std::set<std::string>> 
glob;
 
  524        snapdev::NOT_USED(
glob.read_path<snapdev::glob_to_list_flag_t::GLOB_FLAG_IGNORE_ERRORS>(
pattern));
 
 
  594              "priority must be a number between 0 and 99 inclusive; " 
  601        return std::string();
 
  604    char const * name(
nullptr);
 
  611            return std::string();
 
  620    std::string::size_type 
const pos(
filename.find_last_of(
'/'));
 
  628    if(
pos != std::string::npos)
 
  640    if(
pos == std::string::npos)
 
 
  711    return s == 
"true" || 
s == 
"on" || 
s == 
"yes" | 
s == 
"1";
 
 
  732    return s == 
"false" || 
s == 
"off" || 
s == 
"no" || 
s == 
"0";
 
 
  748    std::int64_t 
cols(80);
 
  760            cols = std::max(
static_cast<unsigned short>(40), 
w.ws_col);
 
 
  796    std::stringstream 
ss;
 
  805        std::string::size_type 
const nl(
line.find(
'\n'));
 
  806        if(
nl != std::string::npos
 
  826            while(std::isspace(
line[
pos]));
 
  833            std::string::size_type 
pos(
line.find_last_of(
' ', 
width));
 
  834            if(
pos == std::string::npos)
 
  853                while(std::isspace(
line[
pos]));
 
 
  901                    , std::string 
const & 
help 
  905    std::stringstream 
ss;
 
 
  963        return std::string(g_empty_string);
 
  966    std::string::size_type 
const pos(
arg.find_first_not_of(g_simple_characters));
 
  967    if(
pos == std::string::npos)
 
  975    std::string::size_type 
p1(0);
 
  976    while(
p1 < 
arg.length())
 
  978        std::string::size_type 
const p2(
arg.find(
'\'', 
p1));
 
  979        if(
p2 == std::string::npos)
 
  985        result += g_escaped_single_quotes;
 
 
 1008#if defined(__SANITIZE_ADDRESS__) || defined(__SANITIZE_THREAD__) 
 1009#if defined(__SANITIZE_ADDRESS__) 
 1010    result += 
"The address sanitizer is compiled in.\n";
 
 1012#if defined(__SANITIZE_THREAD__) 
 1013    result += 
"The thread sanitizer is compiled in.\n";
 
 1016    result += 
"The address and thread sanitizers are not compiled in.\n";
 
 
 1039    std::int64_t 
rows(25);
 
 1050            rows = std::max(
static_cast<unsigned short>(2), 
w.ws_row);
 
 
 1071    if(snapdev::isatty(
out))
 
 1074        auto const lines(std::count(
data.begin(), 
data.end(), 
'\n'));
 
 1079            if(
stat(
"/bin/less", &
s) == 0)
 
 1089            else if(
stat(
"/bin/more", &
s) == 0)
 
 
Definitions of the advanced getopt exceptions.
constexpr char const  * g_escaped_single_quotes
cppthread::mutex * g_mutex
The configuration file mutex.
constexpr char const  * g_empty_string
constexpr char const g_single_quote
constexpr char const  * g_simple_characters
The advgetopt environment to parse command line options.
size_t get_screen_width()
Retrieve the width of one line in your console.
string_list_t insert_group_name(std::string const &filename, char const *group_name, char const *project_name, bool add_default_on_empty)
Insert the group (or project) name in the filename.
void split_string(std::string const &str, string_list_t &result, string_list_t const &separators)
Split a string in sub-strings separated by separators.
bool is_false(std::string s)
Check whether a value represents "false".
std::string breakup_line(std::string line, size_t const option_width, size_t const line_width)
Breakup a string on multiple lines.
constexpr flag_t option_flags_merge()
void less(std::basic_ostream< char > &out, std::string const &data)
Print out a string to the console or use less.
std::string format_usage_string(std::string const &argument, std::string const &help, size_t const option_width, size_t const line_width)
Format a help string to make it fit on a given width.
cppthread::mutex & get_global_mutex()
Get a global mutex.
bool is_true(std::string s)
Check whether a value represents "true".
std::string option_with_underscores(std::string const &s)
Converts an option back to using underscores.
std::string escape_shell_argument(std::string const &arg)
Escape special characters from a shell argument.
std::string quote(std::string const &s, char open, char close)
The converse of unquote.
std::string sanitizer_details()
Generate a string describing whether we're using the sanitizer.
size_t get_screen_height()
Retrieve the height of your console.
std::string unquote(std::string const &s, std::string const &pairs)
Remove single (') or double (") quotes from a string.
std::string option_with_dashes(std::string const &s)
Convert the _ found in a string to - instead.
std::vector< std::string > string_list_t
std::string handle_user_directory(std::string const &filename)
Replace a starting ~/... with the contents of the $HOME variable.
std::string default_group_name(std::string const &filename, char const *group_name, char const *project_name, int priority)
Generate the default filename (the ".../50-...")
A few utility functions that are not specific to an object.