2012-10-21 14:52:34 +02:00
|
|
|
/*
|
2020-11-07 13:06:23 +01:00
|
|
|
** Copyright (C) 2012-2020 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
2012-10-21 14:52:34 +02:00
|
|
|
**
|
|
|
|
** This program is free software; you can redistribute it and/or modify it
|
|
|
|
** under the terms of the GNU General Public License as published by the
|
|
|
|
** Free Software Foundation; either version 3, or (at your option) any
|
|
|
|
** later version.
|
|
|
|
**
|
|
|
|
** This program is distributed in the hope that it will be useful,
|
|
|
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
** GNU General Public License for more details.
|
|
|
|
**
|
|
|
|
** You should have received a copy of the GNU General Public License
|
|
|
|
** along with this program; if not, write to the Free Software Foundation,
|
|
|
|
** Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
|
2020-11-07 13:06:23 +01:00
|
|
|
#ifndef MU_SCRIPT_HH__
|
|
|
|
#define MU_SCRIPT_HH__
|
2012-10-21 14:52:34 +02:00
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
|
|
|
|
/* Opaque structure with information about a script */
|
2020-11-07 13:06:23 +01:00
|
|
|
struct MuScriptInfo;
|
2012-10-21 14:52:34 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* get the name of the script (sans-extension, if some extension was
|
|
|
|
* provided to mu_script_get_scripts)
|
|
|
|
*
|
|
|
|
* @param msi a MuScriptInfo structure
|
|
|
|
*
|
|
|
|
* @return the name
|
|
|
|
*/
|
2021-10-20 11:18:15 +02:00
|
|
|
const char* mu_script_info_name(MuScriptInfo* msi);
|
2012-10-21 14:52:34 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* get the full filesystem path of the script
|
|
|
|
*
|
|
|
|
* @param msi a MuScriptInfo structure
|
|
|
|
*
|
|
|
|
* @return the path
|
|
|
|
*/
|
2021-10-20 11:18:15 +02:00
|
|
|
const char* mu_script_info_path(MuScriptInfo* msi);
|
2012-10-21 14:52:34 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* get a one-line description for the script
|
|
|
|
*
|
|
|
|
* @param msi a MuScriptInfo structure
|
|
|
|
*
|
|
|
|
* @return the description, or NULL if there was none
|
|
|
|
*/
|
2021-10-20 11:18:15 +02:00
|
|
|
const char* mu_script_info_one_line(MuScriptInfo* msi);
|
2012-10-22 22:16:01 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* get a full description for the script
|
|
|
|
*
|
|
|
|
* @param msi a MuScriptInfo structure
|
|
|
|
*
|
|
|
|
* @return the description, or NULL if there was none
|
|
|
|
*/
|
2021-10-20 11:18:15 +02:00
|
|
|
const char* mu_script_info_description(MuScriptInfo* msi);
|
2012-10-21 14:52:34 +02:00
|
|
|
|
2012-10-22 22:16:01 +02:00
|
|
|
/**
|
|
|
|
* check whether either the name or one-line description of a
|
|
|
|
* MuScriptInfo matches regular expression rxstr
|
|
|
|
*
|
|
|
|
* @param msi a MuScriptInfo
|
|
|
|
* @param rxstr a regular expression string
|
|
|
|
* @param err receives error information
|
|
|
|
*
|
|
|
|
* @return TRUE if it matches, FALSE if not or in case of error
|
|
|
|
*/
|
2021-10-20 11:18:15 +02:00
|
|
|
gboolean mu_script_info_matches_regex(MuScriptInfo* msi, const char* rxstr, GError** err);
|
2012-10-21 14:52:34 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the list of all scripts in path with extension ext
|
|
|
|
*
|
|
|
|
* @param path a file system path
|
|
|
|
* @param ext an extension (e.g., ".scm"), or NULL
|
2012-10-21 16:20:20 +02:00
|
|
|
* @param prefix for the one-line description
|
|
|
|
* (e.g., ";; DESCRIPTION: "), or NULL
|
2012-10-21 14:52:34 +02:00
|
|
|
* @param err receives error information, if any
|
|
|
|
*
|
|
|
|
* @return a list of Mu
|
|
|
|
*/
|
2021-10-20 11:18:15 +02:00
|
|
|
GSList* mu_script_get_script_info_list(const char* path,
|
|
|
|
const char* ext,
|
|
|
|
const char* descprefix,
|
|
|
|
GError** err);
|
2012-10-21 14:52:34 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* destroy a list of MuScriptInfo* objects
|
|
|
|
*
|
|
|
|
* @param scriptslst a list of MuScriptInfo* objects
|
|
|
|
*/
|
2021-10-20 11:18:15 +02:00
|
|
|
void mu_script_info_list_destroy(GSList* lst);
|
2012-10-21 14:52:34 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* find the MuScriptInfo object for the first script with a certain
|
|
|
|
* name, or return NULL if not found.
|
|
|
|
*
|
|
|
|
* @param lst a list of MuScriptInfo* objects
|
|
|
|
* @param name the name to search for
|
|
|
|
*
|
|
|
|
* @return a MuScriptInfo* object, or NULL if not found.
|
|
|
|
*/
|
2021-10-20 11:18:15 +02:00
|
|
|
MuScriptInfo* mu_script_find_script_with_name(GSList* lst, const char* name);
|
2012-10-21 14:52:34 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* run the guile script at path
|
|
|
|
*
|
|
|
|
* @param msi MuScriptInfo object for the script
|
2012-10-22 22:16:01 +02:00
|
|
|
* @param muhome path to the mu home dir
|
|
|
|
* @param args NULL-terminated array of strings (argv for the script)
|
2012-10-21 14:52:34 +02:00
|
|
|
* @param err receives error information
|
|
|
|
*
|
|
|
|
* @return FALSE in case of error -- otherwise, this function will
|
|
|
|
* _not return_
|
|
|
|
*/
|
2021-10-20 11:18:15 +02:00
|
|
|
gboolean
|
|
|
|
mu_script_guile_run(MuScriptInfo* msi, const char* muhome, const char** args, GError** err);
|
2012-10-21 14:52:34 +02:00
|
|
|
|
2020-11-07 13:06:23 +01:00
|
|
|
#endif /*MU_SCRIPT_HH__*/
|