~ubuntu-branches/ubuntu/raring/nagios3/raring

« back to all changes in this revision

Viewing changes to cgi/extcmd_list.c

  • Committer: Package Import Robot
  • Author(s): Alexander Wirt
  • Date: 2012-06-16 09:05:19 UTC
  • mfrom: (8.1.9 sid)
  • Revision ID: package-import@ubuntu.com-20120616090519-1okxgkbe21vumokr
Tags: 3.4.1-1
* [28e077b] Imported Upstream version 3.3.1
* [d5314e0] don't call updatepo in clean target
* [45b3eb9] Don't remove config foo
* [54e3dff] Don't fix permissions in cgi postinst
* [d7be9db] Build-depend on libpng-dev (Closes: #662441)
* [4c47006] Add dutch po translation (Closes: #654855)
* [2b6573b] Refresh 10_p1_pl_shebang.dpatch
* [316fd7a] Update 40_fix_spurious_dollar_signs_added_to_command_lines
* [5ff2780] Refresh 55_strip_logarchivepath.dpatch
* [811d269] Refresh 60_fix_p1.pl_patch_mini_epn.dpatch
* [39a1e9c] Remove now unneeded patch 98_fix_XSS_CVE-2011-2179
* [785a4e8] Remove unneded patch 99_fix_XSS_CVE-2011-1523
* [6ce98ef] Remove unneeded patchs from 00list
* [1d18266] Imported Upstream version 3.4.0
* [05584c8] Refresh patches
* [58098cd] Imported Upstream version 3.4.1
* [3e9e07a] Bump standards version
* [fe991e2] wrap-and-sort
* [1ba78f7] Also create /var/run/nagios in cgi package (Closes: #626854)

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
struct nagios_extcmd {
7
7
        const char *name;
8
8
        int id;
9
 
/*      size_t namelen;
10
 
        int min_args;
11
 
        int (*handler)(struct nagios_extcmd *, int, char **);
12
 
        struct nagios_extcmd *next_handler;
13
 
 */
14
 
};
 
9
        /*      size_t namelen;
 
10
                int min_args;
 
11
                int (*handler)(struct nagios_extcmd *, int, char **);
 
12
                struct nagios_extcmd *next_handler;
 
13
         */
 
14
        };
15
15
 
16
16
#define CMD_DEF(name, min_args, handler) \
17
17
        { #name, CMD_ ## name }
18
18
/*      { #name, sizeof(#name) - 1, CMD_ ## name, min_args, handler, NULL } */
19
 
struct nagios_extcmd in_core_commands[] =
20
 
{
 
19
struct nagios_extcmd in_core_commands[] = {
21
20
        CMD_DEF(NONE, 0, NULL),
22
21
        CMD_DEF(ADD_HOST_COMMENT, 0, NULL),
23
22
        CMD_DEF(DEL_HOST_COMMENT, 0, NULL),
185
184
        CMD_DEF(CHANGE_CONTACT_MODATTR, 0, NULL),
186
185
        CMD_DEF(CHANGE_CONTACT_MODHATTR, 0, NULL),
187
186
        CMD_DEF(CHANGE_CONTACT_MODSATTR, 0, NULL),
188
 
};
 
187
        };
189
188
#undef CMD_DEF
190
189
 
191
190
#ifndef ARRAY_SIZE
192
191
# define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
193
192
#endif
194
193
 
195
 
const char *extcmd_get_name(int id)
196
 
{
 
194
const char *extcmd_get_name(int id) {
197
195
        int i;
198
196
 
199
 
        for (i = 0; i < ARRAY_SIZE(in_core_commands); i++) {
 
197
        for(i = 0; i < ARRAY_SIZE(in_core_commands); i++) {
200
198
                struct nagios_extcmd *ecmd;
201
199
                ecmd = &in_core_commands[i];
202
 
                if (ecmd->id == id)
 
200
                if(ecmd->id == id)
203
201
                        return ecmd->name;
204
 
        }
 
202
                }
205
203
 
206
204
        return NULL;
207
 
}
 
205
        }
208
206
 
209
207
#ifdef ECMD_LIST_TESTING
210
 
int main(int argc, char **argv)
211
 
{
 
208
int main(int argc, char **argv) {
212
209
        int i, no_handler = 0;
213
210
 
214
 
        for (i = 0; i < ARRAY_SIZE(in_core_commands); i++) {
 
211
        for(i = 0; i < ARRAY_SIZE(in_core_commands); i++) {
215
212
                struct nagios_extcmd *cmd = &in_core_commands[i];
216
 
                if (!cmd->handler) {
 
213
                if(!cmd->handler) {
217
214
                        no_handler++;
218
215
                        printf("%s has no handler\n", extcmd_get_name(i));
 
216
                        }
219
217
                }
220
 
        }
221
218
        printf("%d of %d commands have no handler\n",
222
219
               no_handler, ARRAY_SIZE(in_core_commands));
223
220
 
224
221
        return 0;
225
 
}
 
222
        }
226
223
#endif