
#include "hifi.h"
#include "hifimsg.h"
#include "hifimsg_private.h"




#define UDPPORT 4567


char *
hifi_getrecorddsp (void)
{
  char buf[1024];
  FILE *f;
  int i;
  sprintf (buf, "%s/.hifi/record_dsp", getenv ("HOME"));

  f = fopen (buf, "r");
  if (!f)
    return NULL;

  fscanf (f, "%[^\n]", buf);


  fclose (f);

  return strdup (buf);
}

int
hifi_getunit (char *name)
{
  char buf[1024];
  FILE *f;
  int i;
  sprintf (buf, "%s/.hifi/%s.unit", getenv ("HOME"), name);

  f = fopen (buf, "r");

  i = HIFI_UNIT_DEFAULT;

  if (f)
    {
      fscanf (f, "%d", &i);
      fclose (f);
    };

  if (i == HIFI_UNIT_DEFAULT)
    {
      fprintf (stderr, "Can't find unit number for device %s, using %d\n",
               name, i);

    }

  return i;
}


int
hifi_getint (char *name, int port)
{
  char buf[1024];
  FILE *f;

  if (port)
    return port;
  sprintf (buf, "%s/.hifi/%s", getenv ("HOME"), name);

  f = fopen (buf, "r");

  if (f)
    {
      fscanf (f, "%d", &port);
      fclose (f);
    };

  return port;
}
