1/*
2 * Copyright (c) 2012-2021 by the GMT Team (https://www.generic-mapping-tools.org/team.html)
3 * See LICENSE.TXT file for copying and redistribution conditions.
4 */
5
6/* gmt_@SHARED_LIB_NAME@_glue.c populates the external array of this shared lib with
7 * module parameters such as name, group, purpose and keys strings.
8 * This file also contains the following convenience functions to
9 * display all module purposes, list their names, or return keys or group:
10 *
11 *   int @SHARED_LIB_NAME@_module_show_all    (void *API);
12 *   int @SHARED_LIB_NAME@_module_list_all    (void *API);
13 *   int @SHARED_LIB_NAME@_module_classic_all (void *API);
14 *
15 * These functions may be called by gmt --help and gmt --show-modules
16 *
17 * Developers of external APIs for accessing GMT modules will use this
18 * function indirectly via GMT_Encode_Options to retrieve option keys
19 * needed for module arg processing:
20 *
21 *   const char *@SHARED_LIB_NAME@_module_keys  (void *API, char *candidate);
22 *   const char *@SHARED_LIB_NAME@_module_group (void *API, char *candidate);
23 *
24 * All functions are exported by the shared library so that gmt can call these
25 * functions by name to learn about the library.
26 */
27
28#include "gmt.h"
29
30/* Sorted array with information for all GMT _@SHARED_LIB_NAME@_ modules */
31
32static struct GMT_MODULEINFO modules[] = {
33#include "gmt_@SHARED_LIB_NAME@_moduleinfo.h"
34	{NULL, NULL, NULL, NULL, NULL} /* last element == NULL detects end of array */
35};
36
37/* Pretty print all shared module names and their purposes for gmt --help */
38EXTERN_MSC int @SHARED_LIB_NAME@_module_show_all (void *API) {
39	return (GMT_Show_ModuleInfo (API, modules, "@SHARED_LIB_PURPOSE@", GMT_MODULE_HELP));
40}
41
42/* Produce single list on stdout of all shared module names for gmt --show-modules */
43EXTERN_MSC int @SHARED_LIB_NAME@_module_list_all (void *API) {
44	return (GMT_Show_ModuleInfo (API, modules, NULL, GMT_MODULE_SHOW_MODERN));
45}
46
47/* Produce single list on stdout of all shared module names for gmt --show-classic [i.e., classic mode names] */
48EXTERN_MSC int @SHARED_LIB_NAME@_module_classic_all (void *API) {
49	return (GMT_Show_ModuleInfo (API, modules, NULL, GMT_MODULE_SHOW_CLASSIC));
50}
51
52/* Lookup module id by name, return option keys pointer (for external API developers) */
53EXTERN_MSC const char *@SHARED_LIB_NAME@_module_keys (void *API, char *candidate) {
54	return (GMT_Get_ModuleInfo (API, modules, candidate, GMT_MODULE_KEYS));
55}
56
57/* Lookup module id by name, return group char name (for external API developers) */
58EXTERN_MSC const char *@SHARED_LIB_NAME@_module_group (void *API, char *candidate) {
59	return (GMT_Get_ModuleInfo (API, modules, candidate, GMT_MODULE_GROUP));
60}
61