File: socklib.h

package info (click to toggle)
asmail 2.1-9
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,352 kB
  • sloc: ansic: 3,050; sh: 183; makefile: 18
file content (57 lines) | stat: -rw-r--r-- 1,858 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/* This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; version 2 dated June, 1991.

   This program 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 General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program;  if not, write to the Free Software
   Foundation, Inc., 675 Mass Ave., Cambridge, MA 02139, USA. */

#define MG_SOCKLIB_H

#include "config.h"
#include <netinet/in.h>
#include <sys/types.h>
#ifdef HAVE_OPENSSL_SSL_H
#include <openssl/ssl.h>
#include <openssl/bio.h>
#endif

#ifdef __QNX__
#define O_NDELAY O_NONBLOCK
#endif

#define SOCKET_DELAY 0
#define SOCKET_NDELAY 1

#define SOCKET_RESET 0
#define SOCKET_SET 1
#define HOST_NAMELEN 64

typedef struct {
   struct sockaddr_in sin;	/* sin and sinlen store address and length	*/
   socklen_t sinlen;				/* information of the server socket			*/
   int bindflag;			/* used to ensure bind() is only used once	*/
   int sd;					/* Socket descriptor						*/
#ifdef HAVE_OPENSSL_SSL_H
   SSL *ssl;            /* descriptor for ssl connection */
   char *sslBufMalloc, *sslBuf;  /* ssl read buffer */
   unsigned int sslBufSize;      /* its current size */
#endif
} SOCKET;

SOCKET *Sopen(void);
int Sclose(SOCKET *);
int Sserver(SOCKET *, int, int);
int Sclient(SOCKET *, char *, int);
size_t Sread(int sd, char *string, int n, int timeout);
size_t Swrite(int sd, char *string);
#ifdef HAVE_OPENSSL_SSL_H
int Sslclient(SOCKET *, char *trustedCaDir);
size_t Sslread(SOCKET *s, char *string, int n, int timeout);
size_t Sslwrite(SOCKET *s, char *string);
#endif