| 
									
										
										
										
											2016-07-08 01:51:27 +03:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Secure eXtended Message Passing framework | 
					
						
							|  |  |  |  * Secure eXtended Transport layer implementation (libsxt). | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * socket wrapper | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * (c) Alexander Vdolainen 2016 <avdolainen@zoho.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 __SXT_SOCKET_H__
 | 
					
						
							|  |  |  | #define __SXT_SOCKET_H__
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | enum { | 
					
						
							|  |  |  |   SXTSOCKET_NIL = 0, | 
					
						
							|  |  |  |   SXTSOCKET_ACTIVE, | 
					
						
							|  |  |  |   SXTSOCKET_DEAD, | 
					
						
							| 
									
										
										
										
											2016-07-08 03:15:47 +03:00
										 |  |  |   SXTSOCKET_CLOSED, | 
					
						
							| 
									
										
										
										
											2016-07-08 01:51:27 +03:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define SXTSCK_RDR  (1 << 1)
 | 
					
						
							|  |  |  | #define SXTSCK_WRR  (1 << 2)
 | 
					
						
							|  |  |  | #define SXTSCT_TMO  (1 << 3)
 | 
					
						
							| 
									
										
										
										
											2016-07-08 03:15:47 +03:00
										 |  |  | #define SXTSCT_ERR  (1 << 4)
 | 
					
						
							| 
									
										
										
										
											2016-07-08 01:51:27 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | typedef struct __sxtsocket_type { | 
					
						
							|  |  |  |   uint8_t state; | 
					
						
							|  |  |  |   int fd; | 
					
						
							|  |  |  | } sxtsocket_t; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* API */ | 
					
						
							| 
									
										
										
										
											2016-07-08 03:15:47 +03:00
										 |  |  | sxtsocket_t *sxtsocket_new(void); | 
					
						
							| 
									
										
										
										
											2016-07-08 01:51:27 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | int sxtsocket_close(sxtsocket_t *); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int sxtsocket_setnb(sxtsocket_t *); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-07-08 03:15:47 +03:00
										 |  |  | ssize_t sxtsocket_read(sxtsocket_t *, void *, size_t); | 
					
						
							| 
									
										
										
										
											2016-07-08 01:51:27 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-07-08 03:15:47 +03:00
										 |  |  | ssize_t sxtsocket_write(sxtsocket_t *, void *, size_t); | 
					
						
							| 
									
										
										
										
											2016-07-08 01:51:27 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-07-08 03:15:47 +03:00
										 |  |  | int sxtsocket_poll(sxtsocket_t **, int, sxtsocket_t **, int, int, int **, | 
					
						
							|  |  |  |                    int **); | 
					
						
							| 
									
										
										
										
											2016-07-08 01:51:27 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | void sxtsocket_free(sxtsocket_t *); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif /* __SXT_SOCKET_H__ */
 |