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>
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------ */
|
|
|
|
static int prim_open (stix_t* stix, stix_ooi_t nargs)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int prim_close (stix_t* stix, stix_ooi_t nargs)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
stix_prim_impl_t handler;
|
|
|
|
};
|
|
|
|
|
|
|
|
static fnctab_t fnctab[] =
|
|
|
|
{
|
|
|
|
{ "close", prim_close },
|
|
|
|
{ "open", prim_open }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------ */
|
|
|
|
|
2016-11-27 15:37:14 +00:00
|
|
|
static stix_prim_impl_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;
|
|
|
|
}
|