* lib: add mu_util_support and mu_util_program_in_path + unit tests
This commit is contained in:
@ -205,6 +205,34 @@ char* mu_util_read_password (const char *prompt)
|
||||
gboolean mu_util_play (const char *path, gboolean allow_local,
|
||||
gboolean allow_remote, GError **err);
|
||||
|
||||
/**
|
||||
* Check whether program prog exists in PATH
|
||||
*
|
||||
* @param prog a program (executable)
|
||||
*
|
||||
* @return TRUE if it exists and is executable, FALSE otherwise
|
||||
*/
|
||||
gboolean mu_util_program_in_path (const char *prog);
|
||||
|
||||
|
||||
|
||||
enum _MuFeature {
|
||||
MU_FEATURE_GUILE = 1 << 0, /* do we support Guile 2.0? */
|
||||
MU_FEATURE_GNUPLOT = 1 << 1, /* do we have gnuplot installed? */
|
||||
MU_FEATURE_CRYPTO = 1 << 2 /* do we support crypto (Gmime >= 2.6) */
|
||||
};
|
||||
typedef enum _MuFeature MuFeature;
|
||||
|
||||
|
||||
/**
|
||||
* Check whether mu supports some particular feature
|
||||
*
|
||||
* @param feature a feature (multiple features can be logical-or'd together)
|
||||
*
|
||||
* @return TRUE if the feature is supported, FALSE otherwise
|
||||
*/
|
||||
gboolean mu_util_supports (MuFeature feature);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@ -303,7 +331,7 @@ typedef gpointer XapianEnquire;
|
||||
|
||||
#define MU_STORE_CATCH_BLOCK_RETURN(GE,R) \
|
||||
catch (const MuStoreError& merr) { \
|
||||
mu_util_g_set_error ((GE), \
|
||||
mu_util_g_set_error ((GE), \
|
||||
merr.mu_error(), "%s", \
|
||||
merr.what().c_str()); \
|
||||
return (R); \
|
||||
@ -320,17 +348,17 @@ typedef gpointer XapianEnquire;
|
||||
|
||||
#define MU_XAPIAN_CATCH_BLOCK_G_ERROR(GE,E) \
|
||||
catch (const Xapian::DatabaseLockError &xerr) { \
|
||||
mu_util_g_set_error ((GE), \
|
||||
mu_util_g_set_error ((GE), \
|
||||
MU_ERROR_XAPIAN_CANNOT_GET_WRITELOCK, \
|
||||
"%s: xapian error '%s'", \
|
||||
__FUNCTION__, xerr.get_msg().c_str()); \
|
||||
} catch (const Xapian::DatabaseCorruptError &xerr) { \
|
||||
mu_util_g_set_error ((GE), \
|
||||
mu_util_g_set_error ((GE), \
|
||||
MU_ERROR_XAPIAN_CORRUPTION, \
|
||||
"%s: xapian error '%s'", \
|
||||
__FUNCTION__, xerr.get_msg().c_str()); \
|
||||
} catch (const Xapian::DatabaseError &xerr) { \
|
||||
mu_util_g_set_error ((GE),MU_ERROR_XAPIAN, \
|
||||
mu_util_g_set_error ((GE),MU_ERROR_XAPIAN, \
|
||||
"%s: xapian error '%s'", \
|
||||
__FUNCTION__, xerr.get_msg().c_str()); \
|
||||
} catch (const Xapian::Error &xerr) { \
|
||||
@ -361,7 +389,7 @@ typedef gpointer XapianEnquire;
|
||||
return (R); \
|
||||
} catch (...) { \
|
||||
if ((GE)&&!(*(GE))) \
|
||||
mu_util_g_set_error ((GE), \
|
||||
mu_util_g_set_error ((GE), \
|
||||
(MU_ERROR_INTERNAL), \
|
||||
"%s: caught exception", __FUNCTION__); \
|
||||
return (R); \
|
||||
@ -447,14 +475,15 @@ enum _MuError {
|
||||
MU_ERROR_FILE_CANNOT_LINK = 72,
|
||||
MU_ERROR_FILE_CANNOT_OPEN = 73,
|
||||
MU_ERROR_FILE_CANNOT_READ = 74,
|
||||
MU_ERROR_FILE_CANNOT_CREATE = 75,
|
||||
MU_ERROR_FILE_CANNOT_MKDIR = 76,
|
||||
MU_ERROR_FILE_STAT_FAILED = 77,
|
||||
MU_ERROR_FILE_READDIR_FAILED = 78,
|
||||
MU_ERROR_FILE_INVALID_SOURCE = 79,
|
||||
MU_ERROR_FILE_TARGET_EQUALS_SOURCE = 80,
|
||||
MU_ERROR_FILE_CANNOT_WRITE = 81,
|
||||
MU_ERROR_FILE_CANNOT_UNLINK = 82,
|
||||
MU_ERROR_FILE_CANNOT_EXECUTE = 75,
|
||||
MU_ERROR_FILE_CANNOT_CREATE = 76,
|
||||
MU_ERROR_FILE_CANNOT_MKDIR = 77,
|
||||
MU_ERROR_FILE_STAT_FAILED = 78,
|
||||
MU_ERROR_FILE_READDIR_FAILED = 79,
|
||||
MU_ERROR_FILE_INVALID_SOURCE = 80,
|
||||
MU_ERROR_FILE_TARGET_EQUALS_SOURCE = 81,
|
||||
MU_ERROR_FILE_CANNOT_WRITE = 82,
|
||||
MU_ERROR_FILE_CANNOT_UNLINK = 83,
|
||||
|
||||
/* not really an error, used in callbacks */
|
||||
MU_STOP = 99
|
||||
|
||||
Reference in New Issue
Block a user