libDwm-0.9.45
DwmExecutor.hh
Go to the documentation of this file.
1//===========================================================================
2// @(#) $DwmPath$
3//===========================================================================
4// Copyright (c) Daniel W. McRobb 2010, 2016
5// All rights reserved.
6//
7// Redistribution and use in source and binary forms, with or without
8// modification, are permitted provided that the following conditions
9// are met:
10//
11// 1. Redistributions of source code must retain the above copyright
12// notice, this list of conditions and the following disclaimer.
13// 2. Redistributions in binary form must reproduce the above copyright
14// notice, this list of conditions and the following disclaimer in the
15// documentation and/or other materials provided with the distribution.
16// 3. The names of the authors and copyright holders may not be used to
17// endorse or promote products derived from this software without
18// specific prior written permission.
19//
20// IN NO EVENT SHALL DANIEL W. MCROBB BE LIABLE TO ANY PARTY FOR
21// DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
22// INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE,
23// EVEN IF DANIEL W. MCROBB HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
24// DAMAGE.
25//
26// THE SOFTWARE PROVIDED HEREIN IS ON AN "AS IS" BASIS, AND
27// DANIEL W. MCROBB HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
28// UPDATES, ENHANCEMENTS, OR MODIFICATIONS. DANIEL W. MCROBB MAKES NO
29// REPRESENTATIONS AND EXTENDS NO WARRANTIES OF ANY KIND, EITHER
30// IMPLIED OR EXPRESS, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
31// WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR
32// PURPOSE, OR THAT THE USE OF THIS SOFTWARE WILL NOT INFRINGE ANY PATENT,
33// TRADEMARK OR OTHER RIGHTS.
34//===========================================================================
35
36//---------------------------------------------------------------------------
39//---------------------------------------------------------------------------
40
41#include <mutex>
42
43namespace Dwm {
44
45 //--------------------------------------------------------------------------
49 //--------------------------------------------------------------------------
51 {
52 public:
53 //------------------------------------------------------------------------
55 //------------------------------------------------------------------------
56 static const int k_COMMAND = 260;
57 //------------------------------------------------------------------------
59 //------------------------------------------------------------------------
60 static const int k_ARGUMENT = 261;
61 //------------------------------------------------------------------------
63 //------------------------------------------------------------------------
64 static const int k_WHITESPACE = 262;
65
66 //------------------------------------------------------------------------
69 //------------------------------------------------------------------------
70 static pid_t Execute(const std::string & commandString);
71
72 //------------------------------------------------------------------------
75 //------------------------------------------------------------------------
76 static pid_t Execute(const std::string & command, char *const argv[]);
77
78 //------------------------------------------------------------------------
81 //------------------------------------------------------------------------
82 static pid_t Execute(char *const argv[]);
83
84 private:
85 static bool FillArgs(const std::string & commandStr, char * & command,
86 char ** & args);
87 static pid_t ExecVP(const std::string & command, char *const argv[]);
88
89 static std::mutex _mutex;
90 };
91
92} // namespace Dwm
93
94#define COMMAND 260
95#define ARGUMENT 261
96#define WHITESPACE 262
97
98//---------------------------- emacs settings -----------------------------
99// Local Variables:
100// mode: C++
101// tab-width: 2
102// indent-tabs-mode: nil
103// c-basic-offset: 2
104// End:
105//-------------------------------------------------------------------------
Provides a simple interface to fork() + execvp().
Definition DwmExecutor.hh:51
static const int k_WHITESPACE
Constant for the lexer.
Definition DwmExecutor.hh:64
static pid_t Execute(const std::string &command, char *const argv[])
Executes the given command with arguments argv.
static pid_t Execute(const std::string &commandString)
Executes the given commandString, which may contain arguments.
static const int k_ARGUMENT
Constant for the lexer.
Definition DwmExecutor.hh:60
static pid_t Execute(char *const argv[])
Executes the command with arguments that are combined in argv.
static const int k_COMMAND
Constant for the lexer.
Definition DwmExecutor.hh:56