wallet-client-example.c (1758B)
1 /* 2 This file is part of GNU Taler 3 Copyright (C) 2014-2022 Taler Systems SA 4 5 GNU Taler is free software; you can redistribute it and/or modify it under the 6 terms of the GNU Affero General Public License as published by the Free Software 7 Foundation; either version 3, or (at your option) any later version. 8 9 GNU Taler 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 Affero General Public License for more details. 12 13 You should have received a copy of the GNU Affero General Public License along with 14 GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> 15 */ 16 17 18 /** 19 * Sample client for a TALER_WALLET_Instance. 20 */ 21 #include <stdlib.h> 22 #include <stdio.h> 23 #include "taler_wallet_core_lib.h" 24 25 26 void 27 my_handler(void *cls, const char *message) 28 { 29 printf("got message: %s\n", message); 30 } 31 32 void 33 log_handler(void *cls, enum TALER_WALLET_LogLevel level, const char *tag, const char *msg) 34 { 35 printf("got log message, level %d, tag %s: %s\n", (int) level, tag, msg); 36 } 37 38 39 int main(int argc, char **argv) 40 { 41 struct TALER_WALLET_Instance *wh = TALER_WALLET_create(); 42 43 TALER_WALLET_set_message_handler(wh, &my_handler, NULL); 44 TALER_WALLET_set_log_handler(wh, &log_handler, NULL); 45 46 TALER_WALLET_run(wh); 47 48 TALER_WALLET_send_request(wh, "{\"operation\": \"init\", \"args\": {\"skipDefaults\": true}}"); 49 50 TALER_WALLET_send_request(wh, "{\"operation\": \"getVersion\"}"); 51 52 //TALER_WALLET_send_request(wh, "{}"); 53 54 // Wait for wallet thread to finish. 55 // If we don't call this, main() exits 56 // and the wallet thread is killed. 57 TALER_WALLET_join(wh); 58 }