anastasis_util_lib.h (3302B)
1 /* 2 This file is part of Anastasis 3 Copyright (C) 2020 Anastasis SARL 4 5 Anastasis is free software; you can redistribute it and/or modify it under the 6 terms of the GNU General Public License as published by the Free Software 7 Foundation; either version 3, or (at your option) any later version. 8 9 Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY 10 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 11 A PARTICULAR PURPOSE. See the GNU General Public License for more details. 12 13 You should have received a copy of the GNU General Public License along with 14 Anastasis; see the file COPYING.GPL. If not, see <http://www.gnu.org/licenses/> 15 */ 16 /** 17 * @file include/anastasis_util_lib.h 18 * @brief anastasis client api 19 * @author Christian Grothoff 20 * @author Dominik Meister 21 * @author Dennis Neufeld 22 */ 23 #ifndef ANASTASIS_UTIL_LIB_H 24 #define ANASTASIS_UTIL_LIB_H 25 26 #include "anastasis_error_codes.h" 27 #define GNU_TALER_ERROR_CODES_H 1 28 #include <gnunet/gnunet_util_lib.h> 29 #include <taler/taler_util.h> 30 31 32 /** 33 * Maximum value allowed for PINs. Limited to 10^15 < 2^52 to ensure the 34 * numeric value survives a conversion to float by JavaScript. 35 * 36 * NOTE: Do not change this value, we map it to a string like 37 * 42353-256-6521-241 and that mapping fails if the number 38 * does not have exactly 15 digits! 39 */ 40 #define ANASTASIS_PIN_MAX_VALUE 1000000000000000 41 42 43 /** 44 * Return default project data used by Anastasis. 45 */ 46 const struct GNUNET_OS_ProjectData * 47 ANASTASIS_project_data (void); 48 49 50 /** 51 * Handle for the child management 52 */ 53 struct ANASTASIS_ChildWaitHandle; 54 55 /** 56 * Defines a ANASTASIS_ChildCompletedCallback which is sent back 57 * upon death or completion of a child process. Used to trigger 58 * authentication commands. 59 * 60 * @param cls handle for the callback 61 * @param type type of the process 62 * @param exit_code status code of the process 63 * 64 */ 65 typedef void 66 (*ANASTASIS_ChildCompletedCallback)(void *cls, 67 enum GNUNET_OS_ProcessStatusType type, 68 long unsigned int exit_code); 69 70 71 /** 72 * Starts the handling of the child processes. 73 * Function checks the status of the child process and sends back a 74 * ANASTASIS_ChildCompletedCallback upon completion/death of the child. 75 * 76 * @param proc child process which is monitored 77 * @param cb reference to the callback which is called after completion 78 * @param cb_cls closure for the callback 79 * @return ANASTASIS_ChildWaitHandle is returned 80 */ 81 struct ANASTASIS_ChildWaitHandle * 82 ANASTASIS_wait_child (struct GNUNET_OS_Process *proc, 83 ANASTASIS_ChildCompletedCallback cb, 84 void *cb_cls); 85 86 /** 87 * Stop waiting on this child. 88 */ 89 void 90 ANASTASIS_wait_child_cancel (struct ANASTASIS_ChildWaitHandle *cwh); 91 92 93 /** 94 * Convert input string @a as into @a pin. 95 * 96 * @param as input of the form 42355-256-2262-265 97 * @param[out] pin set to numeric pin 98 * @return false if @as is malformed 99 */ 100 bool 101 ANASTASIS_scan_pin (const char *as, 102 unsigned long long *pin); 103 104 105 /** 106 * Convert numeric pin to human-readable number for display. 107 * 108 * @param pin number to convert 109 * @return static (!) buffer with the text to show 110 */ 111 const char * 112 ANASTASIS_pin2s (uint64_t pin); 113 114 115 #endif