summaryrefslogtreecommitdiff
path: root/lib/mu-script.h
blob: 586b6f0b5fb498b653c519e337f53fcbd00d3103 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/*
** Copyright (C) 2012-2013 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
**
** 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.
**
*/

#ifndef __MU_SCRIPT_H__
#define __MU_SCRIPT_H__

#include <glib.h>

G_BEGIN_DECLS

/* Opaque structure with information about a script */
struct _MuScriptInfo;
typedef struct _MuScriptInfo MuScriptInfo;

/**
 * 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
 */
const char* mu_script_info_name (MuScriptInfo *msi);


/**
 * get the full filesystem path of the script
 *
 * @param msi a MuScriptInfo structure
 *
 * @return the path
 */
const char* mu_script_info_path (MuScriptInfo *msi);

/**
 * get a one-line description for the script
 *
 * @param msi a MuScriptInfo structure
 *
 * @return the description, or NULL if there was none
 */
const char* mu_script_info_one_line (MuScriptInfo *msi);

/**
 * get a full description for the script
 *
 * @param msi a MuScriptInfo structure
 *
 * @return the description, or NULL if there was none
 */
const char* mu_script_info_description (MuScriptInfo *msi);

/**
 * 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
 */
gboolean mu_script_info_matches_regex (MuScriptInfo *msi, const char *rxstr,
				       GError **err);

/**
 * 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
 * @param prefix for the one-line description
 *        (e.g., ";; DESCRIPTION: "), or NULL
 * @param err receives error information, if any
 *
 * @return a list of Mu
 */
GSList *mu_script_get_script_info_list (const char *path, const char *ext,
					const char *descprefix, GError **err);

/**
 * destroy a list of MuScriptInfo* objects
 *
 * @param scriptslst a list of MuScriptInfo* objects
 */
void mu_script_info_list_destroy (GSList *lst);


/**
 * 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.
 */
MuScriptInfo* mu_script_find_script_with_name (GSList *lst, const char *name);


/**
 * run the guile script at path
 *
 * @param msi MuScriptInfo object for the script
 * @param muhome path to the mu home dir
 * @param args NULL-terminated array of strings (argv for the script)
 * @param err receives error information
 *
 * @return FALSE in case of error -- otherwise, this function will
 * _not return_
 */
gboolean mu_script_guile_run (MuScriptInfo *msi, const char *muhome,
			      const char **args, GError **err);

G_END_DECLS

#endif /*__MU_SCRIPT_H__*/