gnunet_client_lib.h (3251B)
1 /* 2 This file is part of GNUnet. 3 Copyright (C) 2001-2013, 2016 GNUnet e.V. 4 5 GNUnet is free software: you can redistribute it and/or modify it 6 under the terms of the GNU Affero General Public License as published 7 by the Free Software Foundation, either version 3 of the License, 8 or (at your option) any later version. 9 10 GNUnet is distributed in the hope that it will be useful, but 11 WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Affero General Public License for more details. 14 15 You should have received a copy of the GNU Affero General Public License 16 along with this program. If not, see <http://www.gnu.org/licenses/>. 17 18 SPDX-License-Identifier: AGPL3.0-or-later 19 */ 20 21 /** 22 * @addtogroup libgnunetutil 23 * Multi-function utilities library for GNUnet programs 24 * @{ 25 * 26 * @addtogroup networking 27 * @{ 28 * 29 * @author Christian Grothoff 30 * 31 * @file 32 * Functions related to accessing services 33 34 * @defgroup client Client library 35 * Generic client-side communication with services 36 * 37 * @see [Documentation](https://gnunet.org/ipc) 38 * 39 * @{ 40 */ 41 42 #if !defined (__GNUNET_UTIL_LIB_H_INSIDE__) 43 #error "Only <gnunet_util_lib.h> can be included directly." 44 #endif 45 46 #ifndef GNUNET_CLIENT_LIB_H 47 #define GNUNET_CLIENT_LIB_H 48 49 #ifdef __cplusplus 50 extern "C" 51 { 52 #if 0 /* keep Emacsens' auto-indent happy */ 53 } 54 #endif 55 #endif 56 57 58 #include "gnunet_mq_lib.h" 59 60 61 /** 62 * Test if the port or UNIXPATH of the given @a service_name 63 * is in use and thus (most likely) the respective service is up. 64 * 65 * @param cfg our configuration 66 * @param service_name name of the service to connect to 67 * @return #GNUNET_YES if the service is (likely) up (or running remotely), 68 * #GNUNET_NO if the service is (definitively) down, 69 * #GNUNET_SYSERR if the configuration does not give us 70 * the necessary information about the service, or if 71 * we could not check (e.g. socket() failed) 72 */ 73 enum GNUNET_GenericReturnValue 74 GNUNET_CLIENT_test (const struct GNUNET_CONFIGURATION_Handle *cfg, 75 const char *service_name); 76 77 78 /** 79 * Create a message queue to connect to a GNUnet service. 80 * If handlers are specified, receive messages from the connection. 81 * 82 * @param cfg our configuration 83 * @param service_name name of the service to connect to 84 * @param handlers handlers for receiving messages, can be NULL 85 * @param error_handler error handler 86 * @param error_handler_cls closure for the @a error_handler 87 * @return the message queue, NULL on error 88 */ 89 struct GNUNET_MQ_Handle * 90 GNUNET_CLIENT_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, 91 const char *service_name, 92 const struct GNUNET_MQ_MessageHandler *handlers, 93 GNUNET_MQ_ErrorHandler error_handler, 94 void *error_handler_cls); 95 96 97 #if 0 /* keep Emacsens' auto-indent happy */ 98 { 99 #endif 100 #ifdef __cplusplus 101 } 102 #endif 103 104 /* ifndef GNUNET_CLIENT_LIB_H */ 105 #endif 106 107 /** @} */ /* end of group client */ 108 109 /** @} */ /* end of group addition */ 110 111 /** @} */ /* end of group addition */ 112 113 /* end of gnunet_client_lib.h */