1da0c48c4Sopenharmony_ci/* External declarations for the libdebuginfod client library.
2da0c48c4Sopenharmony_ci   Copyright (C) 2019-2020 Red Hat, Inc.
3da0c48c4Sopenharmony_ci   This file is part of elfutils.
4da0c48c4Sopenharmony_ci
5da0c48c4Sopenharmony_ci   This file is free software; you can redistribute it and/or modify
6da0c48c4Sopenharmony_ci   it under the terms of either
7da0c48c4Sopenharmony_ci
8da0c48c4Sopenharmony_ci   * the GNU Lesser General Public License as published by the Free
9da0c48c4Sopenharmony_ci       Software Foundation; either version 3 of the License, or (at
10da0c48c4Sopenharmony_ci       your option) any later version
11da0c48c4Sopenharmony_ci
12da0c48c4Sopenharmony_ci   or
13da0c48c4Sopenharmony_ci
14da0c48c4Sopenharmony_ci   * the GNU General Public License as published by the Free
15da0c48c4Sopenharmony_ci       Software Foundation; either version 2 of the License, or (at
16da0c48c4Sopenharmony_ci       your option) any later version
17da0c48c4Sopenharmony_ci
18da0c48c4Sopenharmony_ci   or both in parallel, as here.
19da0c48c4Sopenharmony_ci
20da0c48c4Sopenharmony_ci   elfutils is distributed in the hope that it will be useful, but
21da0c48c4Sopenharmony_ci   WITHOUT ANY WARRANTY; without even the implied warranty of
22da0c48c4Sopenharmony_ci   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23da0c48c4Sopenharmony_ci   General Public License for more details.
24da0c48c4Sopenharmony_ci
25da0c48c4Sopenharmony_ci   You should have received copies of the GNU General Public License and
26da0c48c4Sopenharmony_ci   the GNU Lesser General Public License along with this program.  If
27da0c48c4Sopenharmony_ci   not, see <http://www.gnu.org/licenses/>.  */
28da0c48c4Sopenharmony_ci
29da0c48c4Sopenharmony_ci#ifndef _DEBUGINFOD_CLIENT_H
30da0c48c4Sopenharmony_ci#define _DEBUGINFOD_CLIENT_H 1
31da0c48c4Sopenharmony_ci
32da0c48c4Sopenharmony_ci/* Names of environment variables that control the client logic. */
33da0c48c4Sopenharmony_ci#define DEBUGINFOD_URLS_ENV_VAR "DEBUGINFOD_URLS"
34da0c48c4Sopenharmony_ci#define DEBUGINFOD_CACHE_PATH_ENV_VAR "DEBUGINFOD_CACHE_PATH"
35da0c48c4Sopenharmony_ci#define DEBUGINFOD_TIMEOUT_ENV_VAR "DEBUGINFOD_TIMEOUT"
36da0c48c4Sopenharmony_ci#define DEBUGINFOD_PROGRESS_ENV_VAR "DEBUGINFOD_PROGRESS"
37da0c48c4Sopenharmony_ci#define DEBUGINFOD_VERBOSE_ENV_VAR "DEBUGINFOD_VERBOSE"
38da0c48c4Sopenharmony_ci#define DEBUGINFOD_RETRY_LIMIT_ENV_VAR "DEBUGINFOD_RETRY_LIMIT"
39da0c48c4Sopenharmony_ci#define DEBUGINFOD_MAXSIZE_ENV_VAR "DEBUGINFOD_MAXSIZE"
40da0c48c4Sopenharmony_ci#define DEBUGINFOD_MAXTIME_ENV_VAR "DEBUGINFOD_MAXTIME"
41da0c48c4Sopenharmony_ci#define DEBUGINFOD_HEADERS_FILE_ENV_VAR "DEBUGINFOD_HEADERS_FILE"
42da0c48c4Sopenharmony_ci
43da0c48c4Sopenharmony_ci/* The libdebuginfod soname.  */
44da0c48c4Sopenharmony_ci#define DEBUGINFOD_SONAME "@LIBDEBUGINFOD_SONAME@"
45da0c48c4Sopenharmony_ci
46da0c48c4Sopenharmony_ci/* Handle for debuginfod-client connection.  */
47da0c48c4Sopenharmony_citypedef struct debuginfod_client debuginfod_client;
48da0c48c4Sopenharmony_ci
49da0c48c4Sopenharmony_ci#ifdef __cplusplus
50da0c48c4Sopenharmony_ciextern "C" {
51da0c48c4Sopenharmony_ci#endif
52da0c48c4Sopenharmony_ci
53da0c48c4Sopenharmony_ci/* Create a handle for a new debuginfod-client session.  */
54da0c48c4Sopenharmony_cidebuginfod_client *debuginfod_begin (void);
55da0c48c4Sopenharmony_ci
56da0c48c4Sopenharmony_ci/* Query the urls contained in $DEBUGINFOD_URLS for a file with
57da0c48c4Sopenharmony_ci   the specified type and build id.  If build_id_len == 0, the
58da0c48c4Sopenharmony_ci   build_id is supplied as a lowercase hexadecimal string; otherwise
59da0c48c4Sopenharmony_ci   it is a binary blob of given length.
60da0c48c4Sopenharmony_ci
61da0c48c4Sopenharmony_ci   If successful, return a file descriptor to the target, otherwise
62da0c48c4Sopenharmony_ci   return a posix error code.  If successful, set *path to a
63da0c48c4Sopenharmony_ci   strdup'd copy of the name of the same file in the cache.
64da0c48c4Sopenharmony_ci   Caller must free() it later. */
65da0c48c4Sopenharmony_ci
66da0c48c4Sopenharmony_ciint debuginfod_find_debuginfo (debuginfod_client *client,
67da0c48c4Sopenharmony_ci			       const unsigned char *build_id,
68da0c48c4Sopenharmony_ci                               int build_id_len,
69da0c48c4Sopenharmony_ci                               char **path);
70da0c48c4Sopenharmony_ci
71da0c48c4Sopenharmony_ciint debuginfod_find_executable (debuginfod_client *client,
72da0c48c4Sopenharmony_ci				const unsigned char *build_id,
73da0c48c4Sopenharmony_ci                                int build_id_len,
74da0c48c4Sopenharmony_ci                                char **path);
75da0c48c4Sopenharmony_ci
76da0c48c4Sopenharmony_ciint debuginfod_find_source (debuginfod_client *client,
77da0c48c4Sopenharmony_ci			    const unsigned char *build_id,
78da0c48c4Sopenharmony_ci                            int build_id_len,
79da0c48c4Sopenharmony_ci                            const char *filename,
80da0c48c4Sopenharmony_ci                            char **path);
81da0c48c4Sopenharmony_ci
82da0c48c4Sopenharmony_ciint debuginfod_find_section (debuginfod_client *client,
83da0c48c4Sopenharmony_ci			     const unsigned char *build_id,
84da0c48c4Sopenharmony_ci			     int build_id_len,
85da0c48c4Sopenharmony_ci			     const char *section,
86da0c48c4Sopenharmony_ci			     char **path);
87da0c48c4Sopenharmony_ci
88da0c48c4Sopenharmony_citypedef int (*debuginfod_progressfn_t)(debuginfod_client *c, long a, long b);
89da0c48c4Sopenharmony_civoid debuginfod_set_progressfn(debuginfod_client *c,
90da0c48c4Sopenharmony_ci			       debuginfod_progressfn_t fn);
91da0c48c4Sopenharmony_ci
92da0c48c4Sopenharmony_civoid debuginfod_set_verbose_fd(debuginfod_client *c, int fd);
93da0c48c4Sopenharmony_ci
94da0c48c4Sopenharmony_ci/* Set the user parameter.  */
95da0c48c4Sopenharmony_civoid debuginfod_set_user_data (debuginfod_client *client, void *value);
96da0c48c4Sopenharmony_ci
97da0c48c4Sopenharmony_ci/* Get the user parameter.  */
98da0c48c4Sopenharmony_civoid* debuginfod_get_user_data (debuginfod_client *client);
99da0c48c4Sopenharmony_ci
100da0c48c4Sopenharmony_ci/* Get the current or last active URL, if known.  */
101da0c48c4Sopenharmony_ciconst char* debuginfod_get_url (debuginfod_client *client);
102da0c48c4Sopenharmony_ci
103da0c48c4Sopenharmony_ci/* Returns set of x-debuginfod* header lines received from current or
104da0c48c4Sopenharmony_ci   last active transfer, \n separated, if known. */
105da0c48c4Sopenharmony_ciconst char* debuginfod_get_headers(debuginfod_client *client);
106da0c48c4Sopenharmony_ci
107da0c48c4Sopenharmony_ci/* Add an outgoing HTTP request  "Header: Value".  Copies string.  */
108da0c48c4Sopenharmony_ciint debuginfod_add_http_header (debuginfod_client *client, const char* header);
109da0c48c4Sopenharmony_ci
110da0c48c4Sopenharmony_ci/* Release debuginfod client connection context handle.  */
111da0c48c4Sopenharmony_civoid debuginfod_end (debuginfod_client *client);
112da0c48c4Sopenharmony_ci
113da0c48c4Sopenharmony_ci#ifdef __cplusplus
114da0c48c4Sopenharmony_ci}
115da0c48c4Sopenharmony_ci#endif
116da0c48c4Sopenharmony_ci
117da0c48c4Sopenharmony_ci
118da0c48c4Sopenharmony_ci#endif /* _DEBUGINFOD_CLIENT_H */
119