/*
 * This file is part of DesktopBSD, see the README file.
 *
 * Author: Peter Hofer <ph@desktopbsd.net>
 *         (C) 2004, 2005
 *
 * Copyright: BSD, see the COPYING file included in this distribution
 *
 */

#include <unixprocess.h>
#include <pkgconstants.h>

#include "portauditengine.h"

/** Returns a QProcess that performs the specified
  * portaudit actions.
  *
  * Returns NULL when no flags are specified.
  *
  * The returned QProcess must be deleted after use.
  */
UnixProcess * PortAuditEngine::getProcess(int f) {
	/* Stop here when no flags are specified */
	if(f == 0)
		return NULL;

	UnixProcess  *process = new UnixProcess(QString(PORTAUDIT_CMD));

	int flags[] = { Verbose, FetchDatabase, CheckAll };
	char *args[] = { "-v", "-F", "-a" };

	for(int i = 0; i < (sizeof flags / sizeof flags[0]); ++i)
		if(f & flags[i])
			process->addArgument(args[i]);

	return  process;
}
