136
136
extern void Init_HR_SWInst(void);
137
137
extern int Get_Next_HR_SWInst(void);
138
138
extern void End_HR_SWInst(void);
139
extern void Save_HR_SW_info(int ix);
139
extern int Save_HR_SW_info(int ix);
141
141
#ifdef HAVE_LIBRPM
142
142
static void Mark_HRSW_token(void);
288
288
oid newname[MAX_OID_LEN];
289
289
int swinst_idx, LowIndex = -1;
291
int err = 0, errcount = 0;
292
293
DEBUGMSGTL(("host/hr_swinst", "var_hrswinstEntry: "));
293
294
DEBUGMSGOID(("host/hr_swinst", name, *length));
298
299
* Find "next" installed software entry
302
while ((swinst_idx = Get_Next_HR_SWInst()) != -1) {
303
DEBUGMSG(("host/hr_swinst", "(index %d ....", swinst_idx));
304
while ((swinst_idx = Get_Next_HR_SWInst()) != -1) {
305
DEBUGMSG(("host/hr_swinst", "(index %d ....", swinst_idx));
305
newname[HRSWINST_ENTRY_NAME_LENGTH] = swinst_idx;
306
DEBUGMSGOID(("host/hr_swinst", newname, *length));
307
DEBUGMSG(("host/hr_swinst", "\n"));
308
result = snmp_oid_compare(name, *length, newname, vp->namelen + 1);
309
if (exact && (result == 0)) {
310
LowIndex = swinst_idx;
311
Save_HR_SW_info(LowIndex);
314
if ((!exact && (result < 0)) &&
315
(LowIndex == -1 || swinst_idx < LowIndex)) {
316
LowIndex = swinst_idx;
317
Save_HR_SW_info(LowIndex);
307
newname[HRSWINST_ENTRY_NAME_LENGTH] = swinst_idx;
308
DEBUGMSGOID(("host/hr_swinst", newname, *length));
309
DEBUGMSG(("host/hr_swinst", "\n"));
310
result = snmp_oid_compare(name, *length, newname, vp->namelen + 1);
311
if (exact && (result == 0)) {
312
LowIndex = swinst_idx;
313
err = Save_HR_SW_info(LowIndex);
316
if ((!exact && (result < 0)) &&
317
(LowIndex == -1 || swinst_idx < LowIndex)) {
318
LowIndex = swinst_idx;
319
err = Save_HR_SW_info(LowIndex);
318
320
#ifdef HRSWINST_MONOTONICALLY_INCREASING
327
/* restart until Save_HR_SW_info() succeeds,max. 3 times */
328
} while (err != 0 && errcount < 3);
330
DEBUGMSGTL(("host/hr_swinst", "restart did not help, bailing out\n"));
331
return (MATCH_FAILED);
324
334
Mark_HRSW_token();
417
427
#ifdef HAVE_PKGINFO
418
428
pver = pkgparam(swi->swi_name, "VERSION");
419
429
/* 1 spot for the terminating null and one for the dash */
420
if (strlen(pver) + 2 + strlen(string) <= sizeof(string)) {
431
(strlen(pver) + 2 + strlen(string) <= sizeof(string))) {
421
432
strcat(string, "-");
422
433
strcat(string, pver);
477
488
case HRSWINST_DATE:
479
490
#ifdef HAVE_LIBRPM
481
492
if ( headerGetEntry(swi->swi_h, RPMTAG_INSTALLTIME, NULL, (void **) &rpm_data, NULL) ) {
482
493
time_t installTime = *rpm_data;
483
494
ret = date_n_time(&installTime, var_len);
663
674
h = rpmdbGetRecord(swi->swi_rpmdb, offset);
678
DEBUGMSGTL(("host/hr_swinst",
679
"RPM cache has probably expired when reading entry %d, "
680
"reloading...\n", ix));
681
swi->swi_timestamp = 0;
668
684
if (swi->swi_h != NULL)
669
685
headerFree(swi->swi_h);