/*
 *
 * (c) Askele Group 2013-2015 <http://askele.com>
 * (c) Alexander Vdolainen 2013-2015 <avdolainen@gmail.com>
 *
 * libsxmp 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 3 of the License, or
 * (at your option) any later version.
 *
 * libsxmp 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 program.  If not, see <http://www.gnu.org/licenses/>.";
 */

#ifndef __SXMPL_INTERNAL_H__
#define __SXMPL_INTERNAL_H__

/* builtin functions protocol description */
#define _SXSTREAMOPEN_ADDMINLEN   18
#define _SXSTREAMOPEN_ADDMAXLEN   24
#define _SXSTREAMCLOSE_ADDLEN     12
#define _SXSTREAMEREAD_ADDLEN     10

#define _SXSTREAMOPEN_CMD       "!#s>"
#define _SXSTREAMOPEN_CMD_R     "!#s<"
#define _SXSTREAMTYPE_PREFIX    ":stid"
#define _SXSTREAMFLAGS_PREFIX   ":flags"
#define _SXSTREAMOPT_PREFIX     ":opt"

#define _SXSTREAMCLOSE_CMD      "!#-s>"

#define _SXSTREAMEREAD_CMD      "!#ers>"

/* link related */
int _sxmpl_writemsg(sxlink_t *co, sxmsg_t *msg);

/* channel operations */
uint8_t _channel_open(sxlink_t *co, uint16_t *chid);
uint8_t _channel_close(sxlink_t *co, uint16_t chid);

/* messages */
void _message_process(sxmsg_t *msg);

/* builtin RPC functions */
int _builtin_stream_open(void *m, sexp_t *sx);
int _builtin_stream_close(void *m, sexp_t *sx);
int _builtin_stream_eread(void *m, sexp_t *sx);

#endif /* __SXMPL_INTERNAL_H__ */