1 /*****
2 *
3 * Copyright (C) 2009-2015 CS-SI. All Rights Reserved.
4 * Author: Yoann Vandoorselaere <yoannv@gmail.com>
5 *
6 * This file is part of the Prelude library.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2, or (at your option)
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 *
22 *****/
23
24 #include "idmef.hxx"
25 #include "prelude-client-profile.hxx"
26 #include "prelude-client-easy.hxx"
27 #include "prelude-error.hxx"
28
29 using namespace Prelude;
30
setup_analyzer(idmef_analyzer_t * analyzer,const char * _model,const char * _class,const char * _manufacturer,const char * _version)31 void ClientEasy::setup_analyzer(idmef_analyzer_t *analyzer,
32 const char *_model, const char *_class,
33 const char *_manufacturer, const char *_version)
34 {
35 int ret;
36 prelude_string_t *string;
37
38 ret = idmef_analyzer_new_model(analyzer, &string);
39 if ( ret < 0 )
40 throw PreludeError(ret);
41 prelude_string_set_dup(string, _model);
42
43 ret = idmef_analyzer_new_class(analyzer, &string);
44 if ( ret < 0 )
45 throw PreludeError(ret);
46 prelude_string_set_dup(string, _class);
47
48 ret = idmef_analyzer_new_manufacturer(analyzer, &string);
49 if ( ret < 0 )
50 throw PreludeError(ret);
51 prelude_string_set_dup(string, _manufacturer);
52
53 ret = idmef_analyzer_new_version(analyzer, &string);
54 if ( ret < 0 )
55 throw PreludeError(ret);
56 prelude_string_set_dup(string, _version);
57 }
58
59
ClientEasy(const char * profile,int permission,const char * _model,const char * _class,const char * _manufacturer,const char * _version)60 ClientEasy::ClientEasy(const char *profile,
61 int permission,
62 const char *_model,
63 const char *_class,
64 const char *_manufacturer,
65 const char *_version) : Client(profile)
66 {
67 setRequiredPermission(permission);
68
69 setFlags(getFlags() | Client::FLAGS_ASYNC_TIMER);
70 setup_analyzer(prelude_client_get_analyzer(getClient()), _model, _class, _manufacturer, _version);
71 }
72