added new functions
[gnutls.git] / lib / system.h
blob2902695add795c0063ee453fa38e219991a122f5
1 /*
2 * Copyright (C) 2010-2012 Free Software Foundation, Inc.
4 * Author: Nikos Mavrogiannopoulos
6 * This file is part of GnuTLS.
8 * The GnuTLS is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation; either version 3 of
11 * the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>
23 #ifndef SYSTEM_H
24 #define SYSTEM_H
26 #include <gnutls_int.h>
28 #ifndef _WIN32
29 # include <sys/uio.h> /* for writev */
30 #else
31 # include <windows.h> /* for Sleep */
32 #endif
34 int system_errno (gnutls_transport_ptr_t);
35 int system_recv_timeout(gnutls_transport_ptr_t ptr, unsigned int ms);
37 #ifdef _WIN32
38 ssize_t system_write (gnutls_transport_ptr_t ptr, const void *data,
39 size_t data_size);
40 #else
41 #define HAVE_WRITEV
42 ssize_t system_writev (gnutls_transport_ptr_t ptr, const giovec_t * iovec,
43 int iovec_cnt);
44 #endif
45 ssize_t system_read (gnutls_transport_ptr_t ptr, void *data, size_t data_size);
47 #ifdef _WIN32
48 #define HAVE_WIN32_LOCKS
49 #else
50 #ifdef HAVE_LIBPTHREAD
51 #define HAVE_PTHREAD_LOCKS
52 #else
53 #define HAVE_NO_LOCKS
54 #endif
55 #endif
57 extern gnutls_time_func gnutls_time;
59 static inline void millisleep(unsigned int ms)
61 #ifdef _WIN32
62 Sleep(ms);
63 #else
64 struct timespec ts;
65 ts.tv_sec = 0;
66 ts.tv_nsec = ms*1000*1000;
68 nanosleep(&ts, NULL);
69 #endif
72 int _gnutls_find_config_path(char* path, size_t max_size);
74 int gnutls_system_global_init (void);
75 void gnutls_system_global_deinit (void);
77 #endif /* SYSTEM_H */