Added rig_set_debug_filename due to Python not being able to pass a FILE*

https://github.com/Hamlib/Hamlib/issues/1307
pull/1330/head
Mike Black W9MDB 2023-05-31 07:04:20 -05:00
rodzic 5745457d7f
commit 2c8f8a9c29
1 zmienionych plików z 27 dodań i 0 usunięć

Wyświetl plik

@ -36,6 +36,7 @@
#include <stdio.h> /* Standard input/output definitions */
#include <string.h> /* String function definitions */
#include <sys/types.h>
#include <errno.h>
#ifdef ANDROID
# include <android/log.h>
@ -326,4 +327,30 @@ FILE *HAMLIB_API rig_set_debug_file(FILE *stream)
return prev_stream;
}
/**
* \brief Change the output stream to a filename
*
* \param filename The filename to direct debugging output.
*
* \sa `FILE`(3)
*/
FILE *HAMLIB_API rig_set_debug_filename(char *filename)
{
FILE *prev_stream = rig_debug_stream;
rig_debug(RIG_DEBUG_WARN, "%s: debug will stream to '%s'\n", __func__,
filename);
FILE *stream = fopen(filename, "w");
if (stream == NULL)
{
rig_debug(RIG_DEBUG_ERR, "%s: error opening stream: %s\n", __func__,
strerror(errno));
return NULL;
}
rig_debug_stream = stream;
return prev_stream;
}
/** @} */