summaryrefslogtreecommitdiffstats
path: root/worker/worker.c
blob: cb8e8131aae5ed9856a3118bb2c691343e06c199 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/**
 * Author: Sumit Bose <sbose@redhat.com>
 * 
 * Copyright (C) 2008  Red Hat
 * 
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation; version 2 only
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
 * for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; see the file COPYING.LGPL.  If not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 * 02111-1307, USA.
 */

#define _GNU_SOURCE
#include <string.h>
#include <stdlib.h>


#include "helpers.h"
#include "util.h"
#include "xml_helper.h"
#include "ipaaction.h"
#include "output_handler.h"


int main(int argc, char **argv)
{

    char *xslt_file_name;
    char *ipa_policy_type;
    char *policy_file_name;

    if (argc != 2) {
        DEBUG(0,
              ("missing or to many arguments, I expect a single filename!\n"));
        exit(1);
    }

    policy_file_name=strdup(argv[1]);

    validate_policy(policy_file_name, &ipa_policy_type, &xslt_file_name);

    if ( strncmp( ipa_policy_type, "ipaaction", 9)==0) {
        handle_ipaaction(policy_file_name);
    } else {

        find_output_handler(policy_file_name, xslt_file_name);

        free(xslt_file_name);
    }

    free(ipa_policy_type);
    free(policy_file_name);

    return 0;
}