/*
    GDAM - Geoff & Dave's Audio Mixer
    Copyright (C) 1999    Dave Benson, Geoff Matters.

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

    This library 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
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA

    Contact:
        daveb@ffem.org <Dave Benson>
        geoff@ugcs.caltech.edu <Geoff Matters>
*/
#ifndef __GDAM_CONFIG_FILE_H_
#define __GDAM_CONFIG_FILE_H_

#include <glib.h>
#include <stdio.h>
/*
 * Syntax:
 *      DeviceType  "module_method"   "parameter"
 *      Device "type" "device_name" "options"
 *      User "username"
 *      Group "groupname"
 *      PidFile "pid-filename"
 *      LogFile "log-filename"
 *      Daemon "yes/no"
 *      Debug "yes/no"
 *      Microphone "device_name"
 *
 *  access control to listening ports:
 *      UnixSocket "path_name" "allowed_users"
 *      TcpSocket "tcp_port" "allowed_hosts"
 */
gboolean       gdam_config_file_parse(const char *filename);


/* Globals for configuring daemon behavior. */
extern const char           *gdam_username;
extern const char           *gdam_groupname;
extern const char           *gdam_pid_file;
extern FILE                 *gdam_log_fp;
extern gboolean              gdam_daemonize;
extern GHashTable           *gdas_microphones;

extern int                   gdam_external_nice;
extern int                   gdam_mlock_kilos;
extern int                   gdam_prebuffer_multiple;
extern int                   gdam_external_catchup_reads;

/* When we do `bind', bind only to localhost. */
extern gboolean              gdam_bind_localhost;

/* returns list of ip-addresses [in binary] to allow
 * or NULL for "anyone" */
GSList *gdam_config_lookup_tcp_auth(int port_no);

/* returns list of usernames or user-ids [in ascii] to allow
 * or NULL for "anyone" */
GSList *gdam_config_lookup_unix_auth(const char *unix_socket_path);

typedef struct _GdamConfigExternalType GdamConfigExternalType;
struct _GdamConfigExternalType
{
  char *type_name;                      /* Uniquely identify the decoder and
					   format, e.g. mpg123-mp3 */
  guint frame_size;			/* frame size in samples */
  guint num_command_args;               /* eg 'mpg123 %s' has two args */
  char **command_args;                  /* NULL-terminated list of commands */
  char *extensions;                     /* comma-separated list of extensions */

  /*
   *  Decoder   name    extension(s) frame_size    exec_format_string
   *  Decoder "sox-aiff" "aif,aiff"   "1152"  "sox -o - -r 44100 -b 16 -k %s %f"
   *
   * %-prefixed sequences:
   *
   *    %{start_frame}          %s
   *    %{start_second}         %S
   *    %{filename}             %f
   *    %%
   */
};
GdamConfigExternalType *gdam_external_type_from_type_name (const char *type);

#endif
