This repository has been archived by the owner on Aug 14, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathpytox.h
68 lines (68 loc) · 2.9 KB
/
pytox.h
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
58
59
60
61
62
63
64
65
66
67
68
/**
* pytoxcore
*
* Copyright (C) 2015 Anton Batenev <[email protected]>
*
* 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, either version 3 of the License, or
* (at your option) any later version.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
//----------------------------------------------------------------------------------------------
#ifndef _pytox_h_
#define _pytox_h_
//----------------------------------------------------------------------------------------------
#define PY_SSIZE_T_CLEAN
//----------------------------------------------------------------------------------------------
#include <Python.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <sodium.h>
#include <pthread.h>
#include <tox/tox.h>
#include <tox/toxav.h>
#include <tox/toxdns.h>
#include <sys/param.h>
#include <arpa/inet.h>
#include <vpx/vpx_image.h>
//----------------------------------------------------------------------------------------------
// https://github.com/abbat/pytoxcore/pull/7
// https://github.com/abbat/pytoxcore/issues/11
#ifdef TOX_TOKTOK
#if TOX_VERSION_IS_API_COMPATIBLE(0, 0, 1)
#define TOX_TOKTOK_STATELESS_CALLBACKS
#endif
#endif
//----------------------------------------------------------------------------------------------
#if PY_MAJOR_VERSION < 3
#define BUF_TCS "s#"
#else
#define BUF_TCS "y#"
#endif
//----------------------------------------------------------------------------------------------
#if PY_MAJOR_VERSION < 3
#define PYSTRING_FromString PyString_FromString
#define PYSTRING_FromStringAndSize PyString_FromStringAndSize
#define PYBYTES_FromStringAndSize PyString_FromStringAndSize
#else
#define PYSTRING_FromString PyUnicode_FromString
#define PYSTRING_FromStringAndSize PyUnicode_FromStringAndSize
#define PYBYTES_FromStringAndSize PyBytes_FromStringAndSize
#endif
//----------------------------------------------------------------------------------------------
PyObject* PyNone_New(void);
//----------------------------------------------------------------------------------------------
void bytes_to_hex_string(const uint8_t* digest, size_t length, uint8_t* hex_digest);
bool hex_string_to_bytes(const uint8_t* hexstr, size_t length, uint8_t* bytes);
//----------------------------------------------------------------------------------------------
#endif // _pytox_h_
//----------------------------------------------------------------------------------------------