libguac  0.7.0
socket.h
Go to the documentation of this file.
00001 
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is libguac.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Michael Jumper.
00019  * Portions created by the Initial Developer are Copyright (C) 2010
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either the GNU General Public License Version 2 or later (the "GPL"), or
00026  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 #ifndef _GUAC_SOCKET_H
00039 #define _GUAC_SOCKET_H
00040 
00041 #include <stdint.h>
00042 #include <unistd.h>
00043 
00050 typedef struct guac_socket guac_socket;
00051 
00062 typedef ssize_t guac_socket_read_handler(guac_socket* socket,
00063         void* buf, size_t count);
00064 
00075 typedef ssize_t guac_socket_write_handler(guac_socket* socket,
00076         void* buf, size_t count);
00077 
00089 typedef int guac_socket_select_handler(guac_socket* socket, int usec_timeout);
00090 
00099 typedef int guac_socket_free_handler(guac_socket* socket);
00100 
00105 struct guac_socket {
00106 
00110     void* data;
00111 
00115     guac_socket_read_handler* read_handler;
00116 
00122     guac_socket_write_handler* write_handler;
00123 
00128     guac_socket_select_handler* select_handler;
00129 
00133     guac_socket_free_handler* free_handler;
00134     
00138     int __ready;
00139 
00144     int __ready_buf[3];
00145 
00149     int __written;
00150 
00155     char __out_buf[8192];
00156 
00160     int __instructionbuf_parse_start;
00161 
00165     int __instructionbuf_size;
00166 
00170     int __instructionbuf_used_length;
00171 
00177     char* __instructionbuf;
00178 
00182     int __instructionbuf_elementc;
00183 
00188     char* __instructionbuf_elementv[64];
00189 
00190 };
00191 
00199 guac_socket* guac_socket_alloc();
00200 
00206 void guac_socket_free(guac_socket* socket);
00207 
00220 guac_socket* guac_socket_open(int fd);
00221 
00236 guac_socket* guac_socket_nest(guac_socket* parent, int index);
00237 
00250 ssize_t guac_socket_write_int(guac_socket* socket, int64_t i);
00251 
00266 ssize_t guac_socket_write_string(guac_socket* socket, const char* str);
00267 
00284 ssize_t guac_socket_write_base64(guac_socket* socket, const void* buf, size_t count);
00285 
00298 ssize_t guac_socket_write(guac_socket* socket, const void* buf, size_t count);
00299 
00313 ssize_t guac_socket_read(guac_socket* socket, void* buf, size_t count);
00314 
00324 ssize_t guac_socket_flush_base64(guac_socket* socket);
00325 
00335 ssize_t guac_socket_flush(guac_socket* socket);
00336 
00337 
00354 int guac_socket_select(guac_socket* socket, int usec_timeout);
00355 
00356 #endif
00357 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines