FreeBSD/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_printer_tbl.c
/**
 * Called for each printer found in /etc/printcap.
 */
Called for each printer found in /etc/printcap.
Called for each printer found in / etc / printcap .
static void
handle_printer(struct printer *pp)
{
	struct device_entry *dev_entry;
	struct printer_entry *printer_entry;
	char dev_only[128];
	struct stat sb;
	if (pp->remote_host != NULL) {
		HRDBG("skipped %s -- remote", pp->printer);
		return;
	}
	if (strncmp(pp->lp, _PATH_DEV, strlen(_PATH_DEV)) != 0) {
		HRDBG("skipped %s [device %s] -- remote", pp->printer, pp->lp);
		return;
	}
	memset(dev_only, '\0', sizeof(dev_only));
	snprintf(dev_only, sizeof(dev_only), "%s", pp->lp + strlen(_PATH_DEV));
	HRDBG("printer %s has device %s", pp->printer, dev_only);
	if (stat(pp->lp, &sb) < 0) {
		if (errno == ENOENT) {
			HRDBG("skipped %s -- device %s missing",
			    pp->printer, pp->lp);
			return;
		}
	}
	if ((dev_entry = device_find_by_name(dev_only)) == NULL) {
		HRDBG("%s not in hrDeviceTable", pp->lp);
		return;
	}
	HRDBG("%s found in hrDeviceTable", pp->lp);
	dev_entry->type = &OIDX_hrDevicePrinter_c;
	dev_entry->flags |= HR_DEVICE_IMMUTABLE;
	if ((printer_entry = printer_find_by_index(dev_entry->index)) == NULL &&
	    (printer_entry = printer_entry_create(dev_entry)) == NULL)
		return;
	printer_entry->flags |= HR_PRINTER_FOUND;
	printer_entry->status = get_printer_status(pp);
	memset(printer_entry->detectedErrorState, 0,
	    sizeof(printer_entry->detectedErrorState));
}
static void handle_printer ( struct printer * pp ) { struct device_entry * dev_entry ; struct printer_entry * printer_entry ; char dev_only [ 128 ] ; struct stat sb ; if ( pp -> remote_host != NULL ) { HRDBG ( " " , pp -> printer ) ; return ; } if ( strncmp ( pp -> lp , _PATH_DEV , strlen ( _PATH_DEV ) ) != 0 ) { HRDBG ( " " , pp -> printer , pp -> lp ) ; return ; } memset ( dev_only , ' \0 ' , sizeof ( dev_only ) ) ; snprintf ( dev_only , sizeof ( dev_only ) , " " , pp -> lp + strlen ( _PATH_DEV ) ) ; HRDBG ( " " , pp -> printer , dev_only ) ; if ( stat ( pp -> lp , & sb ) < 0 ) { if ( errno == ENOENT ) { HRDBG ( " " , pp -> printer , pp -> lp ) ; return ; } } if ( ( dev_entry = device_find_by_name ( dev_only ) ) == NULL ) { HRDBG ( " " , pp -> lp ) ; return ; } HRDBG ( " " , pp -> lp ) ; dev_entry -> type = & OIDX_hrDevicePrinter_c ; dev_entry -> flags |= HR_DEVICE_IMMUTABLE ; if ( ( printer_entry = printer_find_by_index ( dev_entry -> index ) ) == NULL && ( printer_entry = printer_entry_create ( dev_entry ) ) == NULL ) return ; printer_entry -> flags |= HR_PRINTER_FOUND ; printer_entry -> status = get_printer_status ( pp ) ; memset ( printer_entry -> detectedErrorState , 0 , sizeof ( printer_entry -> detectedErrorState ) ) ; }
Called for each printer found in /etc/printcap.
Called for each printer found in / etc / printcap .
/* Then check hrPrinterTable for this device */