Rename default_progressfn to debuginfod_default_progressfn and expose it
in libdebuginfod's public API.  Previously this function could only be
indirectly invoked by clients by setting the DEBUGINFOD_PROGRESS
environment variable and not explicitly setting a progress callback
function with debuginfod_set_progressfn.

The purpose of this change is to make debuginfod_default_progressfn
directly callable so that custom progress callback functions can
delegate progress reporting to it.

Signed-off-by: Aaron Merey <[email protected]>
---
 debuginfod/debuginfod-client.c      |  6 +++---
 debuginfod/debuginfod.h.in          |  2 ++
 debuginfod/libdebuginfod.map        |  3 +++
 doc/debuginfod_default_progressfn.3 |  1 +
 doc/debuginfod_find_debuginfo.3     | 15 ++++++++++++++-
 5 files changed, 23 insertions(+), 4 deletions(-)
 create mode 100644 doc/debuginfod_default_progressfn.3

diff --git a/debuginfod/debuginfod-client.c b/debuginfod/debuginfod-client.c
index c5bc8a4f..68fa9511 100644
--- a/debuginfod/debuginfod-client.c
+++ b/debuginfod/debuginfod-client.c
@@ -752,8 +752,8 @@ add_headers_from_file(debuginfod_client *client, const 
char* filename)
 
 
 /* Offer a basic form of progress tracing */
-static int
-default_progressfn (debuginfod_client *c, long a, long b)
+int
+debuginfod_default_progressfn (debuginfod_client *c, long a, long b)
 {
   const char* url = debuginfod_get_url (c);
   int len = 0;
@@ -2567,7 +2567,7 @@ debuginfod_begin (void)
   if (client != NULL)
     {
       if (getenv(DEBUGINFOD_PROGRESS_ENV_VAR))
-       client->progressfn = default_progressfn;
+       client->progressfn = debuginfod_default_progressfn;
       if (getenv(DEBUGINFOD_VERBOSE_ENV_VAR))
        client->verbose_fd = STDERR_FILENO;
       else
diff --git a/debuginfod/debuginfod.h.in b/debuginfod/debuginfod.h.in
index 0a6a4a22..2f5bd301 100644
--- a/debuginfod/debuginfod.h.in
+++ b/debuginfod/debuginfod.h.in
@@ -105,6 +105,8 @@ int debuginfod_find_metadata (debuginfod_client *client,
                               const char* value,
                               char **path);
 
+int debuginfod_default_progressfn(debuginfod_client *c, long a, long b);
+
 typedef int (*debuginfod_progressfn_t)(debuginfod_client *c, long a, long b);
 void debuginfod_set_progressfn(debuginfod_client *c,
                               debuginfod_progressfn_t fn);
diff --git a/debuginfod/libdebuginfod.map b/debuginfod/libdebuginfod.map
index 9cee91cd..7e59a495 100644
--- a/debuginfod/libdebuginfod.map
+++ b/debuginfod/libdebuginfod.map
@@ -25,3 +25,6 @@ ELFUTILS_0.188 {
 ELFUTILS_0.192 {
   debuginfod_find_metadata;
 } ELFUTILS_0.188;
+ELFUTILS_0.195 {
+  debuginfod_default_progressfn;
+} ELFUTILS_0.192;
diff --git a/doc/debuginfod_default_progressfn.3 
b/doc/debuginfod_default_progressfn.3
new file mode 100644
index 00000000..16279936
--- /dev/null
+++ b/doc/debuginfod_default_progressfn.3
@@ -0,0 +1 @@
+.so man3/debuginfod_find_debuginfo.3
diff --git a/doc/debuginfod_find_debuginfo.3 b/doc/debuginfod_find_debuginfo.3
index 589a2c2b..ab7fc09e 100644
--- a/doc/debuginfod_find_debuginfo.3
+++ b/doc/debuginfod_find_debuginfo.3
@@ -57,9 +57,11 @@ LOOKUP FUNCTIONS
 OPTIONAL FUNCTIONS
 
 .BI "typedef int (*debuginfod_progressfn_t)(debuginfod_client *" client ","
-.BI "                                       long a, long b);"
+.BI "                                       long " a ", long " b ");"
 .BI "void debuginfod_set_progressfn(debuginfod_client *" client ","
 .BI "                               debuginfod_progressfn_t " progressfn ");"
+.BI "int debuginfod_default_progressfn(debuginfod_client *" client ","
+.BI "                                  long " a ", long " b ");"
 .BI "void debuginfod_set_verbose_fd(debuginfod_client *" client ","
 .BI "                               int " fd ");"
 .BI "void debuginfod_set_user_data(debuginfod_client *" client ","
@@ -177,6 +179,17 @@ continue the work, or any other value to stop work as soon 
as
 possible.  Consequently, the \fBdebuginfod_find_*\fP() function will
 likely return with an error, but might still succeed.
 
+.BR debuginfod_default_progressfn ()
+is the progress callback function set by the debuginfod client library
+when the
+.B DEBUGINFOD_PROGRESS
+environment variable is set and no progressfn is explicitly set. For more
+information see
+.B DEBUGINFOD_PROGRESS
+below. Custom progress callback functions may call
+.BR debuginfod_default_progressfn ()
+directly to report download status.
+
 .SS "VERBOSE OUTPUT"
 
 The \fBdebuginfod_find_*\fP() functions may use several techniques
-- 
2.53.0

Reply via email to