1 | /* |
2 | KSysGuard, the KDE System Guard |
3 | |
4 | Copyright (c) 1999 - 2001 Chris Schlaeger <cs@kde.org> |
5 | |
6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. |
10 | |
11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. |
15 | |
16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
19 | |
20 | */ |
21 | |
22 | #include "ksysguardd.h" |
23 | |
24 | #ifndef KSG_COMMAND_H |
25 | #define KSG_COMMAND_H |
26 | |
27 | typedef void (*cmdExecutor)(const char*); |
28 | |
29 | /** |
30 | Set this flag to '1' to request a rescan of the available sensors |
31 | in the front end. |
32 | */ |
33 | extern int ReconfigureFlag; |
34 | |
35 | /** |
36 | Has nearly the same meaning like the above flag ;) |
37 | */ |
38 | extern int CheckSetupFlag; |
39 | |
40 | /** |
41 | * Delivers the message to the front end |
42 | */ |
43 | void output( const char *fmt, ...) |
44 | #ifdef __GNUC__ |
45 | __attribute__ ( ( format ( printf, 1, 2 ) ) ) |
46 | #endif |
47 | ; |
48 | |
49 | /** |
50 | Delivers the error message to the front end. |
51 | */ |
52 | void print_error( const char*, ... ) |
53 | #ifdef __GNUC__ |
54 | __attribute__ ( ( format ( printf, 1, 2 ) ) ) |
55 | #endif |
56 | ; |
57 | |
58 | /** |
59 | Writes the error message to the syslog daemon. |
60 | */ |
61 | void log_error( const char*, ... ) |
62 | #ifdef __GNUC__ |
63 | __attribute__ ( ( format ( printf, 1, 2 ) ) ) |
64 | #endif |
65 | ; |
66 | |
67 | |
68 | |
69 | /** |
70 | Use this function to register a command with the name |
71 | @ref command and the function pointer @ref ex. |
72 | */ |
73 | void registerCommand( const char* command, cmdExecutor ex ); |
74 | |
75 | /** |
76 | Use this function to remove a command with the name |
77 | @ref command. |
78 | */ |
79 | void removeCommand( const char* command ); |
80 | |
81 | /** |
82 | Use this function to add a new monitior with the name @ref monitor |
83 | from the type @ref type. |
84 | @ref ex is a pointer to the function that is called to get a value |
85 | and @ref iq is a pointer to the function that returns information |
86 | about this monitor. |
87 | @ref sm is a parameter to the sensor module object that is passed by |
88 | the initXXX method. |
89 | */ |
90 | void registerAnyMonitor( const char* monitor, const char* type, cmdExecutor ex, |
91 | cmdExecutor iq, struct SensorModul* sm, int isLegacy ); |
92 | |
93 | /** |
94 | Use this function to add a new monitior with the name @ref monitor |
95 | from the type @ref type. |
96 | It will be marked as non-legacy. |
97 | @ref ex is a pointer to the function that is called to get a value |
98 | and @ref iq is a pointer to the function that returns information |
99 | about this monitor. |
100 | @ref sm is a parameter to the sensor module object that is passed by |
101 | the initXXX method. |
102 | */ |
103 | void registerMonitor( const char* monitor, const char* type, cmdExecutor ex, |
104 | cmdExecutor iq, struct SensorModul* sm ); |
105 | |
106 | /** |
107 | Use this function to add a new monitior with the name @ref monitor |
108 | from the type @ref type. This monitor will be flagged as legacy, |
109 | which will forbid it from being listed by the 'modules' command. |
110 | The command will continue to function normally otherwise. |
111 | @ref ex is a pointer to the function that is called to get a value |
112 | and @ref iq is a pointer to the function that returns information |
113 | about this monitor. |
114 | @ref sm is a parameter to the sensor module object that is passed by |
115 | the initXXX method. |
116 | */ |
117 | void registerLegacyMonitor( const char* monitor, const char* type, cmdExecutor ex, |
118 | cmdExecutor iq, struct SensorModul* sm ); |
119 | |
120 | /** |
121 | Use this function to remove the monitior with the name @ref monitor. |
122 | */ |
123 | void removeMonitor( const char* monitor ); |
124 | |
125 | |
126 | /** |
127 | Internal usage. |
128 | */ |
129 | void executeCommand( const char* command ); |
130 | |
131 | void initCommand( void ); |
132 | void exitCommand( void ); |
133 | |
134 | void printMonitors( const char* cmd ); |
135 | void printTest( const char* cmd ); |
136 | |
137 | void exQuit( const char* cmd ); |
138 | |
139 | #endif |
140 | |