2
* $Id: piic.c 140 2006-05-31 15:24:25Z tarik $
3
* Description: Reads from plugin output pipe, writes to arglist.
5
* Authors: - Renaud Deraison <deraison@nessus.org> (Original pre-fork develoment)
6
* - Tim Brown <mailto:timb@openvas.org> (Initial fork)
7
* - Laban Mwangi <mailto:labanm@openvas.org> (Renaming work)
8
* - Tarik El-Yassem <mailto:tarik@openvas.org> (Headers section)
11
* Portions Copyright (C) 2006 Software in the Public Interest, Inc.
12
* Based on work Copyright (C) 1998 - 2006 Tenable Network Security, Inc.
14
* This program is free software; you can redistribute it and/or modify
15
* it under the terms of the GNU General Public License version 2,
16
* as published by the Free Software Foundation
18
* This program is distributed in the hope that it will be useful,
19
* but WITHOUT ANY WARRANTY; without even the implied warranty of
20
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
* GNU General Public License for more details.
23
* You should have received a copy of the GNU General Public License
24
* along with this program; if not, write to the Free Software
25
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
38
void kb_parse(int soc, struct arglist * globals, struct kb_item ** kb, char * buf, int msg )
48
if( buf == NULL || kb == NULL )
51
if ( msg & INTERNAL_COMM_KB_GET )
53
struct kb_item * kitem = kb_item_get_single(kb, buf, 0);
57
internal_send(soc, NULL, INTERNAL_COMM_MSG_TYPE_KB|INTERNAL_COMM_KB_ERROR);
61
if ( kitem->type == KB_TYPE_STR )
63
internal_send(soc, kitem->v.v_str, INTERNAL_COMM_MSG_TYPE_KB|INTERNAL_COMM_KB_SENDING_STR);
66
else if ( kitem->type == KB_TYPE_INT )
69
snprintf(buf, sizeof(buf), "%d", kitem->v.v_int);
70
internal_send(soc, buf, INTERNAL_COMM_MSG_TYPE_KB|INTERNAL_COMM_KB_SENDING_INT);
73
internal_send(soc, NULL, INTERNAL_COMM_MSG_TYPE_KB|INTERNAL_COMM_KB_ERROR);
80
buf_len = strlen(buf);
82
if(buf[buf_len - 1]=='\n')
83
buf[ buf_len - 1 ]='\0';
85
c = strrchr(buf, ';');
98
value = strchr(buf, '=');
108
if ( type == ARG_INT )
111
if ( msg & INTERNAL_COMM_KB_REPLACE )
112
kb_item_set_int(kb, name,v);
115
kb_item_add_int(kb, name,v);
116
if(save_kb(globals))save_kb_write_int(globals, arg_get_value(globals, "CURRENTLY_TESTED_HOST"), name,v);
121
copy = rmslashes(value);
122
if ( msg & INTERNAL_COMM_KB_REPLACE )
123
kb_item_set_str(kb, name, copy);
126
kb_item_add_str(kb, name, copy);
127
if(save_kb(globals))save_kb_write_str(globals, arg_get_value(globals, "CURRENTLY_TESTED_HOST"), name, copy);