cwebs 0.2.1
WebSocket wire protocol
code/iwire.h
Go to the documentation of this file.
00001 #ifndef _iwire_h__
00002 #define _iwire_h__
00003 
00004 // Copyright (c) 2011-2012, Andre Caron (andre.l.caron@gmail.com)
00005 // All rights reserved.
00006 // 
00007 // Redistribution and use in source and binary forms, with or without
00008 // modification, are permitted provided that the following conditions are
00009 // met:
00010 // 
00011 //   Redistributions of source code must retain the above copyright
00012 //   notice, this list of conditions and the following disclaimer.
00013 // 
00014 //   Redistributions in binary form must reproduce the above copyright
00015 //   notice, this list of conditions and the following disclaimer in the
00016 //   documentation and/or other materials provided with the distribution.
00017 // 
00018 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00019 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00020 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00021 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00022 // HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00023 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00024 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00025 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00026 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00027 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00028 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00029 
00037 #include "types.h"
00038 
00039 #ifdef __cplusplus
00040 extern "C" {
00041 #endif
00042 
00043 struct ws_iwire;
00044 
00061 typedef uint64(*ws_iwire_state)
00062     (struct ws_iwire * wire, const uint8 * data, uint64 size);
00063 
00074 struct ws_iwire
00075 {
00088     void(*new_message)(struct ws_iwire * wire);
00089 
00104     void(*end_message)(struct ws_iwire * wire);
00105 
00132     void(*new_fragment)(struct ws_iwire * wire, uint64 size);
00133 
00143     void(*end_fragment)(struct ws_iwire * wire);
00144 
00163     void(*accept_content)
00164         (struct ws_iwire * wire, const void * data, uint64 size);
00165 
00176     void * baton;
00177 
00183     int code;
00184 
00190     int eval;
00191 
00197     int last;
00198 
00206     int usem;
00207 
00213     int good;
00214 
00223     ws_iwire_state state;
00224 
00232     uint8 data[8];
00233 
00241     uint64 size;
00242 
00252     uint8 mask[4];
00253 
00264     uint64 used;
00265 
00276     uint64 pass;
00277 };
00278 
00285 void ws_iwire_init ( struct ws_iwire * stream );
00286 
00304 uint64 ws_iwire_feed
00305     ( struct ws_iwire * stream, const void * data, uint64 size );
00306 
00318 int ws_iwire_mask ( const struct ws_iwire * stream );
00319 
00330 int ws_iwire_last ( const struct ws_iwire * stream );
00331 
00351 int ws_iwire_ping ( const struct ws_iwire * stream );
00352 
00375 int ws_iwire_pong ( const struct ws_iwire * stream );
00376 
00388 int ws_iwire_text ( const struct ws_iwire * stream );
00389 
00401 int ws_iwire_data ( const struct ws_iwire * stream );
00402 
00420 int ws_iwire_dead ( const struct ws_iwire * stream );
00421 
00422 #ifdef __cplusplus
00423 }
00424 #endif
00425 
00426 #endif /* _iwire_h__ */
00427 
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines