mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Remove support code that was only used by price-quotes.scm
This commit is contained in:
parent
e97fc3e408
commit
e5c6f6026b
@ -74,22 +74,6 @@ Account * gnc_get_current_root_account (void);
|
||||
|
||||
|
||||
#if defined(SWIGGUILE)
|
||||
%typemap(out) GncCommodityList * {
|
||||
SCM list = SCM_EOL;
|
||||
GList *node;
|
||||
|
||||
for (node = $1; node; node = node->next)
|
||||
list = scm_cons(gnc_quoteinfo2scm(static_cast<gnc_commodity*>(node->data)), list);
|
||||
|
||||
$result = scm_reverse(list);
|
||||
}
|
||||
|
||||
%inline %{
|
||||
typedef GList GncCommodityList;
|
||||
|
||||
GncCommodityList *
|
||||
gnc_commodity_table_get_quotable_commodities(const gnc_commodity_table * table);
|
||||
%}
|
||||
|
||||
gnc_commodity * gnc_default_currency (void);
|
||||
gnc_commodity * gnc_default_report_currency (void);
|
||||
|
@ -248,34 +248,8 @@ SplitList * qof_query_run_subquery (QofQuery *q, const QofQuery *q);
|
||||
time64 time64CanonicalDayTime(time64 t);
|
||||
|
||||
%include <gnc-budget.h>
|
||||
|
||||
%typemap(in) GList * {
|
||||
SCM path_scm = $input;
|
||||
GList *path = NULL;
|
||||
|
||||
while (!scm_is_null (path_scm))
|
||||
{
|
||||
SCM key_scm = SCM_CAR (path_scm);
|
||||
char *key;
|
||||
if (!scm_is_string (key_scm))
|
||||
break;
|
||||
|
||||
key = scm_to_locale_string (key_scm);
|
||||
path = g_list_prepend (path, key);
|
||||
|
||||
path_scm = SCM_CDR (path_scm);
|
||||
}
|
||||
|
||||
$1 = g_list_reverse (path);
|
||||
}
|
||||
|
||||
%typemap (freearg) GList * "g_list_free_full ($1, g_free);"
|
||||
|
||||
void gnc_quote_source_set_fq_installed (const char* version_string,
|
||||
GList *sources_list);
|
||||
%clear GList *;
|
||||
%ignore gnc_quote_source_set_fq_installed;
|
||||
%ignore gnc_commodity_table_get_quotable_commodities;
|
||||
%include <gnc-commodity.h>
|
||||
|
||||
void gnc_hook_add_scm_dangler (const gchar *name, SCM proc);
|
||||
@ -475,8 +449,3 @@ void qof_book_set_string_option(QofBook* book, const char* opt_name, const char*
|
||||
}
|
||||
$1 = g_list_reverse (path);
|
||||
}
|
||||
Process *gnc_spawn_process_async(GList *argl, const gboolean search_path);
|
||||
%clear GList *;
|
||||
|
||||
gint gnc_process_get_fd(const Process *proc, const guint std_fd);
|
||||
void gnc_detach_process(Process *proc, const gboolean kill_it);
|
||||
|
@ -202,139 +202,3 @@ gnc_glist_string_p(SCM list)
|
||||
{
|
||||
return scm_is_list(list);
|
||||
}
|
||||
|
||||
struct _Process
|
||||
{
|
||||
GPid pid;
|
||||
gint fd_stdin;
|
||||
gint fd_stdout;
|
||||
gint fd_stderr;
|
||||
gboolean dead;
|
||||
gboolean detached;
|
||||
};
|
||||
|
||||
static void
|
||||
on_child_exit (GPid pid, gint status, gpointer data)
|
||||
{
|
||||
Process *proc = data;
|
||||
g_return_if_fail (proc && proc->pid == pid);
|
||||
|
||||
g_spawn_close_pid (proc->pid);
|
||||
|
||||
/* free if the process is both dead and detached */
|
||||
if (!proc->detached)
|
||||
proc->dead = TRUE;
|
||||
else
|
||||
g_free (proc);
|
||||
}
|
||||
|
||||
Process *
|
||||
gnc_spawn_process_async (GList *argl, const gboolean search_path)
|
||||
{
|
||||
gboolean retval;
|
||||
Process *proc;
|
||||
GList *l_iter;
|
||||
guint argc;
|
||||
gchar **argv, **v_iter;
|
||||
GSpawnFlags flags;
|
||||
GError *error = NULL;
|
||||
|
||||
proc = g_new0 (Process, 1);
|
||||
|
||||
argc = g_list_length (argl);
|
||||
argv = g_malloc ((argc + 1) * sizeof(gchar*));
|
||||
|
||||
for (l_iter = argl, v_iter = argv; l_iter; l_iter = l_iter->next, v_iter++)
|
||||
{
|
||||
*v_iter = (gchar*) l_iter->data;
|
||||
}
|
||||
*v_iter = NULL;
|
||||
g_list_free (argl);
|
||||
|
||||
flags = G_SPAWN_DO_NOT_REAP_CHILD;
|
||||
if (search_path)
|
||||
flags |= G_SPAWN_SEARCH_PATH;
|
||||
|
||||
retval = g_spawn_async_with_pipes (
|
||||
NULL, argv, NULL, flags, NULL, NULL, &proc->pid,
|
||||
&proc->fd_stdin, &proc->fd_stdout, &proc->fd_stderr, &error);
|
||||
|
||||
if (retval)
|
||||
{
|
||||
g_child_watch_add (proc->pid, on_child_exit, proc);
|
||||
}
|
||||
else
|
||||
{
|
||||
PWARN ("Could not spawn %s: %s", *argv ? *argv : "(null)",
|
||||
error->message ? error->message : "(null)");
|
||||
g_free (proc);
|
||||
proc = NULL;
|
||||
}
|
||||
g_strfreev (argv);
|
||||
|
||||
return proc;
|
||||
}
|
||||
|
||||
gint
|
||||
gnc_process_get_fd (const Process *proc, const gint std_fd)
|
||||
{
|
||||
const gint *retptr = NULL;
|
||||
g_return_val_if_fail (proc, -1);
|
||||
|
||||
if (std_fd == 0)
|
||||
retptr = &proc->fd_stdin;
|
||||
else if (std_fd == 1)
|
||||
retptr = &proc->fd_stdout;
|
||||
else if (std_fd == 2)
|
||||
retptr = &proc->fd_stderr;
|
||||
else
|
||||
g_return_val_if_reached (-1);
|
||||
|
||||
if (*retptr == -1)
|
||||
PWARN ("Pipe to child's file descriptor %d is -1", std_fd);
|
||||
return *retptr;
|
||||
}
|
||||
|
||||
void
|
||||
gnc_detach_process (Process *proc, const gboolean kill_it)
|
||||
{
|
||||
g_return_if_fail (proc && proc->pid);
|
||||
|
||||
errno = 0;
|
||||
close (proc->fd_stdin);
|
||||
if (errno)
|
||||
{
|
||||
PINFO ("Close of child's stdin (%d) failed: %s", proc->fd_stdin,
|
||||
g_strerror (errno));
|
||||
errno = 0;
|
||||
}
|
||||
close (proc->fd_stdout);
|
||||
if (errno)
|
||||
{
|
||||
PINFO ("Close of child's stdout (%d) failed: %s", proc->fd_stdout,
|
||||
g_strerror(errno));
|
||||
errno = 0;
|
||||
}
|
||||
close (proc->fd_stderr);
|
||||
if (errno)
|
||||
{
|
||||
PINFO ("Close of child's stderr (%d) failed: %s", proc->fd_stderr,
|
||||
g_strerror(errno));
|
||||
errno = 0;
|
||||
}
|
||||
|
||||
if (kill_it && !proc->dead)
|
||||
{
|
||||
/* give it a chance to die */
|
||||
while (g_main_context_iteration (NULL, FALSE) && !proc->dead)
|
||||
;
|
||||
if (!proc->dead)
|
||||
gnc_gpid_kill (proc->pid);
|
||||
}
|
||||
|
||||
/* free if the process is both dead and detached */
|
||||
if (!proc->dead)
|
||||
proc->detached = TRUE;
|
||||
else
|
||||
g_free (proc);
|
||||
}
|
||||
|
@ -37,40 +37,4 @@ int gnc_glist_string_p(SCM list);
|
||||
|
||||
GSList * gnc_scm_to_gslist_string(SCM list);
|
||||
|
||||
/** An opaque process structure returned by gnc_spawn_process_async. */
|
||||
typedef struct _Process Process;
|
||||
|
||||
/** Wraps g_spawn_async_with_pipes minimally. Use gnc_process_get_fd to access
|
||||
* the file descriptors to the child. To close them and free the memory
|
||||
* allocated for the process once it has exited, call gnc_detach_process.
|
||||
*
|
||||
* @param argl A list of null-terminated strings used as arguments for spawning,
|
||||
* i.e. "perl" "-w" "my-perl-script". Will be freed inside.
|
||||
*
|
||||
* @param search_path Determines whether the first element of argl will be
|
||||
* looked for in the user's PATH.
|
||||
*
|
||||
* @return A pointer to a structure representing the process or NULL on failure.
|
||||
*/
|
||||
Process *gnc_spawn_process_async(GList *argl, const gboolean search_path);
|
||||
|
||||
/** Accesses a given process structure and returns the file descriptor connected
|
||||
* to the childs stdin, stdout or stderr.
|
||||
*
|
||||
* @param proc A process structure returned by gnc_spawn_process_async.
|
||||
*
|
||||
* @param std_fd 0, 1 or 2.
|
||||
*
|
||||
* @return The file descriptor to write to the child on 0, or read from the
|
||||
* childs output or error on 1 or 2, resp. */
|
||||
gint gnc_process_get_fd(const Process *proc, const gint std_fd);
|
||||
|
||||
/** Close the file descriptors to a given process and declare it as detached. If
|
||||
* it is both dead and detached, the allocated memory will be freed.
|
||||
*
|
||||
* @param proc A process structure returned by gnc_spawn_process_async.
|
||||
*
|
||||
* @param kill_it If TRUE, kill the process. */
|
||||
void gnc_detach_process(Process *proc, const gboolean kill_it);
|
||||
|
||||
#endif
|
||||
|
@ -32,7 +32,6 @@ extern "C"
|
||||
#include "Account.h"
|
||||
#include "engine-helpers.h"
|
||||
#include "gnc-engine-guile.h"
|
||||
#include "glib-guile.h"
|
||||
#include "gnc-date.h"
|
||||
#include "gnc-engine.h"
|
||||
#include "gnc-session.h"
|
||||
|
@ -92,44 +92,3 @@ gnc_scm2printinfo(SCM info_scm)
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
/* This is a scaled down version of the routine that would be needed
|
||||
* to fully convert a gnc-commodity to a scheme data structure. In an
|
||||
* attempt to optimize the speed of price quote retrieval, this
|
||||
* routine only converts the fields that price-quotes.scm uses. Since
|
||||
* it converts these fields all at once, it should prevent multiple
|
||||
* transitions back and forth from Scheme to C to extract
|
||||
* the data from a pointers to a gnc-commodity (the older method).
|
||||
* This is *not* a reversible conversion as it drops data.
|
||||
*
|
||||
* When this routine was written, gnucash retrieved all quotes into
|
||||
* the user's default currency. (Did earlier version do any
|
||||
* different?) This routine inserts that default currency into the
|
||||
* returned structure as another optimization.
|
||||
*/
|
||||
SCM
|
||||
gnc_quoteinfo2scm(gnc_commodity *comm)
|
||||
{
|
||||
gnc_quote_source *source;
|
||||
const char *name, *tz;
|
||||
SCM info_scm = SCM_EOL, comm_scm, def_comm_scm;
|
||||
|
||||
if (!comm)
|
||||
return SCM_EOL;
|
||||
|
||||
source = gnc_commodity_get_quote_source (comm);
|
||||
name = gnc_quote_source_get_internal_name (source);
|
||||
tz = gnc_commodity_get_quote_tz (comm);
|
||||
comm_scm = SWIG_NewPointerObj(comm, SWIG_TypeQuery("_p_gnc_commodity"), 0);
|
||||
def_comm_scm = SWIG_NewPointerObj(gnc_default_currency (),
|
||||
SWIG_TypeQuery("_p_gnc_commodity"), 0);
|
||||
|
||||
if (tz)
|
||||
info_scm = scm_cons (scm_from_utf8_string (tz), info_scm);
|
||||
else
|
||||
info_scm = scm_cons (SCM_BOOL_F, info_scm);
|
||||
info_scm = scm_cons (def_comm_scm, info_scm);
|
||||
info_scm = scm_cons (comm_scm, info_scm);
|
||||
info_scm = scm_cons (name ? scm_from_utf8_string (name) : SCM_BOOL_F, info_scm);
|
||||
return info_scm;
|
||||
}
|
||||
|
@ -31,16 +31,4 @@
|
||||
SCM gnc_printinfo2scm(GNCPrintAmountInfo info);
|
||||
GNCPrintAmountInfo gnc_scm2printinfo(SCM info_scm);
|
||||
|
||||
/** Given a pointer to a gnc-commodity data structure, build a Scheme
|
||||
* list containing the data needed by the code in price-quotes.scm.
|
||||
* This prevents flipping back and forth from Scheme to C while
|
||||
* extracting values from a pointer.
|
||||
*
|
||||
* @param com A pointer to the commodity to convert.
|
||||
*
|
||||
* @return A pointer to a Scheme list, or SCM_EOL on error.
|
||||
*/
|
||||
SCM gnc_quoteinfo2scm(gnc_commodity *com);
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -139,7 +139,7 @@ gnc_prices_dialog_close_cb (GtkDialog *dialog, gpointer data)
|
||||
void
|
||||
gnc_prices_dialog_help_cb (GtkDialog *dialog, gpointer data)
|
||||
{
|
||||
PricesDialog *pdb_dialog = data;
|
||||
auto pdb_dialog{static_cast<PricesDialog*>(data)};
|
||||
|
||||
gnc_gnome_help (GTK_WINDOW (pdb_dialog->window), HF_HELP, HL_PRICE_DB);
|
||||
}
|
||||
|
@ -311,22 +311,6 @@ gnc_scm_log_debug(const gchar *msg)
|
||||
g_log("gnc.scm", G_LOG_LEVEL_DEBUG, "%s", msg);
|
||||
}
|
||||
|
||||
void gnc_gpid_kill(GPid pid)
|
||||
{
|
||||
#ifdef G_OS_WIN32
|
||||
if (!TerminateProcess((HANDLE) pid, 0))
|
||||
{
|
||||
gchar *msg = g_win32_error_message(GetLastError());
|
||||
g_warning("Could not kill child process: %s", msg ? msg : "(null)");
|
||||
g_free(msg);
|
||||
}
|
||||
#else /* !G_OS_WIN32 */
|
||||
if (kill(pid, SIGKILL))
|
||||
{
|
||||
g_warning("Could not kill child process: %s", g_strerror(errno));
|
||||
}
|
||||
#endif /* G_OS_WIN32 */
|
||||
}
|
||||
|
||||
gchar *
|
||||
gnc_g_list_stringjoin (GList *list_of_strings, const gchar *sep)
|
||||
|
@ -179,10 +179,6 @@ void gnc_scm_log_debug(const gchar *msg);
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @name glib Miscellaneous Functions
|
||||
@{
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @brief Return a string joining a GList whose elements are gchar*
|
||||
@ -198,7 +194,6 @@ void gnc_scm_log_debug(const gchar *msg);
|
||||
* caller.
|
||||
**/
|
||||
gchar * gnc_g_list_stringjoin (GList *list_of_strings, const gchar *sep);
|
||||
|
||||
/**
|
||||
* @brief Scans the GList elements the minimum number of iterations
|
||||
* required to test it against a specified size. Returns -1, 0 or 1
|
||||
@ -213,12 +208,6 @@ gchar * gnc_g_list_stringjoin (GList *list_of_strings, const gchar *sep);
|
||||
**/
|
||||
gint gnc_list_length_cmp (const GList *list, size_t len);
|
||||
|
||||
/** Kill a process. On UNIX send a SIGKILL, on Windows call TerminateProcess.
|
||||
*
|
||||
* @param pid The process ID. */
|
||||
void gnc_gpid_kill(GPid pid);
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
|
Loading…
Reference in New Issue
Block a user