2015-11-01 09:47:27 +00:00
|
|
|
/*
|
|
|
|
* $Id$
|
|
|
|
*
|
2016-05-15 16:01:43 +00:00
|
|
|
Copyright (c) 2014-2016 Chung, Hyung-Hwan. All rights reserved.
|
2015-11-01 09:47:27 +00:00
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
modification, are permitted provided that the following conditions
|
|
|
|
are met:
|
|
|
|
1. Redistributions of source code must retain the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer.
|
|
|
|
2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer in the
|
|
|
|
documentation and/or other materials provided with the distribution.
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
|
|
|
|
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2016-11-18 18:11:13 +00:00
|
|
|
#include "sound.h"
|
2015-11-01 09:47:27 +00:00
|
|
|
#include <stix-utl.h>
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------ */
|
2016-11-29 05:25:08 +00:00
|
|
|
static int pf_open (stix_t* stix, stix_ooi_t nargs)
|
2015-11-01 09:47:27 +00:00
|
|
|
{
|
|
|
|
printf ("<<<<<<<<<<<SND OPEN>>>>>>>>>>>>>>>>>>\n");
|
2016-05-27 15:01:54 +00:00
|
|
|
STIX_STACK_POPS (stix, nargs);
|
2015-11-01 09:47:27 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2016-11-29 05:25:08 +00:00
|
|
|
static int pf_close (stix_t* stix, stix_ooi_t nargs)
|
2015-11-01 09:47:27 +00:00
|
|
|
{
|
|
|
|
printf ("<<<<<<<<<<<<<<<<<<<<SND CLOSE>>>>>>>>>>>>>>>>>>>>>>\n");
|
2016-05-27 15:01:54 +00:00
|
|
|
STIX_STACK_POPS (stix, nargs);
|
2015-11-01 09:47:27 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct fnctab_t fnctab_t;
|
|
|
|
struct fnctab_t
|
|
|
|
{
|
|
|
|
const stix_bch_t* name;
|
2016-11-29 05:25:08 +00:00
|
|
|
stix_pfimpl_t handler;
|
2015-11-01 09:47:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static fnctab_t fnctab[] =
|
|
|
|
{
|
2016-11-29 05:25:08 +00:00
|
|
|
{ "close", pf_close },
|
|
|
|
{ "open", pf_open }
|
2015-11-01 09:47:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------ */
|
|
|
|
|
2016-11-29 05:25:08 +00:00
|
|
|
static stix_pfimpl_t query (stix_t* stix, stix_mod_t* mod, const stix_ooch_t* name)
|
2015-11-01 09:47:27 +00:00
|
|
|
{
|
|
|
|
int left, right, mid, n;
|
|
|
|
|
|
|
|
left = 0; right = STIX_COUNTOF(fnctab) - 1;
|
|
|
|
|
|
|
|
while (left <= right)
|
|
|
|
{
|
|
|
|
mid = (left + right) / 2;
|
|
|
|
|
|
|
|
n = stix_compoocbcstr (name, fnctab[mid].name);
|
|
|
|
if (n < 0) right = mid - 1;
|
|
|
|
else if (n > 0) left = mid + 1;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return fnctab[mid].handler;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
ea.ptr = (stix_char_t*)name;
|
|
|
|
ea.len = stix_strlen(name);
|
|
|
|
stix_seterror (stix, STIX_ENOENT, &ea, QSE_NULL);
|
|
|
|
*/
|
|
|
|
return STIX_NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-11-27 15:37:14 +00:00
|
|
|
static void unload (stix_t* stix, stix_mod_t* mod)
|
2015-11-01 09:47:27 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-11-27 15:37:14 +00:00
|
|
|
int stix_mod_sound (stix_t* stix, stix_mod_t* mod)
|
2015-11-01 09:47:27 +00:00
|
|
|
{
|
|
|
|
mod->query = query;
|
|
|
|
mod->unload = unload;
|
|
|
|
mod->ctx = STIX_NULL;
|
|
|
|
return 0;
|
|
|
|
}
|