summaryrefslogtreecommitdiff
path: root/other/apidsl
diff options
context:
space:
mode:
authorirungentoo <irungentoo@gmail.com>2015-05-22 18:23:56 -0400
committerirungentoo <irungentoo@gmail.com>2015-05-22 18:23:56 -0400
commit8e80ced6cea5c50e628c1931f6b3b764b97efb41 (patch)
tree43d8aaf1500bee9abdbd11be5175990a98414d3b /other/apidsl
parent2ba076ac5cc6efb5eb41fb4aa6a77a151885f26c (diff)
Move savedata to options struct.
Add a way to select the type of savedata (normal savedata, load a secret key, potentially others?) to load.
Diffstat (limited to 'other/apidsl')
-rw-r--r--other/apidsl/tox.in.h43
1 files changed, 36 insertions, 7 deletions
diff --git a/other/apidsl/tox.in.h b/other/apidsl/tox.in.h
index dd47df23..b769135a 100644
--- a/other/apidsl/tox.in.h
+++ b/other/apidsl/tox.in.h
@@ -340,6 +340,24 @@ enum class PROXY_TYPE {
340 SOCKS5, 340 SOCKS5,
341} 341}
342 342
343/**
344 * Type of savedata to create the Tox instance from.
345 */
346enum class SAVEDATA_TYPE {
347 /**
348 * No savedata.
349 */
350 NONE,
351 /**
352 * Savedata is one that was obtained from ${savedata.get}
353 */
354 TOX_SAVE,
355 /**
356 * Savedata is a secret key of length ${SECRET_KEY_SIZE}
357 */
358 SECRET_KEY,
359}
360
343 361
344static class options { 362static class options {
345 /** 363 /**
@@ -416,6 +434,23 @@ static class options {
416 * The port to use for the TCP server. If 0, the tcp server is disabled. 434 * The port to use for the TCP server. If 0, the tcp server is disabled.
417 */ 435 */
418 uint16_t tcp_port; 436 uint16_t tcp_port;
437
438 namespace savedata {
439 /**
440 * The type of savedata to load from.
441 */
442 SAVEDATA_TYPE type;
443
444 /**
445 * The savedata.
446 */
447 const uint8_t[length] data;
448
449 /**
450 * The length of the savedata.
451 */
452 size_t length;
453 }
419 } 454 }
420 455
421 456
@@ -474,21 +509,15 @@ static class options {
474 * This function will bring the instance into a valid state. Running the event 509 * This function will bring the instance into a valid state. Running the event
475 * loop with a new instance will operate correctly. 510 * loop with a new instance will operate correctly.
476 * 511 *
477 * If the data parameter is not NULL, this function will load the Tox instance
478 * from a byte array previously filled by ${savedata.get}.
479 *
480 * If loading failed or succeeded only partially, the new or partially loaded 512 * If loading failed or succeeded only partially, the new or partially loaded
481 * instance is returned and an error code is set. 513 * instance is returned and an error code is set.
482 * 514 *
483 * @param options An options object as described above. If this parameter is 515 * @param options An options object as described above. If this parameter is
484 * NULL, the default options are used. 516 * NULL, the default options are used.
485 * @param data A byte array containing data previously stored by ${savedata.get}.
486 * @param length The length of the byte array data. If this parameter is 0, the
487 * data parameter is ignored.
488 * 517 *
489 * @see $iterate for the event loop. 518 * @see $iterate for the event loop.
490 */ 519 */
491static this new(const options_t *options, const uint8_t[length] data) { 520static this new(const options_t *options) {
492 NULL, 521 NULL,
493 /** 522 /**
494 * The function was unable to allocate enough memory to store the internal 523 * The function was unable to allocate enough memory to store the internal