]> git.lyx.org Git - lyx.git/blob - src/support/Systemcall.h
Compilation fix (with qt4 at least).
[lyx.git] / src / support / Systemcall.h
1 // -*- C++ -*-
2 /**
3  * \file Systemcall.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Asger Alstrup
8  *
9  * Interface cleaned up by
10  * \author Angus Leeming
11  *
12  * Full author contact details are available in file CREDITS.
13  */
14
15 #ifndef SYSTEMCALL_H
16 #define SYSTEMCALL_H
17
18 #include <string>
19
20 namespace lyx {
21 namespace support {
22
23 /**
24  * An instance of Class Systemcall represents a single child process.
25  *
26  * Class Systemcall uses system() to launch the child process.
27  * The user can choose to wait or not wait for the process to complete, but no
28  * callback is invoked upon completion of the child.
29  *
30  * The child process is not killed when the Systemcall instance goes out of
31  * scope.
32  */
33 class Systemcall {
34 public:
35         /// whether to wait for completion
36         enum Starttype {
37                 Wait,     //< wait for completion before returning from startscript()
38                 WaitLoop, //< wait, but check occasionally for cancellation
39                 DontWait  //< don't wait for completion
40         };
41
42         // enum values chosen hopefully not to conflict with ordinary return values
43         enum ReturnValue {
44                 OK = 0,
45                 NOSTART = 1001,
46                 ERROR = 2001,
47                 TIMEOUT = 4001,
48                 KILLED = 9001
49         };
50
51
52         // Kill the process which is running at time being
53         static void killscript();
54
55         /** Start child process.
56          *  The string "what" contains a commandline with arguments separated
57          *  by spaces and encoded in the filesystem encoding. "$$s" will be
58          *  replaced accordingly by commandPrep(). The string "path" contains
59          *  the path to be prepended to the TEXINPUTS environment variable
60          *  encoded in utf-8. Similarly for the string "lpath" that, if not
61          *  empty, specifies an additional directory to be added to TEXINPUTS
62          *  but after "path". Unset "process_events" in case UI should be
63          *  blocked while  processing the external command.
64          */
65         int startscript(Starttype how, std::string const & what,
66                         std::string const & path = empty_string(),
67                         std::string const & lpath = empty_string(),
68                         bool process_events = false);
69 };
70
71 } // namespace support
72 } // namespace lyx
73
74 #endif // SYSTEMCALL_H