/*
 * Copyright (c) 2003-2010 Alexandre Ratchov <alex@caoua.org>
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#ifndef MIDISH_USER_H
#define MIDISH_USER_H

struct song;
struct songtrk;
struct songchan;
struct songfilt;
struct songsx;

struct exec;
struct data;
struct ev;
struct evspec;
struct sysex;

extern struct song *usong;
extern unsigned user_flag_batch;
extern unsigned user_flag_verb;

unsigned user_mainloop(void);

void user_onchar(void *, int);
void user_oncompl(void *, char *, int, int, int *, int *);
void user_oncompl_path(char *, int *, int *);

unsigned exec_runfile(struct exec *, char *);
unsigned exec_runrcfile(struct exec *);

unsigned exec_lookuptrack(struct exec *, char *, struct songtrk **);
unsigned exec_lookupchan_getnum(struct exec *, char *,
    unsigned *, unsigned *, int);
unsigned exec_lookupchan_getref(struct exec *, char *,
    struct songchan **, int);
unsigned exec_lookupfilt(struct exec *, char *, struct songfilt **);
unsigned exec_lookupsx(struct exec *, char *, struct songsx **);
unsigned exec_lookupev(struct exec *, char *, struct ev *, int);
unsigned exec_lookupevspec(struct exec *, char *, struct evspec *, int);
unsigned exec_lookupctl(struct exec *, char *, unsigned *);
unsigned exec_lookupval(struct exec *, char *, unsigned, unsigned *);

void data_print(struct data *);
unsigned data_num2chan(struct data *, unsigned *, unsigned *);
unsigned data_getchan(struct data *, unsigned *, unsigned *, int);
unsigned data_getrange(struct data *, unsigned, unsigned, unsigned *, unsigned *);
unsigned data_matchsysex(struct data *, struct sysex *, unsigned *);
unsigned data_list2ctl(struct data *, unsigned *);
unsigned data_getctlset(struct data *, unsigned *);
unsigned data_getxev(struct data *, unsigned *);
unsigned data_getctl(struct data *, unsigned *);

#endif /* MIDISH_USER_H */
