Skip to content

Commit 72b1a17

Browse files
committed
Merge branch 'GrayHatter-master'
2 parents 94cc8b1 + d552cd6 commit 72b1a17

File tree

4 files changed

+125
-13
lines changed

4 files changed

+125
-13
lines changed

toxav/toxav.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,24 +106,28 @@ void call_kill_transmission(ToxAVCall *call);
106106

107107
uint32_t toxav_version_major(void)
108108
{
109-
return 0;
109+
return TOXAV_VERSION_MAJOR;
110110
}
111+
111112
uint32_t toxav_version_minor(void)
112113
{
113-
return 0;
114+
return TOXAV_VERSION_MINOR;
114115
}
116+
115117
uint32_t toxav_version_patch(void)
116118
{
117-
return 0;
119+
return TOXAV_VERSION_PATCH;
118120
}
121+
119122
bool toxav_version_is_compatible(uint32_t major, uint32_t minor, uint32_t patch)
120123
{
121-
(void)major;
122-
(void)minor;
123-
(void)patch;
124-
125-
return 1;
124+
return (TOXAV_VERSION_MAJOR == major && /* Force the major version */
125+
(TOXAV_VERSION_MINOR > minor || /* Current minor version must be newer than requested -- or -- */
126+
(TOXAV_VERSION_MINOR == minor && TOXAV_VERSION_PATCH >= patch) /* the patch must be the same or newer */
127+
)
128+
);
126129
}
130+
127131
ToxAV *toxav_new(Tox *tox, TOXAV_ERR_NEW *error)
128132
{
129133
TOXAV_ERR_NEW rc = TOXAV_ERR_NEW_OK;

toxcore/tox.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,23 +72,26 @@ typedef struct Messenger Tox;
7272

7373
uint32_t tox_version_major(void)
7474
{
75-
return 0;
75+
return TOX_VERSION_MAJOR;
7676
}
7777

7878
uint32_t tox_version_minor(void)
7979
{
80-
return 0;
80+
return TOX_VERSION_MINOR;
8181
}
8282

8383
uint32_t tox_version_patch(void)
8484
{
85-
return 0;
85+
return TOX_VERSION_PATCH;
8686
}
8787

8888
bool tox_version_is_compatible(uint32_t major, uint32_t minor, uint32_t patch)
8989
{
90-
//TODO
91-
return 1;
90+
return (TOX_VERSION_MAJOR == major && /* Force the major version */
91+
(TOX_VERSION_MINOR > minor || /* Current minor version must be newer than requested -- or -- */
92+
(TOX_VERSION_MINOR == minor && TOX_VERSION_PATCH >= patch) /* the patch must be the same or newer */
93+
)
94+
);
9295
}
9396

9497

toxencryptsave/toxencryptsave.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,30 @@
4747
#error TOX_PASS_ENCRYPTION_EXTRA_LENGTH is assumed to be equal to (crypto_box_MACBYTES + crypto_box_NONCEBYTES + crypto_pwhash_scryptsalsa208sha256_SALTBYTES + TOX_ENC_SAVE_MAGIC_LENGTH)
4848
#endif
4949

50+
uint32_t toxes_version_major(void)
51+
{
52+
return TOXES_VERSION_MAJOR;
53+
}
54+
55+
uint32_t toxes_version_minor(void)
56+
{
57+
return TOXES_VERSION_MINOR;
58+
}
59+
60+
uint32_t toxes_version_patch(void)
61+
{
62+
return TOXES_VERSION_PATCH;
63+
}
64+
65+
bool toxes_version_is_compatible(uint32_t major, uint32_t minor, uint32_t patch)
66+
{
67+
return (TOXES_VERSION_MAJOR == major && /* Force the major version */
68+
(TOXES_VERSION_MINOR > minor || /* Current minor version must be newer than requested -- or -- */
69+
(TOXES_VERSION_MINOR == minor && TOXES_VERSION_PATCH >= patch) /* the patch must be the same or newer */
70+
)
71+
);
72+
}
73+
5074
/* Clients should consider alerting their users that, unlike plain data, if even one bit
5175
* becomes corrupted, the data will be entirely unrecoverable.
5276
* Ditto if they forget their password, there is no way to recover the data.

toxencryptsave/toxencryptsave.h

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,87 @@ struct Tox_Options;
4242
#define TOX_PASS_KEY_LENGTH 32
4343
#define TOX_PASS_ENCRYPTION_EXTRA_LENGTH 80
4444

45+
/**
46+
* ToxEncryptSave.
47+
*/
48+
#ifndef TOXES_DEFINED
49+
#define TOXES_DEFINED
50+
#endif /* TOXES_DEFINED */
51+
52+
53+
/*******************************************************************************
54+
*
55+
* :: API version
56+
*
57+
******************************************************************************/
58+
/**
59+
* The major version number. Incremented when the API or ABI changes in an
60+
* incompatible way.
61+
*/
62+
#define TOXES_VERSION_MAJOR 0u
63+
64+
/**
65+
* The minor version number. Incremented when functionality is added without
66+
* breaking the API or ABI. Set to 0 when the major version number is
67+
* incremented.
68+
*/
69+
#define TOXES_VERSION_MINOR 0u
70+
71+
/**
72+
* The patch or revision number. Incremented when bugfixes are applied without
73+
* changing any functionality or API or ABI.
74+
*/
75+
#define TOXES_VERSION_PATCH 0u
76+
77+
/**
78+
* A macro to check at preprocessing time whether the client code is compatible
79+
* with the installed version of ToxAV.
80+
*/
81+
#define TOXES_VERSION_IS_API_COMPATIBLE(MAJOR, MINOR, PATCH) \
82+
(TOXES_VERSION_MAJOR == MAJOR && \
83+
(TOXES_VERSION_MINOR > MINOR || \
84+
(TOXES_VERSION_MINOR == MINOR && \
85+
TOXES_VERSION_PATCH >= PATCH)))
86+
87+
/**
88+
* A macro to make compilation fail if the client code is not compatible with
89+
* the installed version of ToxAV.
90+
*/
91+
#define TOXES_VERSION_REQUIRE(MAJOR, MINOR, PATCH) \
92+
typedef char toxes_required_version[TOXES_IS_COMPATIBLE(MAJOR, MINOR, PATCH) ? 1 : -1]
93+
94+
/**
95+
* A convenience macro to call toxES_version_is_compatible with the currently
96+
* compiling API version.
97+
*/
98+
#define TOXES_VERSION_IS_ABI_COMPATIBLE() \
99+
toxes_version_is_compatible(TOXES_VERSION_MAJOR, TOXES_VERSION_MINOR, TOXES_VERSION_PATCH)
100+
101+
/**
102+
* Return the major version number of the library. Can be used to display the
103+
* ToxAV library version or to check whether the client is compatible with the
104+
* dynamically linked version of ToxAV.
105+
*/
106+
uint32_t toxes_version_major(void);
107+
108+
/**
109+
* Return the minor version number of the library.
110+
*/
111+
uint32_t toxes_version_minor(void);
112+
113+
/**
114+
* Return the patch number of the library.
115+
*/
116+
uint32_t toxes_version_patch(void);
117+
118+
/**
119+
* Return whether the compiled library version is compatible with the passed
120+
* version numbers.
121+
*/
122+
bool toxes_version_is_compatible(uint32_t major, uint32_t minor, uint32_t patch);
123+
124+
125+
45126
/* This module is conceptually organized into two parts. The first part are the functions
46127
* with "key" in the name. To use these functions, first derive an encryption key
47128
* from a password with tox_derive_key_from_pass, and use the returned key to

0 commit comments

Comments
 (0)