/*

IsMyHwOK: A tool for checking how well-supported hardware is using Free drivers.
Copyright (C) 2010  Thomas Glyn Dennis

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

*/

#include <stdlib.h>
#include <stdio.h>
#include "csv/csv.h"
#include "osstuff.h"

/* Executes lspci. Stores the output to a file and then loads it as a table. */

CsvTable *lspci (void)
{

  CsvTable *result = NULL;

  /* TODO. */

  return result;

}

/* Executes lsusb. Stores the output to a file and then loads it as a table. */

CsvTable *lsusb (void)
{

  CsvTable *result = NULL;

  /* TODO. */

  return result;

}

/* Get some information about the OS. */

CsvTable *osinfo (void)
{

  const char *file_name = "/tmp/sysinfo.tmp";

  CsvTable *result = NULL;

  int val = 0;

  /* Create output file. */

  if (!freopen (file_name, "w", stdout)) { return NULL; }

  val = system ("uname -s");  /* Kernel name. */
  val = system ("uname -p");  /* OS platform. */
  val = system ("uname -r");  /* OS version.  */

  if (!freopen ("/dev/tty", "w", stdout)) { /* TODO: Do something here... */ }

  /* Read the output file as a space-separated-values file. */

  result = csvLoadFile (file_name, 0, 0);

  if (!result) { return NULL; }

  /* Return the result. */

  return result;

}
