diff options
Diffstat (limited to 'Build/source/texk/gregorio/gregorio-src/src/support.h')
-rw-r--r-- | Build/source/texk/gregorio/gregorio-src/src/support.h | 40 |
1 files changed, 34 insertions, 6 deletions
diff --git a/Build/source/texk/gregorio/gregorio-src/src/support.h b/Build/source/texk/gregorio/gregorio-src/src/support.h index 7e7425d57a9..9b355504076 100644 --- a/Build/source/texk/gregorio/gregorio-src/src/support.h +++ b/Build/source/texk/gregorio/gregorio-src/src/support.h @@ -25,18 +25,46 @@ #include <stdlib.h> #include <limits.h> +#ifdef USE_KPSE +#include <kpathsea/kpathsea.h> +#endif #include "bool.h" +#include "config.h" +#include "messages.h" #define GREGORIO_SZ_MAX (~((size_t)0)) #define MAX_BUF_GROWTH \ ((size_t)((((INT_MAX < GREGORIO_SZ_MAX)? INT_MAX : GREGORIO_SZ_MAX) >> 1) + 1)) void gregorio_snprintf(char *s, size_t size, const char *format, ...) - __attribute__ ((__format__ (__printf__, 3, 4))); -void *gregorio_malloc(size_t size); -void *gregorio_calloc(size_t nmemb, size_t size); -void *gregorio_realloc(void *ptr, size_t size); -char *gregorio_strdup(const char *s); -bool gregorio_readline(char **bufptr, size_t *bufsize, FILE *file); + __attribute__((__format__ (__printf__, 3, 4))); +void *gregorio_malloc(size_t size) __attribute__((malloc)); +void *gregorio_calloc(size_t nmemb, size_t size) __attribute__((malloc)); +void *gregorio_realloc(void *ptr, size_t size) __attribute__((warn_unused_result)); +char *gregorio_strdup(const char *s) __attribute__((malloc)); +void gregorio_support_init(const char *program, const char *argv0); +void gregorio_print_version(const char *copyright); +char **gregorio_kpse_find(const char *filename); +void gregorio_exit(int status) __attribute__((noreturn)); + +#ifdef USE_KPSE +bool gregorio_read_ok(const char *filename, gregorio_verbosity verbosity); +bool gregorio_write_ok(const char *filename, gregorio_verbosity verbosity); + +#define gregorio_check_file_access(DIR, FILENAME, LEVEL, ON_NOT_ALLOWED) \ + if (!gregorio_ ## DIR ## _ok(FILENAME, VERBOSITY_ ## LEVEL)) { \ + ON_NOT_ALLOWED; \ + } +#define gregorio_kpse_find_or_else(VAR, FILENAME, ON_FAIL) \ + VAR = gregorio_kpse_find(FILENAME); \ + if (!VAR) { \ + ON_FAIL; \ + } +#else +#define gregorio_check_file_access(DIRECTION, FILENAME, LEVEL, ON_NOT_ALLOWED) +#define gregorio_kpse_find_or_else(VAR, FILENAME, ON_FAIL) \ + VAR = gregorio_kpse_find(FILENAME); \ + gregorio_not_null(VAR, gregorio_kpse_find, ON_FAIL) +#endif #endif |