| 1 | /*---------------------------------------------------------------------------- |
| 2 | ChucK Strongly-timed Audio Programming Language |
| 3 | Compiler, Virtual Machine, and Synthesis Engine |
| 4 | |
| 5 | Copyright (c) 2003 Ge Wang and Perry R. Cook. All rights reserved. |
| 6 | http://chuck.stanford.edu/ |
| 7 | http://chuck.cs.princeton.edu/ |
| 8 | |
| 9 | This program is free software; you can redistribute it and/or modify |
| 10 | it under the dual-license terms of EITHER the MIT License OR the GNU |
| 11 | General Public License (the latter as published by the Free Software |
| 12 | Foundation; either version 2 of the License or, at your option, any |
| 13 | later version). |
| 14 | |
| 15 | This program is distributed in the hope that it will be useful and/or |
| 16 | interesting, but WITHOUT ANY WARRANTY; without even the implied warranty |
| 17 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | MIT Licence and/or the GNU General Public License for details. |
| 19 | |
| 20 | You should have received a copy of the MIT License and the GNU General |
| 21 | Public License (GPL) along with this program; a copy of the GPL can also |
| 22 | be obtained by writing to the Free Software Foundation, Inc., 59 Temple |
| 23 | Place, Suite 330, Boston, MA 02111-1307 U.S.A. |
| 24 | -----------------------------------------------------------------------------*/ |
| 25 | |
| 26 | //----------------------------------------------------------------------------- |
| 27 | // file: chuck_otf.h |
| 28 | // desc: on-the-fly programming utilities |
| 29 | // |
| 30 | // author: Ge Wang ([email protected] | [email protected]) |
| 31 | // date: Autumn 2004 |
| 32 | //----------------------------------------------------------------------------- |
| 33 | #ifndef __CHUCK_OTF_H__ |
| 34 | #define __CHUCK_OTF_H__ |
| 35 | |
| 36 | #include "chuck_def.h" |
| 37 | #include "util_network.h" |
| 38 | #include <memory.h> |
| 39 | |
| 40 | |
| 41 | // defines |
| 42 | #define CK_NET_HEADER 0x8c8cc8c8 |
| 43 | // buffer size |
| 44 | #define CK_NET_BUFFER_SIZE 512 |
| 45 | // error value |
| 46 | #define CK_NET_ERROR 0xffffffff |
| 47 | // forward |
| 48 | struct Chuck_VM; |
| 49 | struct Chuck_Compiler; |
| 50 | |
| 51 | |
| 52 | //----------------------------------------------------------------------------- |
| 53 | // name: struct OTF_Net_Msg() |
| 54 | // desc: a network message for on-the-fly programming |
| 55 | //----------------------------------------------------------------------------- |
| 56 | struct OTF_Net_Msg |
| 57 | { |
| 58 | t_CKUINT header; |
| 59 | t_CKUINT type; |
| 60 | t_CKUINT param; |
| 61 | t_CKUINT param2; |
| 62 | t_CKUINT param3; |
| 63 | t_CKUINT length; |
| 64 | char buffer[CK_NET_BUFFER_SIZE]; |
| 65 | |
| 66 | OTF_Net_Msg() { this->clear(); } |
| 67 | void clear() { header = CK_NET_HEADER; type = param = param2 = param3 = length = 0; |
| 68 | memset( buffer, 0, sizeof(buffer) ); } |
| 69 | |
| 70 | // copy constructor | 1.5.1.5 |
| 71 | OTF_Net_Msg( const OTF_Net_Msg & rhs ) |
| 72 | { |
| 73 | header = rhs.header; |
| 74 | type = rhs.type; |
| 75 | param = rhs.param; |
| 76 | param2 = rhs.param2; |
| 77 | param3 = rhs.param3; |
| 78 | length = rhs.length; |
| 79 | memcpy( buffer, rhs.buffer, sizeof(rhs.buffer) ); |
| 80 | } |
| 81 | }; |
| 82 | |
| 83 | |
| 84 | // host to network |
| 85 | void otf_hton( OTF_Net_Msg * msg ); |
| 86 | // network to host |
| 87 | void otf_ntoh( OTF_Net_Msg * msg ); |
| 88 | |
| 89 | // process incoming message |
| 90 | t_CKUINT otf_process_msg( Chuck_VM * vm, Chuck_Compiler * compiler, |
| 91 | OTF_Net_Msg * msg, t_CKBOOL immediate, void * data ); |
| 92 | |
| 93 | // send command |
| 94 | t_CKINT otf_send_cmd( t_CKINT argc, const char ** argv, t_CKINT & i, const char * host, t_CKINT port, t_CKINT * is_otf = NULL ); |
| 95 | // send file to remote host |
| 96 | t_CKINT otf_send_file( const char * filename, OTF_Net_Msg & msg, const char * op, ck_socket sock ); |
| 97 | // connect |
| 98 | ck_socket otf_send_connect( const char * host, t_CKINT port ); |
| 99 | |
| 100 | // callback |
| 101 | void * otf_recv_cb( void * p ); |
| 102 | |
| 103 | // --poop |
| 104 | void uh(); |
| 105 | |
| 106 | // yes |
| 107 | extern const char * poop[]; |
| 108 | extern long poop_size; |
| 109 | extern t_CKUINT g_otf_log; |
| 110 | |
| 111 | |
| 112 | |
| 113 | |
| 114 | #endif |