~louis/ubuntu/trusty/clamav/lp799623_fix_logrotate

« back to all changes in this revision

Viewing changes to libclamav/c++/llvm/include/llvm/System/Program.h

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2010-03-12 11:30:04 UTC
  • mfrom: (0.41.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100312113004-b0fop4bkycszdd0z
Tags: 0.96~rc1+dfsg-0ubuntu1
* New upstream RC - FFE (LP: #537636):
  - Add OfficialDatabaseOnly option to clamav-base.postinst.in
  - Add LocalSocketGroup option to clamav-base.postinst.in
  - Add LocalSocketMode option to clamav-base.postinst.in
  - Add CrossFilesystems option to clamav-base.postinst.in
  - Add ClamukoScannerCount option to clamav-base.postinst.in
  - Add BytecodeSecurity opiton to clamav-base.postinst.in
  - Add DetectionStatsHostID option to clamav-freshclam.postinst.in
  - Add Bytecode option to clamav-freshclam.postinst.in
  - Add MilterSocketGroup option to clamav-milter.postinst.in
  - Add MilterSocketMode option to clamav-milter.postinst.in
  - Add ReportHostname option to clamav-milter.postinst.in
  - Bump libclamav SO version to 6.1.0 in libclamav6.install
  - Drop clamdmon from clamav.examples (no longer shipped by upstream)
  - Drop libclamav.a from libclamav-dev.install (not built by upstream)
  - Update SO version for lintian override for libclamav6
  - Add new Bytecode Testing Tool, usr/bin/clambc, to clamav.install
  - Add build-depends on python and python-setuptools for new test suite
  - Update debian/copyright for the embedded copy of llvm (using the system
    llvm is not currently feasible)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//===- llvm/System/Program.h ------------------------------------*- C++ -*-===//
 
2
//
 
3
//                     The LLVM Compiler Infrastructure
 
4
//
 
5
// This file is distributed under the University of Illinois Open Source
 
6
// License. See LICENSE.TXT for details.
 
7
//
 
8
//===----------------------------------------------------------------------===//
 
9
//
 
10
// This file declares the llvm::sys::Program class.
 
11
//
 
12
//===----------------------------------------------------------------------===//
 
13
 
 
14
#ifndef LLVM_SYSTEM_PROGRAM_H
 
15
#define LLVM_SYSTEM_PROGRAM_H
 
16
 
 
17
#include "llvm/System/Path.h"
 
18
 
 
19
namespace llvm {
 
20
namespace sys {
 
21
 
 
22
  // TODO: Add operations to communicate with the process, redirect its I/O,
 
23
  // etc.
 
24
 
 
25
  /// This class provides an abstraction for programs that are executable by the
 
26
  /// operating system. It provides a platform generic way to find executable
 
27
  /// programs from the path and to execute them in various ways. The sys::Path
 
28
  /// class is used to specify the location of the Program.
 
29
  /// @since 1.4
 
30
  /// @brief An abstraction for finding and executing programs.
 
31
  class Program {
 
32
    /// Opaque handle for target specific data.
 
33
    void *Data_;
 
34
 
 
35
    // Noncopyable.
 
36
    Program(const Program& other);
 
37
    Program& operator=(const Program& other);
 
38
 
 
39
    /// @name Methods
 
40
    /// @{
 
41
  public:
 
42
 
 
43
    Program();
 
44
    ~Program();
 
45
 
 
46
    /// Return process ID of this program.
 
47
    unsigned GetPid() const;
 
48
 
 
49
    /// This function executes the program using the \p arguments provided.  The
 
50
    /// invoked program will inherit the stdin, stdout, and stderr file
 
51
    /// descriptors, the environment and other configuration settings of the
 
52
    /// invoking program. If Path::executable() does not return true when this
 
53
    /// function is called then a std::string is thrown.
 
54
    /// @returns false in case of error, true otherwise.
 
55
    /// @see FindProgramByName
 
56
    /// @brief Executes the program with the given set of \p args.
 
57
    bool Execute
 
58
    ( const Path& path,  ///< sys::Path object providing the path of the
 
59
      ///< program to be executed. It is presumed this is the result of
 
60
      ///< the FindProgramByName method.
 
61
      const char** args, ///< A vector of strings that are passed to the
 
62
      ///< program.  The first element should be the name of the program.
 
63
      ///< The list *must* be terminated by a null char* entry.
 
64
      const char ** env = 0, ///< An optional vector of strings to use for
 
65
      ///< the program's environment. If not provided, the current program's
 
66
      ///< environment will be used.
 
67
      const sys::Path** redirects = 0, ///< An optional array of pointers to
 
68
      ///< Paths. If the array is null, no redirection is done. The array
 
69
      ///< should have a size of at least three. If the pointer in the array
 
70
      ///< are not null, then the inferior process's stdin(0), stdout(1),
 
71
      ///< and stderr(2) will be redirected to the corresponding Paths.
 
72
      ///< When an empty Path is passed in, the corresponding file
 
73
      ///< descriptor will be disconnected (ie, /dev/null'd) in a portable
 
74
      ///< way.
 
75
      unsigned memoryLimit = 0, ///< If non-zero, this specifies max. amount
 
76
      ///< of memory can be allocated by process. If memory usage will be
 
77
      ///< higher limit, the child is killed and this call returns. If zero
 
78
      ///< - no memory limit.
 
79
      std::string* ErrMsg = 0 ///< If non-zero, provides a pointer to a string
 
80
      ///< instance in which error messages will be returned. If the string
 
81
      ///< is non-empty upon return an error occurred while invoking the
 
82
      ///< program.
 
83
      );
 
84
 
 
85
    /// This function waits for the program to exit. This function will block
 
86
    /// the current program until the invoked program exits.
 
87
    /// @returns an integer result code indicating the status of the program.
 
88
    /// A zero or positive value indicates the result code of the program. A
 
89
    /// negative value is the signal number on which it terminated.
 
90
    /// @see Execute
 
91
    /// @brief Waits for the program to exit.
 
92
    int Wait
 
93
    ( unsigned secondsToWait = 0, ///< If non-zero, this specifies the amount
 
94
      ///< of time to wait for the child process to exit. If the time
 
95
      ///< expires, the child is killed and this call returns. If zero,
 
96
      ///< this function will wait until the child finishes or forever if
 
97
      ///< it doesn't.
 
98
      std::string* ErrMsg = 0 ///< If non-zero, provides a pointer to a string
 
99
      ///< instance in which error messages will be returned. If the string
 
100
      ///< is non-empty upon return an error occurred while waiting.
 
101
      );
 
102
 
 
103
    /// This function terminates the program.
 
104
    /// @returns true if an error occured.
 
105
    /// @see Execute
 
106
    /// @brief Terminates the program.
 
107
    bool Kill
 
108
    ( std::string* ErrMsg = 0 ///< If non-zero, provides a pointer to a string
 
109
      ///< instance in which error messages will be returned. If the string
 
110
      ///< is non-empty upon return an error occurred while killing the
 
111
      ///< program.
 
112
      );
 
113
 
 
114
    /// This static constructor (factory) will attempt to locate a program in
 
115
    /// the operating system's file system using some pre-determined set of
 
116
    /// locations to search (e.g. the PATH on Unix).
 
117
    /// @returns A Path object initialized to the path of the program or a
 
118
    /// Path object that is empty (invalid) if the program could not be found.
 
119
    /// @throws nothing
 
120
    /// @brief Construct a Program by finding it by name.
 
121
    static Path FindProgramByName(const std::string& name);
 
122
 
 
123
    // These methods change the specified standard stream (stdin,
 
124
    // stdout, or stderr) to binary mode. They return true if an error
 
125
    // occurred
 
126
    static bool ChangeStdinToBinary();
 
127
    static bool ChangeStdoutToBinary();
 
128
    static bool ChangeStderrToBinary();
 
129
 
 
130
    /// A convenience function equivalent to Program prg; prg.Execute(..);
 
131
    /// prg.Wait(..);
 
132
    /// @throws nothing
 
133
    /// @see Execute, Wait
 
134
    static int ExecuteAndWait(const Path& path,
 
135
                              const char** args,
 
136
                              const char ** env = 0,
 
137
                              const sys::Path** redirects = 0,
 
138
                              unsigned secondsToWait = 0,
 
139
                              unsigned memoryLimit = 0,
 
140
                              std::string* ErrMsg = 0);
 
141
 
 
142
    /// A convenience function equivalent to Program prg; prg.Execute(..);
 
143
    /// @throws nothing
 
144
    /// @see Execute
 
145
    static void ExecuteNoWait(const Path& path,
 
146
                              const char** args,
 
147
                              const char ** env = 0,
 
148
                              const sys::Path** redirects = 0,
 
149
                              unsigned memoryLimit = 0,
 
150
                              std::string* ErrMsg = 0);
 
151
 
 
152
    /// @}
 
153
 
 
154
  };
 
155
}
 
156
}
 
157
 
 
158
#endif